sudo npm install -g --unsafe-perm node-red
sudo systemctl restart nodered
sudo journalctl -f -u node-red
Per generare messaggi nel log da node-red:
node.log("Something happened");
node.warn("Something happened you should know about");
node.error("Oh no, something bad happened");
// initialise the counter to 0 if it doesn't exist already
var count = context.get('count')||0;
count += 1;
// store the value back
context.set('count',count);
// make it part of the outgoing msg object
msg.count = count;
Scope types:
Ref: https://nodered.org/docs/writing-functions
node.status({fill:"red",shape:"ring",text:"disconnected"});
node.status({fill:"green",shape:"dot",text:"connected"});
node.status({text:"Just text status"});
node.status({}); // to clear the status
<script>
var theScope = scope;
$("#splash_layer").on("click", function(){
theScope.send({payload: 'click'});
});
</script>
<script>
(function(scope) {
scope.$watch('msg.payload', function(data) {
$("#message_line").html(data);
setTimeout(function(){
$("#message_line").html("timeout");
}, 3000);
});
})(scope);
</script>
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g --unsafe-perm node-red
Type at command line prompt:
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
Enable the systemd service by typing:
sudo systemctl enable nodered.service
Then start it:
sudo systemctl start nodered.service
Install git by typing:
sudo apt-get update
sudo apt-get install git
Enable the project feature editing the file setting.js:
sudo nano .node-red/settings.js
Add these lines inside the module.exports session:
module.exports = {
editorTheme: {
projects: {
enabled: true
}
},
...
Restart NodeRED:
sudo systemctl restart nodered.service
Check for any errors at NodeRED startup:
sudo journalctl -f -u nodered -o cat
Install node-red-admin
sudo npm install -g node-red-admin
Create a password hash by typing:
node-red-admin hash-pw
Add these lines in .node-red/settings.js inside the module.exports session:
module.exports = {
adminAuth: {
type: "credentials",
users: [{
username: "admin",
password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
permissions: "*"
}]
},
Restart NodeRED:
sudo systemctl restart nodered.service
Check for any errors at NodeRED startup:
sudo journalctl -f -u node-red -o cat
Installare il nodo:
Quindi crearsi un account nel sito https://alexa-node-red.bm.hardill.me.uk/docs
2018 Ⓒ TanzoLab