I put a motion Sensor under my bed and created an automation that turn 3 lights when i put down my feet on the floor (after the sun went down). I call the automation “Toilet nightvisit”. One of the lights that are triggering are in my hallway.
But if that light are already on i dont want “Toilet nightvisit” automation trigger that light. But it must trigger the other 2 lights.
How do i do that?
Let me see if I understand:
If the motion sensor detects motion, you want to turn on three lights.
Unstated by you, but I think you implied this, when the motion sensor changes to the clear state, you want all three lights to turn off.
But if the hall light is on when the motion sensor detects motion, you don’t want the hall light to be turned off when the motion sensor changes to the clear state.
I would use a toggle helper. When the motion is detected, set the state of the toggle helper to the state of the light. When the motion sensor changes to the clear state, turn off the other two lights and then set the hall light to the state of toggle helper.
When creating automations, it is very important to make a clear list of what you want the automation to do. Using words that succinctly describes the actions helps a lot. Think about a lot of “what ifs” and figure out how to deal with each one.
Use in the action an IF condition to check if the 3th light is on or not and based o that do your action
And i would use ‘choose’
one with a conditional action and
one default action
something like this:
alias: "test"
description: ""
triggers:
- trigger: motion.detected
target:
entity_id: binary_sensor.frontdoor_motion
options: {}
conditions: []
actions:
- choose:
- conditions:
- condition: state
entity_id: light.office_ceiling_light
state:
- "on"
sequence:
- action: light.turn_on
metadata: {}
target:
entity_id:
- light.shelly1_engineroom_light
- light.office_ceiling_light
data: {}
- delay:
hours: 0
minutes: 3
seconds: 0
milliseconds: 0
- action: light.turn_off
metadata: {}
target:
entity_id:
- light.shelly1_engineroom_light
- light.office_ceiling_light
data: {}
default:
- action: light.turn_on
metadata: {}
target:
entity_id:
- light.shelly1_engineroom_light
- light.office_ceiling_light
- light.guestroom_ceiling_light
data: {}
- delay:
hours: 0
minutes: 3
seconds: 0
milliseconds: 0
- action: light.turn_off
metadata: {}
target:
entity_id:
- light.shelly1_engineroom_light
- light.office_ceiling_light
- light.guestroom_ceiling_light
data: {}
mode: single