Hello,
I’m an openHAB user for over 5 years from now, but I still don’t get the Color Items working with Zigbee2MQTT. I spend so many days in researching, trying, scripting and failing. It’s so frustrating.
Can someone help me on this?
I’m using openHAB 3 with the MQTT binding.
All devices in my home are working with zigbee and are connected with Zigbee2MQTT.
I have devices from LIDL, Tuya, IKEA and so on.
I can control all the devices with openHAB except the Color.
What I learned:
- There are different ways to define color (color spaces, CIE 1931 xyz, RGB, HSV/HSB)
- openHAB provides an Item of the type Color.
- A color picker in the UI only works with an Color Item.
- In the mqtt binding there is also an Item of the type Color.
- If I select a Color (e.g. red) in the color picker the Item gets updated with the matching HSV/HSB value e.g. 0,100,100 (H,S,B) and the MQTT binding sends it to the configured MQTT topic “zigbee2mqtt/bulb1/set”.
- Zigbee2MQTT supports different vendors of color light bulbs.
- Different vendors use different ways to define color (IKEA & LIDL: xy or RGB)
- Zigbee2MQTT needs a specific formatted MQTT message and a matching Color definition to work with the Color Items. e.g. {“color”: {“rgb”: “R,G,B”}} or {“color”: {“x”: X_VALUE, “y”: Y_VALUE}}
- To do this, I have to write a transformationPatternOut in the MQTT Thing to convert HSV/HSB to RGB (I did not find a conversion for xy)
- Now I can set the color with the Color picker in openHAB and the bulb turns to the right Color.
- But I get a warning on console, because Zigbee2MQTT sends an “answer” to the MQTT topic of the state of the bulb “zigbee2mqtt/bulb1” with converted xy values {“color”:{“x”:0.6307692307692307,“y”:0.3230769230769231}}.
- openHAB does not understand the value of the data, I would need to add an additional transformationPattern in the MQTT Thing to convert it back to HSV (I did not find a conversion for this)
This is very complex.
Is there an easier way to to this?
Is there a way to get the openHAB Color picker working with Zigbee2MQTT?
Thank you for your help, I really appreciate it!