I know this is an old thread, but I found a working solution to the above problem.
First thing to note
- I’m using OpeHAB 5.2, Mosquitto and Zigbee2MQTT; similar to above.
- Zigbee2MQTT is set to oputput = attribute
If you use Zigbee2MQTT (Z2M) with the global configuration option set to output: attribute (instead of standard JSON), integrating Tuya-based RGB bulbs like the Lidl / Livarno Lux (HG06106) into openHAB text-based .things files can be painful.
Because attribute mode flattens everything into individual text sub-topics (like color-x, color-y, and brightness), openHAB’s native Color channel will throw exceptions, or get completely stuck on a single hardware boundary color (usually solid blue or solid green) if you try to map the incoming state topic directly.
After a lot of trial and error, here is the bulletproof, dual-channel configuration that splits the read/write logic to allow the openHAB UI color wheel and brightness sliders to work flawlessly without snapping back to zero.
Why this works:
- Write-Only Color: We completely strip the
stateTopicfrom the color channel to prevent openHAB from choking on rawcolor-xdecimal updates. - Bundled HSB Payload: We use
colorMode="HSB"to tap into openHAB’s native token arrays (%1$d,%2$d,%3$d). This forces openHAB to publish all three properties simultaneously to Z2M’s base/settopic, preventing the saturation slider from snapping back to zero. - Read/Write Brightness: A separate dimmer channel handles the actual incoming state feedback safely.
The .things File Configuration
Place this inside your existing MQTT broker bridge block. Remember to replace Lidl_HG06106C_1 with your exact friendly name from Zigbee2MQTT.
Thing topic Lidl_HG06106C_1 "Z2M Lidl_HG06106C_1"{
Channels:
Type switch : power "Lidl_HG06106C_1 ON OFF Switch" [stateTopic="zigbee2mqtt/Lidl_HG06106C_1/state", commandTopic="zigbee2mqtt/Lidl_HG06106C_1/set", on="ON", off="OFF"]
// WRITE-ONLY COLOR: No stateTopic to prevent decimal parsing crashes
Type color : color "Color Control" [
commandTopic="zigbee2mqtt/Lidl_HG06106C_1/set",
colorMode="HSB",
formatBeforePublish="{\"color\":{\"hue\":%1$d,\"saturation\":%2$d},\"brightness\":%3$d}"
]
// READ/WRITE BRIGHTNESS: Keeps the slider state synced
Type dimmer : brightness "Brightness" [stateTopic="zigbee2mqtt/Lidl_HG06106C_1/brightness",commandTopic="zigbee2mqtt/Lidl_HG06106C_1/set/brightness",min=0,max=254]
Type number : linkquality "Lidl_HG06106C_1 Link Quality" [stateTopic="zigbee2mqtt/Lidl_HG06106C_1/linkquality"]
}
The .items File Configuration
Link your physical UI widgets to the newly created channels using this structure:
Switch LidlHG06106C_1Power "Lidl Bulb Power" <light> ["Light"] {channel="mqtt:topic:YOUR_BROKER_NAME:Lidl_HG06106C_1:power"}
Color LidlHG06106C_1Color "Lidl Bulb Color" <colorwheel> {channel="mqtt:topic:YOUR_BROKER_NAME:Lidl_HG06106C_1:color"}
Dimmer LidlHG06106C_1Brightness "Lidl Bulb Brightness" <dimmer> {channel="mqtt:topic:YOUR_BROKER_NAME:Lidl_HG06106C_1:brightness"}
Number LidlHG06106C_1Linkquality "Lidl Bulb Link Quality" {channel="mqtt:topic:YOUR_BROKER_NAME:Lidl_HG06106C_1:linkquality"}