Multiple triggers

Hi,

I’m wondering if it’s possible to have multiple triggers - combined like an AND statement. e.g.

trigger:
  platform: state
  entity_id: light.office
  to: 'off'
  for: '00:00:05'
  AND
  entity_id: sensor.office_motion
  to: 'true'
action:
  service: light.turn_on
  entity_id: light.office

The reason for this being that if my light turns off by sensor and I want to get it back on quickly my current set up doesn’t work because there’s a condition which checks the light level, but the light level doesn’t update quick enough for the motion sensor to come back on straight away.

Sure, use it like this:

trigger:
  - platform: state
    entity_id: light.office
    to: 'off'
    for: '00:00:05'
  - platform: state
    entity_id: sensor.office_motion
    state: 'true'
action:
  service: light.turn_on
  entity_id: light.office

Sorry, read to fast. Automation above triggers as an OR statement. If you want it to fire only if both conditions are met, use it like this:

trigger:
  platform: state
    entity_id: sensor.office_motion
    state: 'true'
condition:  
  condition: state
  entity_id: light.office
  state: 'off'
  for: '00:00:05'
action:
  service: light.turn_on
  entity_id: light.office

Thanks Bob that was obvious now I think about it!

1 Like

Hi folks,
is there no way to AND triggers then?

if A & B happens then with condition C, action D

my concern about adding B to a condition is that you will miss some of the automations (and thus need to create 2 automations, one for each way round)

So in the example A happens, when B and C conditions are met, action D

If A happens happens last, the trigger occurs as conditions B and C are met.

however if A happens first, and condition B isnt met action D wont occur?

is the only way to solve this really with 2 automations?

Trigger A
condiitons B, C
Action D

Trigger B
conditions A, C
Action D

welcome insight here

2 Likes

I want to use two motion sensors the same way but it does not work. It should turn the lights off when there is no movement for the given time. What am I doing wrong?

  trigger:
  - entity_id: binary_sensor.motion_sensor_158d00015b89f6
for: 00:02:00
platform: state
to: 'off'
  condition:
  - condition: state
entity_id: binary_sensor.motion_sensor_158d000123265f
state: 'off'
for: 00:05:00
  action:
  - alias: ''
data:
  entity_id: group.wc
service: switch.turn_off