New MQTT setup. Not all channels are discovered

Hi,

I’m trying to transition from deCONZ to Zigbee2MQTT.

I have successfully installed Z2MQTT on a Pi4 with a Sonoff dongle, and have paired some lights and plugs.

In Z2MQTT I can see all the available channels, on/off, colour temperature etc, but in OpenHAB, colour temperature, colour temperature startup, and on/off is missing when using the auto discover.

Any advice?


I have zigbee2mqtt and sonoff dongle.
I have never used the auto-discover.
I manually set up each device and find the information from the zigbee2mqtt web page.
Example: Philips 046677585235 control via MQTT | Zigbee2MQTT
I use friendly names and have the home assistant stuff turned off.

The zigbee2mqtt and the sonoff dongles has been a solid platform and works well. I only have 35 devices but they all communicate.

Can you show me an example things file of yours?

UID: mqtt:topic:mqttbroker:shed4gang
label: Shed 4 gang zigbee switch
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: offline
  payloadAvailable: online
  transformationPattern: JSONPATH:$.state
  availabilityTopic: zigbee2mqtt/shed4gang/availability
bridgeUID: mqtt:broker:mqttbroker
channels:
  - id: 4gangswitch1
    channelTypeUID: mqtt:switch
    label: 4 gang switch 1
    description: Switch one
    configuration:
      commandTopic: zigbee2mqtt/shed4gang/set/state_l1
      stateTopic: zigbee2mqtt/shed4gang
      transformationPattern: JSONPATH:$.state_l1
      off: OFF
      on: ON
  - id: 4gangswitch2
    channelTypeUID: mqtt:switch
    label: 4 gang switch 2
    description: Switch two
    configuration:
      commandTopic: zigbee2mqtt/shed4gang/set/state_l2
      stateTopic: zigbee2mqtt/shed4gang
      transformationPattern: JSONPATH:$.state_l2
      off: OFF
      on: ON
  - id: 4gangswitch3
    channelTypeUID: mqtt:switch
    label: 4 gang switch 3
    description: Switch three
    configuration:
      commandTopic: zigbee2mqtt/shed4gang/set/state_l3
      stateTopic: zigbee2mqtt/shed4gang
      transformationPattern: JSONPATH:$.state_l3
      off: OFF
      on: ON
  - id: 4gangswitch4
    channelTypeUID: mqtt:switch
    label: 4 gang switch 4
    description: Switch four
    configuration:
      commandTopic: zigbee2mqtt/shed4gang/set/state_l4
      stateTopic: zigbee2mqtt/shed4gang
      transformationPattern: JSONPATH:$.state_l4
      off: OFF
      on: ON

Mine are are set-up similar to Greg’s…

Here a RGBCW bulb, using JSON transformations.

UID: mqtt:topic:mosquitto:rgbcw_003
label: LED Eaves (RGBCW 003)
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:mosquitto
location: House eaves
channels:
  - id: availability
    channelTypeUID: mqtt:switch
    label: Online status
    description: ""
    configuration:
      formatBeforePublish: "%s"
      stateTopic: ArgyleCourt/Shed/EaveLights/RGBCW_003/availability
      transformationPattern: JSONPATH:$.state
      off: offline
      on: online
  - id: on_off_switch
    channelTypeUID: mqtt:switch
    label: On-off switch
    description: ""
    configuration:
      commandTopic: ArgyleCourt/Shed/EaveLights/RGBCW_003/set/state
      stateTopic: ArgyleCourt/Shed/EaveLights/RGBCW_003/state
  - id: brightness
    channelTypeUID: mqtt:dimmer
    label: Brightness
    description: ""
    configuration:
      min: 0
      formatBeforePublish: '{"brightness":%s,"transition":3}'
      transformationPatternOut: JS:light_brightness_out.js
      max: 100
      commandTopic: ArgyleCourt/Shed/EaveLights/RGBCW_003/set
      stateTopic: ArgyleCourt/Shed/EaveLights/RGBCW_003/brightness
      transformationPattern: JS:light_brightness_in.js
  - id: colour
    channelTypeUID: mqtt:colorRGB
    label: Colour
    description: ""
    configuration:
      commandTopic: ArgyleCourt/Shed/EaveLights/RGBCW_003/set
      colorMode: RGB
      formatBeforePublish: '{"color":{"rgb":"%s,%s,%s"}}'
      stateTopic: ArgyleCourt/Shed/EaveLights/RGBCW_003/color
  - id: colour_temperature
    channelTypeUID: mqtt:dimmer
    label: Colour temperature
    description: null
    configuration:
      commandTopic: ArgyleCourt/Shed/EaveLights/RGBCW_003/set
      formatBeforePublish: '{"color_temp":%s}'
      transformationPatternOut: JS:light_temp_out.js
      stateTopic: ArgyleCourt/Shed/EaveLights/RGBCW_003/color_temp
      transformationPattern: JS:light_temp_in.js

