Difference between revisions of "Node-red"
(One intermediate revision by the same user not shown) | |||
Line 57: | Line 57: | ||
Same for influxdb. Create a new API Token in Chronograph. Copy it to Notepad++. | Same for influxdb. Create a new API Token in Chronograph. Copy it to Notepad++. | ||
[[File:Node-red6.png|center]] | [[File:Node-red6.png|center]] | ||
Then enter the new token into any of the influxdb links in node-red by clicking on an influxdb link, clicking on the pencil to the right of | Then enter the new token into any of the influxdb links in node-red by clicking on an influxdb link, clicking on the pencil to the right of the server name ([v2.0]http://localhost:8086 ) and add the token. | ||
[[File:ttn1.png|center]] | |||
Create a new token in TTN console and then copy the token to go with the username smbunn@ttn in the node-red setup |
Latest revision as of 14:36, 23 February 2024
Node Red
Backup all flows using 'export' and save as a file (flows.json)
If you have to remove any old versions of node-red
sudo systemctl disable nodered.service sudo npm -g remove node-red rm -R ~/.node-red
Update node
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash - sudo apt-get install -y nodejs
Then to update node-red go to https://nodered.org/docs/getting-started/raspberrypi
and run the bash script
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) node-red-start
If all good stop it and restart as a service with
node-red-stop sudo systemctl enable nodered.service sudo systemctl status nodered.service
Examples of node-red for Home Assistant
[{"id":"66c50c00.a3c8c4","type":"inject","z":"74ddc16c.19655","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":112,"y":1056,"wires":[["87111b5d.423eb8"]]},{"id":"87111b5d.423eb8","type":"ha-get-entities","z":"74ddc16c.19655","server":"351c96ee.9dc3aa","name":"","rules":[{"property":"entity_id","logic":"starts_with","value":"light.","valueType":"str"}],"output_type":"random","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":262,"y":1056,"wires":[["f1234263.eed69"]]},{"id":"541ec87b.02a788","type":"delay","z":"74ddc16c.19655","name":"","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"20","randomLast":"30","randomUnits":"minutes","drop":false,"x":592,"y":1056,"wires":[["5cec6ee6.cfa5a"]]},{"id":"f1234263.eed69","type":"api-call-service","z":"74ddc16c.19655","name":"Turn on Light","server":"351c96ee.9dc3aa","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"{{payload.entity_id}}\"}","render_data":true,"mergecontext":"","output_location":"","output_location_type":"none","x":422,"y":1056,"wires":[["541ec87b.02a788"]]},{"id":"5cec6ee6.cfa5a","type":"api-call-service","z":"74ddc16c.19655","name":"Turn off Light","server":"351c96ee.9dc3aa","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"{{payload.entity_id}}\"}","render_data":true,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":758,"y":1056,"wires":[[]]}]
If the token expires Node-Red will stop talking to Home Assistant. You need to create a new token. First click on my photo icon at the bottom left of the HA page.
Then create a new long lived access token. Copy the token into notepad++ as it will dissapear from view after creatioon.
Next go into node-red and click on any home assistant link, you only need to do this once. Click on the blue connector. This open the main dialogue.
Then click on the pencil to the right of server Home assistant
Then enter the URL and new token into the dialogue box.
Same for influxdb. Create a new API Token in Chronograph. Copy it to Notepad++.
Then enter the new token into any of the influxdb links in node-red by clicking on an influxdb link, clicking on the pencil to the right of the server name ([v2.0]http://localhost:8086 ) and add the token.
Create a new token in TTN console and then copy the token to go with the username smbunn@ttn in the node-red setup