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:
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)
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:
I get the red
status.
Anyone?
Got me beat.
[{"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":[]}]