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

[{"id":"c6f67e7f.de1f9","type":"tab","label":"Google Maps","disabled":false,"info":""},{"id":"da7424e9.8a5178","type":"json","z":"c6f67e7f.de1f9","name":"","x":530,"y":140,"wires":[["e19909dc.ec11d8"]]},{"id":"e19909dc.ec11d8","type":"function","z":"c6f67e7f.de1f9","name":"Parse data","func":"msg.topic = \"work\";\nmsg.payload = msg.payload.rows[0].elements[0].duration_in_traffic.text.replace(\"mins\",\"m\");\nmsg.payload = msg.payload.replace(\"hour\",\"u\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":690,"y":140,"wires":[["719b4322.1702ec","7120542a.a2e60c"]]},{"id":"60a398b7.3cacf8","type":"json","z":"c6f67e7f.de1f9","name":"","property":"payload","action":"","pretty":false,"x":530,"y":300,"wires":[["81fce402.0a6ee8"]]},{"id":"81fce402.0a6ee8","type":"function","z":"c6f67e7f.de1f9","name":"Parse data","func":"msg.topic = \"home\";\nmsg.payload = msg.payload.rows[0].elements[0].duration_in_traffic.text.replace(\"mins\",\"m\");\nmsg.payload = msg.payload.replace(\"hour\",\"u\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":670,"y":280,"wires":[["719b4322.1702ec"]]},{"id":"719b4322.1702ec","type":"join","z":"c6f67e7f.de1f9","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":890,"y":220,"wires":[["f86f2992.6beb98","b7cc0738.117108"]]},{"id":"674e23b2.e695ac","type":"http request","z":"c6f67e7f.de1f9","name":"Travel to work","method":"GET","ret":"txt","paytoqs":false,"url":"https://maps.googleapis.com/maps/api/distancematrix/json?origins=Utrecht&destinations=Amsterdam&key=MAPS-API&mode=driving&units=metric&departure_time=now","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":140,"wires":[["da7424e9.8a5178"]]},{"id":"56133ffe.06f9a","type":"http request","z":"c6f67e7f.de1f9","name":"Travel to work","method":"GET","ret":"txt","paytoqs":false,"url":"https://maps.googleapis.com/maps/api/distancematrix/json?origins=Amsterdam&destinations=Utrecht&key=MAPS-API&mode=driving&units=metric&departure_time=now","tls":"","persist":false,"proxy":"","authType":"","x":360,"y":300,"wires":[["60a398b7.3cacf8"]]},{"id":"f86f2992.6beb98","type":"debug","z":"c6f67e7f.de1f9","name":"","active":false,"console":"false","complete":"false","x":1070,"y":260,"wires":[]},{"id":"f3ab56d5.ec7e68","type":"inject","z":"c6f67e7f.de1f9","name":"Ochtend","repeat":"","crontab":"*/1 6-8 * * 1,2,3,4,5","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":140,"wires":[["674e23b2.e695ac","7a90ff92.0db17","56133ffe.06f9a","dcfb8f9d.b73c4"]]},{"id":"2c35f0a8.1dd58","type":"inject","z":"c6f67e7f.de1f9","name":"Avond","repeat":"","crontab":"*/1 17-18 * * 1,2,3,4,5","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":300,"wires":[["56133ffe.06f9a","7a90ff92.0db17","674e23b2.e695ac","dcfb8f9d.b73c4"]]},{"id":"7a90ff92.0db17","type":"simpletime","z":"c6f67e7f.de1f9","name":"Tijd","mydate":true,"myymd":true,"myyear":true,"mymonth":true,"mymonthn":true,"mydom":true,"mydoy":true,"myday":true,"myhourpm":true,"myhour":true,"mytime":true,"mytimes":true,"myminute":true,"myminutes":true,"mysecond":true,"mymillis":true,"myepoch":true,"myrawdate":true,"mypm":true,"x":330,"y":220,"wires":[["9854f705.215138"]]},{"id":"b7cc0738.117108","type":"ui_template","z":"c6f67e7f.de1f9","group":"daf50d5b.5ef0f","name":"reistijd","order":8,"width":4,"height":1,"format":"<table>\n<tr><td>Reistijd naar werk {{msg.payload.work}}</td></tr>\n<tr><td>Reistijd naar huis {{msg.payload.home}}</td></tr>\n</table>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":1050,"y":220,"wires":[[]]},{"id":"9854f705.215138","type":"ui_text","z":"c6f67e7f.de1f9","group":"daf50d5b.5ef0f","order":9,"width":4,"height":1,"name":"","label":"Laatste update","format":"{{msg.mytime}}","layout":"row-spread","x":560,"y":220,"wires":[]},{"id":"6f2d7cf1.51cee4","type":"comment","z":"c6f67e7f.de1f9","name":"Reistijd bepaling","info":"","x":100,"y":80,"wires":[]},{"id":"2a773de7.4317d2","type":"comment","z":"c6f67e7f.de1f9","name":"Maps met verkeersdruk","info":"","x":120,"y":380,"wires":[]},{"id":"dcfb8f9d.b73c4","type":"ui_template","z":"c6f67e7f.de1f9","group":"daf50d5b.5ef0f","name":"Verkeer","order":7,"width":4,"height":4,"format":"<!DOCTYPE html>\n<html>\n  <head>\n    <meta name=\"viewport\" content=\"initial-scale=1.0, user-scalable=no\">\n    <meta charset=\"utf-8\">\n    <style>\n      /* Always set the map height explicitly to define the size of the div\n       * element that contains the map. */\n      #map {\n        height: 100%;\n      }\n      /* Optional: Makes the sample page fill the window. */\n      html, body {\n        height: 100%;\n        margin: 0;\n        padding: 0;\n      }\n    </style>\n  </head>\n  <body>\n    <div id=\"map\"></div>\n    <script>\n      function initMap() {\n        var map = new google.maps.Map(document.getElementById('map'), {\n          zoom: 7,\n          center: {lat: 51.95000, lng: 5.1030332},\n          disableDefaultUI: true,\n          fullscreenControl: true,\n          mapTypeId: 'hybrid'\n        });\n\n        var trafficLayer = new google.maps.TrafficLayer();\n        trafficLayer.setMap(map);\n      }\n    </script>\n    <script async defer\n    src=\"https://maps.googleapis.com/maps/api/js?key=MAPS-API&callback=initMap\">\n    </script>\n  </body>\n</html>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":340,"y":460,"wires":[[]]},{"id":"64693331.123efc","type":"inject","z":"c6f67e7f.de1f9","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1 hour 58 mins","payloadType":"str","x":540,"y":60,"wires":[["e19909dc.ec11d8"]]},{"id":"7120542a.a2e60c","type":"debug","z":"c6f67e7f.de1f9","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":900,"y":80,"wires":[]},{"id":"daf50d5b.5ef0f","type":"ui_group","name":"Weer + Verkeer","tab":"a74c5fa4.31437","order":3,"disp":true,"width":"4","collapse":false},{"id":"a74c5fa4.31437","type":"ui_tab","name":"Overzicht","icon":"fa-home fa-lg","order":1,"disabled":false,"hidden":false,"info":"<title>Thuis</title>"}]

