In new 0.113 HA Version four different automation modes (single, restart, queued, parallel) were introduced.
I’d like to know if node reds integrations are going to include these new attributes.
By P.
In new 0.113 HA Version four different automation modes (single, restart, queued, parallel) were introduced.
I’d like to know if node reds integrations are going to include these new attributes.
By P.
As I see it those modes exist already.
The default in node red is parallel. You can use a trigger and block node to get singel.
Restart is possible but messy.
Queued, not sure. Haven’t thought about it enough
Queued is probably also possible but it will probably be very messy.
I’m thinking a counter node that assigns each message with a number then split node to split them in to separate channels and have them stop with a wait until node that waits for the previous message to finnish.
You would have to guess the number of maximum messages you could have and build for that and in case of an overflow deal with it somehow…
I’m interested in this as well, particularly the queued mode.
Does anyone know if this mode in HA checks for successful completion, i.e. the action that is triggered has done what it it supposed to do, or if it just checks that the previous automation finished? If it is the latter then that shouldn’t be too difficult to replicate in Node Red, should it?
As @Hellis81 said, you can do all those in NodeRed already using various methods. However, if you are calling scripts and/or automations from NodeRed, the mode would be set there, so NodeRed wouldn’t really have any access to change or modify that.
Queued is basically the default mode for NodeRed as it runs as a single threaded application on the host. It uses an event loop to process flows in the background, so that multiple flows can virtually run at the same time, albeit with a few microseconds in between them due to processing and overhead. You can get a flow to run in parallel with itself by making use of some async calls though. Basically, it’s not NodeRed that has this “limitation”; It’s how node.js works.
From what I’ve read in discussion and the docs, HA doesn’t check for a successful completion, per se. It just looks at completion.
but isn’t queued more that each message stops and waits for the previous to finish? Node red can as you say run several with milliseconds in between which I think is “parallel”.
To NodeRed, everything outside of async code is basically queued in the sense that each module gets pushed to the event loop in a FIFO fashion. It’s not message based, it’s flow based. So, you have Flow 1 that executes. Then, that same flow receives a notification that it needs to run again. 2 copies of the same flow will be pushed into the event loop and then executed synchronously. While it might only be a few microseconds apart, they are still executed in a queue.
Both of these are excellent articles on how NodeRed works behind the scenes:
Case in point: There’s 5 different ways this one flow will get executed, but none of them will be in parallel (unless the HA modules use some async code underneath; I have never looked at the source for them). If there’s motion and a switch gets pushed, 2 copies of the same flow get placed into the event stream and each one will execute as soon as there is a free process to deal with it.
In the very simple sequences, but as soon as you have some splits and delays or services that take different amount of time then message 2 can “overtake” message 1 because it takes a different path.
Either way, in my opinion it doesn’t matter what it’s called or how it’s translated to HA automation names.
What you want to do just works and most of the time with more flexibility.