Node Red: A widget based dashboard working with Homey trough MQTT

@pvdhelm1974

Sorry for delayed answer.

Here are an example to follow how to create one of the sliders and button to control a dimmable light.
Slider


Layout

And the example code to import in node-red

[{"id":"72e56722.d233d8","type":"homie-convention-device","z":"f6a0cce1.578a1","broker":"d2489f03.0a455","name":"","deviceID":"homey-topic","nodeID":"foraldrar-fonster","propertyID":"onoff","topic":"homey-topic/foraldrar-fonster/onoff","infoAttributes":true,"infoTiming":true,"infoError":true,"addLabel":"property","labelTopic":false,"labelPayload":true,"labelName":"","uiPlaceName":"","uiNode":"uiButton","uiControlDropdown":true,"uiControlMinMax":true,"uiColor1":"#ffffff","uiBgColor1":"#ffffff","uiColorON":"#ff0000","uiColorOFF":"#ff0000","uiColorPredicted":"#ffffff","uiUseColorPredicted":false,"uiColorPredictedOff":"#ffffff","uiUseColorPredictedOff":false,"uiFormat":false,"uiTooltip":"","uiIcon1":"fa-lightbulb-o fa-2x","uiIconON":"","uiIconOFF":"","uiSwitchPredicted":false,"uiSwitchColorPredictedON":"#aaaaaa","uiSwitchColorPredictedOFF":"#aaaaaa","uiSwitchIconPredictedON":"fa-toggle-on","uiSwitchIconPredictedOFF":"fa-toggle-off","uiFormatColor":"homieString","settable":false,"x":560,"y":2940,"wires":[["f14f7e88.0e955","367ea77c.81c798"],[]]},{"id":"84106271.7bd47","type":"homie-convention-device","z":"f6a0cce1.578a1","broker":"d2489f03.0a455","name":"","deviceID":"homey-topic","nodeID":"foraldrar-fonster","propertyID":"dim","topic":"homey-topic/foraldrar-fonster/dim","infoAttributes":true,"infoTiming":true,"infoError":true,"addLabel":"property","labelTopic":false,"labelPayload":true,"labelName":"","uiPlaceName":"","uiNode":"uiSlider","uiControlDropdown":true,"uiControlMinMax":true,"uiColor1":"#ffffff","uiBgColor1":"#ffffff","uiColorON":"#ffffff","uiColorOFF":"#ffffff","uiColorPredicted":"#ffffff","uiUseColorPredicted":false,"uiColorPredictedOff":"#ffffff","uiUseColorPredictedOff":false,"uiFormat":false,"uiTooltip":"","uiIcon1":"","uiIconON":"","uiIconOFF":"","uiSwitchPredicted":false,"uiSwitchColorPredictedON":"#aaaaaa","uiSwitchColorPredictedOFF":"#aaaaaa","uiSwitchIconPredictedON":"fa-toggle-on","uiSwitchIconPredictedOFF":"fa-toggle-off","uiFormatColor":"homieString","settable":false,"x":1500,"y":2900,"wires":[["207e8b6b.cae994","8bc034df.eb5108"],[]]},{"id":"207e8b6b.cae994","type":"ui_slider","z":"f6a0cce1.578a1","name":"","label":"","tooltip":"","group":"350d861f.e5e85a","order":3,"width":12,"height":2,"passthru":false,"outs":"all","topic":"","min":0,"max":"100","step":1,"x":1390,"y":2800,"wires":[["8313346b.166a18"]]},{"id":"c85d6a99.4acf38","type":"change","z":"f6a0cce1.578a1","name":"","rules":[{"t":"set","p":"colour","pt":"msg","to":"#333333","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":2800,"wires":[["7aedbf38.29e5d"]]},{"id":"7aedbf38.29e5d","type":"ui_button","z":"f6a0cce1.578a1","name":"","group":"350d861f.e5e85a","order":2,"width":3,"height":3,"passthru":false,"label":"","tooltip":"","color":"","bgcolor":"{{colour}}","icon":"","payload":"press","payloadType":"str","topic":"","x":910,"y":2820,"wires":[["a4a485aa.b21058"]]},{"id":"f14f7e88.0e955","type":"switch","z":"f6a0cce1.578a1","name":"False","property":"payload","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":2800,"wires":[["71834290.71333c"]]},{"id":"367ea77c.81c798","type":"switch","z":"f6a0cce1.578a1","name":"True","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":2840,"wires":[["30ed9bcc.637f04"]]},{"id":"ca58f.7a331a718","type":"change","z":"f6a0cce1.578a1","name":"","rules":[{"t":"set","p":"colour","pt":"msg","to":"#205524","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":2840,"wires":[["7aedbf38.29e5d"]]},{"id":"71834290.71333c","type":"function","z":"f6a0cce1.578a1","name":"Store State 3","func":"var state3;\n\nstate3=1;\n\nflow.set('state3',state3);\n\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":2800,"wires":[["c85d6a99.4acf38"]]},{"id":"a4a485aa.b21058","type":"function","z":"f6a0cce1.578a1","name":"Change state 3","func":"\nvar state = flow.get('state3') || 0;\n\nif (state == 1) { state = true; }\n\nif (state == 2) { state = false; } \n \nmsg.payload = state\n\nreturn msg;\n\n\n","outputs":1,"noerr":0,"x":1100,"y":2820,"wires":[["72e56722.d233d8"]]},{"id":"30ed9bcc.637f04","type":"function","z":"f6a0cce1.578a1","name":"Store State 3","func":"var state3;\n\nstate3=2;\n\nflow.set('state3',state3);\n\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":2840,"wires":[["ca58f.7a331a718"]]},{"id":"2522f0d0.ecaf6","type":"ui_text","z":"f6a0cce1.578a1","group":"350d861f.e5e85a","order":1,"width":12,"height":1,"name":"","label":"Föräldrar Sovrum","format":"<font size = 2> {{msg.payload}}</font><font size = 1> %</font>","layout":"row-spread","x":2070,"y":2800,"wires":[]},{"id":"8313346b.166a18","type":"trigger","z":"f6a0cce1.578a1","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"500","extend":true,"units":"ms","reset":"","bytopic":"all","name":"","x":1580,"y":2800,"wires":[["84106271.7bd47","2522f0d0.ecaf6"]]},{"id":"8bc034df.eb5108","type":"range","z":"f6a0cce1.578a1","minin":"0","maxin":"100","minout":"0","maxout":"100","action":"scale","round":true,"property":"payload","name":"Avnrunda till heltal","x":1810,"y":2880,"wires":[["2522f0d0.ecaf6"]]},{"id":"d2489f03.0a455","type":"homie-convention-broker-config","z":"","mqtt-host":"192.168.1.201","mqtt-port":"1883","usetls":false,"name":"Node-RED","homieName":"Node-RED","homieRoot":"homie","storeGlobal":false},{"id":"350d861f.e5e85a","type":"ui_group","z":"","name":"Sovrum Fönster ","tab":"472bf35c.a0808c","order":10,"disp":false,"width":15,"collapse":false},{"id":"472bf35c.a0808c","type":"ui_tab","z":"","name":"Lights","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

1 Like