Thanks guys, but I’m a bit confused - the syntax for a text file should be

Thing mqtt:topic:mything "mything" (mqtt:broker:myInsecureBroker) {
    Channels:
    Type switch : lamp "Kitchen Lamp" [ stateTopic="lamp/enabled", commandTopic="lamp/enabled/set" ]
    Type switch : fancylamp "Fancy Lamp" [ stateTopic="fancy/lamp/state", commandTopic="fancy/lamp/command", on="i-am-on", off="i-am-off" ]
    Type string : alarmpanel "Alarm system" [ stateTopic="alarm/panel/state", commandTopic="alarm/panel/set", allowedStates="ARMED_HOME,ARMED_AWAY,UNARMED" ]
    Type color : lampcolor "Kitchen Lamp color" [ stateTopic="lamp/color", commandTopic="lamp/color/set", colorMode="RGB" ]
    Type dimmer : blind "Blind" [ stateTopic="blind/state", commandTopic="blind/set", min=0, max=5, step=1 ]
}

Your code looks like what I see when I look at the code tab in the UI.

And how do we know what the topics are?
Where do these parts come from in your example “ArgyleCourt/Shed/EaveLights/RGBCW_003/availability” and " zigbee2mqtt/shed4gang/set/state_l2"?

I’m trying to get mine working with this but it’s not happening for me:


Thing mqtt:topic:LightH1OfficeCeiling "Light,H1,Office,Ceiling" (mqtt:broker:aab6726def) {
    Channels:
    Type switch : onoff "On/Off" [ stateTopic="zigbee2mqtt/Light,H1,Office,Ceiling/state", commandTopic="zigbee2mqtt/Light,H1,Office,Ceiling/state/set" ]
}

Having a similar setup, I believe the files above ARE the UI code tab files from creating a “Generic MQQT” thing with the MQTT binding.
Generally I get the channels from MQTT explorer and just copy/paste using the copy icon in the upper right.
mqtt 2024-08-03 084328

1 Like

They aren’t using thing files. They’re adding Generic MQTT Things and then defining the channels manually. Effectively the same thing you’re trying to do with a thing file, but in MainUI.

Does anyone have text file examples?
I have loads of devices and would find it much easier to create text files.

On closer inspection, you’ve used commas in your topics.

Note that everyone else’s examples are using slashes.

Good observation. That will never work. :smiley:

I think using the UI stops a lot of typos but you can STILL introduce them even when using the UI.

I don’t use any DSL or files.

1 Like

Can’t help with a thing example, but when I transferred a 100 or so Zwave channels. I copied an example from the OH code tab into a text editor and did copy/paste or find/replace to create more channels. For me the topics were repetitive (12 switches, etc.). I then just pasted the expanded list back into the generic Mqtt OH code tab. You could literally copy the channels provided above, change some names and paste into your code tab.

Depending on how you use OH you can also regroup the Thing/channels. I put all the switch channels in one thing, all the sensors in another, etc. I don’t use location info and all my rules are related to items.

Just an unsolicited idea :wink:

1 Like

I configured a lot of things during the UI, but I was not to happy with the handling, so recently, I started to set up new things as file (Z2M and other MQTT stuff like shellies, esp8266 etc.).

Here an example from a thing file containing things and channels from Z2M:

