Dashboard tips - Gauge with selective input

Make one gauge to show different measurements by selecting source of measurement using regular dashboard buttons acting like radio buttons. Handy solution for situations where screen size is limited but components can't be made smaller anymore.

image

[{"id":"6d08d5ab.a8aa3c","type":"tab","label":"SELECTABLE INPUT","disabled":false,"info":""},{"id":"e3ac04d9.d3c308","type":"ui_ui_control","z":"6d08d5ab.a8aa3c","name":"inject dash events","events":"all","x":170,"y":110,"wires":[["76ef4267.f6b58c"]]},{"id":"76ef4267.f6b58c","type":"link out","z":"6d08d5ab.a8aa3c","name":"dash-init","links":["7814ed99.4469e4","86181860.e50238","4fe3141f.0fa66c"],"x":305,"y":110,"wires":[]},{"id":"29e8935c.6601fc","type":"ui_gauge","z":"6d08d5ab.a8aa3c","name":"","group":"99609e7b.c8ed4","order":2,"width":5,"height":3,"gtype":"gage","title":"{{title}}","label":"","format":"{{value | number:2}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":810,"y":370,"wires":[]},{"id":"15ad39f2.4f9556","type":"function","z":"6d08d5ab.a8aa3c","name":"create groups","func":"var g_members = [\"temperature\",\"humidity\",\"wind\"]\nvar g_limits = [{lo:0,hi:30},{lo:0,hi:100},{lo:0,hi:10}]\nvar g = {\"gaugegroup\":{\"members\":[],\"selected\":\"temperature\"}}\nfor(var i=0;i<g_members.length;i++){\n    g.gaugegroup.members.push( {\"topic\":g_members[i],\"lastvalue\":0,\"min\":g_limits[i].lo,\"max\":g_limits[i].hi})\n}\n\nglobal.set(\"buttongroups\",g)\n","outputs":1,"noerr":0,"x":370,"y":60,"wires":[[]]},{"id":"64822339.ba387c","type":"inject","z":"6d08d5ab.a8aa3c","name":"init","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":60,"wires":[["15ad39f2.4f9556"]]},{"id":"cd314554.dc9408","type":"ui_button","z":"6d08d5ab.a8aa3c","name":"temperature","group":"99609e7b.c8ed4","order":1,"width":3,"height":1,"passthru":false,"label":"TEMPERATURE","tooltip":"","color":"","bgcolor":"{{bgr}}","icon":"","payload":"","payloadType":"str","topic":"temperature","x":520,"y":210,"wires":[["1426c20e.a3021e"]]},{"id":"860fe47f.8bb7f8","type":"ui_button","z":"6d08d5ab.a8aa3c","name":"humidity","group":"99609e7b.c8ed4","order":3,"width":3,"height":1,"passthru":false,"label":"HUMIDITY","tooltip":"","color":"","bgcolor":"{{bgr}}","icon":"","payload":"","payloadType":"str","topic":"humidity","x":510,"y":250,"wires":[["1426c20e.a3021e"]]},{"id":"87a34045.d3559","type":"ui_button","z":"6d08d5ab.a8aa3c","name":"wind","group":"99609e7b.c8ed4","order":4,"width":3,"height":1,"passthru":false,"label":"WIND","tooltip":"","color":"","bgcolor":"{{bgr}}","icon":"","payload":"","payloadType":"str","topic":"wind","x":500,"y":290,"wires":[["1426c20e.a3021e"]]},{"id":"ce279d91.f64be","type":"switch","z":"6d08d5ab.a8aa3c","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"temperature","vt":"str"},{"t":"eq","v":"humidity","vt":"str"},{"t":"eq","v":"wind","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":370,"y":250,"wires":[["cd314554.dc9408"],["860fe47f.8bb7f8"],["87a34045.d3559"]]},{"id":"199657db.8602c8","type":"function","z":"6d08d5ab.a8aa3c","name":"get color","func":"var group = global.get(\"buttongroups.gaugegroup\")\nvar m\nfor(var i=0;i<group.members.length;i++){\n    m = {topic:group.members[i].topic}\n    m.bgr = group.members[i].topic == group.selected ? 'green' : 'gray'\n    node.send(m)\n}\n","outputs":1,"noerr":0,"x":240,"y":250,"wires":[["ce279d91.f64be"]]},{"id":"1426c20e.a3021e","type":"change","z":"6d08d5ab.a8aa3c","name":"set selected","rules":[{"t":"set","p":"buttongroups.gaugegroup.selected","pt":"global","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":250,"wires":[["d985b16f.388de"]]},{"id":"d985b16f.388de","type":"link out","z":"6d08d5ab.a8aa3c","name":"gaugegroup out","links":["86181860.e50238","4fe3141f.0fa66c"],"x":805,"y":250,"wires":[]},{"id":"86181860.e50238","type":"link in","z":"6d08d5ab.a8aa3c","name":"gaugegroup in","links":["d985b16f.388de","76ef4267.f6b58c"],"x":145,"y":250,"wires":[["199657db.8602c8"]]},{"id":"4fe3141f.0fa66c","type":"link in","z":"6d08d5ab.a8aa3c","name":"gauge in","links":["d985b16f.388de","76ef4267.f6b58c"],"x":415,"y":340,"wires":[["c4bcbd8b.30332"]]},{"id":"d00c74c.d252588","type":"inject","z":"6d08d5ab.a8aa3c","name":"","topic":"","payload":"","payloadType":"date","repeat":"2.45","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":420,"wires":[["5de3e70d.177ee8"]]},{"id":"78c363c6.bca72c","type":"change","z":"6d08d5ab.a8aa3c","name":"fake temp","rules":[{"t":"set","p":"payload","pt":"msg","to":"$random()*28","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"temperature","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":380,"wires":[["5adc8e68.a23b3"]]},{"id":"5de3e70d.177ee8","type":"change","z":"6d08d5ab.a8aa3c","name":"fake humidity","rules":[{"t":"set","p":"payload","pt":"msg","to":"$random()*100","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"humidity","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":420,"wires":[["5adc8e68.a23b3"]]},{"id":"ad8abcd7.f3d43","type":"change","z":"6d08d5ab.a8aa3c","name":"fake wind","rules":[{"t":"set","p":"payload","pt":"msg","to":"$random()*8","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"wind","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":460,"wires":[["5adc8e68.a23b3"]]},{"id":"7647d883.4841a8","type":"inject","z":"6d08d5ab.a8aa3c","name":"","topic":"","payload":"","payloadType":"date","repeat":"3.7","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":460,"wires":[["ad8abcd7.f3d43"]]},{"id":"5c564e32.b1d5e","type":"inject","z":"6d08d5ab.a8aa3c","name":"","topic":"","payload":"","payloadType":"date","repeat":"1.3","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":380,"wires":[["78c363c6.bca72c"]]},{"id":"5adc8e68.a23b3","type":"function","z":"6d08d5ab.a8aa3c","name":"store inactive & bypass active","func":"var group = global.get(\"buttongroups.gaugegroup\")\nif(group.selected != msg.topic){\n    var member = group.members.find(element => element.topic == msg.topic);\n    member.lastvalue = msg.payload\n    global.set(\"buttongroups.gaugegroup\",group)\n    return\n}\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":390,"wires":[["29e8935c.6601fc"]]},{"id":"c4bcbd8b.30332","type":"function","z":"6d08d5ab.a8aa3c","name":"prepare after selection change","func":"var group = global.get(\"buttongroups.gaugegroup\")\nvar member = group.members.find(element => element.topic == group.selected);\nmsg.title = group.selected.toUpperCase()\nmsg.payload = member.lastvalue\nmsg.ui_control = {min:member.min,max:member.max}\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":350,"wires":[["29e8935c.6601fc"]]},{"id":"99609e7b.c8ed4","type":"ui_group","z":"","name":"GAUGE INPUT SELECTOR","tab":"c38fb46f.de97f8","disp":true,"width":8,"collapse":false},{"id":"c38fb46f.de97f8","type":"ui_tab","z":"","name":"Controls","icon":"dashboard","disabled":false,"hidden":false}]

Flow Info

Created 5 years, 5 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x4)
  • function (x4)
  • inject (x4)
  • link in (x2)
  • link out (x2)
  • switch (x1)
Other

Tags

  • Buttons
  • group
  • gauge
  • dashboard
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option