Automations (Node-Red): wait for event?

Hi everyone, I’m looking to set up an automation that relies on a sequence of buttons being pushed from a Z-wave scene selector.

This selector already has automations set up for it that are triggered by the zwave.scene_activated event, which doesn’t change any states or attributes:

  - event_data:
      node_id: 7
      scene_data: 0
      scene_id: 1
    event_type: zwave.scene_activated
    platform: event

While events are easy to use for automation triggers, I was hoping to use them for a wait instead. I know that templates can do this, but I’m having trouble trying to build them, both in the regular automations and Node-Red.

Any help greatly appreciated!

So you want two or more different events to happen before moving forward in the flow?

Is the number of events defined static? is the same for the event data?

So while I’d love two or more events to happen before moving on with the flow, a “continue or fail” situation would be okay too.

In the below example, the scene_id and scene_data can be different depending on what buttons are pushed and how they’re pushed. Let’s assume single pushes, so node_id will always be 7 and scene_data will always be 0. scene_id will be different depending on which button pressed (1, 2, etc.).

I’d want it so the flow will continue if the first button is pressed, followed immediately by button 2.

- event_data:
      node_id: 7
      scene_data: 0
      scene_id: 1
    event_type: zwave.scene_activated
    platform: event

This here simulates the event objects so the trigger node waits for 4 seconds before sending the object, if something comes in between that period it will wait another four seconds, finally it will send the last object, The switch node filters out any scene_id that is not 1, 2 or 3.

[{"id":"72db09a0.17a488","type":"debug","z":"64b0477e.6a31f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1110,"y":300,"wires":[]},{"id":"783fc16d.031bf","type":"inject","z":"64b0477e.6a31f8","name":"","topic":"","payload":"{\"event_type\":\"zwave.scene_activated\",\"topic\":\"zwave.scene_activated\",\"payload\":{\"event_type\":\"zwave.scene_activated\",\"event_data\":{\"node_id\":7,\"scene_data\":0,\"scene_id\":2}},\"_msgid\":\"c7da680e.adbf88\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":450,"y":300,"wires":[["d648a823.a28468"]]},{"id":"d648a823.a28468","type":"function","z":"64b0477e.6a31f8","name":"","func":"msg = msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":300,"wires":[["ee0e2466.f0e9c8"]]},{"id":"ee0e2466.f0e9c8","type":"switch","z":"64b0477e.6a31f8","name":"","property":"(\tpayload.event_data.scene_id in [1,2,3]\t)","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":790,"y":300,"wires":[["7ce645c8.34e47c"]]},{"id":"19970078.0df8","type":"inject","z":"64b0477e.6a31f8","name":"","topic":"","payload":"{\"event_type\":\"zwave.scene_activated\",\"topic\":\"zwave.scene_activated\",\"payload\":{\"event_type\":\"zwave.scene_activated\",\"event_data\":{\"node_id\":7,\"scene_data\":0,\"scene_id\":1}},\"_msgid\":\"c7da680e.adbf88\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":450,"y":240,"wires":[["d648a823.a28468"]]},{"id":"324a5c77.b1d514","type":"inject","z":"64b0477e.6a31f8","name":"","topic":"","payload":"{\"event_type\":\"zwave.scene_activated\",\"topic\":\"zwave.scene_activated\",\"payload\":{\"event_type\":\"zwave.scene_activated\",\"event_data\":{\"node_id\":7,\"scene_data\":0,\"scene_id\":3}},\"_msgid\":\"c7da680e.adbf88\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":450,"y":360,"wires":[["d648a823.a28468"]]},{"id":"a0dc346d.210648","type":"inject","z":"64b0477e.6a31f8","name":"","topic":"","payload":"{\"event_type\":\"zwave.scene_activated\",\"topic\":\"zwave.scene_activated\",\"payload\":{\"event_type\":\"zwave.scene_activated\",\"event_data\":{\"node_id\":7,\"scene_data\":0,\"scene_id\":4}},\"_msgid\":\"c7da680e.adbf88\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":450,"y":400,"wires":[["d648a823.a28468"]]},{"id":"7ce645c8.34e47c","type":"trigger","z":"64b0477e.6a31f8","op1":"1","op2":"","op1type":"str","op2type":"payl","duration":"4","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":960,"y":300,"wires":[["72db09a0.17a488"]]}]

If you are looking at a combination of presses then you probably need a join node, i have a similar flow for that which works on a sonoff t1, a double press on one button, then a double on the second button in a short period of time activates a scene, and another scene if executed in reverse.