Homey Community Forum

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

Hi, sorry this message is in Dutch, to help Dutch users installing MQTT broker and Node Red on Windows!

Hoi,

Ik heb Node-RED en MQTT broker net op een Windows 10 ‘servertje’ geïnstalleerd. Ik denk laat ik het delen voor iedereen die dat ook wil doen. Scheelt wat uitzoekwerk. Is wel in het Nederlands:

Windows 10 – 1809 – 64 bit
Dit wordt de server. Deze moet je dus altijd aan laten staan.

  • Installeer een Windows 10 – 64-bit en update naar meest recente versie

  • Log in met een administrator

Node JS – 12.14.1 LTS

Dit is nodig om straks Node-RED en MQQT te installeren

Node-RED – 1.0.3
Hiermee installeer je de Node-RED server. Na installatie is een webpagina beschikbaar, waarop je Node-RED kan gebruiken.

  • Installeer NodeRed volgens stappen: https://nodered.org/docs/getting-started/windows

  • Start de Node.js CMD

  • Type: npm install -g --unsafe-perm node-red

  • Node-RED wordt gedownload en geïnstalleerd, wacht dit af.

  • De ‘Warn’ melding die je ziet kan je negeren

  • Type nu: node-red

  • Je krijgt een melding van Windows defender Firewall. Kies Toegang toestaan.

  • Je ziet in het CMD scherm dat de server is running. Nu draait de Node-RED server op poort 1880 .

  • TIP: Wil je de Node-RED server automatisch laten starten, bij opstarten van Windows, voer dan de stappen onderaan deze pagina uit: https://nodered.org/docs/getting-started/windows#running-on-windows

  • Open een browser en plak in de adresregel: http://127.0.0.1:1880/ Je ziet nu de Node-RED startpagina

  • Je kan de Node-RED pagina nu ook vanaf een ander apparaat openen via: http://X.X.X.X:1880/ (waar x.x.x.x staat voor het ipadres van je Windows 10 machine)

MQTT Broker – 1.6.8
Hiermee installeer je de MQTT broker (ook wel server genoemd).

  • Download de juiste versie (64 bit) via: https://mosquitto.org/download/

  • Standard installatie -> next -> next etc

  • Ga na de installatie naar de map waar je MQTT hebt geïnstalleerd (C:\Program Files\mosquitto)

  • Dubbelklik daar op Mosquitto.exe

  • Je krijgt een melding van Windows defender Firewall. Kies Toegang toestaan.

  • Je ziet nu enkel een zwart CMD scherm. Nu draait de MQTT broker server op poort 1883 .

  • Sluit deze eventueel af met de toetscombi CTRL+BREAK.

  • TIP: Wil je de MQTT als een Windows service starten, voer dan dit uit:

  • Open een CMD als administrator!

  • Ga in de CMD naar C:\Program Files\mosquitto

  • Type: mosquitto install

  • Nu heb je een Windows service met de naam ‘Mosquitto broker’, welke je automatisch kan laten opstarten (open services in Windows).

MQTT Explorer – 0.3.5
Tool om MQTT verkeer te bekijken. Deze kan je ook op een andere plek installeren, hoeft niet op de server.

  • Download via: http://mqtt-explorer.com/

  • Standaard installatie -> next -> next etc

  • Als de explorer is gestart, maak je een nieuwe verbinding.

  • Geef een willekeurige naam en maak verbinding met het IPadres van de MQTT broker server.

MQTT hub + MQTT client

  • Installeer deze apps op Homey

  • Vul het juiste ipadres (van de MQTT broker) en poort in bij de MQTT client

  • Ga dan naar de hub en verander het topic naar: “homie/homey-topic” en druk dan op Broadcast

  • Je ziet in de MQTT explorer nu nieuwe topics en messages binnen komen

Verder
Volg nu de stappen bovenaan in dit Topic. Goed lezen, filmpjes kijken, en dan kom je er wel.

Struggling with alarmlist.
Only the latest item shows in list.
Is this the right way to do ?


Code for sending to list looks like this:
var lista=flow.get(“Larmlista”) || ;
var DateVar=global.get(“GlobalDate”) || ‘’;
var TimeVar=global.get(“GlobalTime”) || ‘’;
lista.unshift({“title”:DateVar,“description”:TimeVar+": Rörelse Kök",“icon_name”:“fa-bell”});
lista.splice(10)
msg.payload = lista;
return msg;


