Closed hans-peter123 closed 9 years ago
That's not a HAP but a nodeJS question. Dr. Google shows up with http://www.dzone.com/snippets/execute-unix-command-nodejs for example.
Oh, thanks for that. Now it works with: "/home/pi/milight_sources/./milight OFF" But when I hit On (in the MyTouchHome app), by both positions the OFF command is send. How van I use the value variable to control this?
By the way, I use this code:
cType: types.POWER_STATE_CTYPE,
onUpdate: function(value) {
var cmd = "/home/pi/milight_sources/./milight OFF"
exec(cmd, function(error, stdout, stderr) {
// command output is in stdout
});
},
Here is the OFF command hardcoded...
I also tried this:
var cmd = "/home/pi/milight_sources/./milight " + value;
But it doesn't work :(
what about:
var cmd = "/home/pi/milight_sources/./milight";
var cmdOn = cmd + " ON";
var cmdOff = cmd + " OFF";
if (value) {
// now we now it's "true-ish" (True, >0, a string not empty, whatever javascript likes as true)
exec(cmdOn, function(error, stdout, stderr) {
// command output is in stdout
});
} else {
// now we now it's "false-ish" (undefined, false, 0, an empty string ... etc)
exec(cmdOff, function(error, stdout, stderr) {
// command output is in stdout
});
};
But really: have a look at javascript documentation, otherwise you are going to have a really hard time configuring your devices!
Woh, thanks for that. It works!! :)
Hello, I search after a accessory.js file, who execute own bash commands!? Does anyone have a solution? I want to control my milight controller. With bash, for example, this works how follow: "/home/pi/milight_sources/./milight 1 b 19" Thanks for helping