Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report RGB as one entity #9

Open
jghaanstra opened this issue Sep 9, 2020 · 3 comments
Open

Report RGB as one entity #9

jghaanstra opened this issue Sep 9, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@jghaanstra
Copy link
Contributor

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?

@alexryd
Copy link
Owner

alexryd commented Sep 9, 2020

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)
}

@jghaanstra
Copy link
Contributor Author

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.

@alexryd
Copy link
Owner

alexryd commented Sep 11, 2020

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

@alexryd alexryd added the enhancement New feature or request label Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants