Set up colorpicker for mqtt device

  • Platform information:
    • Hardware: Raspberry Pi 4
    • openHAB version: 3.4.0

Hello together,

as I´m out of ideas after trying for hours i want to ask for help.

Im setting up a Tint Aris LED Panel. I use zigbee2mqtt to connect all my devices. On/Off and Brightness are already working fine but i stuck with the colors.

The panel supports color xy, rgb and hex. As i learned a colorpicker works with HSB. When i manually send a payload

{"color":{"r":255,"g":0,"b":0}}

to the panel with Mqtt.fx im able to change the color but im not able to set this up in my configuration.

There a lot of informations about HSB to RGB but i dont understand how to put these informations together to get the payload i need. Any ideas?

I tried a lot, this is my latest setup:

Items:

Switch                     LivingRoomMainLight            "Hauptlicht"                      <lightbulb>    (gLight,eLightLivingroom)            ["Light","Switch"]    {channel="mqtt:topic:livingroom:main_light"}
Dimmer                     LivingRoomMainBrightness       "Helligkeit Hauptlicht [%s]"      <lightbulb>    (eLightLivingroom)                   ["Light"]             {channel="mqtt:topic:livingroom:main_light_brightness", ga="Light", synonyms="Hauptlicht", roomHint="Wohnzimmer"}
Color                      LivingRoomMainLightColor       "Farbe"                           <lightbulb>    (eLightLivingroom)                   ["Light"]             {channel="mqtt:topic:livingroom:main_light_color2", ga="Light", synonyms="Hauptlicht Farbe", roomHint="Wohnzimmer"}

Things:

Thing  mqtt:topic:livingroom "MQTT Living Room" (mqtt:broker:Zigbee2Mqtt) {
    Channels:
//mueller licht
        Type switch : main_light    "Hauptlicht"    [ stateTopic="zigbee2mqtt/LivingRoomMain/state", commandTopic="zigbee2mqtt/LivingRoomMain/set", on="ON", off="OFF"] 
        Type dimmer : main_light_brightness "Hauptlicht Helligkeit" [ stateTopic="zigbee2mqtt/LivingRoomMain", transformationPatternOut="JS:openhabdimmer2zigbeebridge.js", transformationPattern="JS:tradfri2openhab.js" ,commandTopic="zigbee2mqtt/LivingRoomMain/set", min=0, max=100, step=1]
        Type color : main_light_color2   "Hauptlicht Farbe" [ stateTopic="zigbee2mqtt/LivingRoomMain", commandTopic="zigbee2mqtt/LivingRoomMain/set", transformationPattern="JSONPATH:$.color", colorMode="RGB", formatBeforePublish="{\"color\":{\"r\":255,\"g\":0,\"b\":0}}"] //
        Type string : main_light_effect "Hauptlicht Effekt" [ stateTopic="zigbee2mqtt/LivingRoomMain", commandTopic="zigbee2mqtt/LivingRoomMain/set", transformationPattern="JSONPATH:$.effect" ]
}

Sitemap:

Colorpicker item=LivingRoomMainLightColor label="Farbe" icon="colorwheel"

Actual error message within zigbee2mqtt:

2023-02-04 08:57:59</small>`Publish 'set' 'color' to 'LivingRoomMain' failed: 'Error: Value does not contain valid color definition'`

Default pattern for formatBeforePublish for RGB: "%1$d,%2$d,%3$d"
"{\"color\":{\"r\":%1$d,\"g\":%2$d,\"b\":%3$d}}" might work.

1 Like

good hint. i guess i had kinda double color attribut in my transformation.

This one is working:

Item:

Color                      LivingRoomMainLightColor       "Farbe"                           <lightbulb>    (eLightLivingroom)                   ["Light"]             {channel="mqtt:topic:livingroom:main_light_color", ga="Light", synonyms="Hauptlicht Farbe", roomHint="Wohnzimmer"}

Thing:

Type color : main_light_color   "Hauptlicht Farbe" [ stateTopic="zigbee2mqtt/LivingRoomMain/color", commandTopic="zigbee2mqtt/LivingRoomMain/set", colorMode="RGB", formatBeforePublish="{\"color\":{\"r\":%1$d,\"g\":%2$d,\"b\":%3$d}}"]