# Dashbord active awarness

**URL:** <https://discourse.nodered.org/t/dashbord-active-awarness/33542>\
**Category:** Dashboard\
**Created:** [30 September 2020 07:42 UTC](https://discourse.nodered.org/t/dashbord-active-awarness/33542 "2020-09-30T07:42:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbc99](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mbc99/32/13764_2.png) [@mbc99](https://discourse.nodered.org/u/mbc99)\
**Post date:** [30 September 2020 07:42 UTC](https://discourse.nodered.org/t/dashbord-active-awarness/33542/1 "2020-09-30T07:42:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [30 September 2020 07:49 UTC](https://discourse.nodered.org/t/dashbord-active-awarness/33542/2 "2020-09-30T07:49:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [30 September 2020 07:51 UTC](https://discourse.nodered.org/t/dashbord-active-awarness/33542/3 "2020-09-30T07:51:59Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/aedaf16d67cac5b954d99d0395fe0a0b9261aa72.png)

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [1 October 2020 19:12 UTC](https://discourse.nodered.org/t/dashbord-active-awarness/33542/4 "2020-10-01T19:12:51Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [1 October 2020 19:41 UTC](https://discourse.nodered.org/t/dashbord-active-awarness/33542/5 "2020-10-01T19:41:55Z")

</div>

Basics may be something like this

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)\
**Post date:** [2 October 2020 18:16 UTC](https://discourse.nodered.org/t/dashbord-active-awarness/33542/6 "2020-10-02T18:16:38Z")

</div>

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

---

<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:** [16 October 2020 18:16 UTC](https://discourse.nodered.org/t/dashbord-active-awarness/33542/7 "2020-10-16T18:16:40Z")

</div>

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