# Help with sub-flow and status part

**URL:** <https://discourse.nodered.org/t/help-with-sub-flow-and-status-part/38689>\
**Category:** General\
**Created:** [7 January 2021 02:24 UTC](https://discourse.nodered.org/t/help-with-sub-flow-and-status-part/38689 "2021-01-07T02:24:52Z")\
**Posts on this page:** 6\
**Page:** 1

<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:** [7 January 2021 02:24 UTC](https://discourse.nodered.org/t/help-with-sub-flow-and-status-part/38689/1 "2021-01-07T02:24:52Z")

</div>

Yeah, sorry folks. I am seeing weird things happening.

Basic flow.

You will need to set `global.Shutdown_temperature` to `75` for it to work.

Picture of flow:

![Screenshot from 2021-01-07 13-18-36](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/3/f3590bf4803b4a9e28f48d4268ab2cb51da41ba7.png)

Idea:  
inputs: "test" for testing purposes.  
0 - (or low number) all things good.  
1 - (`65`) getting close to cut off temperature.  
2 - (`76`) "We have a problem!""

Oh, sorry - edit here:  
I call the inputs `1` and `2` by mistake. By `1` I mean the `65` node and by `2` I mean the `76` node.

`TEST` gives a `blue` status.  
`0` gives a `green` status  
`65` gives a `yellow` status  
`76` gives a `red` status.

Or so it should.

It doesn't. UNLESS - and I'll get back to that in a second.

This is the sub-flow:  
(Picture)

 ![Screenshot from 2021-01-07 13-17-35](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/42773e703e7101d740a1d2b9fbd2ea423966ea46.png)

Note the red circle around `status`.  
As is, it is `all nodes` and it doesn't work as expected.  
Pressing `2` I get a `blue` status.

If I change the `status` node to this:

 ![Screenshot from 2021-01-07 13-17-57](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/9/d96b4bfac4b297bfd28505a04374d2c8b03b0a2e.png)

I get the `red` status.

Anyone?

Got me beat.

```auto
[{"id":"5df7f03f.3dfc68","type":"subflow","name":"Temperature protection","info":"","category":"","in":[{"x":60,"y":320,"wires":[{"id":"18616350.15428d"}]}],"out":[{"x":880,"y":290,"wires":[{"id":"c90a725f.876048","port":1},{"id":"c90a725f.876048","port":0}]},{"x":880,"y":350,"wires":[{"id":"9f21f928.a74e58","port":0}]}],"env":[],"color":"#DD0099","outputLabels":["MQTT output","STOP output"],"icon":"font-awesome/fa-thermometer-3","status":{"x":880,"y":420,"wires":[{"id":"5929a3d6.4de11c","port":0}]}},{"id":"6e26fa3b.8e867c","type":"comment","z":"5df7f03f.3dfc68","name":"Force shutdown","info":"","x":620,"y":230,"wires":[]},{"id":"5929a3d6.4de11c","type":"status","z":"5df7f03f.3dfc68","name":"","scope":null,"x":630,"y":420,"wires":[[]]},{"id":"29b734f0.a09f14","type":"function","z":"5df7f03f.3dfc68","name":"2","func":"msg.payload = 2;\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":340,"wires":[["c90a725f.876048"]]},{"id":"c90a725f.876048","type":"function","z":"5df7f03f.3dfc68","name":"Make message","func":"// Set up messages\nvar name = global.get(\"myDeviceName\");\nvar msg1 = {};\nvar msg2 = {};\nvar msg3 = {};\nmsg1.payload = {\n event: \"Over temperature\",\n priority: 1\n};\nmsg2.payload = {\n event:\"BedPi shutting down. Excess heat\",\n priority: 4\n}\nmsg3.payload = {\n DEVICE:name,COMMAND:\"Shutdown\",state:1\n}\n\nif (msg.payload == 0)\n{\n node.status({fill:\"green\"});\n} else\nif (msg.payload == 1)\n{\n node.status({fill:\"yellow\"});\n return [msg1,null,null];\n} else\nif (msg.payload == 2)\n{\n node.status({fill:\"red\"});\n return [msg1, msg2, msg3];\n} else\nif (msg.payload == \"TEST\")\n{\n node.status({fill:\"blue\"});\n msg1.payload = {\n event: \"TEST MESSAGE - Over temperature\",\n priority: 1\n };\n msg2.payload = {\n event:\"TEST MESSAGE - BedPi shutting down. Excess heat\",\n priority: 4\n }\n return [msg1,msg2,null];\n}","outputs":3,"noerr":0,"initialize":"","finalize":"","x":600,"y":300,"wires":[[],[],["9f21f928.a74e58"]],"outputLabels":["A1","Shutdown command","A4"]},{"id":"18616350.15428d","type":"switch","z":"5df7f03f.3dfc68","name":"Ok","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"$globalContext(\"Shutdown_temperature\")-10","vt":"jsonata"},{"t":"gte","v":"$globalContext(\"Shutdown_temperature\")-10","vt":"jsonata"},{"t":"gte","v":"Shutdown_temperature","vt":"global"},{"t":"eq","v":"TEST","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":160,"y":320,"wires":[["ec2dad19.41374"],["47ccd305.a151e4"],["29b734f0.a09f14"],["c90a725f.876048"]]},{"id":"9f21f928.a74e58","type":"delay","z":"5df7f03f.3dfc68","name":"delay","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":780,"y":350,"wires":[[]]},{"id":"1c8a6757.7915a9","type":"function","z":"5df7f03f.3dfc68","name":"1","func":"msg.payload = 1;\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":300,"wires":[["c90a725f.876048"]]},{"id":"ec2dad19.41374","type":"function","z":"5df7f03f.3dfc68","name":"0","func":"msg.payload = 0;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":260,"wires":[["c90a725f.876048"]]},{"id":"47ccd305.a151e4","type":"switch","z":"5df7f03f.3dfc68","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"Shutdown_temperature","vt":"global"}],"checkall":"true","repair":false,"outputs":1,"x":335,"y":300,"wires":[["1c8a6757.7915a9"]],"l":false},{"id":"f09d1a25.4e6b8","type":"subflow:5df7f03f.3dfc68","z":"d6850a4c.d8eac8","name":"","x":540,"y":260,"wires":[["d19d6b90.ff28a"],[]]},{"id":"612b693e.2b9468","type":"inject","z":"d6850a4c.d8eac8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":290,"y":240,"wires":[["f09d1a25.4e6b8"]]},{"id":"3d7e9545.6c151a","type":"inject","z":"d6850a4c.d8eac8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"TEST","payloadType":"str","x":290,"y":190,"wires":[["f09d1a25.4e6b8"]]},{"id":"dd3bff2d.ff2cd","type":"inject","z":"d6850a4c.d8eac8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"65","payloadType":"num","x":290,"y":290,"wires":[["f09d1a25.4e6b8"]]},{"id":"7c81e63b.4ebc08","type":"inject","z":"d6850a4c.d8eac8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"76","payloadType":"num","x":290,"y":340,"wires":[["f09d1a25.4e6b8"]]},{"id":"d19d6b90.ff28a","type":"debug","z":"d6850a4c.d8eac8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":260,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [7 January 2021 06:33 UTC](https://discourse.nodered.org/t/help-with-sub-flow-and-status-part/38689/2 "2021-01-07T06:33:58Z")

</div>

If it receives a status from "all" nodes it might overwrite the status that you are expecting (?) (ie; sometimes it might work perhaps?)

---

<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:** [7 January 2021 06:36 UTC](https://discourse.nodered.org/t/help-with-sub-flow-and-status-part/38689/3 "2021-01-07T06:36:52Z")

</div>

Thanks.

I didn't think of it like that - well maybe I did.

But I think I dismissed it as implausible.

I've got another question but that's another thread. 😉

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [7 January 2021 07:54 UTC](https://discourse.nodered.org/t/help-with-sub-flow-and-status-part/38689/4 "2021-01-07T07:54:22Z")

</div>

The delay node (for example) will set a status, so if you catch all then that will be included.

---

<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:** [7 January 2021 07:59 UTC](https://discourse.nodered.org/t/help-with-sub-flow-and-status-part/38689/5 "2021-01-07T07:59:18Z")

</div>

Thanks @dceejay

It isn't I wanted to sound dismissive of @bakman2, but I suspected something else was happening.

That will be it I guess.

---

<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:** [21 January 2021 07:59 UTC](https://discourse.nodered.org/t/help-with-sub-flow-and-status-part/38689/6 "2021-01-21T07:59:26Z")

</div>

Closed on 21 January 2021 07:59 UTC

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