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:
6 files changed
+42
-7
No files matched your search
@@ -50,6 +50,10 @@ async def test_lg_tv(hass):
|
||||
SUPPORT_PAUSE | SUPPORT_PLAY | SUPPORT_SELECT_SOURCE
|
||||
)
|
||||
|
||||
# The LG TV doesn't (at least at this patch level) report its media state via
|
||||
# CURRENT_MEDIA_STATE. Therefore "ok" is the best we can say.
|
||||
assert state.state == "ok"
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
|
||||
device = device_registry.async_get(entry.device_id)
|
||||
|
||||
@@ -4,6 +4,7 @@ from aiohomekit.model.characteristics import (
|
||||
CharacteristicsTypes,
|
||||
)
|
||||
from aiohomekit.model.services import ServicesTypes
|
||||
import pytest
|
||||
|
||||
from tests.components.homekit_controller.common import setup_test_component
|
||||
|
||||
@@ -21,6 +22,8 @@ def create_tv_service(accessory):
|
||||
"""
|
||||
tv_service = accessory.add_service(ServicesTypes.TELEVISION)
|
||||
|
||||
tv_service.add_char(CharacteristicsTypes.ACTIVE, value=True)
|
||||
|
||||
cur_state = tv_service.add_char(CharacteristicsTypes.CURRENT_MEDIA_STATE)
|
||||
cur_state.value = 0
|
||||
|
||||
@@ -245,3 +248,19 @@ async def test_tv_set_source(hass, utcnow):
|
||||
|
||||
state = await helper.poll_and_get_state()
|
||||
assert state.attributes["source"] == "HDMI 2"
|
||||
|
||||
|
||||
async def test_tv_set_source_fail(hass, utcnow):
|
||||
"""Test that we can set the input source of a HomeKit TV."""
|
||||
helper = await setup_test_component(hass, create_tv_service)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
await hass.services.async_call(
|
||||
"media_player",
|
||||
"select_source",
|
||||
{"entity_id": "media_player.testdevice", "source": "HDMI 999"},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
state = await helper.poll_and_get_state()
|
||||
assert state.attributes["source"] == "HDMI 1"
|
||||
Reference in new issue
Block a user