Difference between revisions of "Node-red"

From Simon's Help System
Jump to navigation Jump to search
Line 55: Line 55:
[[File:Node-red2.png|center]]
[[File:Node-red2.png|center]]


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
Same for influxdb.  Create a new API Token in Chronograph.  Copy it to Notepad++.   
[[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 teh server name ([v2.0]http://localhost:8086 ) and add the token.

Revision as of 15:41, 15 January 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

DBCG5AO.png
[{"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":[[]]}]
Node-red5.png

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.

Node-red3.png

Then create a new long lived access token. Copy the token into notepad++ as it will dissapear from view after creatioon.

Node-red4.png

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.

Node-red1.png

Then click on the pencil to the right of server Home assistant

Then enter the URL and new token into the dialogue box.

Node-red2.png

Same for influxdb. Create a new API Token in Chronograph. Copy it to Notepad++.

Node-red6.png

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 teh server name ([v2.0]http://localhost:8086 ) and add the token.