Make the switch keep-alive callback conditional on the entity state (#382)

This commit is contained in:
Paulo Ferreira de Castro
2024-02-16 06:23:30 +00:00
committed by GitHub
parent a440b35815
commit dce8fa2ed6
2 changed files with 11 additions and 5 deletions

View File

@@ -210,6 +210,7 @@ class TestKeepAlive:
common_mocks,
[call("switch", SERVICE_TURN_ON, {"entity_id": "switch.mock_switch"})],
)
common_mocks.mock_is_state.return_value = True
# Call the keep-alive callback a few times (as if `async_track_time_interval`
# had done it) and assert that the callback function is replaced each time.
@@ -240,6 +241,7 @@ class TestKeepAlive:
common_mocks,
[call("switch", SERVICE_TURN_OFF, {"entity_id": "switch.mock_switch"})],
)
common_mocks.mock_is_state.return_value = False
# Call the keep-alive callback a few times (as if `async_track_time_interval`
# had done it) and assert that the callback function is replaced each time.