Increase time before scene and script HomeKit entities are reset (#54105)

This commit is contained in:
J. Nick Koston 2021-08-05 21:24:24 -05:00 committed by GitHub
parent 46ad55455b
commit adc9f75493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -57,6 +57,8 @@ VALVE_TYPE = {
ACTIVATE_ONLY_SWITCH_DOMAINS = {"scene", "script"}
ACTIVATE_ONLY_RESET_SECONDS = 10
@TYPES.register("Outlet")
class Outlet(HomeAccessory):
@ -141,7 +143,7 @@ class Switch(HomeAccessory):
self.async_call_service(self._domain, service, params)
if self.activate_only:
async_call_later(self.hass, 1, self.reset_switch)
async_call_later(self.hass, ACTIVATE_ONLY_RESET_SECONDS, self.reset_switch)
@callback
def async_update_state(self, new_state):

View File

@ -329,7 +329,13 @@ async def test_reset_switch(hass, hk_driver, events):
future = dt_util.utcnow() + timedelta(seconds=1)
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert acc.char_on.value is True
future = dt_util.utcnow() + timedelta(seconds=10)
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert acc.char_on.value is False
assert len(events) == 1
assert not call_turn_off
@ -367,7 +373,13 @@ async def test_script_switch(hass, hk_driver, events):
future = dt_util.utcnow() + timedelta(seconds=1)
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert acc.char_on.value is True
future = dt_util.utcnow() + timedelta(seconds=10)
async_fire_time_changed(hass, future)
await hass.async_block_till_done()
assert acc.char_on.value is False
assert len(events) == 1
assert not call_turn_off