Dashbord active awarness

So probably the title isn't very clear but I will try to explain myself.

I have Node Red connected via MQTT to and Arduino that publishes data values.

The Arduino runs on GSM so I would only want the values to be published when the dasboard is active (so when somene is visualizing data).
So I would need some variable that triggers when a connection to the dashboard is active, this variable would be sent to the Arduino so that it could start sending data continuously until the dashboard is exited.

Does this variable exist?

Take a look at ui control node in dashboard nodes, it reports connect disconnect etc

Such variable does not exist but you can create it and fill with latest value from ui_control node.
if you use it as event trigger you can also start and stop the listening.

I have a todo.... to only show popup dialog alerts when the dashboard is active. Otherwise I get tons of queued dialog popups, lots of flashing of windows, or I have to kill the intervening alerts. Not a great trade off sometimes. So if someone implements a flow to illustrate this idea? I would love to see it!

Basics may be something like this

[{"id":"982bfb95.2053d8","type":"ui_ui_control","z":"3dd56201.af994e","name":"","events":"all","x":300,"y":160,"wires":[["a110e2ba.085ae"]]},{"id":"dbf26e9d.177","type":"debug","z":"3dd56201.af994e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":720,"y":160,"wires":[]},{"id":"a110e2ba.085ae","type":"function","z":"3dd56201.af994e","name":"store dashboard state","func":"let state = global.get('dashboardState');\nlet event = {} \nif(msg.payload == 'connect'){\n    if(state != 'online'){\n        state = 'online'\n        event.payload = 'online'\n    }\n}\nif(msg.payload == 'change'){\n    if(state != 'online'){\n        state = 'online'\n        event.payload = 'online'\n    }\n}\nif(msg.payload == 'lost'){\n    if(state != 'offline'){\n        state = 'offline'\n        event.payload = 'offline';\n    }\n}\nif(event.payload){\n    global.set('dashboardState',state);\n    event.topic = \"dashboard-state\" ;\n    return event;\n}\n\n","outputs":1,"noerr":0,"x":500,"y":160,"wires":[["dbf26e9d.177"]]},{"id":"e711a82a.9b9668","type":"switch","z":"3dd56201.af994e","name":"","property":"dashboardState","propertyType":"global","rules":[{"t":"eq","v":"online","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":540,"y":260,"wires":[["2aafefe5.d0046"]]},{"id":"3fc37183.dc643e","type":"inject","z":"3dd56201.af994e","name":"","topic":"","payload":"DASHBOARD CHECK","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":260,"wires":[["e711a82a.9b9668"]]},{"id":"2aafefe5.d0046","type":"ui_toast","z":"3dd56201.af994e","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":760,"y":260,"wires":[]}]

Ah... and I take it, ui-control state updates automatically, so no need for polling or such. Thank you!

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