I’ve got a simple automation, at 11 pm I turn on my night scene (scene.night) only if the following “and” conditions are met. The lights in this example are dimmers if that makes any difference. If I remove the conditions the automation works fine. So if I put back the conditions, the automation should only execute if all lights are off. However, it seems that the automation executes regardless of the state of the lights. Using the developer tools, I can see in the states panel that the lights are on, yet the automation proceeds. Any suggestions?
- alias: 'Set nightlight scene'
initial_state: true
hide_entity: false
trigger:
platform: time
after: '23:00:00'
condition:
condition: and
conditions:
- condition: state
entity_id: light.light6_level_17_0
state: 'off'
- condition: state
entity_id: light.light3_level_18_0
state: 'off'
- condition: state
entity_id: light.dininglight_level_20_0
state: 'off'
action:
- service: scene.turn_on
entity_id: scene.night
You could group your lights together and just call one condition that group.lights (or whatever you call the group) state is off or you can try getting rid of the
condition:
condition: and
conditions:
and just do
condition:
- condition: state
entity_id: light.light6_level_17_0
state: 'off'
- condition: state
entity_id: light.light3_level_18_0
state: 'off'
- condition: state
entity_id: light.dininglight_level_20_0
state: 'off'
That also seems to execute the automation even when the lights are on.
I’m testing the automation by executing the trigger condition on the automation control. Is it possible that when I trigger the automation the action is always executed regardless of the condition?
Well, I think that’s it. HA skips the condition when the automation is manually triggered. Not sure why they did this since events occur occasionally and condition check states that persist, so it seems to me it would be much better to let manual triggers check conditions. But heck, I’m just a lonely user.
Does anyone have a suggestion on how I could check my conditions with the code above?