Mqtt color xy brightness

Hello,
I am using OH3 on a raspberry pi 4

I have a paulmann Amaris Color Lamp that works with zigbee2mqtt. I want to control it with color x y and brightness. I made a mqtt thing, with a color channel xy.

UID: mqtt:topic:broker:gf_office_light
label: Licht Büro
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:broker
location: Office
channels:
  - id: Office_Light_xy
    channelTypeUID: mqtt:color
    label: Licht Büro xy
    description: ""
    configuration:
      formatBeforePublish: '{"color":{"x":%s,"y":"%s"},"brightness":"%s"}'
      commandTopic: zigbee2mqtt/GF_Office_Light/set
      colorMode: XYY
      stateTopic: zigbee2mqtt/GF_Office_Light
      off: '{"state": "OFF"}'
      onBrightness: 100
      on: '{"state": "ON"}'

That works fine, but I can not get the full brightness, because the lamp expects as max 254, and openhab send max 100.
Is it possible with JavaScript to calculate the string “x, y, brightness” from example “0.3,0.3,100” to “0.3,0.3, 254”.
I testet it only with the brightness on a extra dimmer channel, but don’t get it work with x y and brightness in one string.

Thanks and Bye

Instead of using the formatBeforePublish, you can use a JavaScript outgoing transformation to both format the message and do the calculation for the brightness.

You could use zigbee2mqtt’s “experimental” feature “attribute_and_json”. Then send commands for colorXY and brightness in two separate channels. This allows to use a dimmer channel for brightness, where you can set minimum and maximum value.
This is how I configured my lamp (Aldi brand):

UID: mqtt:topic:mqtt_raspberry:ZigbeeRGBLight01
label: ZigbeeRGBLight01
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:systemBroker:mqtt_raspberry
location: Bedroom
channels:
  - id: power
    channelTypeUID: mqtt:switch
    label: Power
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/ZigbeeRGBLight01/set
      stateTopic: zigbee2mqtt/ZigbeeRGBLight01/state
      off: OFF
      on: ON
  - id: dimmer
    channelTypeUID: mqtt:dimmer
    label: Brightness
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/ZigbeeRGBLight01/set/brightness
      min: 0
      stateTopic: zigbee2mqtt/ZigbeeRGBLight01/brightness
      max: 254
  - id: color
    channelTypeUID: mqtt:color
    label: Color
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/ZigbeeRGBLight01/set
      colorMode: XYY
      formatBeforePublish: '{"color":{"x": %1$s, "y": %2$s}}'
      stateTopic: zigbee2mqtt/ZigbeeRGBLight01

(Note: removed some channels from the code for brevity)

Hi Jens,
thats very similar to the configuration that I use at the moment. I also made an extra channel for brightness, and one for rgb (also tested xy). But when I change the brightness in then Item there will be send two commands on mqtt (testet with mqttfx), each fo r one channel. and then tho colortemp changes a bit.
Have you linked all these channels with the same Item?

I use separate items for each channel.
This is also how zigbee2mqtt handles my particular lamp (in the “new” zigbee2mqtt web interface)

Okay, I understood, this works.

But than you can’t regulate the brightness with the colorpicker Item. I also thougt about this solution.

i have a solution for controlling brightness also, the only remaining problem is that brightness expects values from 0-254, but the slider in openhab only gives me 100 at max…

  - id: color_xy
    channelTypeUID: mqtt:color
    label: color_xy
    description: ""
    configuration:
      commandTopic: zigbee2mqtt/Hue white and color ambiance LightStrip plus/set
      colorMode: XYY
      formatBeforePublish: '{"color":{"x":"%s", "y":"%s"},"brightness":"%s"}'
      stateTopic: zigbee2mqtt/Hue white and color ambiance LightStrip plus/
      onBrightness: 20

i am running zigbee2mqtt in

output: 'attribute'