mirror of
https://github.com/home-assistant/core.git
synced 2025-12-26 14:08:21 +00:00
Cache webostv supported_features state (#65930)
* Cache webostv supported_features state * Fixes typings * Restore supported_features attribute on restart * Reverts change on supported_features initial state Co-authored-by: Shay Levy <levyshay1@gmail.com> * Fixes tests Co-authored-by: Shay Levy <levyshay1@gmail.com>
This commit is contained in:
@@ -556,3 +556,57 @@ async def test_supported_features(hass, client, monkeypatch):
|
||||
attrs = hass.states.get(ENTITY_ID).attributes
|
||||
|
||||
assert attrs[ATTR_SUPPORTED_FEATURES] == supported
|
||||
|
||||
|
||||
async def test_cached_supported_features(hass, client, monkeypatch):
|
||||
"""Test test supported features."""
|
||||
monkeypatch.setattr(client, "is_on", False)
|
||||
monkeypatch.setattr(client, "sound_output", None)
|
||||
await setup_webostv(hass)
|
||||
await client.mock_state_update()
|
||||
|
||||
# TV off, support volume mute, step, set
|
||||
supported = SUPPORT_WEBOSTV | SUPPORT_WEBOSTV_VOLUME | SUPPORT_VOLUME_SET
|
||||
attrs = hass.states.get(ENTITY_ID).attributes
|
||||
|
||||
assert attrs[ATTR_SUPPORTED_FEATURES] == supported
|
||||
|
||||
# TV on, support volume mute, step
|
||||
monkeypatch.setattr(client, "is_on", True)
|
||||
monkeypatch.setattr(client, "sound_output", "external_speaker")
|
||||
await client.mock_state_update()
|
||||
|
||||
supported = SUPPORT_WEBOSTV | SUPPORT_WEBOSTV_VOLUME
|
||||
attrs = hass.states.get(ENTITY_ID).attributes
|
||||
|
||||
assert attrs[ATTR_SUPPORTED_FEATURES] == supported
|
||||
|
||||
# TV off, support volume mute, step
|
||||
monkeypatch.setattr(client, "is_on", False)
|
||||
monkeypatch.setattr(client, "sound_output", None)
|
||||
await client.mock_state_update()
|
||||
|
||||
supported = SUPPORT_WEBOSTV | SUPPORT_WEBOSTV_VOLUME
|
||||
attrs = hass.states.get(ENTITY_ID).attributes
|
||||
|
||||
assert attrs[ATTR_SUPPORTED_FEATURES] == supported
|
||||
|
||||
# TV on, support volume mute, step, set
|
||||
monkeypatch.setattr(client, "is_on", True)
|
||||
monkeypatch.setattr(client, "sound_output", "speaker")
|
||||
await client.mock_state_update()
|
||||
|
||||
supported = SUPPORT_WEBOSTV | SUPPORT_WEBOSTV_VOLUME | SUPPORT_VOLUME_SET
|
||||
attrs = hass.states.get(ENTITY_ID).attributes
|
||||
|
||||
assert attrs[ATTR_SUPPORTED_FEATURES] == supported
|
||||
|
||||
# TV off, support volume mute, step, step, set
|
||||
monkeypatch.setattr(client, "is_on", False)
|
||||
monkeypatch.setattr(client, "sound_output", None)
|
||||
await client.mock_state_update()
|
||||
|
||||
supported = SUPPORT_WEBOSTV | SUPPORT_WEBOSTV_VOLUME | SUPPORT_VOLUME_SET
|
||||
attrs = hass.states.get(ENTITY_ID).attributes
|
||||
|
||||
assert attrs[ATTR_SUPPORTED_FEATURES] == supported
|
||||
|
||||
Reference in New Issue
Block a user