File tree Expand file tree Collapse file tree
custom_components/aqara_gateway Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,6 +159,10 @@ def update(self, data: dict = None):
159159 self ._state = not value
160160
161161 self .schedule_update_ha_state ()
162+
163+ def reset_state (self ):
164+ self ._state = ''
165+ self .async_write_ha_state ()
162166
163167
164168class GatewayMotionSensor (GatewayBinarySensor ):
@@ -598,10 +602,6 @@ def update(self, data: dict = None):
598602
599603 self .schedule_update_ha_state ()
600604
601- def reset_state (self ):
602- self ._state = ''
603- self .async_write_ha_state ()
604-
605605
606606class GatewayAction (GatewayBinarySensor , BinarySensorEntity ):
607607 """ Xiaomi/Aqara Action Cube """
@@ -714,9 +714,8 @@ def update(self, data: dict = None):
714714 'entity_id' : self .entity_id , 'click_type' : self ._state
715715 })
716716
717- time .sleep (.1 )
718-
719- self ._state = ''
717+ # reset the state to empty after 0.1 second
718+ self .hass .loop .call_later (.1 , self .reset_state )
720719
721720 self .schedule_update_ha_state ()
722721
You can’t perform that action at this time.
0 commit comments