Nodered

From Braindump
Jump to navigation Jump to search

Service

Alpine OpenRC Service script

/etc/init.d/nodered

cd /usr/local/lib/node_modules/node-red

sudo npm install -g --unsafe-perm node-red

influxdb

127.0.0.1:8086

chronograph

http://127.0.0.1:8888/sources/1/dashboards/2?refresh=Paused&lower=now%28%29%20-%2024h

nodered

git clone https://github.com/node-red/node-red.git
cd node-red
cat packages.json
npm install
npm run build
npm start

npm install node-red-contrib-castv2

localhost:1880

NPM Update fails

https://github.com/npm/cli/issues/3257

The root cause for many is a connection problem, due to wifi failure, ipv6 enabled, but no routing, dns failure, http proxy or tls certificate checking failure.

npm set strict-ssl false
npm config delete proxy
.npmrc
yarn.lock
node --dns-result-order=ipv4first /usr/bin/npm


Manage Palette

node-red-contrib-castv2 4.2.2
node-red-contrib-googlehome-actions-v2 0.0.7
node-red-contrib-huemagic-fork 4.2.5
node-red-contrib-influxdb 0.6.1

https://flows.nodered.org/node/node-red-contrib-googlehome-actions-v2

https://actions-on-google.github.io/actions-on-google-nodejs/2.12.0/index.html

Nodered Temperature.png

Capture temperature from HUE function

On Message

var temperatur = msg.payload.celsius;
msg.payload = {}
msg.payload.temp = temperatur;
return msg;

When movement is detected, turn on the light and make it red

On Message

var moved = msg.payload.motion;
msg.payload = {}
if (moved) {
    msg.payload.on = true;
    msg.payload.color = "red";
} else {
    msg.payload.on = true;
    msg.payload.color = "green";
}
return msg;

After 20:00 or before 1:00 at night use a long press to turn off all lights

On Message

var pressed = msg.payload.button;
msg.payload = {}
var date = new Date();
var hour = date.getHours(); 

if (hour > 20 || hour < 1) {
    msg.payload.on = false;
    return msg;
}
msg.topic
 {"app":"DefaultMediaReceiver","type":"MEDIA","media":{"url":"https: //icecast-qmusicnl-cdp.triple-it.nl/Qmusic_nl_nonstop_high.aac","streamType":"LIVE"}}

{"app":"DefaultMediaReceiver","type":"TTS","text":"Zei je nou dat ik een klootzak ben?","speed":1,"language":"nl","metadata":{"title":"Pappa talks"}}