Timestamp injection when Switch in Dashboard is on

Hello,

I want to have a timestamp injection with an interval (1 or 2 seconds) when the switch in the Dashboard is on.....I want to simulate an alarm system with an ultrasonic sensor.......if somebody is "near my house" and the alarm system ist armed, I will have a LED to blink....
Sorry for my english !!:slight_smile:

use a trigger-node to create/send the interval messages...connect the dashbord button to the trigger node and its on/off messages can control the triggering of the interval messages.

A simple way to do this is to have an Inject node injecting at the appropriate rate and send that through a node-red-contrib-simple-gate which you can control from the dashboard switch to allow or block the messages.

Here is a basic flow which does what you want.

Replace the inject and debug nodes as required.
And adjust the frequency too as required.

[{"id":"d5fdca2.390b0b8","type":"inject","z":"a941e919.4a7d88","name":"","topic":"","payload":"start","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":2270,"wires":[["310dcbed.f8124c"]]},{"id":"f3bf6ab5.45f388","type":"inject","z":"a941e919.4a7d88","name":"","topic":"","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":2320,"wires":[["310dcbed.f8124c"]]},{"id":"310dcbed.f8124c","type":"trigger","z":"a941e919.4a7d88","op1":"1","op2":"","op1type":"str","op2type":"nul","duration":"-1","extend":false,"units":"s","reset":"stop","bytopic":"all","name":"","x":400,"y":2270,"wires":[["6a7d8b0c.1d1adc"]]},{"id":"6a7d8b0c.1d1adc","type":"debug","z":"a941e919.4a7d88","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":580,"y":2270,"wires":[]}]

Oh yes, I forgot you could do that. @Trying_to_learn's way is better than my suggestion.

No problem.

I only know that because I have recently needed something just like that and so it is fresh in the memory.