Replaced a bunch of log by log_info

This commit is contained in:
Pierre committed 2026-09-27 22:55:17 +02:00
1 parent 098e95b439
commit 533785151e
4 files changed
+27 -27

No files matched your search

+13 -13
View File
@@ -104,7 +104,7 @@ class SmartSwitch(SmartObject):
if self.smart_conditions_evaluator == None:
self.off_conditions_evaluator = SmartCondition.Evaluator(self,self.args['off_conditions'],condition_name = "off_conditions",on_succeed_cb = self.on_off_conditions,constants = self.constants, templates_library = self.templates_library)
else:
self.log(f"Warning you can't have both an off_conditons and a smart_conditions, the off_conditions will be ignored")
self.log_warning(f"Warning you can't have both an off_conditons and a smart_conditions, the off_conditions will be ignored")
# Event-driven controls (off / on / toggle / iOS action)
self.event_handlers = []
@@ -120,12 +120,12 @@ class SmartSwitch(SmartObject):
self.auto_switch_cb_handle = None
if 'auto_switch_on_after' in self.args:
if self.is_off():
self.log(f"Smartswitch has been restarted while it was on. Since we have auto_switch_on_after activated we turn it on as we can't know how long is left for the timer",level = 'WARNING')
self.log_warning(f"Smartswitch has been restarted while it was on. Since we have auto_switch_on_after activated we turn it on as we can't know how long is left for the timer")
self.switch_on()
self.listen_state(self.on_state_change,self.entity_id, old = 'on',new = 'off')
if 'auto_switch_off_after' in self.args:
if self.is_on():
self.log(f"Smartswitch has been restarted while it was on. Since we have auto_switch_off_after activated we turn it off as we can't know how long is left for the timer",level = 'WARNING')
self.log_warning(f"Smartswitch has been restarted while it was on. Since we have auto_switch_off_after activated we turn it off as we can't know how long is left for the timer")
self.switch_off()
self.listen_state(self.on_state_change,self.entity_id, old = 'off',new = 'on')
@@ -137,7 +137,7 @@ class SmartSwitch(SmartObject):
# listen_state callback for auto_switch_*_after. Cancels any pending
# timer then arms a new one for the configured delay.
def on_state_change(self, entity, attribute, old, new, kwargs):
self.log("state changed from " + str(old) + " to " + str(new))
self.log_info("state changed from " + str(old) + " to " + str(new))
if old != new:
if self.auto_switch_cb_handle != None:
self.cancel_timer(self.auto_switch_cb_handle)
@@ -145,18 +145,18 @@ class SmartSwitch(SmartObject):
if new == 'on' and 'auto_switch_off_after' in self.args:
delay = self.args['auto_switch_off_after']
self.log(f"{self.entity_id} will auto switch on in {delay}s")
self.log_info(f"{self.entity_id} will auto switch on in {delay}s")
self.auto_switch_cb_handle = self.run_in(self.on_auto_switch_after, delay, new_state = 'off',autoswitch_delay = delay)
if new == 'off' and 'auto_switch_on_after' in self.args:
delay = self.args['auto_switch_on_after']
self.log(f"{self.entity_id} will auto switch off in {delay}s")
self.log_info(f"{self.entity_id} will auto switch off in {delay}s")
self.auto_switch_cb_handle = self.run_in(self.on_auto_switch_after, delay, new_state = 'on',autoswitch_delay = delay)
# Timer callback: applies the deferred state set by auto_switch_*_after.
def on_auto_switch_after(self, kwargs):
self.auto_switch_cb_handle = None
new_state = kwargs['new_state']
self.log(f"Switching {self.entity_id} {new_state} after {kwargs['autoswitch_delay']}s")
self.log_info(f"Switching {self.entity_id} {new_state} after {kwargs['autoswitch_delay']}s")
if new_state == 'on':
self.switch_on()
else:
@@ -167,7 +167,7 @@ class SmartSwitch(SmartObject):
# ------------------------------------------------------------------
def switch_on(self):
self.log(f"Turn on {self.entity_id}")
self.log_info(f"Turn on {self.entity_id}")
self.turn_on(self.entity_id)
# not needed yet
# if self.smart_conditions_evaluator:
@@ -176,7 +176,7 @@ class SmartSwitch(SmartObject):
# self.off_conditions_evaluator.force_last_evaluation_result(SmartCondition.Result.Succeeded)
def switch_off(self):
self.log(f"Turn off {self.entity_id}")
self.log_info(f"Turn off {self.entity_id}")
self.turn_off(self.entity_id)
# not needed yet
# if self.smart_conditions_evaluator:
@@ -186,10 +186,10 @@ class SmartSwitch(SmartObject):
def on_toggle_event(self, event_name, data, kwargs):
if self.is_on():
self.log(f"Toggled off by event {event_name}")
self.log_info(f"Toggled off by event {event_name}")
self.switch_off()
else:
self.log(f"Toggled on by event {event_name}")
self.log_info(f"Toggled on by event {event_name}")
self.switch_on()
def is_on(self): return self.get_state(self.entity_id) != 'off'
@@ -201,11 +201,11 @@ class SmartSwitch(SmartObject):
# ------------------------------------------------------------------
def on_turn_off_event(self, event_name, data, kwargs):
self.log(f"Turned off by event {event_name}")
self.log_info(f"Turned off by event {event_name}")
self.switch_off()
def on_turn_on_event(self, event_name, data, kwargs):
self.log(f"Turned on by event {event_name}")
self.log_info(f"Turned on by event {event_name}")
self.switch_on()
def on_toggle_event_action(self, event_name, data, kwargs):