Displaying Boolean Global Via a Switch Node

I've created a global variable and set it to boolean true or false in my sequences. I would like to display it on a dashboard. I connected the change nodes for the global to a switch and set on and off payload to global. and then entered the global variable name into the input field next to it. The switch doesn't change. It seems as something is missing or I'm not understanding how it works. Is the switch just testing for the existence of the variable and not its setting? If it's the setting, how do I indicate true or false? I tried global.varName, varName, varNane.true, and global.varName.true.

If there is documentation on this somewhere, I'll gladly refer to it. My Internet searches didn't turn anything up.

Related nodes for a text node (wrong one, but answered by @Paul-Reed)

[{"id":"a4cbbbc3.55b9d8","type":"change","z":"4ed8298c.44ba6","name":"Set Hallway Occupied","rules":[{"t":"set","p":"hallwayOccupied","pt":"global","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":100,"wires":[["bf55f2c9.225a48","689fb39c.d7e034","eb6b6af0.e39438"]]},{"id":"69cc6d5f.effd5c","type":"change","z":"4ed8298c.44ba6","name":"Reset Hallway Occupied","rules":[{"t":"set","p":"hallwayOccupied","pt":"global","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":120,"wires":[["689fb39c.d7e034","eb6b6af0.e39438"]]},{"id":"eb6b6af0.e39438","type":"ui_text","z":"4ed8298c.44ba6","group":"d127657e.88b01","order":1,"width":0,"height":0,"name":"","label":"Hallway Occupied:","format":"{{global.hallwayOccupied | char}}","layout":"row-spread","x":1480,"y":60,"wires":[]},{"id":"d127657e.88b01","type":"ui_group","name":"Group 3","tab":"5a31f675.ba7d2","order":3,"disp":true,"width":6},{"id":"5a31f675.ba7d2","type":"ui_tab","name":"Test Tab","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Update

I originally posted the wrong sequence. It's for using a text node, which @Paul-Reed answered. My question was about the switch node. Here is the correct example:

[{"id":"a4cbbbc3.55b9d8","type":"change","z":"4ed8298c.44ba6","name":"Set Hallway Occupied","rules":[{"t":"set","p":"hallwayOccupied","pt":"global","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":140,"wires":[["bf55f2c9.225a48","689fb39c.d7e034","4efd4b20.9ef094"]]},{"id":"69cc6d5f.effd5c","type":"change","z":"4ed8298c.44ba6","name":"Reset Hallway Occupied","rules":[{"t":"set","p":"hallwayOccupied","pt":"global","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1170,"y":160,"wires":[["689fb39c.d7e034","4efd4b20.9ef094"]]},{"id":"689fb39c.d7e034","type":"ui_switch","z":"4ed8298c.44ba6","name":"Hallway Occupied Global","label":"Hallway Occupied Global","tooltip":"","group":"d127657e.88b01","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"global.hallwayOccupied","onvalueType":"global","onicon":"","oncolor":"","offvalue":"global.hallwayOccupied","offvalueType":"global","officon":"","offcolor":"","animate":false,"x":1550,"y":240,"wires":[[]]},{"id":"d127657e.88b01","type":"ui_group","name":"Group 3","tab":"5a31f675.ba7d2","order":3,"disp":true,"width":6},{"id":"5a31f675.ba7d2","type":"ui_tab","name":"Test Tab","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Hi Curt, welcome to the forum.
Is it possible that you could export the flow which you are having problems with, and paste it here in the forum.
Just try to include the nodes which are necessary to demonstrate the problem.

Before doing so, please read this post about how to share flows in the forum, otherwise we will not be able to import it.

1 Like

@Paul-Reed No problem. Added to the original post

The 2 change nodes in your flow only change the value stored in global context.
But to change the value in the text node, you must retrieve the value from global context, and inject it into the text node - take a look at the flow below.

[{"id":"a4cbbbc3.55b9d8","type":"change","z":"a4801683.1c0448","name":"Set Hallway Occupied","rules":[{"t":"set","p":"hallwayOccupied","pt":"global","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":3030,"wires":[[]]},{"id":"69cc6d5f.effd5c","type":"change","z":"a4801683.1c0448","name":"Reset Hallway Occupied","rules":[{"t":"set","p":"hallwayOccupied","pt":"global","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":3070,"wires":[[]]},{"id":"eb6b6af0.e39438","type":"ui_text","z":"a4801683.1c0448","group":"61d2dced.3db8f4","order":1,"width":"4","height":"1","name":"","label":"Hallway Occupied:","format":"{{msg.payload}}","layout":"row-spread","x":500,"y":3150,"wires":[]},{"id":"cc7666d0.b64df8","type":"inject","z":"a4801683.1c0448","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":100,"y":3030,"wires":[["a4cbbbc3.55b9d8"]]},{"id":"b2520f05.7a9df","type":"inject","z":"a4801683.1c0448","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":100,"y":3070,"wires":[["69cc6d5f.effd5c"]]},{"id":"87e1a926.1377f8","type":"change","z":"a4801683.1c0448","name":"Get global state","rules":[{"t":"set","p":"payload","pt":"msg","to":"hallwayOccupied","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":3150,"wires":[["eb6b6af0.e39438"]]},{"id":"1ef8a44f.7c779c","type":"inject","z":"a4801683.1c0448","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":100,"y":3150,"wires":[["87e1a926.1377f8"]]},{"id":"61d2dced.3db8f4","type":"ui_group","name":"flowtest","tab":"3c94630c.13381c","order":1,"disp":true,"width":16,"collapse":false},{"id":"3c94630c.13381c","type":"ui_tab","name":"Test","icon":"dashboard","order":9}]

I would suggest that you reconfigure your flow so that the Boolean value directly changes the 'text node' text, and also saves the value to context.
You may only need to retrieve and inject the context value into the text node if you reboot, restart the flow, etc.

Example

[{"id":"a4cbbbc3.55b9d8","type":"change","z":"a4801683.1c0448","name":"Set Hallway Occupied","rules":[{"t":"set","p":"hallwayOccupied","pt":"global","to":"true","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":3030,"wires":[["eb6b6af0.e39438"]]},{"id":"69cc6d5f.effd5c","type":"change","z":"a4801683.1c0448","name":"Reset Hallway Occupied","rules":[{"t":"set","p":"hallwayOccupied","pt":"global","to":"false","tot":"bool"},{"t":"set","p":"payload","pt":"msg","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":3070,"wires":[["eb6b6af0.e39438"]]},{"id":"eb6b6af0.e39438","type":"ui_text","z":"a4801683.1c0448","group":"61d2dced.3db8f4","order":1,"width":"4","height":"1","name":"","label":"Hallway Occupied:","format":"{{msg.payload}}","layout":"row-spread","x":600,"y":3040,"wires":[]},{"id":"cc7666d0.b64df8","type":"inject","z":"a4801683.1c0448","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":100,"y":3030,"wires":[["a4cbbbc3.55b9d8"]]},{"id":"b2520f05.7a9df","type":"inject","z":"a4801683.1c0448","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":100,"y":3070,"wires":[["69cc6d5f.effd5c"]]},{"id":"87e1a926.1377f8","type":"change","z":"a4801683.1c0448","name":"Get global state","rules":[{"t":"set","p":"payload","pt":"msg","to":"hallwayOccupied","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":3130,"wires":[["eb6b6af0.e39438"]]},{"id":"1ef8a44f.7c779c","type":"inject","z":"a4801683.1c0448","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":170,"y":3130,"wires":[["87e1a926.1377f8"]]},{"id":"61d2dced.3db8f4","type":"ui_group","name":"flowtest","tab":"3c94630c.13381c","order":1,"disp":true,"width":16,"collapse":false},{"id":"3c94630c.13381c","type":"ui_tab","name":"Test","icon":"dashboard","order":9}]

You example fixes my problem, but not the one I wanted to ask. I posted the wrong sequence. Nonetheless. I needed an answer for the text node as well, so thanks. Is it the case that the value field will only accept payload data? Given that it's freeform, I was hoping I could use {{ global.hallwayOccupied }}

No you can't do that, you can change the source of the incoming msg to for example {{msg.hallway}} or use HTML or angular filters (which change the way the text is displayed - but not the msg source).
The text to be displayed needs to flow into the text node. The text node will not just go and get it (if that makes sense!)

1 Like

That makes sense. I was trying to make it do more than it is supposed to.

I also fed text into the switch node and got it to work. You would think that, since you and set to the on and off payload to global, you could use global data.

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