diff --git a/apps/smartswitch.py b/apps/smartswitch.py index 2d49578..eb6425f 100644 --- a/apps/smartswitch.py +++ b/apps/smartswitch.py @@ -155,8 +155,12 @@ class SmartSwitch(SmartObject): # Timer callback: applies the deferred state set by auto_switch_*_after. def on_auto_switch_after(self, kwargs): self.auto_switch_cb_handle = None - self.log(f"Switching {self.entity_id} {kwargs['new_state']} after {kwargs['autoswitch_delay']}s") - self.set_state(self.entity_id,state = kwargs['new_state']) + new_state = kwargs['new_state'] + self.log(f"Switching {self.entity_id} {new_state} after {kwargs['autoswitch_delay']}s") + if new_state == 'on': + self.switch_on() + else: + self.switch_off() # ------------------------------------------------------------------ # Public switch API