You will have to make sure you will an api from Google maps and traffic. Replace MAPS-API with your own key.
Also destination and origin should be changed to your preference.

Hello all!

I am fairly new here and think it is a fantastic topic!
I went through everything and took the first steps to create my own dashboard.
I can operate my lights with a slider and a switch. Something simple that I can’t figure out … I would like to operate a lamp with a button, so turn the lamp on and off with 1 button. Preferably also that the color of the button changes. Does anyone have a tutorial or code for me?

1 Like

Don’t forget to post pictures :wink:

Please help me, I’m een noob and starter with Node red. Sorry for that!

I have followed the manual at the start but i can’t figure it out.

I have the following problems:

Where can I find the “good” Topic ?
Now i work with: homie/homey-topic/Betton-lamp/onoff/set
(see picture)

It says that it is connected, but when I switch to my dashboard and switch the light button NOTHING HAPPENS… What do i do wrong ?

And is this the right/easiest solution or is there a better option? I have also find this one: node-red-contrib-homie-convention

1 Like

I have also tried this option.
But this does not help.

Have decided to use the Ipad Air2 for the Dashboard anyway.

Currently programming an ESP32 with Arduino IDE.
To be able to lock and unlock the iPad.
But without some knowledge of Arduino and programming, this is not easy.

Maybe you could write a step-by-step plan in the other topic for dummies ?
Ha ha!
Think you help me and others a lot with that.

