I created this automation to check and, in case, turn off all the lights if, during all the night, i experiment a shutdown of my router which causes some lights turn on.
- id: '1639219618905'
alias: Spegni tutte le luci dopo assenza elettricità
description: Spegni Luci dopo shutdown elettricità
trigger:
- platform: state
entity_id: light.yeelight_6
from: 'off'
to: 'on'
condition:
- condition: time
after: 01:00
before: 08:30
action:
- service: light.turn_off
target:
entity_id: all
mode: single
Is this automation ok? Will do what i want it does? Or is there a better way to do that?
Sorry for my english and i hope you understand well what i mean…
If that is the actual automation, then no it will not do what you want.
You cannot just put “all” under entity_id, you need to enter the actual entities or put the lights in a group.
You need to be careful with your trigger. Depending on the light, Home Assistant may see the light’s state go from “unavailable” to “on” not from “off” to “on”. Is there any possible reason that someone will turn light.yeelight_6 “on” between 1am and 8:30am? You don’t want to be fumbling around in the dark because you flipped a light on and the automation then turned all the lights off.
Keep in mind that for it to work as you want all the devices need to be under the light domain. For example a “dumb” lightbulb that is controlled by a switch entity will not be turned off. You can get around this by creating a template light.
… I guess it would have helped if I had remembered that the “lights” in the room I was in when I tested it this morning (before posting) were actually under the switch domain.
I will check it as, if the electricity goes off and on in really few seconds, i see the light doesn’t go in ‘unavailable’ state, but only from ‘off’ to ‘on’…
Thanks, but all my lights are under ‘light’ domain…