MQTT and xiaomi switch

After upgrading to 2.4; I managed to make sensors working again (thanks to other forum entries). Now I am trying add https://www.zigbee2mqtt.io/devices/QBKG12LM.html but I am missing some bits.

I don’t know how to define it at .things neither at .items

The mqtt message when switching is

topic 'zigbee2mqtt/laundryswitch', 
payload '{"power":0,
"consumption":0,
"temperature":33,
"linkquality":80,
"state_left":"ON",
"state_right":"OFF",
"click":"",
"device":{"ieeeAddr":"0x00158d0002a6de0e","friendlyName":"laundryswitch","type":"Router","nwkAddr":2841,"manufId":4447,"manufName":"LUMI","powerSource":"Mains (single phase)","modelId":"lumi.ctrl_ln2.aq1","hwVersion":18,"swBuildId":"unknown","dateCode":"06-25-2018","status":"online"}}'

I have defined the thing as

    Thing topic lightlaundry "Light" @ "FF_LaundryRoom" {
    Channels:
        Type switch : PowerSwitch  [ stateTopic="zigbee2mqtt/laundryswitch" , commandTopic="zigbee2mqtt/laundryswitch/left/set", on="ON", off="OFF" ]
    }

and item as

Switch lightlaundry "Light" <light> (FF_LaundryRoom) {channel="mqtt:topic:mosquitto:laundryswitch" }

You haven’t got a channel named laundryswitch. You did make one called PowerSwitch belonging to a thing called lightlaundry.

That will give you all of the JSON payload. I expect you’ll want to parse out some part of the JSON using a JSONPATH transformationPattern

You are right, I messed (sometimes I mess labels with keywords), still learning…

Thanks a lot, now it is working.

Hi enboig,
can you share your .things and .items und the JS scripts?
Thanks,
Ingo

They are for openhab2; things is

Bridge mqtt:broker:mosquitto "Mosquitto" [ host="127.0.0.1", secure=false, clientID="openHAB2"]
{
  Thing topic interruptorssafreig {
    Channels:
      Type switch : switch_left   [ stateTopic="zigbee2mqtt/interruptorssafreig", transformationPattern="JSONPATH:$.st>
      Type switch : switch_right  [ stateTopic="zigbee2mqtt/interruptorssafreig", transformationPattern="JSONPATH:$.st>
  }
...
}

items is

Switch LaundrySwitch "Llum Safreig" <light> (FF_LaundryRoom) {channel="mqtt:topic:mosquitto:interruptorssafreig:switch_left" }

I have to migrate everything to OH3, where all of this should be easier… :wink:

And for openHAB 3 - your configuration will work perfectly fine in OH3!

well… for some sensors I didn’t install all channels (movement sensors are missing light, temperature are missing humidity…). I was planning a clean install.
I plan keeping my zigbee2mqtt to avoid pairing again all the devices.

Evey thing connected, in OH3 I missed JINJA transmformation. Once installed everything is working