Bridge mqtt:broker:mosquitto [ host="localhost", secure=false] {
  Thing topic aqaravibrationsensor1 "Aqara Vibration Sensor 1" @ "Büro" {
    Channels:
      Type number : angle_y [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_1", transformationPattern="JSONPATH:$.angle_y"]
      Type number : battery [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_1", transformationPattern="JSONPATH:$.battery"]
  }
  Thing topic aqaravibrationsensor2 "Aqara Vibration Sensor 2" @ "Büro" {
    Channels:
      Type number : angle_y [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_2", transformationPattern="JSONPATH:$.angle_y"]
      Type number : battery [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_2", transformationPattern="JSONPATH:$.battery"]
  }
  Thing topic aqaravibrationsensor3 "Aqara Vibration Sensor 3" @ "Badezimmer" {
    Channels:
      Type number : angle_y [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_3", transformationPattern="JSONPATH:$.angle_y"]
      Type number : battery [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_3", transformationPattern="JSONPATH:$.battery"]
  }
  Thing topic aqaravibrationsensor4 "Aqara Vibration Sensor 4" @ "Treppe" {
    Channels:
      Type number : angle_y [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_4", transformationPattern="JSONPATH:$.angle_y"]
      Type number : battery [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_4", transformationPattern="JSONPATH:$.battery"]
  }
  Thing topic aqaravibrationsensor5 "Aqara Vibration Sensor 5" @ "Schlafzimmer" {
    Channels:
      Type number : angle_y [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_5", transformationPattern="JSONPATH:$.angle_y"]
      Type number : battery [stateTopic="zigbee2mqtt/Aqara_Vibration_Sensor_5", transformationPattern="JSONPATH:$.battery"]
  }
  Thing topic oeeoneE27lamp "Smart Bulb Leselamope" @ "Wohnzimmer" {
    Channels:
      Type switch : power     [ stateTopic="zigbee2mqtt/oeeone_e27_1", commandTopic="zigbee2mqtt/oeeone_e27_1/set", on="ON", off="OFF" ]
      Type dimmer : brightness [ stateTopic="zigbee2mqtt/oeeone_e27_1", commandTopic="zigbee2mqtt/oeeone_e27_1/set", transformationPattern="JS:getZigbeeBrightness.js", transformationPatternOut="JS:setZigbeeBrightness.js" ]
      Type number : color_temp [ stateTopic="zigbee2mqtt/oeeone_e27_1", commandTopic="zigbee2mqtt/oeeone_e27_1/set", transformationPattern="JS:getZigbeeWhiteTemp.js", transformationPatternOut="JS:setZigbeeWhiteTemp.js" ]
  }
  Thing topic tuyasmartbulb01 "Tuya Smart Bulb" @ "Wohnzimmer" {
    Channels:
      Type switch : power "Power" [ stateTopic="zigbee2mqtt/0xa4c138a22a91ab3f/state", commandTopic="zigbee2mqtt/0xa4c138a22a91ab3f/set/state", on="ON", off="OFF" ]
      Type dimmer : brightness "Brightness" [ stateTopic="zigbee2mqtt/0xa4c138a22a91ab3f/brightness", commandTopic="zigbee2mqtt/0xa4c138a22a91ab3f/set/brightness", min=0, max=255 ]
      Type color : color "Color" [ stateTopic="zigbee2mqtt/0xa4c138a22a91ab3f/color", commandTopic="zigbee2mqtt/0xa4c138a22a91ab3f/set/color" ]
      Type number : colorTemp "Color Temperature" [ stateTopic="zigbee2mqtt/0xa4c138a22a91ab3f/color_temp", commandTopic="zigbee2mqtt/0xa4c138a22a91ab3f/set/color_temp", min=153, max=500 ]
    }
Thing topic tuerkontaktOG "Türkontakt OG" @ "Obergeschoss" {
    Channels:
        Type contact : contact [ stateTopic="zigbee2mqtt/0x00158d0009e7c88d", transformationPattern="JS:contactState.js" ]
        Type number : battery [ stateTopic="zigbee2mqtt/0x00158d0009e7c88d", transformationPattern="JSONPATH:$.battery" ]
}

Thing topic tuerkontaktEG "Türkontakt EG" @ "Erdgeschoss" {
    Channels:
        Type contact : contact [ stateTopic="zigbee2mqtt/0x00158d0009e7ac01", transformationPattern="JS:contactState.js" ]
        Type number : battery [ stateTopic="zigbee2mqtt/0x00158d0009e7ac01", transformationPattern="JSONPATH:$.battery" ]
}

Thing topic tuerkontaktEingangstuer "Türkontakt Eingangstür" @ "Eingang" {
    Channels:
        Type contact : contact [ stateTopic="zigbee2mqtt/0x00158d000201e28a", transformationPattern="JS:contactState.js"  ]
        Type number : battery [ stateTopic="zigbee2mqtt/0x00158d000201e28a", transformationPattern="JSONPATH:$.battery" ]
}

Thing topic zigbeeRemoteDachfenster "Zigbee Fernbedienung Dachfenster Treppe" @ "Treppe" {
    Channels:
        Type string : action    [ stateTopic="zigbee2mqtt/0xbc33acfffed699f9", transformationPattern="JSONPATH:$.action" ]
        Type number : battery  [ stateTopic="zigbee2mqtt/0xbc33acfffed699f9", transformationPattern="JSONPATH:$.battery" ]
    }

}

Please consider that you might have to use transformation patterns to connect OH items with the numbers delivered by MQTT (e. g. see brightness and color_temp channels in light bulb).