var lista=flow.get(“Larmlista”) || ;
var DateVar=global.get(“GlobalDate”) || ‘’;
var TimeVar=global.get(“GlobalTime”) || ‘’;
lista.push({“title”:DateVar,“description”:TimeVar+": Rörelse Vardagsrum",“icon_name”:“fa-bell”});
lista.splice(10)
msg.payload = lista;
return msg;

Hi!!

I only see the difference in the first line.

var lista=flow.get(“FlowLarmlista”) || ;

Can be?

Greetings

I’m trying to control some Phillips hue lights through mqtt.

So far I have been able to control the “on-off” and the “dimmer” (thanks to the great help of this forum and @satoer). But I am not able to take control of the color.

As I see in the debug, sending the information to the bulb is correct but, the bulb does not change color.

I have tried sending via the RGB and HSV string but I can’t.

Does anyone have any ideas?

Thanks in advance!!!

I’ve encountered the same problem allthough I use Mi-Lights instead of the Philip Hue. (I thought it was a Milight problem, but I guess it’s an MQTT problem) I could not set the hue of the light:


Eventually when no-one could lead me to a workable solution, I created a workaround. It uses HomeyScript to translate custom MQTT messages to setting the colour:

It’s not pretty, but it works. If I activate a light a extra panel appears to set the light colour and brightness.


I’m using simple coloured buttons. In my opinion this is more touch friendly than the colour picker. I still should give this a graphic overhaul with more colour choice, but to be honest, I hardly use the direct setting of the lights. Most of the time I just set a scene.

Later in that topic user @xAPPO profided some hint’s. But I still had a hard time how to formulate the message to send. And since I had a working solution I did not explore it any further. If you find the right topic / payload please let us know!

According to the homie3 specification it should just be 3 values h,s,v comma delimited to the color topic. They should be 0-255,0-100,0-100

color=200,70,80
no spaces

I have not tried this on Homey but that’s how I’m using it on Hubitat with homie. I’ll try it later if I can find a colour bulb to add.

There is another variant when in RGB mode that supports the same 3 values RGB but each is 0-255 this time.

Im assuming this wasn’t Homey’ised’ as 0.0 to 1.0 float values… like dim level.

Hey @Jan_Willem_Visser, I’m curious about the buttons to set the radio stations. In your screenshot Slam FM is selected. If you now select for example Qmusic, will the button of Slam FM turn grey again? If so, can you show me the Node-red example of how you did that?

Thanks!

I’l try to explane, (my englisch is not verry good)

In homey i have made a virtual button for each radio station. When i turn a virtual button on the a cast started to the chromecast which is connected to my marantz receiver. The inputs of al the buttons on the dashboard shows the state of te buttons in homey. So when a button is turned on in homey the collor gets green and when a button is set off the coller gets white. The output of the butten turns the virtual button in homey on en homey set the other buttons back to off.

This a print screen of some flows

The node red script of the stations:

