[Edit] temporarily stop flows from executing

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.


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.

[{"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.)

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.

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.

Thanks, going to try this!

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

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

Done and I will....thanks!

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

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....

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.

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.

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.

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.... :wink:


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

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!

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

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

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