Stairs motion light help

Hi …

I have two motion sensors with different behavior (i.e. time to turn off is different) one at the bottom of my stairs one at the top that I want to use to control a light on the stairs.

How would I code this with in HA yaml?

I’m fairly certain I want this pseudo code but don’t know how to put that into an HA yaml:

if (sensor_a or sensor_b) to 'on' then
  light on
  if (sensor_a and sensor_b) to 'off' then
    wait 2 minutes
    light off
  fi
fi

Thanks :slight_smile:

Create a helper group binary switch, of class Motion. You could call it ‘stairs Motion’ or some such. Put your 2 motion sensors in that group.

Then build your automation around that, in the UI. Something like: when ‘stairs motion’ goes ‘off’ (for 2 minutes) → light off.

Actually it’s a perhaps intermediate topic, but you could do both on and off in one automation using trigger IDs.

You could leave it just like that, but if you want to learn the YAML, click on ‘show YAML’ once you have it working.

1 Like