Help on message construction in a TRIGGER node

This is a broken down flow of my problem.

Putting aside the change node at the top:

Press the inject node and get a message saying 192.168.0.254 is online.

The trigger node waits 10 seconds and if nothing is received I want it to send the same message but replace online with offline.

Alas this isn't happening.

--
Now the top part:

This sets the flow variable SCAN_FREQUENCY to 20000. (20 seconds)

I want the delay on the trigger node to be twice that value.

It is shown like this because there is no direct connection from how the SCAN_FREQUENCY is set and the trigger node.

The code:

[{"id":"7b035fc4.696038","type":"inject","z":"a941e919.4a7d88","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":2270,"wires":[["d263b33b.c60ba8"]]},{"id":"d263b33b.c60ba8","type":"change","z":"a941e919.4a7d88","name":"","rules":[{"t":"set","p":"SCAN_TIME","pt":"flow","to":"20000","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":2270,"wires":[[]]},{"id":"ae0a9ed3.61274","type":"function","z":"a941e919.4a7d88","name":"","func":"msg = {\"topic\":\"192.168.0.254\",\n    \"host\":\"192.168.0.254\",\n    \"_topic\":\"Gateway\",\n    \"payload\":\"192.168.0.254 On-line\",\n    };\n\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":2380,"wires":[["45d4648.bca2c9c","f302ebc0.037eb8"]]},{"id":"834f8cd5.72dd28","type":"inject","z":"a941e919.4a7d88","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":2380,"wires":[["ae0a9ed3.61274"]]},{"id":"45d4648.bca2c9c","type":"debug","z":"a941e919.4a7d88","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":420,"y":2340,"wires":[]},{"id":"f302ebc0.037eb8","type":"trigger","z":"a941e919.4a7d88","op1":"","op2":"{\"topic\":\"192.168.0.254\",\"host\":\"192.168.0.254\",\"_topic\":\"Gateway\",\"payload\":\"192.168.0.254 Off-line\",\"_msgid\":\"f742073e.b764d8\"}","op1type":"pay","op2type":"json","duration":"10","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":440,"y":2380,"wires":[["598f8ae4.df6c7c"]]},{"id":"598f8ae4.df6c7c","type":"debug","z":"a941e919.4a7d88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":2340,"wires":[]}]

Your bottom flow is sending the 'offline' msg, but you have stuck it inside an object inside msg.payload.
Change the 'Then Send' option to
Screen Shot 2020-03-20 at 7.40.48 PM
and your debug will look like:
Screen Shot 2020-03-20 at 7.40.54 PM

I don't believe that you can dynamically set the delay time

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.