homekit_controller fixes from testing with an LG TV: (#32610)

* Bump aiohomekit to get better reconnection handling and cleaner shutdowns.
 * Read the ACTIVE characteristic and set ok/problem state

Also gets test coverage to 100%.
This commit is contained in:
Jc2k 2020-03-09 16:19:17 +00:00 committed by GitHub
parent 22b5690607
commit 19faf06ce7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 7 deletions

View file

@ -17,7 +17,13 @@ from homeassistant.components.media_player.const import (
SUPPORT_SELECT_SOURCE,
SUPPORT_STOP,
)
from homeassistant.const import STATE_IDLE, STATE_PAUSED, STATE_PLAYING
from homeassistant.const import (
STATE_IDLE,
STATE_OK,
STATE_PAUSED,
STATE_PLAYING,
STATE_PROBLEM,
)
from homeassistant.core import callback
from . import KNOWN_DEVICES, HomeKitEntity
@ -62,6 +68,7 @@ class HomeKitTelevision(HomeKitEntity, MediaPlayerDevice):
def get_characteristic_types(self):
"""Define the homekit characteristics the entity cares about."""
return [
CharacteristicsTypes.ACTIVE,
CharacteristicsTypes.CURRENT_MEDIA_STATE,
CharacteristicsTypes.TARGET_MEDIA_STATE,
CharacteristicsTypes.REMOTE_KEY,
@ -143,10 +150,15 @@ class HomeKitTelevision(HomeKitEntity, MediaPlayerDevice):
@property
def state(self):
"""State of the tv."""
active = self.get_hk_char_value(CharacteristicsTypes.ACTIVE)
if not active:
return STATE_PROBLEM
homekit_state = self.get_hk_char_value(CharacteristicsTypes.CURRENT_MEDIA_STATE)
if homekit_state is None:
return None
return HK_TO_HA_STATE[homekit_state]
if homekit_state is not None:
return HK_TO_HA_STATE[homekit_state]
return STATE_OK
async def async_media_play(self):
"""Send play command."""