Hey
Is there a go-to way to re-trigger automations once conditions are met?
I have an automation that turns off a device once it false below a certain power consumption but only when a few conditions are met:
- witihin specific time window OR when not at home
- etc.
The trigger is that if power is < 25W for some time.
However, if the conditions aren’t met, the power stays below 25W but later on the conditions would pass of course there is no new trigger.
I figure I could somehow add all conditions as slightly modified as triggers, add the original as condition but this feels cumbersome and I was wondering whether there is a more generic way to do this.
For reference, please find the automation attached.
Notice that I even needed a helper sensor “max power schreibtisch” with history of some minutes to be able to properly add the condition if power < x for some time t.
alias: Schreibtisch ausschalten
description: ""
trigger:
- alias: Desk power consumption below threshold for certain time
platform: numeric_state
entity_id:
- sensor.schreibtisch_shelly_switch_0_power
for:
hours: 0
minutes: 10
seconds: 0
below: 25
- platform: state
entity_id:
- input_boolean.auto_power_off
to: "on"
for:
hours: 0
minutes: 0
seconds: 10
- platform: time
at: "18:10:00"
- platform: numeric_state
entity_id:
- zone.home
for:
hours: 0
minutes: 10
seconds: 0
below: 1
- platform: numeric_state
entity_id:
- sensor.max_power_schreibtisch
below: 25
condition:
- alias: Confirm Plug is on
condition: state
state: "on"
entity_id: switch.schreibtisch_shelly_switch_0
- condition: state
entity_id: input_boolean.auto_power_off
state: "on"
- condition: or
conditions:
- alias: Check days and times
condition: or
conditions:
- condition: time
after: "18:00:00"
before: "08:00:00"
weekday:
- mon
- tue
- wed
- thu
- fri
alias: Confirm outside working hours on work days
- condition: time
weekday:
- sat
- sun
alias: Confirm weekend
- condition: numeric_state
entity_id: zone.home
below: 1
- condition: numeric_state
entity_id: sensor.max_power_schreibtisch
below: 25
above: 2
action:
- alias: Notify
service: notify.notify
data:
title: Energie Sparen 🔋
message: >-
Schreibtischleiste wurde ausgeschaltet weil der Verbrauch unter den
Grenzwert gefallen ist.
- service: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.schreibtisch_shelly_switch_0
mode: single
trace:
stored_traces: 5