Subflow node.status

I have been developing some subflows recently, the biggest thing I miss is the ability to use node.status in function nodes and the fact that there is no indication on trigger nodes etc etc, it makes tracking down problems very difficult in fact on several occasions I have had to resort to pasting the flows from my subflow back into a normal page (deleting all of the $parent. statements etc) just to find why a subflow is not working as expected.

I know I can add the status node which displays stuff under/on the subflow node and I can add an extra output or two to the subflow node and feed them to a debug nodes outside the subflow which is useful but in reality it doesn't replace the need for node.status indication.

I am guessing there has to be a big reason why 'node.status' does not work in subflows but thought I would ask if theirs any chance in the future this could be implemented.


I also noticed that in 10.0.2 the dotted lines are now normal lines ... actually I didn't mind the dotted lines it was a reminder that I was working on a subflow another point that has cought me out several times is in a subflow global.get( does not need $parent. but flow.get( does .. ok I get that global is everywhere, flow.get( is specifically from the flow containing the subflow node but its still a bitch when you forget.

Imagine a flow file that uses ten instances of the subflow. If you open the subflow in the editor which one of the ten instances would you like to see the status for?

Hmmm I never used one subflow multiple times so I guess your right it would be a problem.

When building the sub-flow where you assign how many inputs/outputs there are, there is a button with status node.

Add a status-all node and connect it to the newly created status node and you will see any node.status( ) messages below the sub-flow node.

9 Likes

Wow! This is fantastic! Thx for the info!

How did you know? I would never guessed.

Possibly from reading the docs
https://nodered.org/docs/user-guide/editor/workspace/subflows

Do you mean this?

Status node
The toolbar provides an option to add a ‘status’ output to a subflow. This can be used to update the Status of subflow instance nodes.

That's all the info on the docs. Maybe it's just me, but that doesn't give me a clue about how to use it

Well it does assume you know what a node status is, and how to use a Status node. I assumed that by the time anyone got as far as using subflows they would know about node status and the use of Status nodes.
However it does appear that Status nodes are not well documented (or even not documented at all) in the User Guide, so it appears my assumption was ill founded. Pull Requests for enhancements to the docs are always welcome, I believe, and that might be a good way to start getting involved in the project.

There is where my confusion comes from. I saw the reference to status, but I was expecting a link to a more detailed explanation about how to use status nodes and how they work. I searched both docs and Google for documentation about the status node, but I didn't found any.
Sure I can make a PR now that I know how it works, but before thar I had no choice but ask.

1 Like

Here is an example of how to use the status node of a subflow:

image

The function node contains:

let statusMsg = { fill:"green", shape:"dot", text:"My status message" };
return [msg, {payload:statusMsg}];
3 Likes