[{“id”:“1f165d06.58ee53”,“type”:“tab”,“label”:“Radiozenders”,“disabled”:false,“info”:""},{“id”:“cef64778.d245e8”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“if is on”,“func”:“msg.background = “#00ff00”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:120,“wires”:[[“271e5f65.c0e18”]]},{“id”:“5b9bad4f.a14804”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“if its off”,“func”:“msg.background = “#ffffff”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:380,“y”:160,“wires”:[[“271e5f65.c0e18”]]},{“id”:“271e5f65.c0e18”,“type”:“ui_button”,“z”:“1f165d06.58ee53”,“name”:“538 dance”,“group”:“4dc75d04.dd6574”,“order”:2,“width”:3,“height”:2,“passthru”:false,“label”:“538 Dance”,“tooltip”:"",“color”:"#0f0950",“bgcolor”:"{{msg.background}}",“icon”:"",“payload”:“none”,“payloadType”:“str”,“topic”:“button”,“x”:530,“y”:140,“wires”:[[“889011e8.a32b”]]},{“id”:“889011e8.a32b”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“topic”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“button”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:690,“y”:140,“wires”:[[“f7cfbfe9.56829”]]},{“id”:“f7cfbfe9.56829”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:"",“func”:“var obtaindata = global.get (“switch2”)\nif (obtaindata == “1”){msg.payload = 0}\nif (obtaindata == “0”){msg.payload = 1}\nreturn msg;\n\n”,“outputs”:1,“noerr”:0,“x”:810,“y”:140,“wires”:[[“548066be.d65008”,“9f4403af.1da84”]]},{“id”:“548066be.d65008”,“type”:“mqtt out”,“z”:“1f165d06.58ee53”,“name”:"",“topic”:“homie/homey-topic/538-dance/onoff/set”,“qos”:"",“retain”:"",“broker”:“ec8ba132.0d3a3”,“x”:1060,“y”:140,“wires”:},{“id”:“9eb391c0.f80a5”,“type”:“mqtt in”,“z”:“1f165d06.58ee53”,“name”:“538 dance”,“topic”:“homie/homey-topic/538-dance/onoff”,“qos”:“2”,“datatype”:“auto”,“broker”:“ec8ba132.0d3a3”,“x”:80,“y”:140,“wires”:[[“d6f983b4.ba58”]]},{“id”:“d6f983b4.ba58”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“cont”,“v”:“true”,“vt”:“str”},{“t”:“cont”,“v”:“false”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:230,“y”:140,“wires”:[[“cef64778.d245e8”,“a559937b.fbd14”],[“5b9bad4f.a14804”,“4325b405.11615c”]]},{“id”:“9f4403af.1da84”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“move”,“p”:“payload”,“pt”:“msg”,“to”:“switch2”,“tot”:“global”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:990,“y”:80,“wires”:[]},{“id”:“a559937b.fbd14”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“switch2”,“pt”:“global”,“to”:“1”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:410,“y”:60,“wires”:[]},{“id”:“4325b405.11615c”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“switch2”,“pt”:“global”,“to”:“0”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:410,“y”:220,“wires”:[]},{“id”:“b9b6e560.81b3b8”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“off”,“func”:“msg.background = “#ffffff”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:400,“wires”:[[“be0419a3.7384b8”]]},{“id”:“3ce6b7bc.567be8”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“cont”,“v”:“true”,“vt”:“str”},{“t”:“cont”,“v”:“false”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:230,“y”:380,“wires”:[[“537a5dad.012144”,“86c6a279.bfb57”],[“b9b6e560.81b3b8”,“2b27fc02.4f32b4”]]},{“id”:“537a5dad.012144”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“on”,“func”:“msg.background = “#00ff00”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:360,“wires”:[[“be0419a3.7384b8”]]},{“id”:“be0419a3.7384b8”,“type”:“ui_button”,“z”:“1f165d06.58ee53”,“name”:“538”,“group”:“4dc75d04.dd6574”,“order”:1,“width”:3,“height”:2,“passthru”:false,“label”:“Radio 538”,“tooltip”:"",“color”:"#0f0950",“bgcolor”:"{{msg.background}}",“icon”:"",“payload”:“none”,“payloadType”:“str”,“topic”:“button”,“x”:510,“y”:380,“wires”:[[“185d5feb.2e7d8”]]},{“id”:“185d5feb.2e7d8”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“topic”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“button”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:690,“y”:380,“wires”:[[“19a04f80.d913e1”]]},{“id”:“19a04f80.d913e1”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:"",“func”:“var obtaindata = global.get (“switch3”)\nif (obtaindata == “1”){msg.payload = 0}\nif (obtaindata == “0”){msg.payload = 1}\nreturn msg;\n\n”,“outputs”:1,“noerr”:0,“x”:810,“y”:380,“wires”:[[“def0b5be.3c5ae8”,“1739a7a1.bb4448”]]},{“id”:“def0b5be.3c5ae8”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:“re-wirte switch variable”,“rules”:[{“t”:“move”,“p”:“payload”,“pt”:“msg”,“to”:“switch3”,“tot”:“global”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:1000,“y”:340,“wires”:[]},{“id”:“1739a7a1.bb4448”,“type”:“mqtt out”,“z”:“1f165d06.58ee53”,“name”:"",“topic”:“homie/homey-topic/538/onoff/set”,“qos”:"",“retain”:"",“broker”:“ec8ba132.0d3a3”,“x”:1030,“y”:380,“wires”:},{“id”:“ad5c66c9.7cc3f8”,“type”:“mqtt in”,“z”:“1f165d06.58ee53”,“name”:“538”,“topic”:“homie/homey-topic/538/onoff”,“qos”:“2”,“datatype”:“auto”,“broker”:“ec8ba132.0d3a3”,“x”:70,“y”:380,“wires”:[[“3ce6b7bc.567be8”]]},{“id”:“86c6a279.bfb57”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“switch3”,“pt”:“global”,“to”:“1”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:410,“y”:300,“wires”:[]},{“id”:“2b27fc02.4f32b4”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“switch3”,“pt”:“global”,“to”:“0”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:410,“y”:460,“wires”:[]},{“id”:“1a472f6e.d4c0e1”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:“switch”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“cont”,“v”:“true”,“vt”:“str”},{“t”:“cont”,“v”:“false”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:230,“y”:620,“wires”:[[“a445daf3.be6718”,“653e7620.6fa848”],[“a9db2e30.092e”,“d9ea6c34.9c94c”]]},{“id”:“a445daf3.be6718”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“if is on”,“func”:“msg.background = “#00ff00”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:580,“wires”:[[“bbb3cb6c.9ebed8”]]},{“id”:“a9db2e30.092e”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“if its off”,“func”:“msg.background = “#ffffff”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:380,“y”:640,“wires”:[[“bbb3cb6c.9ebed8”]]},{“id”:“bbb3cb6c.9ebed8”,“type”:“ui_button”,“z”:“1f165d06.58ee53”,“name”:“Slam”,“group”:“4dc75d04.dd6574”,“order”:3,“width”:3,“height”:2,“passthru”:false,“label”:“Slam FM”,“tooltip”:"",“color”:"#0f0950",“bgcolor”:"{{msg.background}}",“icon”:"",“payload”:“none”,“payloadType”:“str”,“topic”:“button”,“x”:510,“y”:600,“wires”:[[“401f7ea5.af067”]]},{“id”:“401f7ea5.af067”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“topic”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“button”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:690,“y”:600,“wires”:[[“1854cfc8.d7bac”]]},{“id”:“1854cfc8.d7bac”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:"",“func”:“var obtaindata = global.get (“slam”)\nif (obtaindata == “1”){msg.payload = 0}\nif (obtaindata == “0”){msg.payload = 1}\nreturn msg;\n\n”,“outputs”:1,“noerr”:0,“x”:810,“y”:600,“wires”:[[“869cc1be.281d3”,“7bfb4dca.ea1e94”]]},{“id”:“869cc1be.281d3”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:“re-wirte switch variable”,“rules”:[{“t”:“move”,“p”:“payload”,“pt”:“msg”,“to”:“slam”,“tot”:“global”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:1000,“y”:560,“wires”:[]},{“id”:“7bfb4dca.ea1e94”,“type”:“mqtt out”,“z”:“1f165d06.58ee53”,“name”:"",“topic”:“homie/homey-topic/slam/onoff/set”,“qos”:"",“retain”:"",“broker”:“ec8ba132.0d3a3”,“x”:1040,“y”:600,“wires”:},{“id”:“112f7dd9.7fee82”,“type”:“mqtt in”,“z”:“1f165d06.58ee53”,“name”:“Slam”,“topic”:“homie/homey-topic/slam/onoff”,“qos”:“2”,“datatype”:“auto”,“broker”:“ec8ba132.0d3a3”,“x”:70,“y”:620,“wires”:[[“1a472f6e.d4c0e1”]]},{“id”:“653e7620.6fa848”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“slam”,“pt”:“global”,“to”:“1”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:400,“y”:540,“wires”:[]},{“id”:“d9ea6c34.9c94c”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“slam”,“pt”:“global”,“to”:“0”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:400,“y”:680,“wires”:[]},{“id”:“9cf6b836.144cc8”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“cont”,“v”:“true”,“vt”:“str”},{“t”:“cont”,“v”:“false”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:230,“y”:820,“wires”:[[“46d69a20.5e4814”,“5c3d22fd.4a2b2c”],[“d0ddf816.2a9078”,“e1212eeb.91f3”]]},{“id”:“46d69a20.5e4814”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“on”,“func”:“msg.background = “#00ff00”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:800,“wires”:[[“c6fd20a2.25161”]]},{“id”:“d0ddf816.2a9078”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“off”,“func”:“msg.background = “#ffffff”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:840,“wires”:[[“c6fd20a2.25161”]]},{“id”:“c6fd20a2.25161”,“type”:“ui_button”,“z”:“1f165d06.58ee53”,“name”:“Hardstyle”,“group”:“4dc75d04.dd6574”,“order”:5,“width”:3,“height”:2,“passthru”:false,“label”:“Hardstyle”,“tooltip”:"",“color”:"#0f0950",“bgcolor”:"{{msg.background}}",“icon”:"",“payload”:“none”,“payloadType”:“str”,“topic”:“button”,“x”:520,“y”:820,“wires”:[[“3cd76c56.b2a814”]]},{“id”:“3cd76c56.b2a814”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“topic”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“button”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:690,“y”:820,“wires”:[[“20b451b6.1c0c5e”]]},{“id”:“20b451b6.1c0c5e”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:"",“func”:“var obtaindata = global.get (“switch5”)\nif (obtaindata == “1”){msg.payload = 0}\nif (obtaindata == “0”){msg.payload = 1}\nreturn msg;\n\n”,“outputs”:1,“noerr”:0,“x”:810,“y”:820,“wires”:[[“af5902e.22525”,“eacbcb81.2972a8”]]},{“id”:“af5902e.22525”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:“re-wirte switch variable”,“rules”:[{“t”:“move”,“p”:“payload”,“pt”:“msg”,“to”:“switch5”,“tot”:“global”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:1000,“y”:780,“wires”:[]},{“id”:“eacbcb81.2972a8”,“type”:“mqtt out”,“z”:“1f165d06.58ee53”,“name”:"",“topic”:“homie/homey-topic/hardstyle-fm/onoff/set”,“qos”:"",“retain”:"",“broker”:“ec8ba132.0d3a3”,“x”:1060,“y”:820,“wires”:},{“id”:“c8a5cc51.6f29e”,“type”:“mqtt in”,“z”:“1f165d06.58ee53”,“name”:“Hardstyle FM”,“topic”:“homie/homey-topic/hardstyle-fm/onoff”,“qos”:“2”,“datatype”:“auto”,“broker”:“ec8ba132.0d3a3”,“x”:90,“y”:820,“wires”:[[“9cf6b836.144cc8”]]},{“id”:“5c3d22fd.4a2b2c”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“switch5”,“pt”:“global”,“to”:“1”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:410,“y”:760,“wires”:[]},{“id”:“e1212eeb.91f3”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“switch5”,“pt”:“global”,“to”:“0”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:410,“y”:880,“wires”:[]},{“id”:“7d61c72d.a53c18”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“cont”,“v”:“true”,“vt”:“str”},{“t”:“cont”,“v”:“false”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:230,“y”:1020,“wires”:[[“beb0f544.095a78”,“5f6d4cbf.ea6c64”],[“8a8d7bb.d476c88”,“bd69a531.ec6938”]]},{“id”:“beb0f544.095a78”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“on”,“func”:“msg.background = “#00ff00”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:1000,“wires”:[[“50ae983c.d86c78”]]},{“id”:“8a8d7bb.d476c88”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“off”,“func”:“msg.background = “#ffffff”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:1040,“wires”:[[“50ae983c.d86c78”]]},{“id”:“50ae983c.d86c78”,“type”:“ui_button”,“z”:“1f165d06.58ee53”,“name”:“Trance”,“group”:“4dc75d04.dd6574”,“order”:6,“width”:3,“height”:2,“passthru”:false,“label”:“Trance”,“tooltip”:"",“color”:"#0f0950",“bgcolor”:"{{msg.background}}",“icon”:"",“payload”:“none”,“payloadType”:“str”,“topic”:“button”,“x”:510,“y”:1020,“wires”:[[“14116b3.8da9295”]]},{“id”:“14116b3.8da9295”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“topic”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“button”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:690,“y”:1020,“wires”:[[“76f6e24e.bb917c”]]},{“id”:“76f6e24e.bb917c”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:"",“func”:“var obtaindata = global.get (“trance”)\nif (obtaindata == “1”){msg.payload = 0}\nif (obtaindata == “0”){msg.payload = 1}\nreturn msg;\n\n”,“outputs”:1,“noerr”:0,“x”:810,“y”:1020,“wires”:[[“18d46cdf.ae7353”,“7a19b228.fbfd9c”]]},{“id”:“18d46cdf.ae7353”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:“re-wirte switch variable”,“rules”:[{“t”:“move”,“p”:“payload”,“pt”:“msg”,“to”:“trance”,“tot”:“global”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:1000,“y”:980,“wires”:[]},{“id”:“7a19b228.fbfd9c”,“type”:“mqtt out”,“z”:“1f165d06.58ee53”,“name”:"",“topic”:“homie/homey-topic/trance/onoff/set”,“qos”:"",“retain”:"",“broker”:“ec8ba132.0d3a3”,“x”:1040,“y”:1020,“wires”:},{“id”:“7ad01230.c12b5c”,“type”:“mqtt in”,“z”:“1f165d06.58ee53”,“name”:“Trance”,“topic”:“homie/homey-topic/trance/onoff”,“qos”:“2”,“datatype”:“auto”,“broker”:“ec8ba132.0d3a3”,“x”:70,“y”:1020,“wires”:[[“7d61c72d.a53c18”]]},{“id”:“5f6d4cbf.ea6c64”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“trance”,“pt”:“global”,“to”:“1”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:400,“y”:960,“wires”:[]},{“id”:“bd69a531.ec6938”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“trance”,“pt”:“global”,“to”:“0”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:400,“y”:1080,“wires”:[]},{“id”:“1504d4d7.29b3fb”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“cont”,“v”:“true”,“vt”:“str”},{“t”:“cont”,“v”:“false”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:2,“x”:230,“y”:1240,“wires”:[[“dc3c67da.63e5a8”,“29e5ef0b.c4c26”],[“358dbffa.3542f”,“51e829aa.0dda18”]]},{“id”:“dc3c67da.63e5a8”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“on”,“func”:“msg.background = “#00ff00”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:1220,“wires”:[[“15d85ff9.be0db”]]},{“id”:“358dbffa.3542f”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:“off”,“func”:“msg.background = “#ffffff”;\nreturn msg;”,“outputs”:1,“noerr”:0,“x”:370,“y”:1260,“wires”:[[“15d85ff9.be0db”]]},{“id”:“15d85ff9.be0db”,“type”:“ui_button”,“z”:“1f165d06.58ee53”,“name”:“Qmusic”,“group”:“4dc75d04.dd6574”,“order”:4,“width”:3,“height”:2,“passthru”:false,“label”:“Qmusic”,“tooltip”:"",“color”:"#0f0950",“bgcolor”:"{{msg.background}}",“icon”:"",“payload”:“none”,“payloadType”:“str”,“topic”:“button”,“x”:520,“y”:1240,“wires”:[[“a63beb0d.35fa58”]]},{“id”:“a63beb0d.35fa58”,“type”:“switch”,“z”:“1f165d06.58ee53”,“name”:"",“property”:“topic”,“propertyType”:“msg”,“rules”:[{“t”:“eq”,“v”:“button”,“vt”:“str”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:690,“y”:1240,“wires”:[[“db1f37d.968aac8”]]},{“id”:“db1f37d.968aac8”,“type”:“function”,“z”:“1f165d06.58ee53”,“name”:"",“func”:“var obtaindata = global.get (“switch4”)\nif (obtaindata == “1”){msg.payload = 0}\nif (obtaindata == “0”){msg.payload = 1}\nreturn msg;\n\n”,“outputs”:1,“noerr”:0,“x”:810,“y”:1240,“wires”:[[“38109b27.fd9c84”,“30886c.23c54794”]]},{“id”:“38109b27.fd9c84”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:“re-wirte switch variable”,“rules”:[{“t”:“move”,“p”:“payload”,“pt”:“msg”,“to”:“switch4”,“tot”:“global”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:1000,“y”:1200,“wires”:[]},{“id”:“30886c.23c54794”,“type”:“mqtt out”,“z”:“1f165d06.58ee53”,“name”:"",“topic”:“homie/homey-topic/qmusic/onoff/set”,“qos”:"",“retain”:"",“broker”:“ec8ba132.0d3a3”,“x”:1050,“y”:1240,“wires”:},{“id”:“aca26529.583278”,“type”:“mqtt in”,“z”:“1f165d06.58ee53”,“name”:“Qmusic”,“topic”:“homie/homey-topic/qmusic/onoff”,“qos”:“2”,“datatype”:“auto”,“broker”:“ec8ba132.0d3a3”,“x”:70,“y”:1240,“wires”:[[“1504d4d7.29b3fb”]]},{“id”:“29e5ef0b.c4c26”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“switch4”,“pt”:“global”,“to”:“1”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:410,“y”:1160,“wires”:[]},{“id”:“51e829aa.0dda18”,“type”:“change”,“z”:“1f165d06.58ee53”,“name”:"",“rules”:[{“t”:“set”,“p”:“switch4”,“pt”:“global”,“to”:“0”,“tot”:“str”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:410,“y”:1320,“wires”:[]},{“id”:“4dc75d04.dd6574”,“type”:“ui_group”,“z”:"",“name”:“Bediening”,“tab”:“f703361.68de3c8”,“order”:4,“disp”:false,“width”:“6”,“collapse”:false},{“id”:“ec8ba132.0d3a3”,“type”:“mqtt-broker”,“z”:"",“name”:“Homey MQTT”,“broker”:“192.168.178.37”,“port”:“1883”,“clientid”:"",“usetls”:false,“compatmode”:true,“keepalive”:“60”,“cleansession”:true,“birthTopic”:"",“birthQos”:“0”,“birthPayload”:“woonk”,“closeTopic”:"",“closeQos”:“0”,“closePayload”:"",“willTopic”:"",“willQos”:“0”,“willPayload”:""},{“id”:“f703361.68de3c8”,“type”:“ui_tab”,“z”:"",“name”:“Homeydash”,“icon”:“dashboard”,“order”:2,“disabled”:false,“hidden”:false}]

1 Like

I’ve something similar with my light scene’s. When I select the scene that scene gets active by turning green. The rest goes back to blue:

I do it like this:
First of all, you need to let Node-red know that a new scene is selected:

In Node-red the MQTT, every button is connected to a function node:

The function node determends if the button behind the node is selected. If so, it makes the background variable in the payload green. Otherwise blue:
var color;

var color;

if(msg.payload === "Sfeerlicht"){
// state is true (lets make button green)
 color = "#53c653";
}
else{
    // state is false (lets make button blue)
 color = "#0094ce";
}

msg = {background:color};
return msg;

Inside the button, you need to set the background to the color variable:
ButtonColorsLightSetColor

1 Like

Thanks @Satoer and @Jan_Willem_Visser ! I’m going to try it myself.

I have it working now like the example from @Satoer, but I see that variables send from homey via MQTT had a ‘space’ in front… So it’s not recognised in Node-red.

This is what is received:

homie/homey-topic/huismodus-from-homey : msg.payload : string[13]
" Automatisch" 

This is what should be send by Homey:

homie/homey-topic/huismodus-from-homey : msg.payload : string[13]
"Automatisch"

Hello @Satoer

I was doing several tests and reading several tutorials. I found this way to control the tone of Philips bulbs.

Surely it is a simple way to do it and it may not work for you, but I share it in case it helps.

Keep in touch!!

Thank you.

[{"id":"9e52b7af.3462f8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"df39fe63.a528f","type":"ui_switch","z":"9e52b7af.3462f8","name":"Bombilla Salon 1","label":"Bombilla Salon 1","tooltip":"","group":"cdf86204.1611e","order":9,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"fa-3x fa-lightbulb-o","oncolor":"#81a41a","offvalue":"false","offvalueType":"bool","officon":"fa-3x fa-lightbulb-o","offcolor":"black","x":710,"y":260,"wires":[["372d6eed.54e1d2"]]},{"id":"372d6eed.54e1d2","type":"hue-light","z":"9e52b7af.3462f8","name":"Bombilla Salón 1","bridge":"c9eab922.43e148","lightid":"3","colornamer":true,"skipevents":false,"x":1210,"y":320,"wires":[[]]},{"id":"3a611da5.b19132","type":"function","z":"9e52b7af.3462f8","name":"Splitt","func":"return [\n    { payload: msg.payload.on },\n    { payload: msg.payload.hex },\n    { payload: msg.payload.brightness }\n    \n];","outputs":3,"noerr":0,"x":430,"y":340,"wires":[["df39fe63.a528f"],["783450eb.7815c"],["6c47bab4.afe004"]]},{"id":"783450eb.7815c","type":"ui_colour_picker","z":"9e52b7af.3462f8","name":"Color Bombilla 1","label":"Color Bombilla","group":"cb80238.cbb0ae","format":"hex","outformat":"object","showSwatch":true,"showPicker":false,"showValue":false,"showHue":false,"showAlpha":false,"showLightness":true,"square":"false","dynOutput":"false","order":9,"width":0,"height":0,"passthru":false,"topic":"","x":700,"y":360,"wires":[["368fe4ea.7e813c"]]},{"id":"368fe4ea.7e813c","type":"function","z":"9e52b7af.3462f8","name":"Funcion Color","func":"return { payload: { hex: msg.payload } };","outputs":1,"noerr":0,"x":920,"y":360,"wires":[["372d6eed.54e1d2"]]},{"id":"c6569d.fac5396","type":"hue-light","z":"9e52b7af.3462f8","name":"Bombilla Salón 1","bridge":"c9eab922.43e148","lightid":"3","colornamer":true,"skipevents":false,"x":190,"y":340,"wires":[["3a611da5.b19132"]]},{"id":"6c47bab4.afe004","type":"ui_slider","z":"9e52b7af.3462f8","name":"Brightness","label":"Brightness","tooltip":"","group":"cb80238.cbb0ae","order":17,"width":0,"height":0,"passthru":false,"outs":"end","topic":"","min":0,"max":"100","step":"10","x":690,"y":420,"wires":[["881367c9.9d6808"]]},{"id":"881367c9.9d6808","type":"function","z":"9e52b7af.3462f8","name":"Funcion Brightness","func":"return { payload: { brightness: msg.payload } };","outputs":1,"noerr":0,"x":930,"y":420,"wires":[["372d6eed.54e1d2"]]},{"id":"cdf86204.1611e","type":"ui_group","z":"","name":"Iluminacion","tab":"3abaad29.0e7442","order":1,"disp":true,"width":"8","collapse":false},{"id":"c9eab922.43e148","type":"hue-bridge","z":"","name":"Philips hue Bridge","bridge":"192.168.11.151","key":"fkRRh1XTEda2MyYvGFOxuHa6x5x6Og0sYgzGkqH1","interval":"3000","disableupdates":false},{"id":"cb80238.cbb0ae","type":"ui_group","z":"","name":"Iluminacion","tab":"41973f9d.b568a","order":1,"disp":true,"width":"6","collapse":false},{"id":"3abaad29.0e7442","type":"ui_tab","z":"","name":"Salon","icon":"fa-film","order":6,"disabled":false,"hidden":false},{"id":"41973f9d.b568a","type":"ui_tab","z":"","name":"Home","icon":"home","order":1}]

Thanks for sharing. Sadly this does not work for me. You are controlling the hue bulbs directly and bypassing Homey. (Does homey know the state of the lights if they are controlled outside of homey?)

Hi

Thank you’
Is it only the url that i need to change to make this work?

Something as this can strip the first character, use the substr() function.

var myString = '!thisIsMyString';
msg.payload = myString.substr(1);

Though it shouldn’t have a space before it. Are you sure you didn’t add the leading space in the Homey Flow by accident?

Problems with buffer, after 4-5 days of data screen starts to flicker and in the end the container on my qnap-server stops node red. Some of the graphs have 7 days of data, but obviously it can`t handle that many days.

Is this problem know to anyone? I guess its a buffer thing, did install the module, but dosent work.

It’s actually very stable over here. I use node red in a docker container on a Synology. It’s been running for 70 day’s now. But I only use 2 graph’s with a week length of data points.

Hi,

I want to display a tempetature, but also want to change the color of the background. So for this I use a button. But I get only one of the 2 thing working. Or the color is changing, or the text is changing, but nog both.

So when I disconnect the bottom line, the color is changing acording to the temperature. And when I am disconnecting the ‘Freezing function’, the text in the button is changing acording to the temperature. But I don’t get it both working at the same time. Any ideas??

This is how I did it:
image

This is the code in the function:

var color;

if(msg.payload <= "2"){
// state is true (lets make button blue)
 color = "#03b6fc";
}
else{
    // state is false (lets make button red)
 color = "#fc2803";
}

msg = {background:color};
return msg;

And this is the code of the complete flow:

[{"id":"1241d3ec.b9c4ec","type":"mqtt in","z":"7b4023c5.1e24fc","name":"MQTT receiver temp AT","topic":"homie/homey-topic/at-temp-and-hum/measure-temperature","qos":"2","datatype":"auto","broker":"649f9a36.29ece4","x":180,"y":900,"wires":[["5032722a.811f8c","936b097f.ea3fd8"]]},{"id":"5032722a.811f8c","type":"function","z":"7b4023c5.1e24fc","name":"Freezing","func":"var color;\n\nif(msg.payload <= \"2\"){\n// state is true (lets make button blue)\n color = \"#03b6fc\";\n}\nelse{\n    // state is false (lets make button red)\n color = \"#fc2803\";\n}\n\nmsg = {background:color};\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":840,"wires":[["936b097f.ea3fd8"]]},{"id":"936b097f.ea3fd8","type":"ui_button","z":"7b4023c5.1e24fc","name":"AT temp kleur","group":"b7e44d48.b227d","order":8,"width":2,"height":1,"passthru":false,"label":"tmp: {{msg.payload}} ","tooltip":"","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":560,"y":900,"wires":[[]]},{"id":"649f9a36.29ece4","type":"mqtt-broker","z":"","name":"MQTT server Jeroen","broker":"192.168.178.129","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"b7e44d48.b227d","type":"ui_group","z":"","name":"Group 6","tab":"bf9cdcc.4e7c92","order":6,"disp":false,"width":"4","collapse":false},{"id":"bf9cdcc.4e7c92","type":"ui_tab","z":"","name":"Startscherm","icon":"home","order":1,"disabled":false,"hidden":false}]

When you do this:

msg = {background:color};
return msg;

you are replacing the original message with only the background color inside it.
Change it to this (and remove the bottom node connection):

msg.background = color;
return msg;

Then you add the color variable. This way, you don’t remove the msg.payload.

1 Like

Thanks! That does the trick. I guess I need to learn some basic node.js… :slight_smile: