avea_bulb icon indicating copy to clipboard operation
avea_bulb copied to clipboard

Turning Power On and Off

Open miliante opened this issue 8 years ago • 1 comments

Is there any way to turn it on and off?

Additionally, I am converting the values from Brightness, Saturation and Hue to RGB, but I am not quite getting the same colors. Perhaps the White value is missing?

miliante avatar Apr 13 '16 13:04 miliante

just in case somebody is looking for the turn on / off.

add this methods in lib/avea.js:

class Avea {
    constructor(peripheral) {
        // ...
    }

    // ... 
    turnOn() {
        const buffer = new Buffer([
            // |some numbers       |white 8     | red  3     |green 2     | blue 1|
            53,  244, 1, 10, 0,     255, 143,     0, 48,      0, 32,         0, 16 // White 1 - warm
            // 53,  244, 1, 10, 0,     255, 143,     0, 48,      0, 32,         0, 31 // White 2 - cold
        ])
        this._write(new Buffer(buffer)).then((response) => {
            console.log("---> on")
        });
    }
    
    
    turnOff() {
        const buffer = new Buffer([
            53, 244,    1,  10, 0,  0,  128,    0,  48, 0,  32, 0,  16
        ])
        this._write(new Buffer(buffer)).then((response) => {
            console.log("---> off")
        });
    }
   
   // ... 
}

alternative you can turn it on, by just simply set the color of th bulb:

bulb.setColor(new avea.Color(0xaaa, 0xFFF, 0x000, 0x000), 0x000)

Vanillabacke avatar Jan 11 '23 13:01 Vanillabacke