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

multiZoneSetColorZones() does not support CSS (as per LifxLanColor) #11

Closed
paolotremadio opened this issue Aug 5, 2018 · 9 comments
Closed

Comments

@paolotremadio
Copy link

paolotremadio commented Aug 5, 2018

Hi,

I've been trying to use the multiZoneSetColorZones() that should accept as color the class LifxLanColor.

It looks like the color property is not transformed properly as it only accepts LifxLanColorHSB objects. I've been trying to use LifxLanColorCSS without success.

Example:

device.multiZoneSetColorZones({
     start    : 0,
     end      : 8,
     color    :  { css: "#ff0000" },
     duration : 0,
     apply    : 1
   })

Error:

(node:61955) UnhandledPromiseRejectionWarning: Error: The `color.hue` is required.
    at LifxLanComposer._checkColorValues (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-composer.js:414:12)
    at LifxLanComposer._composePayload501 (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-composer.js:652:29)
    at LifxLanComposer._composePayload (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-composer.js:135:15)
    at LifxLanComposer.compose (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-composer.js:44:33)
    at Promise (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:131:26)
    at new Promise (<anonymous>)
    at LifxLanUdp._requestUnicast (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:118:16)
    at Promise (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:107:9)
    at new Promise (<anonymous>)
    at LifxLanUdp.request (/Users/paolo/Downloads/node-lifx-lan-master/node_modules/node-lifx-lan/lib/lifx-lan-udp.js:92:16)
@futomi
Copy link
Owner

futomi commented Aug 6, 2018

Thank you for your feedback.

The multiZoneSetColorZones() method did not accept a LifxLanColor object for the color parameter even though this document says the method does. The method accepted only a LifxLanColorHSB object.

I updated this module. Now the method accepts a LifxLanColor object for the parameter. That is, the method accepts not only a LifxLanColorHSB object but also a LifxLanColorRGB, LifxLanColorXyb, and LifxLanColorCSS object.

Try the latest version.

@paolotremadio
Copy link
Author

It works! One last thing: is there an option to override the brightness of a colour?
Otherwise: how do you set the brightness of a multi-zone strip?

@futomi
Copy link
Owner

futomi commented Aug 6, 2018

One last thing: is there an option to override the brightness of a colour?

RGB intrinsically includes the factor of brightness. CSS color based on RGB also does.
Each level in RGB is relevant to brightness. For example, #110000 is dark red, #ff0000 is bright red.
As long as you use RGB or CSS color, you can not specify brightness independently.

Otherwise: how do you set the brightness of a multi-zone strip?

If you want to specify brightness independently, you should use HSB color.

@paolotremadio
Copy link
Author

paolotremadio commented Aug 7, 2018

That’s what I was thinking. Any chance to module exports the lifx-lan-color.js library? Or to access it using the public api of the package as is.. so I don’t have to implement my own RGB-HSB converter

@futomi
Copy link
Owner

futomi commented Aug 7, 2018

Let me ask same questions:

  • What is the lifx-lab-colors library?
  • Does it accept brightness with RGB?
  • If so, how does it calculate HSB from RGB + brightness? Is the formula open?

I have an idea to calculate HSB from RGB + brightness. But I'm not sure that my idea is compatible with the lifx-lab-colors library.

@paolotremadio
Copy link
Author

Sorry, that was a typo. I meant: I'd like to use your lifx-lan-color.js package to convert RGB to HSB and override the brightness after the conversion has been calculated. Is that file exported or its API accessible using the main package?

@futomi
Copy link
Owner

futomi commented Aug 7, 2018

Oh, lifx-lan-color.js is my my own. I thought it is LIFX official SDK or something. Sorry not to noticed that. I'll try to implement your request. Give me some time.

@futomi
Copy link
Owner

futomi commented Aug 8, 2018

I added the brightness parameter to the LifxLanColorCSS and LifxLanColorRGB object. Try the latest version.

Thank you.

@paolotremadio
Copy link
Author

It works, thanks!

Here's how I'm using your package: https://github.com/paolotremadio/homebridge-automation-lifx-colour-palettes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants