Dashboard is open/active notification ?

186 views
Skip to first unread message

Toshi Bass

unread,
Sep 28, 2016, 1:32:49 PM9/28/16
to Node-RED
I have a esp8266 which spits out various datas when I send a "get_data" command via MQTT output node , 
the datas are received via MQTT input node, gets split up and sent to the dashboard, fine that all works. 

So at the moment I send "get_data" each say 1 minute using an inject node, however I want to change this 
to only send the command if the dashboard is open/active thus allowing the esp8266 to deep sleep when the
Dashboard is not calling for data.

So to the question, in node-red is there anything I can use to tell if the dashboard is open/active ?


Dave C-J

unread,
Sep 28, 2016, 5:05:36 PM9/28/16
to node...@googlegroups.com
Sort of - but we want to change it... so it's on the to-do list.
The "new" control node currently allow input to change tabs etc... - but providing "client connected"  as an output - would be an obvious thing to add to it. We're just debating what exactly the message should be (probably an object - probably with the socketid - or.... suggestions gratefully accepted)

PS - right now the chart 2nd output reports connected - but as we know the chart leaks badly so again is being fixed and as part of that we would like to remove that output.

Toshi Bass

unread,
Oct 22, 2016, 5:58:43 AM10/22/16
to Node-RED
Just wondered if there has been any update in recent releases that I missed that enables status if dashboard is open/active ?
 

Dave C-J

unread,
Oct 22, 2016, 6:06:10 AM10/22/16
to node...@googlegroups.com
Hi,
not yet... 

Toshi Bass

unread,
Dec 6, 2016, 9:08:08 AM12/6/16
to Node-RED


On Saturday, October 22, 2016 at 11:06:10 AM UTC+1, Dave C-J wrote:
Hi,
not yet... 

Toshi Bass

unread,
Dec 6, 2016, 9:10:06 AM12/6/16
to Node-RED


Thought I would post this here as well as I am so happy.

Ive been hoping for some way to "know when a dashboard screen is active" so that I only request data via mqtt say from my esp8266's when the relevant dashboard is being viewed or data is only transferred to the dashboard elements when the relevant screen is being viewed and some code by Andrei on the Node-red UI group works great.

I combined the code with the Dark Theme & Border settings as follows....

[{"id":"9ae8a258.02025","type":"ui_template","z":"a9f80ed0.06b2f","group":"9ec5240.aa7d3e","name":"Theme-dark + boarder & Dashboard_Active","order":1,"width":"5","height":"1","format":"<style>\n    .nr-dashboard-theme-dark ui-card-panel {\n \tbackground-color: #222;\n \toutline: 1px solid #4F4F4F;\n \t//color:red;\n    //font-family:Arial;\n    //font-size:6px;\n    //text-align:center;\n  }\n\n</style>\n<div style=\"line-height:34px;font-size:14pt;color:#0ABCC8;\">Blynk Data 91</div>\n\n<div ng-init=\"init()\"></div>\n<script>\n(function(scope) {\n    var timer;\n    \n    scope.init = function() { \n        scope.send({payload: 'init'});\n        \n        timer = setInterval(function() {\n            scope.send({payload: 'refresh'});\n        }, 20000);//20seconds\n    };\n    \n    scope.$on('$destroy', function () {\n        scope.send({payload: 'done'});\n        clearInterval(timer); \n    });\n}(scope));\n</script>","storeOutMessages":true,"fwdInMessages":true,"x":216.33331298828125,"y":68.66666030883789,"wires":[["8883fd59.c3e6d"]]},{"id":"98547992.8872c8","type":"debug","z":"a9f80ed0.06b2f","name":"","active":false,"console":"false","complete":"false","x":636.3333740234375,"y":68.66666030883789,"wires":[]},{"id":"8883fd59.c3e6d","type":"function","z":"a9f80ed0.06b2f","name":"Dashboard","func":"var Dashboard_Active = flow.get('Dashboard_Active')||0;\n\nif(msg.payload==\"init\"){\n    Dashboard_Active=1;\n    flow.set('Dashboard_Active',Dashboard_Active);\n}\n\nif(msg.payload==\"done\"){\n    Dashboard_Active=0;\n    flow.set('Dashboard_Active',Dashboard_Active);\n}\n\n\nnode.status({text:\"Dashboard_Active = \"+Dashboard_Active});\n\n\nreturn msg;\n\n","outputs":1,"noerr":0,"x":477.33331298828125,"y":68.66666030883789,"wires":[["98547992.8872c8"]]},{"id":"d74dfb90.1d3ad8","type":"mqtt in","z":"a9f80ed0.06b2f","name":"","topic":"out91","qos":"2","broker":"7ccbbba9.002024","x":108,"y":122,"wires":[["98b8034.9d6a1"]]},{"id":"98b8034.9d6a1","type":"function","z":"a9f80ed0.06b2f","name":"Dashboard_Active ?","func":"if(flow.get('Dashboard_Active')==1){\n    msg.payload=msg.payload;\n}else{\n    msg=null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":279,"y":122,"wires":[[]]},{"id":"de81154f.86e678","type":"inject","z":"a9f80ed0.06b2f","name":"","topic":"","payload":"","payloadType":"str","repeat":"2","crontab":"","once":true,"x":111,"y":201,"wires":[["5caa3be6.108264"]]},{"id":"5caa3be6.108264","type":"function","z":"a9f80ed0.06b2f","name":"Dashboard_Active ?","func":"if(flow.get('Dashboard_Active')==1){\n    msg.payload=msg.payload;\n}else{\n    msg=null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":202,"wires":[[]]},{"id":"23933440.51279c","type":"comment","z":"a9f80ed0.06b2f","name":"Split mqtt data and send to dashboard elements","info":"","x":571,"y":123,"wires":[]},{"id":"41399aff.e2ecb4","type":"comment","z":"a9f80ed0.06b2f","name":"Send request via mqtt to return sensor data","info":"","x":564,"y":202,"wires":[]},{"id":"9837550f.16d258","type":"comment","z":"a9f80ed0.06b2f","name":"       or","info":"","x":372,"y":162,"wires":[]},{"id":"9ec5240.aa7d3e","type":"ui_group","z":"","name":"Data new","tab":"a169baa4.e246b8","order":2,"disp":false,"width":"6"},{"id":"7ccbbba9.002024","type":"mqtt-broker","z":"","broker":"192.168.0.240","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"a169baa4.e246b8","type":"ui_tab","z":"","name":"Data 91","icon":"dashboard","order":7}]
Reply all
Reply to author
Forward
0 new messages