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 , state : str = '' ):
164+ self ._state = 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,11 @@ 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+ if self .device ['model' ] in ('lumi.vibration.aq1' ):
719+ self .hass .loop .call_later (.1 , self .reset_state ('none' ))
720+ else :
721+ self .hass .loop .call_later (.1 , self .reset_state )
720722
721723 self .schedule_update_ha_state ()
722724
You can’t perform that action at this time.
0 commit comments