Sonoff ZbBridge over mqtt: how to add an RGB light?

Tags: #<Tag:0x00007f3281508d30>

I’m using a Sonoff ZbBridge fashed with Tasmota 8.5.1. With Tasmota firmware, I can control and read the status of zigbee devices over mqtt. It works great with various Aqura and Sonoff Zigbee sensors so far. I started adding my zigbee bulbs to this network and faced a problem.

Autodiscovery for ZIgBee is not supported by Tasmota yet, so not a big deal, I created a manual configuration for an mqtt light using a template schema. It works great for CT lights but adding RGB channels is a challenge. MQTT Template schema requires setting and reading RGB values for lights. However, ZigBee protocol reports Dimmer and HS values in separate clusters, so does the ZbBridge - it takes and recives separate commands for setting Dimmer and HS values.

I wonder if and how I can overcome these problems:

  1. For controlling the light I need to convert RGB to Dimmer + HueSat inside the template. Unfortunatly, hass does not expose any such functions to jinja2.
  2. Light status is reported for the Dimmer and HueSat in separate mqtt messages. So it seems there is no way combining them in a template schema and calculating the RGB values, even if a helper function of hsv2rgb would have provided.

I would appriciate any help or hints here. My thoughts right now are around writing a custom integration, which would support autodicovery and proper configuration for ZbBridge connected devices. But if there is a shorter way, I would appriciate that.