# Timestamp injection when Switch in Dashboard is on

**URL:** <https://discourse.nodered.org/t/timestamp-injection-when-switch-in-dashboard-is-on/23283>\
**Category:** Dashboard\
**Created:** [18 March 2020 18:18 UTC](https://discourse.nodered.org/t/timestamp-injection-when-switch-in-dashboard-is-on/23283 "2020-03-18T18:18:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![StevenRott](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@StevenRott](https://discourse.nodered.org/u/StevenRott)\
**Post date:** [18 March 2020 18:18 UTC](https://discourse.nodered.org/t/timestamp-injection-when-switch-in-dashboard-is-on/23283/1 "2020-03-18T18:18:30Z")

</div>

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 !!🙂

---

<div class="post-metadata">

**Author:** ![hominidae](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hominidae/32/4174_2.png) [@hominidae](https://discourse.nodered.org/u/hominidae)\
**Post date:** [18 March 2020 19:10 UTC](https://discourse.nodered.org/t/timestamp-injection-when-switch-in-dashboard-is-on/23283/2 "2020-03-18T19:10:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 March 2020 20:44 UTC](https://discourse.nodered.org/t/timestamp-injection-when-switch-in-dashboard-is-on/23283/3 "2020-03-18T20:44:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [18 March 2020 21:37 UTC](https://discourse.nodered.org/t/timestamp-injection-when-switch-in-dashboard-is-on/23283/4 "2020-03-18T21:37:41Z")

</div>

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.

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 March 2020 21:58 UTC](https://discourse.nodered.org/t/timestamp-injection-when-switch-in-dashboard-is-on/23283/5 "2020-03-18T21:58:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [18 March 2020 22:10 UTC](https://discourse.nodered.org/t/timestamp-injection-when-switch-in-dashboard-is-on/23283/6 "2020-03-18T22:10:11Z")

</div>

No problem.

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 April 2020 22:10 UTC](https://discourse.nodered.org/t/timestamp-injection-when-switch-in-dashboard-is-on/23283/7 "2020-04-17T22:10:15Z")

</div>

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