Refactor auto switch handling in SmartSwitch to use dedicated methods for state changes

This commit is contained in:
2026-05-09 13:35:32 +02:00
parent 9f8d0b68fa
commit 0e14281516

View File

@@ -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