Automation with multiple groups and delays

Trying to get the following automation to work:

While sensor X is below value X
When ( Lights Group 1 are off AND Lights Group 2 are off AND Lights Group 3 are off )
After X amount of time, while these conditions still met
Trigger X

Can’t seem to get this to work. Any help would be awesome.

If I understood you requirements correctly, this should get you going:

binary_sensor:
- platform: template
  sensors:
    is_dark:
      value_template: >
        {{ states('sensor.sensorx') | int < 100 and
           is_state('group.lighting1', 'off') and
           is_state('group.lighting2', 'off') and
           is_state('group.lighting3', 'off') }}


automation:
- alias: 'Monitor is_dark'
  trigger:
    platform: state
    entity_id: sensor.is_dark
    to: 'on'
    for: '00:05:00'
  action:
    service: notify.whatever
    data:
      message: 'Dark for more than 5 minutes.' 

The first item is a Template Binary Sensor called binary_sensor.is_dark. I don’t know what you are monitoring so I chose darkness level. The value_template determines if the binary_sensor’s state is on or off. For the binary_sensor to be on, some other sensor called sensor.sensorx must be less than 100 and all three lighting groups must be off.

The second item is an automation that monitors the state of sensor.is_dark. If the state remains on for at least 5 minutes it proceeds to the action where it sends a notification (or whatever it is you actually want to do).

1 Like