HomeKit Controller: Adopt config entries for pairing with homekit accessories (#23825)
* Fix user initiated pairing + show more user friendly name * Add lock around async_refresh_entity_map * Migrate homekit_controller to config entries. * Improve docstring Co-Authored-By: Martin Hjelmare <marhje52@kth.se> * Add dummy async_setup_platform * add_service -> async_add_service * Add missing returns * Enable coverage checks for homekit_controller
This commit is contained in:
parent
3508622e3b
commit
b8cbd39985
19 changed files with 334 additions and 287 deletions
|
@ -24,12 +24,25 @@ TARGET_STATE_MAP = {
|
|||
}
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up Homekit Lock support."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
accessory = hass.data[KNOWN_DEVICES][discovery_info['serial']]
|
||||
add_entities([HomeKitLock(accessory, discovery_info)], True)
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_entities, discovery_info=None):
|
||||
"""Legacy set up platform."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up Homekit lock."""
|
||||
hkid = config_entry.data['AccessoryPairingID']
|
||||
conn = hass.data[KNOWN_DEVICES][hkid]
|
||||
|
||||
def async_add_service(aid, service):
|
||||
if service['stype'] != 'lock-mechanism':
|
||||
return False
|
||||
info = {'aid': aid, 'iid': service['iid']}
|
||||
async_add_entities([HomeKitLock(conn, info)], True)
|
||||
return True
|
||||
|
||||
conn.add_listener(async_add_service)
|
||||
|
||||
|
||||
class HomeKitLock(HomeKitEntity, LockDevice):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue