Add @cheerlights colour handling to LEDBorg node for Pi...

(just because)
This commit is contained in:
Dave C-J 2014-01-07 16:00:55 +00:00
parent 914885dd6b
commit 0e955ea120
1 changed files with 13 additions and 1 deletions

View File

@ -45,7 +45,19 @@ function LedBorgNode(n) {
});
}
else {
node.warn("Invalid LedBorg colour code");
// you can add fancy colours by name here if you want...
// these are the @cheerlight ones.
var colors = {"red":"200","green":"020","blue":"002","cyan":"022","white":"222","pink":"201",
"warmwhite":"221","purple":"101","magenta":"202","yellow":"220","orange":"210","black":"000"}
if (msg.payload.toLowerCase() in colors) {
var c = colors[msg.payload.toLowerCase()];
fs.writeFile('/dev/ledborg', c, function (err) {
if (err) node.warn(msg.payload+" : No LedBorg found");
});
}
else {
node.warn("Invalid LedBorg colour code");
}
}
});
}