Light automation trigger & timer

Hi,

I’m trying to automate my hallway lights and what seems like a straight forward thing to do turns increasingly complex the more I think about it. I was wondering if some of you have some ideas/input to point me in the right direction:

I have several triggers to turn the lights on and off:

  • Aeotec wallmote smart switch
  • Motion sensor
  • Pressure pad under the stairs

Currently the Aeotec wallmote smart switch simply turns the light on and off. However what I would like to achieve is the following:

The light comes on automatically when either

  • The pressure pad gets triggered
  • The motion sensor gets triggered

and it stays on for 5 min. Any fresh motion trigger resets the 5 min timer.

I’m not sure how to deal with the timer, re-setting it with each new motion trigger and pack this in a HA automation - any ideas?

Cheers!

I do it with two automations. Could do one but it starts getting complicated as I use an input_boolean when the robot vacuum is running.

alias: Study Lights On via Motion
description: Control Study Lights with Shelly Motion Detection
trigger:
  - platform: state
    entity_id: binary_sensor.shellymotionsensor_study
    to: 'on'
  - platform: state
    entity_id: binary_sensor.touchpad
    to: 'on'
condition:
  - condition: device
    type: is_off
    device_id: xxxxxxxxxxxx
    entity_id: light.study_cans_current_value
    domain: light
action:
  - service: light.turn_on
    target:
      entity_id: light.study_cans_current_value
    data:
      brightness: 159
mode: single
alias: Study Lights Off via Motion
description: Control Study Lights with Shelly Motion Detection
trigger:
  - platform: state
    entity_id: binary_sensor.shellymotionsensor_study
    to: 'off'
    for:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - platform: state
    entity_id: binary_sensor.touchpad
    to: 'off'
    for:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
condition:
  - condition: state
    entity_id: input_boolean.vacuum
    state: 'off'
action:
  - service: light.turn_off
    target:
      entity_id: light.study_cans_current_value
mode: single

I added a second trigger below the motion sensor for the pressure pad. You can do this from the UI.

It would be easier to give advice if you post the (properly formatted yaml) current version of the automation(s) you have and then exactly what isn’t working for you.

Well I haven’t build it yet as I am looking for ways of implementing this :slight_smile:

well, give it a shot on your own and if you get stuck then pop back in with what you have until that point and we can try to help you from there.