Refactor homekit_controller entity update to work more like update coordinator (#32670)

* Clean up use of get_characteristic_types

* Get rid of get_hk_char_value helper

* Get rid of _update_fn callbacks

* Call async_write_has_state directly as async_state_changed doesnt do anything any more
This commit is contained in:
Jc2k authored and GitHub committed 2020-03-11 07:40:47 -04:00
1 parent 4248893007
commit 647d137daa
12 files changed
+159 -358

No files matched your search

@@ -130,9 +130,7 @@ class HomeKitTelevision(HomeKitEntity, MediaPlayerDevice):
@property
def source(self):
"""Name of the current input source."""
active_identifier = self.get_hk_char_value(
CharacteristicsTypes.ACTIVE_IDENTIFIER
)
active_identifier = self.service.value(CharacteristicsTypes.ACTIVE_IDENTIFIER)
if not active_identifier:
return None
@@ -150,11 +148,11 @@ class HomeKitTelevision(HomeKitEntity, MediaPlayerDevice):
@property
def state(self):
"""State of the tv."""
active = self.get_hk_char_value(CharacteristicsTypes.ACTIVE)
active = self.service.value(CharacteristicsTypes.ACTIVE)
if not active:
return STATE_PROBLEM
homekit_state = self.get_hk_char_value(CharacteristicsTypes.CURRENT_MEDIA_STATE)
homekit_state = self.service.value(CharacteristicsTypes.CURRENT_MEDIA_STATE)
if homekit_state is not None:
return HK_TO_HA_STATE[homekit_state]