Peter

After a few days it was finally possible to program the ESP32.

Works super well, soon attach the iPad to the wall in the living room with a nice wall holder.

Super made Satoer !!

Hoi Joost,

Dank voor de code!

Ik heb deze net geïmporteerd, en krijg helaas een foutmelding, zie bijlage. Moet er nog een javascript node geinstalleerd worden in Node-RED?

Alvast ontzettend bedankt voor je hulp.

Mvg,
Khoi

nu met bijlage.

Het is me toch gelukt, ik moest een betaalde versie kiezen van Google…

Bedankt voor alles!

Hi, to figure out which topics exist on your Homey, use an MQTT explorer tool, like:

1 Like

@Khoi_Ho_Si would it be possible to share your entire code/config for your spotify solution?

i have a Unraid server. Is it possible to install the broker on it? i see smarthings broker etc, but nothing for homey

of course, i need to change a few things and will send it to you when ready.

Can somebody please explain me what this means?

“Inside this backend you can past node code snippets”

I have used the code on this page:
https://flows.nodered.org/flow/1727790dfc3f6bac8c5b39f5a952b804


spotify dashboad player/controller (flow) - Node-RED
spotify dashboad player/controller. This is my first flow published, feel free to comment on it. Due to some limitations at my current workplace, it is possible to listen to Spotify only on my phone.
flows.nodered.org
|

  • |

All i changed was adding my own API

1 Like

You can export (multiple) nodes to Json. (Json is a type of code formatting). These codes can be shared. So you can also import these exported Json Nodes:
afbeelding
If you paste the JSON code inside here.

This way you can use pre-made node constructions made by others. Like the examples.

First of all: I’m a newbee with MQTT, so don’t shoot me when i do or ask the things not in the correct way :sweat_smile: (i’m learning).

My situation:
I have a Synology NAS with Node-Red installed (in Docker). I played a little bit around with the “Buienradar” and it is working OK. So far so good.
I installed, in Node-Red, node-red-contrib-mqtt-broker (I noticed, Node-Red is using port 1880 instead of 1883).
To see if everything is working ok, i installed MQTT Explorer (also port 1880 selected) on my laptop. I cannot connect to node-red-contrib-mqtt-broker. MQTT Explorer tells me , the client is offline.
Switched off the NAS firewall to see if the firewall is blocking ports, but no result.

As test I removed the node-red-contrib-mqtt-broker from Node-Red and installed MQTT Client, Hub and Broker on my Homey. Configured them as mentioned in the app’s.
And i can connect directly without any problem.
MQTT1

Now my questions:
1 - Any idea what can be wrong with connecting to the NAS? Frontend an Backend are reachable via HTTP port 1880
2 - The log from MQTT Hub (on my Homey) is full with the error “Error Publishing message”, every three seconds one or two messages. What does this error message mean?

Did you adjust the docker of nodered to allow the 1880 port to outside? Normally you use the docker bridge as network and need to add the additional port forwarding.

I have installed mosquitto also as docker, so that on the homey I dont need the broker.

In case of errors in the hub, then it could be a permissions problem.

On my synology i have nodered, influxdb, mqtt and grafana as dockers running.

I was assuming these ports were open

.