Node Red monitor sensor state then kick off another flow

How does the current state node detect a sensor’s state change is this automatic or do I need a injection node?

Below is the basic flow to detected when sensor.piralarm sensor goes high for 0.5/sec then goes to debug. Issue is testing via my IOT device or via the /developer-tools/state I can change the sensor to on|off but the current state node does detect this by itself?

Ultimately I am trying to detect when the sensor state change to ‘on’ then delay for 3minutes before starting another flow to download a image from a remote FTP server rather than the flow checking and downloading the image file every 15minutes.

[{"id":"3b0b29c2a2ece136","type":"api-current-state","z":"467354e6dd094a5f","name":"Sensor State","server":"b561a051.8e723","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.piralarm","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"override_payload":false,"override_data":false,"x":170,"y":680,"wires":[["5455b58520140264","12c90de32f96ab48"],[]]},{"id":"5455b58520140264","type":"switch","z":"467354e6dd094a5f","name":"Check State","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":600,"wires":[["06952f160b84f8b8","12c90de32f96ab48"],[]]},{"id":"06952f160b84f8b8","type":"function","z":"467354e6dd094a5f","name":"Output True","func":"msg.payload = true;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":170,"y":500,"wires":[["12c90de32f96ab48"]]},{"id":"12c90de32f96ab48","type":"debug","z":"467354e6dd094a5f","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":990,"y":700,"wires":[]},{"id":"e8c26a7545b99939","type":"inject","z":"467354e6dd094a5f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":820,"wires":[["3b0b29c2a2ece136"]]},{"id":"b561a051.8e723","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

Use the Event:State Node instead.
That one is ‘automatic’ and output on changes.
M.

1 Like