node-shellies icon indicating copy to clipboard operation
node-shellies copied to clipboard

Report RGB as one entity

Open jghaanstra opened this issue 4 years ago • 3 comments

Nice library. Will probably be using this to integrate Shelly devices with the Homey domotica controller. I have a request though.

Currently the Shelly RGBW2 and Shelly Bulb report color changes with individual reports for each R, G and B values. Is it possible to receive only one status change when the color changes containing all values for red, green and blue channel at once?

jghaanstra avatar Sep 09 '20 10:09 jghaanstra

That can be achieved using something like this:

device.on('change:red', changeHandler)
device.on('change:green', changeHandler)
device.on('change:blue', changeHandler)

let timeout = null

const changeHandler = () => {
  if (timeout !== null) {
    return
  }

  timeout = setTimeout(() => {
    console.log(device.red, device.green, device.blue)
    timeout = null
  }, 0)
}

alexryd avatar Sep 09 '20 18:09 alexryd

Yeah, I already have something similar in place but just thought it would make more sense to report the RGB color as one entity. Feel free to close it though.

jghaanstra avatar Sep 09 '20 19:09 jghaanstra

Yeah it might, I'll look in to it.

alexryd avatar Sep 11 '20 03:09 alexryd