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

Hi all, I got my dashboard set up almost done now, only some tweaking here and there left. Thanks everyone for the help and advice.

However, now I sometimes encounter a problem.
I have the MQTT broker running in docker on my Synology nas, but when the nas is rebooted after a update for instance, all my lights flicker, home alarm is set to active and some other things happen.
What could cause this problem?

I was thinking the birth message of nodered activates a broadcast from the MQTT hub, but the hub sends wrong states.
Anyone else who also encounters this problem and is there a solution for this?

I have not encountered something like this. A received mqtt message should never activate a device unless you specifically programmed it to do so. In theory you could flip everting around and use the homey just as a device and do the flows on Node-red to control anything (just like the new pro-flows on Homey).

I think you need to check if all msg pass troughs are disabled on buttons and switches. (This could also lead to continues looping).
Like:
afbeelding
or
afbeelding

Thnx for the reply.
The thing is that I only have an “mqtt in” node to read my home alarm state which in turn shows an icon based on the state, so nothing in node red can actually control my alarm.
Still it is activated after a broadcast.

I also don’t use any switches, I noticed the switches somethings didn’t work so now I only use buttons set up to act as a switch

Will try to watch the messages, best by setting an debug node watching for “alarm” and then trigger a broadcast. See what happens…

What happens when you press the broadcast button in the MQTT hub settings?

Sorry for the late reply. Been a bit busy.
Just pushing broadcast in the mqtt hub does exactly what is expected, it triggers a broadcast and updates all selected devices. Nothing strange here.
As it seems it only happens when homey is rebooted or when my NAS is rebooted.
Will do some further testing when I have the time to see which exact app and/or docker container causes the strange behavior.

This solved those kind of problems here:

After implementing the above settings (and changing all topics in the dashboard) my problem still exists.
Yesterday is was able to narrow it down to the application giving the error.
After restarting the Mosquitto MQTT docker container, all my lights flicker, thermostat is turned off and alarm is activated.
Creating a debug in Node-red didn’t give any result, because the Mosquitto server is restarting, no topics are received in nodered during the restart.

This conclusion exludes nodered from causing the problem, so i will have to investigate what happens within Homey after a restart of Mosquitto.
Anyone knows if there any way to create a debug log in Homey?

You can install the app by CLI, and then run
homey app run
Then you can see the debug output in the cmd screen.

How to CLI:
https://community.homey.app/t/how-to-cli-install-method/198

Source:
https://github.com/harriedegroot/nl.hdg.mqtt

1 Like

You can add a debug node in Node -red to see all messages coming in. That might be helpful narrowing down the problem:

The Homey MQTT Hub has also a log, but I don’t think it could solve your problem:

The Homey MQTT Client has also a log:

(All in the app settings)

1 Like

@Peter_Kawa @Satoer Thank you Peter and Michel,
Already found the log in the mqtt client.
Will try to narrow down the issue with teh loggings in Homey when i get back from work.

Thanks in advance for the support!

1 Like

Controlling the color of philips hue lights: It seems like a pain in the ass.
I have no idea if someone already solved it. I searched through the replies but i was unable to find it so i sat down and tried to come up with a solution.
I wanted to control 4 color spots that i have. Meaning, turning them on and off but also changing the color. And i found a solution :grinning:
This is what i came up with.

[{"id":"9a46ebd1.1b884","type":"debug","z":"6c14bc3e8b976abe","name":"abracadabra","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":740,"wires":[]},{"id":"3905076c1d531c67","type":"ui_colour_picker","z":"6c14bc3e8b976abe","name":"Eetkamer","label":"","group":"2b0d2624.525502","format":"hsv","outformat":"string","showSwatch":true,"showPicker":true,"showValue":true,"showHue":true,"showAlpha":true,"showLightness":true,"square":"false","dynOutput":"false","order":3,"width":"2","height":"1","passthru":true,"topic":"homie/homey/hue-color-spot-7/color/hsv/set","topicType":"msg","className":"","x":760,"y":820,"wires":[["2b9c8a67b0edc6c4","9a46ebd1.1b884"]]},{"id":"8c7e874185b78b0b","type":"mqtt in","z":"6c14bc3e8b976abe","name":"mqtt spot 7","topic":"homie/homey/hue-color-spot-7/color","qos":"2","datatype":"auto-detect","broker":"3327dd14625028dc","nl":false,"rap":false,"inputs":0,"x":440,"y":820,"wires":[["0615e923196c70f7"]]},{"id":"1d187528.c409e3","type":"ui_switch","z":"6c14bc3e8b976abe","name":"Light Switch","label":"Eetkamer","tooltip":"","group":"2b0d2624.525502","order":9,"width":"2","height":"1","passthru":false,"decouple":"true","topic":"homie/homey/hue-color-spot-7/onoff/set","topicType":"str","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":true,"className":"","x":970,"y":500,"wires":[["0212fea4c7f5e76c","8a53cae18582f582","22522521974dc5b5","f0575ce5.e23a58"]]},{"id":"de41fdc2.8f4218","type":"mqtt in","z":"6c14bc3e8b976abe","name":"MQTT receiver light","topic":"homie/homey/hue-color-spot-7/onoff","qos":"2","datatype":"auto","broker":"3327dd14625028dc","nl":false,"rap":false,"inputs":0,"x":490,"y":500,"wires":[["80c8f8f1.e28b9"]]},{"id":"80c8f8f1.e28b9","type":"function","z":"6c14bc3e8b976abe","name":"Convert String to Boolean","func":"if(msg.payload === \"true\"){\n   msg.payload = true;  \n}else{\n   msg.payload = false;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":745.1667022705078,"y":500.60003662109375,"wires":[["1d187528.c409e3"]]},{"id":"2b9c8a67b0edc6c4","type":"function","z":"6c14bc3e8b976abe","name":"function 1","func":"// Get the input text\nvar inputText = msg.payload;\n\n// Remove \"hsv(\" and \")\" from the input text\nvar cleanedText = inputText.replace(\"hsv(\", \"\").replace(\")\", \"\");\n\n// Split the cleaned text into an array of values\nvar values = cleanedText.split(\", \");\n\n// Get the hue value (first value in the array) and convert it to a number\nvar hue = Number(values[0]);\n\n// Get the saturation value (second value in the array) and remove \"%\" character, then convert it to a number\nvar saturation = Number(values[1].replace(\"%\", \"\"));\n\n// Get the value (third value in the array) and remove \"%\" character, then convert it to a number\nvar value = Number(values[2].replace(\"%\", \"\"));\n\n// Create a new string in the format \"hue,saturation,value\"\nvar outputText = hue + \",\" + saturation + \",\" + value;\n\n// Set the modified text as the output of the function node\nmsg.payload = outputText;\n\n// Return the modified message object\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":820,"wires":[["10c4df957690bb4b","6b3223c4638ec862","452983a8919ce860","1148472cb9e0f7c8"]]},{"id":"10c4df957690bb4b","type":"mqtt out","z":"6c14bc3e8b976abe","name":"MQTT transmit","topic":"homie/homey/hue-color-spot-7/color/set","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"3327dd14625028dc","x":1180,"y":740,"wires":[]},{"id":"6b3223c4638ec862","type":"mqtt out","z":"6c14bc3e8b976abe","name":"MQTT transmit","topic":"homie/homey/hue-color-spot-6/color/set","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"3327dd14625028dc","x":1180,"y":780,"wires":[]},{"id":"452983a8919ce860","type":"mqtt out","z":"6c14bc3e8b976abe","name":"MQTT transmit","topic":"homie/homey/hue-color-spot-4/color/set","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"3327dd14625028dc","x":1180,"y":820,"wires":[]},{"id":"1148472cb9e0f7c8","type":"mqtt out","z":"6c14bc3e8b976abe","name":"MQTT transmit","topic":"homie/homey/hue-color-spot-5/color/set","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"3327dd14625028dc","x":1180,"y":860,"wires":[]},{"id":"0615e923196c70f7","type":"function","z":"6c14bc3e8b976abe","name":"function 2","func":"// Get the input text\nvar inputText = msg.payload;\n\n// Split the input text into an array of values\nvar values = inputText.split(\",\");\n\n// Get the hue value (first value in the array) and convert it to a number\nvar hue = Number(values[0]);\n\n// Get the saturation value (second value in the array) and convert it to a number\nvar saturation = Number(values[1]);\n\n// Get the value (third value in the array) and convert it to a number\nvar value = Number(values[2]);\n\n// Create a new string in the format \"hsv(hue,saturation%,value%)\"\nvar outputText = \"hsv(\" + hue + \", \" + saturation + \"%, \" + value + \"%)\";\n\n// Set the modified text as the output of the function node\nmsg.payload = outputText;\n\n// Return the modified message object\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":820,"wires":[["3905076c1d531c67","9a46ebd1.1b884"]]},{"id":"0212fea4c7f5e76c","type":"mqtt out","z":"6c14bc3e8b976abe","name":"MQTT Transmitter","topic":"homie/homey/hue-color-spot-4/onoff/set","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"3327dd14625028dc","x":1190,"y":540,"wires":[]},{"id":"8a53cae18582f582","type":"mqtt out","z":"6c14bc3e8b976abe","name":"MQTT Transmitter","topic":"homie/homey/hue-color-spot-5/onoff/set","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"3327dd14625028dc","x":1190,"y":580,"wires":[]},{"id":"22522521974dc5b5","type":"mqtt out","z":"6c14bc3e8b976abe","name":"MQTT Transmitter","topic":"homie/homey/hue-color-spot-6/onoff/set","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"3327dd14625028dc","x":1190,"y":620,"wires":[]},{"id":"9b5d7e1c6f7b4d1e","type":"mqtt in","z":"6c14bc3e8b976abe","name":"MQTT receiver light","topic":"homie/homey/hue-color-spot-4/onoff","qos":"2","datatype":"auto","broker":"3327dd14625028dc","nl":false,"rap":false,"inputs":0,"x":490,"y":540,"wires":[["80c8f8f1.e28b9"]]},{"id":"e7213c978459e7de","type":"mqtt in","z":"6c14bc3e8b976abe","name":"MQTT receiver light","topic":"homie/homey/hue-color-spot-5/onoff","qos":"2","datatype":"auto","broker":"3327dd14625028dc","nl":false,"rap":false,"inputs":0,"x":490,"y":580,"wires":[["80c8f8f1.e28b9"]]},{"id":"40d35767cf21b43a","type":"mqtt in","z":"6c14bc3e8b976abe","name":"MQTT receiver light","topic":"homie/homey/hue-color-spot-6/onoff","qos":"2","datatype":"auto","broker":"3327dd14625028dc","nl":false,"rap":false,"inputs":0,"x":490,"y":620,"wires":[["80c8f8f1.e28b9"]]},{"id":"f0575ce5.e23a58","type":"mqtt out","z":"6c14bc3e8b976abe","name":"MQTT Transmitter","topic":"homie/homey/hue-color-spot-7/onoff/set","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"3327dd14625028dc","x":1190,"y":500,"wires":[]},{"id":"2b0d2624.525502","type":"ui_group","name":"Lampen","tab":"2f1cda12.393b96","order":1,"disp":true,"width":"6","collapse":false},{"id":"3327dd14625028dc","type":"mqtt-broker","name":"","broker":"192.168.1.1","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"2f1cda12.393b96","type":"ui_tab","name":"Homey Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Can you share how you got the time and date to display like that on your dashboard please?

Please tag the person you reply to @Emile_F1 . Tags appear with typing an @

Good morning. I haven’t been here for a long time, I gave up continuing with the node-red panel for professional reasons, but I’ve decided to come back.

I have installed node-red on raspberry pi but have run into the following problem.

I manage to connect correctly with MQTT. Through the MQTT Explorer I see all the sensors and devices that I have running on Homey.

I put the test node to transmit the ignition of a philips light. I see in the MQTT explore that the state of the light changes. But the light…does nothing.

I have also tried with a Fibaro actuator. It does exactly the same. In the MQTT explorer you see the state change, but the trigger…does nothing.

Has anyone been through this?

Any idea where the error or failure could be?

Thanks to everyone beforehand.

hello, i have a mac computer at home, and i can’t connect to the rasberry pi. This makes it impossible to install node red. I want to try this now using a windows computer. Only my question if this is successful can I log in and program via the Mac computer? Or does this have to be done every time via the windows computer

Also with a Mac you can connect to a RaspberryPI. Maybe this can help you https://www.instructables.com/Connect-Raspberry-pi-to-MacOS-or-Linux-using-SSH/

thank you, it helped. node red is now running on the raspberry pi

Hello @DeepBlueNine, I had a question about your message from Sept 2020 about the glowing ‘on’ button. I understand the function necessary to pass the classportail, but not the “code for the UI Template” and the CSS code. Both those things go in the UI Template node? Or does the button get its own UI Template node? In your previous examples, the CSS code in the UI Template node doesn’t have anywhere written <div class.... </div>, only <style> and <script>.

Basic question is where exactly does <div class="{msg.cportail}}">{{msg.topic}}</div> go? And is it a typo to have only one opening bracket on {msg.cportail}}?

Thank you for your CSS code hints for improving the node-red dashboard. Helps me use an old iPad 2 for a display.

hello, maybe I have read over it, but I am working on Node red and Mqtt. turning the lights on and off works hard.
only with a slider to dim it doesn’t work, from homey when I change something it happens but when I do something from the dashboard nothing happens,

can anyone help me with this