Homekit controller BLE groundwork (#20538)
* Define the characteristics to poll (or subscribe to) up front * Configure characteristics immediately instead of during first poll * Do as much cover configuration upfront as possible * Remove test workaround as no longer needed * Remove switch code that is already handled by HomeKitEntity * Remove lock code already handled by HomeKitEntity * Remove light code already handled by HomeKitEntity * Remove alarm code already handled by HomeKitEntity * Remove climate code already handled by HomeKitEntity
This commit is contained in:
parent
995758b8ac
commit
41c1997b88
9 changed files with 177 additions and 72 deletions
|
@ -51,6 +51,16 @@ class HomeKitLock(HomeKitEntity, LockDevice):
|
|||
self._name = discovery_info['model']
|
||||
self._battery_level = None
|
||||
|
||||
def get_characteristic_types(self):
|
||||
"""Define the homekit characteristics the entity cares about."""
|
||||
# pylint: disable=import-error
|
||||
from homekit.model.characteristics import CharacteristicsTypes
|
||||
return [
|
||||
CharacteristicsTypes.LOCK_MECHANISM_CURRENT_STATE,
|
||||
CharacteristicsTypes.LOCK_MECHANISM_TARGET_STATE,
|
||||
CharacteristicsTypes.BATTERY_LEVEL,
|
||||
]
|
||||
|
||||
def update_characteristics(self, characteristics):
|
||||
"""Synchronise the Lock state with Home Assistant."""
|
||||
# pylint: disable=import-error
|
||||
|
@ -60,14 +70,8 @@ class HomeKitLock(HomeKitEntity, LockDevice):
|
|||
ctype = characteristic['type']
|
||||
ctype = CharacteristicsTypes.get_short(ctype)
|
||||
if ctype == "lock-mechanism.current-state":
|
||||
self._chars['lock-mechanism.current-state'] = \
|
||||
characteristic['iid']
|
||||
self._state = CURRENT_STATE_MAP[characteristic['value']]
|
||||
elif ctype == "lock-mechanism.target-state":
|
||||
self._chars['lock-mechanism.target-state'] = \
|
||||
characteristic['iid']
|
||||
elif ctype == "battery-level":
|
||||
self._chars['battery-level'] = characteristic['iid']
|
||||
self._battery_level = characteristic['value']
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue