# \[Edit\] temporarily stop flows from executing

**URL:** <https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754>\
**Category:** General\
**Tags:** function-node\
**Created:** [9 October 2022 10:18 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754 "2022-10-09T10:18:18Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [9 October 2022 10:18 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/1 "2022-10-09T10:18:18Z")

</div>

So, quick question, how do I implement a "pauze"in my automations after the user has overridden the flow control.  
So i.e. I have a flow that controls our light, based on lumen and sun elevation (my version of adaptive lighting so to say), but how do I prevent the system from undoing a user interaction. So the flow is changing the brightness and color temp all the time, but I want the system to stop doing that if I myself set a certain brightness and/or color(temp). So whenever I interact via the HA UI(which I hope never to have to do) I want that setting to be kept for say 12 hours at which time it's logical the system resumes functioning.

---

<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:** [9 October 2022 10:23 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/2 "2022-10-09T10:23:55Z")

</div>

Hi.

There are a few ways to do it.

Have your normal code/nodes and when it is sending the brightness out to the bulb, you add a bit of code:

Well, actually your write another bit of code and then set a `flow context` that is set for `12` hours then resets.

During the time that value is set, the other values are not passed.

I'll write some code and post/edit this reply shortly.

Try this example.

```auto
[{"id":"82e90658c3f9fa2b","type":"inject","z":"0918ee609bf69fc7","name":"Your existing message come in here.","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":3460,"y":2860,"wires":[["5db0255799643df4"]]},{"id":"5db0255799643df4","type":"switch","z":"0918ee609bf69fc7","name":"","property":"pass","propertyType":"flow","rules":[{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":3680,"y":2860,"wires":[["3740b3a8f1cec4b0"]]},{"id":"5fe673df5413df77","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":3370,"y":2960,"wires":[["7aa8e54577e45c12","3740b3a8f1cec4b0"]]},{"id":"41403907ef77248b","type":"comment","z":"0918ee609bf69fc7","name":"Manual control values here","info":"","x":3430,"y":2920,"wires":[]},{"id":"c5b93ad3952d5c9e","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2","payloadType":"num","x":3370,"y":3000,"wires":[["7aa8e54577e45c12","3740b3a8f1cec4b0"]]},{"id":"2ad486289646a63a","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"3","payloadType":"num","x":3370,"y":3040,"wires":[["7aa8e54577e45c12","3740b3a8f1cec4b0"]]},{"id":"380c665c1e4d73b6","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":3370,"y":3080,"wires":[["7aa8e54577e45c12","3740b3a8f1cec4b0"]]},{"id":"81775eef43401fc8","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5","payloadType":"num","x":3370,"y":3120,"wires":[["7aa8e54577e45c12","3740b3a8f1cec4b0"]]},{"id":"7aa8e54577e45c12","type":"trigger","z":"0918ee609bf69fc7","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"12","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":3630,"y":3120,"wires":[["776c0b6574fd759c"]]},{"id":"776c0b6574fd759c","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"set","p":"pass","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3790,"y":3120,"wires":[[]]},{"id":"3740b3a8f1cec4b0","type":"function","z":"0918ee609bf69fc7","name":"The next node in your existing flow","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3910,"y":2860,"wires":[["12d22606e42ac3b3"]]},{"id":"2fdac87c27b00cd0","type":"comment","z":"0918ee609bf69fc7","name":"Put the SWITCH node blow in your flow","info":"","x":3700,"y":2820,"wires":[]},{"id":"7137f9d42a2a5f4f","type":"comment","z":"0918ee609bf69fc7","name":"Set to 12 seconds for demonstraion purposes only.","info":"","x":3760,"y":3080,"wires":[]},{"id":"12d22606e42ac3b3","type":"debug","z":"0918ee609bf69fc7","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3970,"y":2910,"wires":[]},{"id":"fc5f93af3d09315e","type":"inject","z":"0918ee609bf69fc7","name":"setup","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"str","x":3650,"y":3160,"wires":[["776c0b6574fd759c"]]}]

```

Oh: How to use:  
_Normally_ Press the `Your existing message comes in here` node.  
You will see the `output` message echos this.

Now, press one of the `inject` nodes below - simulating you changing the value - you will see that in the `output` and if you press the first `inject` node (the first one) the messages won't get to the `output` for 12 seconds.

Change the `trigger` node to `hours` and it will be 12 hours.

Hope that helps.  
(oh, make sure you get the latest. The original was a bit problematic. I edited it but still had a bug. Now it does work. Sorry.)

---

<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:** [9 October 2022 10:31 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/3 "2022-10-09T10:31:37Z")

</div>

What has the question got to do with undefined arrays?

It isn't at all clear what you are trying to do, but if you want to stop messages getting through under some circumstances then have a look at node-red-contrib-simple-gate which can be used to block messages when you tell it to.

**[Edit]** Personally I avoid flow and global context except in unusual circumstances where it is significantly more simple to do that than to do it the node-red way by passing messages.

---

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [9 October 2022 11:57 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/4 "2022-10-09T11:57:57Z")

</div>

This has absolutely NOTHING to do with array's, I made a boo-boo, didn't pay enough attention, but the forum saves drafts....#stupid.

More to the point, the goal is to temporarily stop flows, after a user has overridden the settings the flow influences.

---

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [9 October 2022 11:58 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/5 "2022-10-09T11:58:12Z")

</div>

Thanks, going to try this!

---

<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:** [9 October 2022 12:23 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/6 "2022-10-09T12:23:06Z")

</div>

You can edit the thread title by clicking the pen item next to it.

> [@Sandmman](#):
>
> the goal is to temporarily stop flows, after a user has overridden the settings the flow influences.

As I suggested, have a look at the simple gate node.

---

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [9 October 2022 12:42 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/7 "2022-10-09T12:42:54Z")

</div>

Done and I will....thanks!

---

<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:** [12 October 2022 06:34 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/8 "2022-10-12T06:34:53Z")

</div>

So..... Just wondering: Did it help?

---

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [12 October 2022 22:23 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/9 "2022-10-12T22:23:41Z")

</div>

Kinda, sorta, but not really.

Difficulty is making the distinction between actual user input through the UI and the same service call via the backend through flow and automations.  
I have set up an override system, that is not so much the issue, the devil is getting the system to see who does what.  
Normal operation, system runs the house, but when I interfere, the system has no way of knowing, unless I add extra information when we use the UI. (We are on Lovelace, have to look into NR UI, but from what I've seen at a friend....well his family will not touch it, he is very satisfied otherwise.... ;-))

@Colin why don't you use flow and global context, I find it extremely easy to use them.?? Not that I'm not running into issues, but, how do you store data? I mean, "homeassistant.homeAssitantxx" is also a global (and yes I have my own array that's easier to read, but replicates data), in my view, messages are volatile and context less so.

Anyway thanks again, learning a lot here....

---

<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:** [13 October 2022 07:26 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/10 "2022-10-13T07:26:38Z")

</div>

> [@Sandmman](#):
>
> why don't you use flow and global context

The biggest problem is that when the context value is changed there is no automatic way of making that trigger actions that depend on that value.  
Next is related to startup, when node red starts there are generally things that need to be done with stored values. For example, dashboard switches need to be aligned with the stored state. This involves extra flows if the state is stored in context.

> [@Sandmman](#):
>
> , how do you store data? I mean, "homeassistant.homeAssitantxx" is also a global

I don't use HA so know nothing about that. For system state variables I use retained MQTT topics. This solves both problems mentioned above, as, on startup, the initial values are automatically injected where they are needed (dashboard state for example), and whenever one of those is changed in one part of the flow (or by an external process publishing to MQTT) again it is automatically fed to any flows that need it.

---

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [13 October 2022 10:49 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/11 "2022-10-13T10:49:08Z")

</div>

> [@Colin](#):
>
> The biggest problem is \<\>no trigger actions \<\>on that value("change")  
> Next is related to startup ......

Ah yes I get it, no I do not use them in that fashion, everything non-volatile is stored in HA and refreshed/pushed to NR. All data I need to poll are of course polled, this is mostly sensors which do not update frequently and over which I have no control. My Möhlenhoff Alpha heating controller are a prime example of needing to poll them. In effect to me the context is just an easier (sometimes quicker) and less cluttered and surely flattened way of accessing the data.

> [@Colin](#):
>
> ..... I use retained MQTT topics. This solves both problems ..... initial values are automatically injected ... whenever one of those is changed ....or publishing to MQTT)....automatically fed to any flows that need it.

My MQTT is just beginning to develop as almost everything is comming from ZigBee running on SmartThings (migration to ZHA etc). I'm not sure as to how the data model in MQTT is, the one in HA is an extensive sprawl, so to make life easy I just ad a small translation step (house[0] ion my case where I group stuff logically. I guess I will move over to msg more and more in due time.... 😉

Thanks!

---

<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:** [13 October 2022 11:11 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/12 "2022-10-13T11:11:31Z")

</div>

> [@Sandmman](#):
>
> flattened way of accessing the data.

I would not say that is a good thing, but it is a matter of personal preference.

> [@Sandmman](#):
>
> almost everything is comming from ZigBee

If you are using Zigbee then do look at zigbee2mqtt, if you have not done so already. It is easy to setup and use and gives you an interface to all the device via friendly names on mqtt.

---

<div class="post-metadata">

**Author:** ![Sandmman](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Sandmman](https://discourse.nodered.org/u/Sandmman)\
**Post date:** [13 October 2022 14:46 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/13 "2022-10-13T14:46:43Z")

</div>

> [@Colin](#):
>
> If you are using Zigbee then do look at zigbee2mqtt, if you have not done so already. It is easy to setup and use and gives you an interface to all the device via friendly names on mqtt.

I'm using an SmartThingsHub with HA integration, and recnetly bought a ConBeeII stick and use ZHA (the phoscon bit was way wore) As I read, not all devices are supported by Zigbee2MQTT, that's why I went to ZHA.  
Is running Zigbee2MQTT lighter resource wise? Will look at it's interface!

---

<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:** [13 October 2022 16:15 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/14 "2022-10-13T16:15:39Z")

</div>

> [@Sandmman](#):
>
> As I read, not all devices are supported by Zigbee2MQTT

I don't know. Do you have something in particular in mind that may not be supported?

> [@Sandmman](#):
>
> Is running Zigbee2MQTT lighter resource wise

I suspect it is very light, but how it compares I don't know.

---

<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:** [12 December 2022 16:16 UTC](https://discourse.nodered.org/t/edit-temporarily-stop-flows-from-executing/68754/15 "2022-12-12T16:16:01Z")

</div>

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