(Been away in case you hadn't noticed)

There is an option for the status to be sent to an output.

@Jpsy I was so glad to find your solution, but it doesn't work. I explicitely copied your code. What I have in my subflow:

// show status message at subflow node
let value = msg.payload === true ? "on" : "off";
let statusMsg = { fill:"green", shape:"dot", text:"Automatic: "+ value };

return {payload:statusMsg};

This is a working code in the case of getting my on/off result out of the subflow. But no status message and no output on "output 3".

What i find out:
I copied the flow out of subflow in a testflow. Of course I got an additional button on the dashboard. Using original switch, nothing happens as before. But if I use the new switch (from outside the subflow) I get also the message and status out of the subflow!?

I'm confused? What's wrong? Is it not allowed to use dashboard nodes inside subflows??

Here the whole subflow, but it need the gate-node:

[{"id":"bf2492af.6b49a8","type":"subflow","name":"invert boolean","info":"","category":"","in":[{"x":40,"y":80,"wires":[{"id":"9e8c468b.c1fd98"}]}],"out":[{"x":360,"y":80,"wires":[{"id":"9e8c468b.c1fd98","port":0}]}],"env":[],"meta":{},"color":"#DDAA99"},{"id":"9e8c468b.c1fd98","type":"function","z":"bf2492af.6b49a8","name":"invert boolean","func":"msg.payload = !msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":200,"y":80,"wires":[[]],"info":"Invertiert den boolschen Wert am Eingang"},{"id":"349f3267.282b16","type":"subflow","name":"auto on/off","info":"","category":"","in":[{"x":60,"y":420,"wires":[{"id":"e7642ff8.6ecc6"},{"id":"8050d627.fe0958"}]}],"out":[{"x":860,"y":360,"wires":[{"id":"196bf120.478bff","port":0}]},{"x":860,"y":420,"wires":[{"id":"8050d627.fe0958","port":0}]},{"x":840,"y":80,"wires":[{"id":"5bfd9175.e4ebb8","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","status":{"x":840,"y":40,"wires":[{"id":"89b32369.7cf2a","port":0}]}},{"id":"150dfb6.a90a385","type":"ui_switch","z":"349f3267.282b16","name":"","label":"A-Boiler on/off","tooltip":"","group":"c14af889.9a4db","order":4,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"switch","topicType":"str","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":true,"x":440,"y":300,"wires":[["196bf120.478bff"]]},{"id":"5bfd9175.e4ebb8","type":"ui_switch","z":"349f3267.282b16","name":"","label":"Automatic mode","tooltip":"","group":"c14af889.9a4db","order":4,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"switch","topicType":"str","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":true,"x":160,"y":80,"wires":[["f3016ff7.47c398","6b7ffefc.0e89f8","36de4653.d2419a","89b32369.7cf2a"]]},{"id":"e3435a58.cf6b4","type":"change","z":"349f3267.282b16","name":"control switch","rules":[{"t":"set","p":"enabled","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":240,"wires":[["150dfb6.a90a385"]],"info":"Enable/disable switch and control on/off\n\n**Enable** when `automatic == off`  \n**Disable** when `automatic == on`  \n\nSet **switch ON**, when `automatic == off`  \nSet **switch OFF**, when `automatic == on`"},{"id":"8050d627.fe0958","type":"jvmg_gate","z":"349f3267.282b16","name":"Boiler automatic","default":true,"trigger":"a94dd678.e92fe8","x":700,"y":420,"wires":[[]]},{"id":"196bf120.478bff","type":"jvmg_gate","z":"349f3267.282b16","name":"Boiler Manual","default":true,"trigger":"7efb2b1d.1838e4","x":700,"y":360,"wires":[[]]},{"id":"f3016ff7.47c398","type":"jvmg_key","z":"349f3267.282b16","name":"Automatic control","trigger":"a94dd678.e92fe8","x":690,"y":140,"wires":[]},{"id":"1ee5b905.b843df","type":"jvmg_key","z":"349f3267.282b16","name":"Manual control","trigger":"7efb2b1d.1838e4","x":680,"y":200,"wires":[]},{"id":"6b7ffefc.0e89f8","type":"subflow:bf2492af.6b49a8","z":"349f3267.282b16","name":"","env":[],"x":440,"y":180,"wires":[["1ee5b905.b843df","e3435a58.cf6b4"]]},{"id":"e7642ff8.6ecc6","type":"function","z":"349f3267.282b16","name":"latch","func":"\nif (msg.payload === 'repeat') {\n    msg.payload = context.get(\"lastValue\");\n    msg.topic = 'repeat'\n} else {\n    context.set(\"lastValue\",msg.payload);\n}\nnode.status({text:msg.payload});\nreturn msg;","outputs":1,"noerr":0,"initialize":"// Der Code hier wird ausgefĂźhrt,\n// wenn der Node gestartet wird\n\ncontext.set(\"lastValue\",false);","finalize":"","libs":[],"x":410,"y":360,"wires":[["8050d627.fe0958"]],"info":"\n\nSave the last value in a context variable. \nIf keyword 'repeat' received, this lase value will be send again."},{"id":"36de4653.d2419a","type":"switch","z":"349f3267.282b16","name":"if true","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":210,"y":240,"wires":[["4b0ce538.4978cc"]]},{"id":"4b0ce538.4978cc","type":"change","z":"349f3267.282b16","name":"send 'repeat'","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"repeat","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":170,"y":320,"wires":[["e7642ff8.6ecc6"]]},{"id":"89b32369.7cf2a","type":"function","z":"349f3267.282b16","name":"","func":"// show status message at subflow node\nlet value = msg.payload === true ? \"on\" : \"off\";\nlet statusMsg = { fill:\"green\", shape:\"dot\", text:\"Automatic: \"+ value };\n\nreturn {payload:statusMsg};\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":40,"wires":[[]]},{"id":"c14af889.9a4db","type":"ui_group","name":"Ute","tab":"297873db.981d0c","order":1,"disp":true,"width":"6","collapse":false},{"id":"a94dd678.e92fe8","type":"jvmg_trigger","trigger":"Automatic"},{"id":"7efb2b1d.1838e4","type":"jvmg_trigger","trigger":"Manual"},{"id":"297873db.981d0c","type":"ui_tab","name":"Sonoff","icon":"dashboard","disabled":false,"hidden":false}]

Me, reading the docs????!!!!! :wink:

I'm male. It's in our genetics to not read that stuff. :wink:

Maybe a nicer way of using status in a subflow is by using a status node:
subflow-status

In the function node use:

node.status({ fill: 'yellow', shape: 'dot', text: 'Status message' });

No need to add an extra output to the function node.

3 Likes

Is this a distinction without a difference or does it really matter?
:man_shrugging:

None that I'm aware of. I guess it's more a choice of personal preference than a technical issue. I suppose that the solution with a status node is more the node-red way, but in the end, both solutions do the same.

1 Like