How to use homeassistant discovery to control a dimmer?

  • Platform information:
    • Hardware: Intel(R) Core™ i5-7300U CPU @ 2.60GHz/16GB/1T EXT4
    • OS: Ubuntu server 22.04.2 LTS
    • Java Runtime Environment: openjdk version “11.0.17” 2022-10-18
    • openHAB version: 3.4.2
  • Issue of the topic:
    I am trying to operate a zigbee dimmer using zigbee2mqtt > mosquitto > openhab mqtt binding with homeassistant autodiscovery

From zigbee2mqtt I can read and operate the device as expected.
From Mosquitto I can read the topics for this device including the light topic:

{“availability”:[{“topic”:“zigbee2mqtt/bridge/state”,“value_template”:“{{ value_json.state }}”},
{“topic”:“zigbee2mqtt/sw.dimm1/availability”,“value_template”:“{{ value_json.state }}”}],
“availability_mode”:“all”,“brightness”:true,
“brightness_scale”:254,
“command_topic”:“zigbee2mqtt/sw.dimm1/set”,
“device”:{“identifiers”:[“zigbee2mqtt_0xa4c138508e410e7b”],
“manufacturer”:“TuYa”,
“model”:“1 channel dimmer (TS110E_1gang_1)”,
“name”:“sw.dimm1”},
“json_attributes_topic”:“zigbee2mqtt/sw.dimm1”,
“name”:“sw.dimm1”,“schema”:“json”,
“state_topic”:“zigbee2mqtt/sw.dimm1”,
“unique_id”:“0xa4c138508e410e7b_light_zigbee2mqtt”}

From openhab I can see the thing and config topics:

light/0xa4c138508e410e7b/light
select/0xa4c138508e410e7b/power_on_behavior
select/0xa4c138508e410e7b/switch_type
sensor/0xa4c138508e410e7b/last_seen
sensor/0xa4c138508e410e7b/linkquality
sensor/0xa4c138508e410e7b/power_on_behavior
sensor/0xa4c138508e410e7b/switch_type

but the light topic channels are not coming through (Sensor and select do).

To me it seems the Zigbee2mqtt is publishing the correct data (though I am not familiar enough with the syntax to exclude possible config errors here). Mosquitto seems to be passing the date as expected and openhab receives the data.

Why could it be unable to identify the channels and how can I debug this issue. I tried cranking up the logging but so far I have not found an error which would explain the missing channels to me.
My config is running around 50 sensors and switches without (big) issues, but this is the first with a light topic; so possibly I am just forgetting some installation setting or plugin, however from the documentation I should expect it to run “out of the box”

This assumption might be incorrect, considering this open issue:

Anyone who can gives me some guides on how to solve this issue? Or should I change the setup for this thing to a manual config?

Apparently the home-assistant JSON implementation is not yet implemented (Openhab 3.4), so a manual thing definition is for now the way to go.

I added a new “Generic MQTT-Thing” from the Things tab, bound it to the my MQTT-broker and used the code field to define the channels:

UID: mqtt:topic:5a3240f665:51b7eb5bf4
label: sw.dimm1.dimmer
thingTypeUID: mqtt:topic
configuration:
  topics: null
  basetopic: homeassistant
bridgeUID: mqtt:broker:5a3240f665
channels:
  - id: switch
    channelTypeUID: mqtt:switch
    label: Light Switch
    description: null
    configuration:
      commandTopic: zigbee2mqtt/sw.dimm1/set
      retained: false
      postCommand: false
      formatBeforePublish: "%s"
      stateTopic: zigbee2mqtt/sw.dimm1
  - id: brightness
    channelTypeUID: mqtt:dimmer
    label: Light Brightness
    description: null
    configuration:
      retained: false
      postCommand: false
      min: 40
      formatBeforePublish: "%s"
      max: 254
      commandTopic: zigbee2mqtt/sw.dimm1/set/brightness
      step: 1
      stateTopic: zigbee2mqtt/sw.dimm1

Now the brightness and on/off channels showed up and could be linked to items. So I can enjoy my home-made wake-up light :sweat_smile:

1 Like