|
@@ -82,12 +82,41 @@ def handle_kitchen_worklights():
|
|
|
light.turn_off(entity_id='light.kitchen_worktop_4k')
|
|
|
light.turn_off(entity_id='light.kitchen_worktop_27k')
|
|
|
|
|
|
+#@state_trigger("binary_sensor.kitchen_fridge_door")
|
|
|
+#def light_turned_on(**kwargs):
|
|
|
+# log.info(f"got arguments {kwargs}")
|
|
|
+
|
|
|
+@state_trigger("binary_sensor.kitchen_fridge_door == 'on'")
|
|
|
+@task_unique('fridge_open_too_long', kill_me=True)
|
|
|
+def fridge_door_open_too_long():
|
|
|
+ log.info("Fridge door has been opened")
|
|
|
+ #service.call("button", "press", entity_id="button.kitchen_alarm_notification")
|
|
|
+ t_info = task.wait_until(state_trigger="binary_sensor.kitchen_fridge_door == 'off'",timeout=30)
|
|
|
+ if t_info["trigger_type"] != "timeout":
|
|
|
+ log.info("Fridge door closed before timeout")
|
|
|
+ return
|
|
|
+ log.info("Fridge door has been opened for 30 seconds — do a notification.")
|
|
|
+ service.call("button", "press", entity_id="button.kitchen_alarm_notification")
|
|
|
+ t_info = task.wait_until(state_trigger="binary_sensor.kitchen_fridge_door == 'off'",timeout=10)
|
|
|
+ if t_info["trigger_type"] != "timeout":
|
|
|
+ log.info("Fridge door closed before timeout")
|
|
|
+ return
|
|
|
+ log.info("Fridge door has been opened for 40 seconds — do a notification.")
|
|
|
+ service.call("button", "press", entity_id="button.kitchen_alarm_notification")
|
|
|
+ t_info = task.wait_until(state_trigger="binary_sensor.kitchen_fridge_door == 'off'",timeout=10)
|
|
|
+ if t_info["trigger_type"] != "timeout":
|
|
|
+ log.info("Fridge door closed before timeout")
|
|
|
+ return
|
|
|
+ log.info("Fridge door has been opened for 50 seconds — do a notification.")
|
|
|
+ service.call("button", "press", entity_id="button.kitchen_alarm_notification")
|
|
|
+ t_info = task.wait_until(state_trigger="binary_sensor.kitchen_fridge_door == 'off'",timeout=10)
|
|
|
+ if t_info["trigger_type"] != "timeout":
|
|
|
+ log.info("Fridge door closed before timeout")
|
|
|
+ return
|
|
|
+ log.info("Fridge door has been opened for 60 seconds — activate alarm.")
|
|
|
+ service.call("switch", "turn_on", entity_id="switch.kitchen_audible_alarm")
|
|
|
+ t_info = task.wait_until(state_trigger="binary_sensor.kitchen_fridge_door == 'off'",timeout=5*60)
|
|
|
+ log.info("Door closed or alarm has been active for 5 minutes — turn off.")
|
|
|
+ service.call("switch", "turn_off", entity_id="switch.kitchen_audible_alarm")
|
|
|
|
|
|
|
|
|
-@state_trigger("select.fridge_door_alarm")
|
|
|
-def reset_fridge_alarm_state(value=None, old_value=None):
|
|
|
- log.info(f"********* FRIDGE ALARM CONFIG *********** To:" + value + " From:" + old_value)
|
|
|
- if value == 'TEST':
|
|
|
- #task.sleep(1) # Wait 1 second
|
|
|
- select.fridge_door_alarm = old_value
|
|
|
- mqtt.publish(topic="kitchen/fridge/doorAlarmControl", payload=old_value , retain=True)
|