Skip to content

Instantly share code, notes, and snippets.

@dceejay
Created April 17, 2018 11:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dceejay/f1b077d49f52866e74e9b983690b470f to your computer and use it in GitHub Desktop.
Save dceejay/f1b077d49f52866e74e9b983690b470f to your computer and use it in GitHub Desktop.
Simple example of hiding groups

A simple example to show how hiding groups can be used (Dashboard v2.9.0 onwards)

You can jump to any stage of the process using the buttons on the left. But can also automatically trigger the next stage by something within a group - in this case sliding the slider above 7. You can then reset the process or wait 10 seconds, and it will reset automatically.

[{"id":"4f3cf202.2fb4fc","type":"ui_button","z":"2f0eea75.da6d06","name":"","group":"e40e97d4.1356e8","order":0,"width":0,"height":0,"passthru":false,"label":"button1","color":"","bgcolor":"","icon":"","payload":"{\"group\":{\"hide\":[\"Home_Group_2\",\"Home_Group_3\"],\"show\":[\"Home_Group_1\"]}}","payloadType":"json","topic":"","x":260,"y":520,"wires":[["e374a3ea.93523"]]},{"id":"20929192.34fbbe","type":"ui_button","z":"2f0eea75.da6d06","name":"","group":"e40e97d4.1356e8","order":0,"width":0,"height":0,"passthru":false,"label":"button2","color":"","bgcolor":"","icon":"","payload":"{\"group\":{\"hide\":[\"Home_Group_1\",\"Home_Group_3\"],\"show\":[\"Home_Group_2\"]}}","payloadType":"json","topic":"","x":260,"y":560,"wires":[["e374a3ea.93523"]]},{"id":"bcd5bc48.851","type":"ui_button","z":"2f0eea75.da6d06","name":"","group":"e40e97d4.1356e8","order":0,"width":0,"height":0,"passthru":false,"label":"button3","color":"","bgcolor":"","icon":"","payload":"{\"group\":{\"hide\":[\"Home_Group_1\",\"Home_Group_2\"],\"show\":[\"Home_Group_3\"]}}","payloadType":"json","topic":"","x":260,"y":600,"wires":[["e374a3ea.93523"]]},{"id":"3073f8a1.91abe8","type":"ui_gauge","z":"2f0eea75.da6d06","name":"","group":"f2aefa84.a9a108","order":0,"width":0,"height":0,"gtype":"gage","title":"Gauge","label":"units","format":"{{value}}","min":0,"max":10,"colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":830,"y":420,"wires":[]},{"id":"e6d025a4.d4a868","type":"ui_template","z":"2f0eea75.da6d06","group":"b09937f3.b814f8","name":"","order":0,"width":"6","height":"3","format":"This is the start group.<br/>\nPress button 2 to move to the next group.<br/>\nThen slide the slider.","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":840,"y":360,"wires":[[]]},{"id":"97564f2f.aea38","type":"ui_button","z":"2f0eea75.da6d06","name":"","group":"75944167.0434b","order":2,"width":0,"height":0,"passthru":false,"label":"Reset","color":"","bgcolor":"","icon":"","payload":"{\"group\":{\"hide\":[\"Home_Group_2\",\"Home_Group_3\"],\"show\":[\"Home_Group_1\"]}}","payloadType":"json","topic":"","x":830,"y":520,"wires":[["e374a3ea.93523"]]},{"id":"e374a3ea.93523","type":"ui_ui_control","z":"2f0eea75.da6d06","name":"","x":660,"y":600,"wires":[[]]},{"id":"9cbd5e64.629f5","type":"ui_slider","z":"2f0eea75.da6d06","name":"","label":"slider","group":"f2aefa84.a9a108","order":0,"width":0,"height":0,"passthru":false,"topic":"","min":0,"max":10,"step":1,"x":470,"y":400,"wires":[["3073f8a1.91abe8","2da21b04.ec98d4"]]},{"id":"5ee9247b.cfcefc","type":"ui_template","z":"2f0eea75.da6d06","group":"75944167.0434b","name":"","order":1,"width":"6","height":"3","format":"Slider reached > 7 = Passed</br>\nHit Reset to go back to stage 1</br>\nOr wait 10 seconds.","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":840,"y":480,"wires":[[]]},{"id":"2da21b04.ec98d4","type":"function","z":"2f0eea75.da6d06","name":"","func":"if (msg.payload > 7) {\n m2 = {payload : 0};\n msg.payload = {\"group\":{\"hide\":[\"Home_Group_1\",\"Home_Group_2\"],\"show\":[\"Home_Group_3\"]}};\n return [ m2, msg];\n}\nreturn null;","outputs":2,"noerr":0,"x":470,"y":460,"wires":[["9cbd5e64.629f5","3073f8a1.91abe8"],["95b70ae.d995ff8"]]},{"id":"8835b353.14965","type":"inject","z":"2f0eea75.da6d06","name":"","topic":"","payload":"{\"group\":{\"hide\":[\"Home_Group_2\",\"Home_Group_3\"],\"show\":[\"Home_Group_1\"]}}","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":270,"y":480,"wires":[["e374a3ea.93523"]]},{"id":"95b70ae.d995ff8","type":"trigger","z":"2f0eea75.da6d06","op1":"","op2":"{\"group\":{\"hide\":[\"Home_Group_2\",\"Home_Group_3\"],\"show\":[\"Home_Group_1\"]}}","op1type":"pay","op2type":"json","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":550,"y":520,"wires":[["e374a3ea.93523"]]},{"id":"e40e97d4.1356e8","type":"ui_group","z":"","name":"Menu","tab":"12c7c5a9.cc3c3a","disp":true,"width":"6","collapse":false},{"id":"f2aefa84.a9a108","type":"ui_group","z":"","name":"Group 2","tab":"12c7c5a9.cc3c3a","order":3,"disp":true,"width":"6","collapse":false},{"id":"b09937f3.b814f8","type":"ui_group","z":"","name":"Group 1","tab":"12c7c5a9.cc3c3a","order":2,"disp":true,"width":"6","collapse":false},{"id":"75944167.0434b","type":"ui_group","z":"","name":"Group 3","tab":"12c7c5a9.cc3c3a","order":4,"disp":true,"width":"6","collapse":false},{"id":"12c7c5a9.cc3c3a","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]
@davidcgu
Copy link

Note: It works to show or hide a group, I don't know if could be used for a tab, only when the device you are using shows the full dashboard on the entire screen, if you use it with a smaller screen then is not working I guess due to the different screen format, in my case I have tested with my laptop and a 10" tablet and is ok but with my 5,5" cellphone then not.

Nice job mate!!!! Thanks for sharing

@mapleeight
Copy link

Hi Dave, thank you for the example, very helpful. I have updated it a little, now a Dashboard Slider will show or hide a group

So if interesting for anybody, here my example with a litte explanation:
I would like to show or hide the group "Test" in tab "Computer" of the dashboard.
Dashboard

As described by you, the JSON message it needs to be {"group":{"show":["Computer_Test"]}} or {"group":{"hide":["Computer_Test"]}}.

Hide-Show Tab

The "Show-Hide" change node will set the JSON message:
Hide-Show ChangeNode

Here the flow for import:
[{"id":"4ace1d65.7298b4","type":"ui_ui_control","z":"c91264d9.2239d8","name":"","x":540,"y":660,"wires":[[]]},{"id":"5c43468e.26f8c8","type":"ui_switch","z":"c91264d9.2239d8","name":"","label":"Hide/Show Tab","tooltip":"","group":"97bd3521.3b59a8","order":3,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":180,"y":660,"wires":[["83157b2b.ad41a8"]]},{"id":"83157b2b.ad41a8","type":"change","z":"c91264d9.2239d8","name":"Show-Hide","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"bool","to":"{\"group\":{\"show\":[\"Computer_Test\"]}}","tot":"json"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"{\"group\":{\"hide\":[\"Computer_Test\"]}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":660,"wires":[["4ace1d65.7298b4"]]},{"id":"54db81dd.ed3cf","type":"inject","z":"c91264d9.2239d8","name":"Set to Disabled","topic":"msg.payload","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":120,"y":600,"wires":[["5c43468e.26f8c8"]]},{"id":"97bd3521.3b59a8","type":"ui_group","z":"","name":"Computer","tab":"c1e23531.720978","disp":true,"width":8,"collapse":false},{"id":"c1e23531.720978","type":"ui_tab","z":"","name":"Computer","icon":"dashboard","order":9,"disabled":false,"hidden":false}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment