OH3. Ikea TRADFRI Driver 30W and Zigbee2mqtt. Dimmer doesn't work properly

Hi,
I spend a lot of time trying to configure dimming the Ikea Tradfri Driver 30W.
OH3 is running on RPI4. Zigbee2mqtt is used to communicate with this device.
I can control the driver using Zigbe2mqtt GUI (state and brightness).
Using OH3 I can control only the state (on/off).

Ikea Driver configuration:

UID: mqtt:topic:227088f605:IkeaDriver01
label: Ikea Driver 01
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: offline
  availabilityTopic: zigbee2mqtt/IkeaDriver01/availability
  payloadAvailable: online
bridgeUID: mqtt:broker:227088f605
channels:
  - id: State
    channelTypeUID: mqtt:switch
    label: State
    description: ""
    configuration:
      postCommand: true
      qos: 1
      commandTopic: zigbee2mqtt/IkeaDriver01/set
      stateTopic: zigbee2mqtt/IkeaDriver01
      transformationPattern: JSONPATH:$.state
      off: OFF
      on: ON
  - id: Brightness
    channelTypeUID: mqtt:number
    label: Brightness
    description: ""
    configuration:
      postCommand: true
      min: 0
      qos: 1
      max: 254
      commandTopic: zigbee2mqtt/IkeaDriver01/set/brightness
      stateTopic: zigbee2mqtt/IkeaDriver01
      transformationPattern: JSONPATH:$.brightness

Dimmer configuration in semantic model:

For example, when I set up a dimmer value for 28 I can see in Zigbee2mqqt logs something like that:

MQTT publish: topic 'zigbee2mqtt/IkeaDriver01', payload '{"brightness":0.28,"linkquality":42,"state":"ON","update":{"state":"idle"},"update_available":false}'

Values from 0 to 100 are sent as 0 to 1. Values from 100 to 254 are not sent (no Zigbee2mqqt logs are present after value change).

Please let me know how to force the OH to send the correct value.
Thanks in advance.

Is it this one?

You dimmer code seems to be different that normal, below mine:

Channel config:

channels:

  • id: dimmer
    channelTypeUID: mqtt:dimmer
    label: Dimmer
    description: null
    configuration:
    commandTopic: zigbee2mqtt/IKEA_LED_806_1/set/brightness
    step: 10
    min: 0
    formatBeforePublish: “%s”
    stateTopic: zigbee2mqtt/IKEA_LED_806_1/brightness
    max: 255

The item has then the 0 to 100% range to display correct:

Item:

Take into account though that i am not using json transformation as zigbee2mqtt also supports normal numbers with their advanced mode, no need for json anymore.

@ubeaut Yes.

@chrismast
I changed channelTypeUID from Number to Dimmer in code.
There is no Dimmer in GUI so I am a little bit confused.

Dimmer in code is a Percentage Value in GUI?

I’ve added a stateDescription to the item like You but nothing has changed, still, 50% are sent as 0.5.

zigbee2mqtt/IkeaDriver01/brightness doesn’t work as a state topic. I used MQTT spy to sniff if there are values propagated. There were no values using this topic.

Channel config after changes:

  - id: Brightness
    channelTypeUID: mqtt:dimmer
    label: Brightness
    description: ""
    configuration:
      min: 0
      max: 254
      commandTopic: zigbee2mqtt/IkeaDriver01/set/brightness
      step: 1
      stateTopic: zigbee2mqtt/IkeaDriver01
      transformationPattern: JSONPATH:$.brightness

In semantic model:

And the item state description:

value: " "
config:
  pattern: "%0.f"
  step: "1"
  min: "0"
  max: "100"

Your dimmer item looks better, at least you got now the 100% range in it.
Below again my full item (besides state description which you had above).

Item:

For the thing channel, you need indeed to choose the percentage value, my remaining thing configs below:

Thing & Channel:

image

Take into account though, as mentioned, that I am not using any JSONPATH transform as I am using zigbee2mqtt’s experimental feature of attribute output:

experimental:
  output: attribute

Using this, there is no need for json anymore.

Based on your IKEA item you got indeed only zigbee2mqtt/FRIENDLY_NAME/set and not zigbee2mqtt/IkeaDriver01/set/brightness.

brightness: To control the brightness publish a message to topic zigbee2mqtt/FRIENDLY_NAME/set
 with payload {"brightness": VALUE} where VALUE is a number between 0 and 254. To read the 
brightness send a message to zigbee2mqtt/FRIENDLY_NAME/get with payload {"brightness": ""}.

@chrismast Thank you very much.

It is great that it is possible to change the MQTT output type from json to attribute!

I spent all day changing parameters on existing items and channels and there was still no progress. Error was displayed:

I decided to delete the brightness channel and item and configure it all once again. And now works fine !!!