Queueing Triggers in Automation or Node-Red

Looking for either some logic help or suggestions on the best way to handle a specific scenario.

I have an automation set up in Node Red for when a person enters my “home” zone, it opens the garage door.

The automation works perfectly when a single person enters the zone. However, if there are multiple people riding together and they enter the zone at nearly the same time, the automation runs for each person and the process does not catch that the door is already open in time, causing the door to stop opening. I added the delay to see if that would give enough time for it to detect that the door is already open but it has just delayed the same behavior by 2 seconds.

Is there a (better?) way to essentially queue the trigger events and apply a delay to them? Or possibly have the first event run the automation and ignore any subsequent events for a short period of time? I’m ok with changing to an actual Automation if I need to. I’m not married to Node Red.

i don’t use node red, but this is super easy to do directly in ha automation.

see comments marked with # below

  - platform: state
      - person.person1   #if any of these people arrive home
      - person.person2
    to: home
condition: []
## generally speaking, you don't need to check if it's open.  calling open on an open door is fine.
  - service: cover.open_cover    
      entity_id: cover.garage_door_door
  - delay:
      seconds: 2   
mode: single      

the thing that does what you want is the delay of 2 seconds combined with mode: single at the end.

the delay makes this automation wait around for 2 seconds
single mode means that if this automation is attempted to run while it’s already running, don’t run it again. combined with the delay of 2 seconds, it solves your problem

I believe the best solution is to create a group with the device trackers or persons then you trigger on the group coming home.
This way it will only trigger once.

But it will also not trigger if the persons arrive half an hour apart.

wouldn’t that have the same behavior as triggering on zone.home state going from 0 to 1? and then you wouldn’t need to create the group?

i was presuming op wanted to trigger anytime anyone came home regardless of whether someone is already home. but i could be mistaken…

I believe so yes. You are correct.

If you want to keep this in NR, you can use a trigger state that will disable itself until the door is closed. Using a regex in the trigger, it will find all persons and fire when a person enters home.

[{"id":"3ca4603c763ccd79","type":"trigger-state","z":"0a325c35fc29f44e","name":"","server":"","version":4,"inputs":1,"outputs":2,"exposeAsEntityConfig":"","entityId":"^person\\..*$","entityIdType":"regex","debugEnabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"home"},{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is_not","comparatorValueDatatype":"str","comparatorValue":"home"}],"customOutputs":[],"outputInitially":false,"stateType":"str","enableInput":true,"x":510,"y":6340,"wires":[["29bfd5d776c10f6b","18196366851fc2bd"],[]]},{"id":"29bfd5d776c10f6b","type":"change","z":"0a325c35fc29f44e","name":"disable automation","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":6280,"wires":[["3ca4603c763ccd79"]]},{"id":"18196366851fc2bd","type":"api-call-service","z":"0a325c35fc29f44e","name":"open door","server":"","version":5,"debugenabled":false,"domain":"","service":"","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":790,"y":6340,"wires":[[]]},{"id":"fa141200ec59b7c4","type":"server-state-changed","z":"0a325c35fc29f44e","name":"enable door closes","server":"","version":5,"outputs":2,"exposeAsEntityConfig":"","entityIdType":"exact","outputInitially":false,"stateType":"str","ifState":"closed","ifStateType":"str","ifStateOperator":"is","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"enable","valueType":"str"}],"x":230,"y":6340,"wires":[["3ca4603c763ccd79"],[]]}]

Thanks everyone. Solution marked. Moving to a single run automation worked like a charm.

I like NR and use it for most of my automations. Tying nodes together allows for some really creative uses. But there are occasions where an Automation is actually easier.