diff --git a/custom_components/localthings/registry/capabilities/common.py b/custom_components/localthings/registry/capabilities/common.py index 4ed9bab..82fe42b 100644 --- a/custom_components/localthings/registry/capabilities/common.py +++ b/custom_components/localthings/registry/capabilities/common.py @@ -259,6 +259,12 @@ def sensor_item_value(items, sensor_type, index=0): POWER_GENERIC = Capability( href='/power/0', + # Neither href of this pair carried a poll_tier before (issue #56's + # follow-up), so power state only ever refreshed on the once-per-30s + # summary poll instead of the subscribe/subpoll cadence 'warm' and 'hot' + # hrefs get -- the same "signal drives real-time state, but sat in the + # slow default tier" gap as REMOTE_CONTROL_GENERIC/VS_FALLBACK above. + poll_tier='warm', entities=( # Writable when firmware allows remote power; otherwise a read-only # binary_sensor with the same key keeps HA state without a dead switch. @@ -277,6 +283,7 @@ POWER_GENERIC = Capability( POWER_VS_FALLBACK = Capability( href='/power/vs/0', match_fn=lambda rep, resources: '/power/0' not in resources, + poll_tier='warm', entities=( SwitchDesc(key='power_switch', field='x.com.samsung.da.power', value_fn=lambda v: v == 'On', diff --git a/tests/test_common_capabilities.py b/tests/test_common_capabilities.py index d536165..37218cf 100644 --- a/tests/test_common_capabilities.py +++ b/tests/test_common_capabilities.py @@ -152,6 +152,14 @@ class TestPowerFallback: assert switch.exists_fn(resources['/power/0'], resources) is True assert sensor.exists_fn(resources['/power/0'], resources) is False + def test_polled_warm_so_power_state_reflects_quickly(self): + """issue #56 follow-up: neither href had a poll_tier, so power state + only ever refreshed on the once-per-30s summary poll instead of the + subscribe/subpoll cadence 'warm'/'hot' hrefs get -- same reasoning + as REMOTE_CONTROL_GENERIC/VS_FALLBACK's own 'warm' tier.""" + assert common.POWER_GENERIC.poll_tier == 'warm' + assert common.POWER_VS_FALLBACK.poll_tier == 'warm' + class TestWmSetinfoFlags: def test_washer_fixture_carries_setinfo_from_device0(self):