zwave-js / zwave-js-ui

Full featured Z-Wave Control Panel UI and MQTT gateway. Built using Nodejs, and Vue/Vuetify
https://zwave-js.github.io/zwave-js-ui
MIT License
969 stars 204 forks source link

[feat] RGBWWCW support #381

Closed DanielWinks closed 3 years ago

DanielWinks commented 3 years ago

Is your feature request related to a problem? Please describe.

There doesn't seem to be a way to set (or read) the color temp for RGBWWCW bulbs when using Home Assistant. In the control panel, I see a place where I can set the 0-255 WW color and the 0-255 CW color. This lets me manually set it to any combination I want, but only from the admin panel. In Home Assistant, it expects that white value is a single MQTT topic. There's no way to configure an MQTT light in HA that uses separate MQTT topics for WW and CW.

In Zwave2MQTT it was set with a HEX string, with the first 3 numbers all 00, with a template like: "{{ '#%02x%02x%02x%02x%02x' | format(0, 0, 0, (0.7349 * ((value|int) - 153)) | round(0), 255 - (0.7349 * ((value|int) - 153)) | round(0))}}"

In the new zwavejs, there's a spot where I can submit a RRGGBB number, but nowhere I can submit an RRGGBBWWCW like Zwave2MQTT allowed.

This mean is I can't create an MQTT light in Home Assistant that allows me to control the white temps.

Describe the solution you'd like Add a hexWhite topic to accompany the new hexColor. This would be better than what existed in zwave2MQTT, since the templates for MQTT in HASS would be simpler:

{{'%02x%02x%02x' | format(red, green, blue)}} and "{{ '%02x%02x' | format((0.7349 * ((value|int) - 153)) | round(0), 255 - (0.7349 * ((value|int) - 153)) | round(0))}}"

instead of what existed in zwave2mqtt (where you needed to pass in #000000 in front of your WWCW value.

Describe alternatives you've considered Add a full hex topic like zwave2mqtt has.

robertsLando commented 3 years ago

@AlCalzone needs a new property along with the hexColor?

AlCalzone commented 3 years ago

Imo this rather sounds like a workaround for a HA shortcoming which should be addressed there. I've asked the HA devs, let's wait for their response.

marcelveldt commented 3 years ago

I believe he's talking about MQTT to HA and not the new Zwave JS integration in HA. In the integration we combine all values into RGB-CT/RGBWWCT

AlCalzone commented 3 years ago

alternate solution as discussed on Discord: https://github.com/zwave-js/node-zwave-js/issues/1526 That's better than hacking hex strings together IMO

marcelveldt commented 3 years ago

Great, both the HA integration as others (like MQTT) can benefit from that.

robertsLando commented 3 years ago

Yep I think that would be the best solution

DanielWinks commented 3 years ago

Hi, I took a look over at zwave-js/node-zwave-js#1526

There's not a lot of info there as to what that will change, so I just want to make sure I've covered the issue I'm running into properly.

This isn't with the zwave-js addon. I'm using zwavejs2mqtt. The problem here is that under "Color Switch" for my Inovelli Ilumin RGBWWCW bulbs, I have a bunch of settings (which are also MQTT topics). There's one for R, G, and B, both to set a target value and get the current value. There's also a hexColor (which doesn't have any description under it, like all the other settings, btw). There's a topic/setting for warm white and a separate setting for cold white.

The issue is that HASS doesn't have any facility available in their MQTT Light for having "white temperature" set using 2 topics. They expect a single topic. Previously on zwave2mqtt there was a combined hex topic where you could send #RRGGBB0000 and set an RGB or send #000000WWCW to set a white value.

Seeing as this is technically a limitation of HASS, we could address it there, but that would likely cause a breaking change for lots of people. Or we could address it here by providing either a zwave2mqtt-like combined RRGGBBWWCW hex OR a separate 'hexWhite' which only does WWCW (or both).

Also, the way the "currentColor" is sent to MQTT is a bit weird. On the admin page, there's a bunch of values displayed, such as 17-51-0-currentColor-0, 17-51-0-currentColor-1, and so on. In MQTT these are NOT sent as 0,1,2,3. Instead 17-51-0-currentColor-0 ends up being the value attached to currentColor and all the sub topics start at 1. Ideally there would be the topic currentColor with no value and then you'd have currentColor\0, currentColor\1, currentColor\2 etc. Seems a bit inconsistent to put 17-51-0-currentColor-0 as the value for currentColor and the rest as sub topics, it almost feels as if there's a missing \ somewhere in the code.

And since I'm on the topic of MQTT and HASS.... what's the chances of maybe getting a JSON compatible topic added? Where you could send a JSON object for multiple settings at once, that's compatible with HASS?

AlCalzone commented 3 years ago

The issue is that HASS doesn't have any facility available in their MQTT Light for having "white temperature" set using 2 topics

That won't be necessary - the issue is about adding a combined value that accepts a JSON object with all the colors that should be updated at once. So you would send a single command to set RGB or WWCW or RGBWWCW or Cyan,Amber,CW or whatever your light supports. The devs I've talked to are on board with this, so I expect no breaking changes.

Except if you're setting these weird values manually, which seem like a workaround for OZW shortcomings.

Seems a bit inconsistent to put 17-51-0-currentColor-0 as the value for currentColor and the rest as sub topics

That's weird... @robertsLando did you do if (propertyKey) instead of if (propertyKey != undefined) somewhere?

DanielWinks commented 3 years ago

That's weird...

Yeah, I thought so too. It looks super weird in MQTT Explorer, if you look at my screencap, and it makes it awkward to use.

That won't be necessary - the issue is about adding a combined value that accepts a JSON object with all the colors that should be updated at once.

So I will be able to just craft up a template in my HASS MQTT config to generate a JSON object for setting the white values? What about getting their state? That's an issue too, as HASS expects a single topic for "white value" for both the command and state topics?

Also, possibly of note, is that I use zwavejs2mqtt in "Just value" as the payload type in the gateway options (because that's the only thing that works with MQTT Device Triggers in HASS). Not sure if that has impact on the above JSON object changes.

AlCalzone commented 3 years ago

I don't know anything about the MQTT internals - I just work with the values zjs2m gives me. The combined value will work like any other value - you can read and write it. It is just an object instead of a primitive.

DanielWinks commented 3 years ago

Cool, I'll keep an eye out for when that change makes it to something I can try.

AlCalzone commented 3 years ago

https://github.com/zwave-js/node-zwave-js/pull/1782 for anyone who wants to try

robertsLando commented 3 years ago

Fixed by #568