Node Red equivalent of "for"

Hi,

I currently have an automation that looks something like this :

- alias: Alarm Armed Notification
  trigger:
    - platform: state
      entity_id: group.all_people
      from: 'home'
      to: 'not_home'
      for:
        minutes: 1
  action:
    - service: notify.notifyme
      data:
        message: Alarm Has Been Armed

I’ve managed to replicate most of it’s behaviour in Node Red except the “for: minutes :1” part. This ensures that the state has settled for at least 1min before it processed the action. Could you suggest how I can replicate this in Node Red please?

Thanks

Use the “delay” node. The basic flow is: have the trigger (in your case the switch to “not_home” go in to a delay node, then to the notify service call node.

If you want the delay to be sopped if you go to “home” before the delay is up, put a second trigger that sends “STOP” to the delay node when “home” is triggered.

I do a similar thing for my attic door. I want the light to come on when I open it, but turn off 5 min after I close it. Looks like this:

3 Likes

Thanks.

With help from the Node-Red forum, I was also able to achieve what I needed using the built-in ‘trigger’ node.

  • Send nothing immediately
  • tick extend time with new message
  • Send new message after time delay

Thanks

I found this thread when I was looking for a way to use ‘for’ in a condition. In my case I want to turn the lights on when a door opens and the lights have been off for at least 5 minutes. The solution I ended up with was to use the stoplight node, like this:

Clipboard export

[{"id":"29eb14ba.059efc","type":"trigger-state","z":"2912f873.4442d8","name":"doorsensor","server":"c219f95c.2019c8","entityid":"sensor.door_sensor","debugenabled":false,"constraints":[{"id":"hl6oasl8o","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"open"},{"id":"zeamaqftt2o","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"closed"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"x":130,"y":140,"wires":[["fc08098.c317ef8"],[]]},{"id":"5d3e616c.05fc7","type":"trigger-state","z":"2912f873.4442d8","name":"lights","server":"c219f95c.2019c8","entityid":"group.lights","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":true,"x":110,"y":220,"wires":[["5767bf34.e6a1d"],[]]},{"id":"fc08098.c317ef8","type":"traffic","z":"2912f873.4442d8","name":"light off for 5 minutes?","property_allow":"payload","filter_allow":"go","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"stop","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":false,"differ":false,"x":840,"y":140,"wires":[["189ae328.9ff1cd"]]},{"id":"5767bf34.e6a1d","type":"switch","z":"2912f873.4442d8","name":"on / off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":220,"wires":[["5fb1487e.e7ed88"],["3b00aa21.0dadc6"]]},{"id":"3b00aa21.0dadc6","type":"trigger","z":"2912f873.4442d8","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"1","extend":true,"units":"min","reset":"","bytopic":"all","name":"5min. delay","x":450,"y":260,"wires":[["b388e66b.b3b728"]]},{"id":"b388e66b.b3b728","type":"change","z":"2912f873.4442d8","name":"go","rules":[{"t":"set","p":"payload","pt":"msg","to":"go","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":260,"wires":[["fc08098.c317ef8"]]},{"id":"5fb1487e.e7ed88","type":"change","z":"2912f873.4442d8","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":200,"wires":[["fc08098.c317ef8"]]},{"id":"189ae328.9ff1cd","type":"api-call-service","z":"2912f873.4442d8","name":"beneden licht aan","server":"c219f95c.2019c8","service_domain":"group","service":"turn_on","data":"{\"entity_id\": \"living_room\"}","mergecontext":"","x":1090,"y":140,"wires":[[]]},{"id":"c219f95c.2019c8","type":"server","z":"","name":"Home Assistant"}]