Closed ArtichautDev closed 2 years ago
and what is callback in the readme.md please
The signature of the setColor
method is setColor(red, green, blue, ?callback)
so you need to provide all 3 values.
Also you don't seem to set the variable green
in your code before using it so of course it is going to be undefined.
Here is a minimal example that turns the light on and then sets the color to 100% green:
const { Control } = require('magic-home');
const light = new Control("192.168.1.100");
light.setPower(true).then(() => {
const red = 0;
const green = 255;
const blue = 0;
return light.setColor(red, green, blue);
}).then(() => {
console.log("success");
}).catch(err => {
console.log(`An error occured: ${err}`);
});
Also this question really belongs into the Discussions and not the Issues, since the issue is clearly within your own code. If you have general questions, please open a discussion instead of an issue - that's what they are for after all.
C:\Users\pierr\Documents\Chroma\commands\core\ping.js:29 light.setColor(green) ^
ReferenceError: green is not defined at C:\Users\pierr\Documents\Chroma\commands\core\ping.js:29:28
my code : let light = new Control("192.168.0.103"); light.setPower(true).then(success => { light.setColor(green) });