# Delay in activating a second command

**URL:** <https://discourse.nodered.org/t/delay-in-activating-a-second-command/12353>\
**Category:** General\
**Created:** [18 June 2019 06:41 UTC](https://discourse.nodered.org/t/delay-in-activating-a-second-command/12353 "2019-06-18T06:41:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Unikumet](https://avatars.discourse-cdn.com/v4/letter/u/7ea924/32.png) [@Unikumet](https://discourse.nodered.org/u/Unikumet)\
**Post date:** [18 June 2019 06:41 UTC](https://discourse.nodered.org/t/delay-in-activating-a-second-command/12353/1 "2019-06-18T06:41:42Z")

</div>

Hi all,

I'm currently working on a flow which has a basic UI which allows you to activate a function with a on / off switch which is connected to a trigger function automatically turning it off again after x-seconds.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1f0589337f7b3fe775239dd24bb6791587da0a13.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2016d30f30ee30d59eec7df4621cc7c27014ba1c.png)

What I want to achieve is that it is not possible to activate two functions at the same time, could any of you give me a pointing in the right direction for this?

Lets say when I activate the "Vibration Main" function, the "Vibration Backup" function should not be possible to activate at the same time.

All help is appreciated.

Best regards  
Alex

---

<div class="post-metadata">

**Author:** ![stew](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stew/32/9360_2.png) [@stew](https://discourse.nodered.org/u/stew)\
**Post date:** [18 June 2019 07:28 UTC](https://discourse.nodered.org/t/delay-in-activating-a-second-command/12353/2 "2019-06-18T07:28:45Z")

</div>

Setting `msg.enabled` to `false` will disable the switch widget. You can reset this after your timer expires.

---

<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 June 2019 08:00 UTC](https://discourse.nodered.org/t/delay-in-activating-a-second-command/12353/3 "2019-06-18T08:00:05Z")

</div>

Even with the button disabling suggested it may be possible to beat it by hitting the two buttons in quick succession, before the second one has been disabled (or possibly there are two instances of the the dashboard open on separate devices and the two users request the actions simultaneously) so if it would be serious if they somehow both got activated at the same time I would put some additional logic in that prevents them both happening. You could use node-red-contrib-semaphore to do that for example.

---

<div class="post-metadata">

**Author:** ![Unikumet](https://avatars.discourse-cdn.com/v4/letter/u/7ea924/32.png) [@Unikumet](https://discourse.nodered.org/u/Unikumet)\
**Post date:** [18 June 2019 08:59 UTC](https://discourse.nodered.org/t/delay-in-activating-a-second-command/12353/4 "2019-06-18T08:59:34Z")

</div>

The tool would break if both were activated at the same time. I'll see what I can figure out with the semaphore. Thanks for recommending it!

---

<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 June 2019 09:05 UTC](https://discourse.nodered.org/t/delay-in-activating-a-second-command/12353/5 "2019-06-18T09:05:08Z")

</div>

If it is that serious then I suggest a completely independent mechanism around the machine itself. Possibly something like a changeover relay that selects one or the other then another relay in series that says on/off. Then on the pi (or whatever) have outputs that drive the enable and the selection relays.  
**[Edit]** Otherwise you can never be certain that a problem with the pi (hardware or software) will not enable both at the same time.
