I have been tinkering around with shutting off lights that do not save their per-blackout state. I am able to use a numeric state value (ac voltage input) from my Ecoflow Delta Pro to trigger the automation when power is restored but have been unable to pass the specific entity ids to an action.
alias: Ecoflow Delta Pro Power Restored lights off
description: Turn off devices with always-on power loss behaviour
triggers:
- trigger: numeric_state
entity_id:
- sensor.delta_pro_210560_ac_input_voltage
above: 110
conditions: []
actions:
- wait_for_trigger:
- trigger: state
entity_id:
- light.ceiling_light_c1_local
- light.ceiling_light_c2_local
- light.hall_light_local
- light.kitchen_light_local
- light.dining_room_dimmer_local
- light.living_room_light_l1_local
- light.living_room_light_l2_local
- light.living_room_light_r1_local
- light.living_room_light_r2_local
- light.front_door_light_local
- light.porch_light_local
- light.bathroom_dimmer_local
to: "on"
from: unavailable
timeout:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
continue_on_timeout: false
- action: light.turn_off
data: {}
target:
entity_id: "{{ trigger.entity_id }}"
mode: parallel
max: 10
The main trigger works and the the wait for trigger works but the trigger.entity_id is not passed outside of the wait for trigger to the action. Any help would be appreciated.
No, I’m not sure of that. I don’t think that is it but I should eliminate the possibility. I will set up a test automation to test it that doesn’t involve simulating a power outrage and tell you the results.
Thanks for the input. I can’t believe it was so obvious. The solution was the understanding that the wait for trigger is a separate object (wait.trigger vs trigger) so all I did was change trigger.entity_id to wait.trigger.entity_id and it worked. The remaining issue is that it does not shut off all devices just the first one the changed from unavailable to on. I thought that using parallel mode would have solved this but I believe I need a loop in the actions to cycle thru all the lights instead of running the whole automation in parallel mode.
The problem with power outages is that you can’t tell how long everything has been off for. I have a housekeeping automation which basically switches everything off, then turns lights on again selectively on the basis of light levels, time of day, occupancy and so on. It’s triggered by a restart, not by the state of any particular device.
Good point to keep in mind as generally the HA server is also down during an outage. In my case the HA server (odroid N2), internet, router and network switches are on a UPS and the Ecoflow Delta Pro so they do not lose power (for at least 24 hours) during an outage.
I added a while loop to check when all listed entities are off and it works but I am sure there is a more efficient way to accomplish this. Here is what I got for a working automation.
alias: Ecoflow Delta Pro Power Restored lights off
description: Turn off devices with always-on power loss behaviour
triggers:
- trigger: numeric_state
entity_id:
- sensor.delta_pro_210560_ac_input_voltage
above: 110
conditions: []
actions:
- repeat:
sequence:
- wait_for_trigger:
- trigger: state
entity_id:
- light.ceiling_light_c1_local
- light.ceiling_light_c2_local
- light.hall_light_local
- light.kitchen_light_local
- light.dining_room_dimmer_local
- light.living_room_light_l1_local
- light.living_room_light_l2_local
- light.living_room_light_r1_local
- light.living_room_light_r2_local
- light.front_door_light_local
- light.front_door_strip_light_local
- light.porch_light_local
- light.bathroom_dimmer_local
to: "on"
from: unavailable
timeout:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
continue_on_timeout: true
- action: light.turn_off
data: {}
target:
entity_id: "{{ wait.trigger.entity_id }}"
enabled: true
until:
- condition: and
conditions:
- condition: state
entity_id: light.ceiling_light_c1_local
state: "off"
- condition: state
entity_id: light.ceiling_light_c2_local
state: "off"
- condition: state
entity_id: light.kitchen_light_local
state: "off"
- condition: state
entity_id: light.dining_room_dimmer_local
state: "off"
- condition: state
entity_id: light.living_room_light_l1_local
state: "off"
- condition: state
entity_id: light.living_room_light_l2_local
state: "off"
- condition: state
entity_id: light.living_room_light_r1_local
state: "off"
- condition: state
entity_id: light.living_room_light_r2_local
state: "off"
- condition: state
entity_id: light.front_door_light_local
state: "off"
- condition: state
entity_id: light.front_door_strip_light_local
state: "off"
- condition: state
entity_id: light.porch_light_local
state: "off"
- condition: state
entity_id: light.bathroom_dimmer_local
state: "off"
mode: restart
I am mulling over the while loop and the wait trigger sections to see if I can improve on it or go another route. If I (or anyone else) comes up with a more streamlined process, I will post it.