mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Ignore duplicate state changes GarageDoor HomeKit (#18149)
* Ignore duplicate state changes GarageDoor HomeKit * Don't ignore service_call
This commit is contained in:
parent
dcdae325ea
commit
26ba4a56e8
@ -46,10 +46,12 @@ class GarageDoorOpener(HomeAccessory):
|
||||
|
||||
params = {ATTR_ENTITY_ID: self.entity_id}
|
||||
if value == 0:
|
||||
self.char_current_state.set_value(3)
|
||||
if self.char_current_state.value != value:
|
||||
self.char_current_state.set_value(3)
|
||||
self.call_service(DOMAIN, SERVICE_OPEN_COVER, params)
|
||||
elif value == 1:
|
||||
self.char_current_state.set_value(2)
|
||||
if self.char_current_state.value != value:
|
||||
self.char_current_state.set_value(2)
|
||||
self.call_service(DOMAIN, SERVICE_CLOSE_COVER, params)
|
||||
|
||||
def update_state(self, new_state):
|
||||
|
@ -80,13 +80,30 @@ async def test_garage_door_open_close(hass, hk_driver, cls, events):
|
||||
hass.states.async_set(entity_id, STATE_CLOSED)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await hass.async_add_job(acc.char_target_state.client_update_value, 1)
|
||||
await hass.async_block_till_done()
|
||||
assert acc.char_current_state.value == 1
|
||||
assert acc.char_target_state.value == 1
|
||||
assert len(events) == 2
|
||||
assert events[-1].data[ATTR_VALUE] is None
|
||||
|
||||
await hass.async_add_job(acc.char_target_state.client_update_value, 0)
|
||||
await hass.async_block_till_done()
|
||||
assert call_open_cover
|
||||
assert call_open_cover[0].data[ATTR_ENTITY_ID] == entity_id
|
||||
assert acc.char_current_state.value == 3
|
||||
assert acc.char_target_state.value == 0
|
||||
assert len(events) == 2
|
||||
assert len(events) == 3
|
||||
assert events[-1].data[ATTR_VALUE] is None
|
||||
|
||||
hass.states.async_set(entity_id, STATE_OPEN)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await hass.async_add_job(acc.char_target_state.client_update_value, 0)
|
||||
await hass.async_block_till_done()
|
||||
assert acc.char_current_state.value == 0
|
||||
assert acc.char_target_state.value == 0
|
||||
assert len(events) == 4
|
||||
assert events[-1].data[ATTR_VALUE] is None
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user