How to use Aqara switch (WXKG11LM) over deConz binding?

Hi all,

OS+Platform: Raspbian on a Raspberry Pi 3 Model B Rev 1.2
OH: openHAB 2.5.1-2 (Release Build)
Switch: Aqara Xiaomi WXKG11LM Rev.2, Version 20180525

I’m struggling with the setup of a multi switch (Aqara WXKG11LM) to react on a button click in a rule. I’m using the switch via the deConz binding (the switch is a supported device) over conBee2. It is connected fine via the Phoscon app:

I am able to get the button events via the REST-api. In my case the button events are 1002 (click) 1003 (long press) and 1004 (double click). Therefore I assume, it’s working in general:

Unfortunately, I’m not able to get this mapped to a rule in OH. Maybe I really miss the obvious…
I’ve installed the deConz binding, created the Bridge and added the item (based on the binding documentation:
Thing: Thing switch xiaomi-ffagent-button "deCONZ FFAgent Button" @ "Flur" [ id="6" ]
Number FFAgent_Button "Button" { channel="deconz:switch:conbee2server:xiaomi-ffagent-button:button" }
Switch FFAgent_ButtonEvent "Buttonevent" { channel="deconz:switch:conbee2server:xiaomi-ffagent-button:buttonevent" }
DateTime FFAgent_LastUpdate "Letztes Update" { channel="deconz:switch:conbee2server:xiaomi-ffagent-button:last_updated" }
Number FFAgent_BatteryLevel "Batterieladezustand [%.0f%%]" { channel="deconz:switch:conbee2server:xiaomi-ffagent-button:battery_level" }
Switch FFAgent_BatteryLow "Batterie FFAgent leer?" { channel="deconz:switch:conbee2server:xiaomi-ffagent-button:battery_low" }

It shows up as connected, except the greyed out “Button Trigger”:

Finally the rule script looks like:
rule "FFAgent Button pressed"
Channel "deconz:switch:conbee2server:xiaomi-ffagent-button:buttonevent" triggered 1002
//do somehting

I cant find any error in the logs. For example, I can see some events for FFAgent_LastUpdate in the event log but that’s it. No errors in any other log related to this. No indication whether the button was clicked or whether something went wrong. The rule (the WHEN statement looks like it’s never true).
Did someone already get this constellation working? I appreciate any inputs.

I used a cube example for the my cube rule. I bet it would work for you. Search xiamoi cube on openHAB forum. I still have a few intermittent issues I am trying to work though. I think the rule I have used the http binding to poll the deconz rest api.

I used IKEA switch with deConz. All configuration was done by paperUi.
My rule looks like next:

rule “remote_switched”
Channel “deconz:switch:91716378:14b457fffe73b5de011000:buttonevent” triggered
var eventValue = receivedEvent.getEvent()
switch (eventValue) {
case “1002”: …
Check if this channel was triggered at all - for example, remove value 1002 after word triggered and try to output to log the received value

logInfo(“Xiaomi”, “Received value” + receivedEvent.getEvent())

Indeed… it looks like the channel is never triggered at all. But I have no clue why not.

@Itzamna I see the same issue. I need to trouble shoot more but I can confirm the rule does not trigger as you have it. Other forum post suggest it should so I am confused also.


I sat down today and played with my remote and deconz. The rule below works for me.

rule "FFAgent Button pressed"
Channel "deconz:switch:homeserver:KitchenRemote:buttonevent" triggered 1003
logInfo("DimmerTest", "receivedEvent=" + receivedEvent)



Thanks. I still having trouble but I think I get closer to the issue. It looks like that I’ve a gap in my .things configuration for the sensors. I don’t have only this switch but also at least 6 Xiaomi Multi Sensors (Temperature) defined.
It might be related to the [id="x"] parameter for each defined Thing in the file. It’s the first time I came across such a parameter at all and I can’t find any documentation about it. Neither in the common openHAB documentation ( - there, it’s just a lightId="x" with no explanation) nor in the deCONZ binding documentation.
All I know is, that if I remove this parameter for each Thing in the bridge, all Things show up as “OFFLINE Configuration Pending” in PaperUI. So it must be somehow important. Therefore my next question is:

  • Where does this [id="x"] parameter belongs to? Is this related to the sensor type (i.e. all temperaturesensor's must have [id="2"] (based on Full Things File example on Or must this be a unique id over all Things in this file?

For reference, this is my current .things configuration file. I’ve set up a unique id for each sensor. With this, all xiaomi-xm06 Things are OFFLINE in PaperUI. However, even if I setup the id based on the sensor types it doesn’t work. Then everything is Online but the button channel is not triggered.

Bridge deconz:deconz:conbee2server [ host="", httpPort="8085", apikey="F2137CAE60" ] {
	//XM00 - Kinderzimmer
	Thing daylightsensor		xiaomi-xm00-daylightsensor		"deCONZ XM00 Daylightsensor"	[ id="1" ]
	Thing temperaturesensor		xiaomi-xm00-temperaturesensor	"deCONZ XM00 Temperatur"		[ id="2" ]
	Thing humiditysensor		xiaomi-xm00-humiditysensor		"deCONZ XM00 Luftfeuchte"		[ id="3" ]
	Thing pressuresensor		xiaomi-xm00-pressuresensor		"deCONZ XM00 Luftdruck"			[ id="4" ]
	//XM01 - Wohnzimmer
	Thing daylightsensor		xiaomi-xm01-daylightsensor		"deCONZ XM01 Daylightsensor"	@	"Wohnzimmer"	[ id="5" ]
	Thing temperaturesensor		xiaomi-xm01-temperaturesensor	"deCONZ XM01 Temperatur"		@	"Wohnzimmer"	[ id="6" ]
	Thing humiditysensor		xiaomi-xm01-humiditysensor		"deCONZ XM01 Luftfeuchte"		@	"Wohnzimmer"	[ id="7" ]
	Thing pressuresensor		xiaomi-xm01-pressuresensor		"deCONZ XM01 Luftdruck"			@	"Wohnzimmer"	[ id="8" ]

	//XM02 - Kueche
	Thing daylightsensor		xiaomi-xm02-daylightsensor		"deCONZ XM02 Daylightsensor"	@	"Kueche"	[ id="9" ]
	Thing temperaturesensor		xiaomi-xm02-temperaturesensor	"deCONZ XM02 Temperatur"		@	"Kueche"	[ id="10" ]
	Thing humiditysensor		xiaomi-xm02-humiditysensor		"deCONZ XM02 Luftfeuchte"		@	"Kueche"	[ id="11" ]
	Thing pressuresensor		xiaomi-xm02-pressuresensor		"deCONZ XM02 Luftdruck"			@	"Kueche"	[ id="12" ]

	//XM03 - Schlafzimmer
	Thing daylightsensor		xiaomi-xm03-daylightsensor		"deCONZ XM03 Daylightsensor"	@	"Schlafzimmer"	[ id="13" ]
	Thing temperaturesensor		xiaomi-xm03-temperaturesensor	"deCONZ XM03 Temperatur"		@	"Schlafzimmer"	[ id="14" ]
	Thing humiditysensor		xiaomi-xm03-humiditysensor		"deCONZ XM03 Luftfeuchte"		@	"Schlafzimmer"	[ id="15" ]
	Thing pressuresensor		xiaomi-xm03-pressuresensor		"deCONZ XM03 Luftdruck"			@	"Schlafzimmer"	[ id="16" ]
 	//XM04 - Badezimmer
	Thing daylightsensor		xiaomi-xm04-daylightsensor		"deCONZ XM04 Daylightsensor"	@	"Badezimmer"	[ id="17" ]
	Thing temperaturesensor		xiaomi-xm04-temperaturesensor	"deCONZ XM04 Temperatur"		@	"Badezimmer"	[ id="18" ]
	Thing humiditysensor		xiaomi-xm04-humiditysensor		"deCONZ XM04 Luftfeuchte"		@	"Badezimmer"	[ id="19" ]
	Thing pressuresensor		xiaomi-xm04-pressuresensor		"deCONZ XM04 Luftdruck"			@	"Badezimmer"	[ id="20" ]
	 //XM05 - Gaestetoilette
	Thing daylightsensor		xiaomi-xm05-daylightsensor		"deCONZ XM05 Daylightsensor"	@	"Toilette"	[ id="21" ]
	Thing temperaturesensor		xiaomi-xm05-temperaturesensor	"deCONZ XM05 Temperatur"		@	"Toilette"	[ id="22" ]
	Thing humiditysensor		xiaomi-xm05-humiditysensor		"deCONZ XM05 Luftfeuchte"		@	"Toilette"	[ id="23" ]
	Thing pressuresensor		xiaomi-xm05-pressuresensor		"deCONZ XM05 Luftdruck"			@	"Toilette"	[ id="24" ]
	 //XM06 - Esszimmer
	Thing daylightsensor		xiaomi-xm06-daylightsensor		"deCONZ XM06 Daylightsensor"	@	"Esszimmer"	[ id="25" ]
	Thing temperaturesensor		xiaomi-xm06-temperaturesensor	"deCONZ XM06 Temperatur"		@	"Esszimmer"	[ id="26" ]
	Thing humiditysensor		xiaomi-xm06-humiditysensor		"deCONZ XM06 Luftfeuchte"		@	"Esszimmer"	[ id="27" ]
	Thing pressuresensor		xiaomi-xm06-pressuresensor		"deCONZ XM06 Luftdruck"			@	"Esszimmer"	[ id="28" ]
	//FFAgent - Flur Switch
	Thing switch				xiaomi-ffagent-button			"deCONZ FFAgent Button"			@	"Flur"		[ id="29" ]

Something must be obviously wrong here, I guess?

The id = xx can be obtained from the deconz rest api. When you go to the link: deconzip/api/apikey/sensors/xx where xx is the sensor number in the api. You want your things file to match these numbers based on description of sensor in api.

Have a look in the api it should line up. If not I can give more explanation.

1 Like

OMG :open_mouth:
This is the obvious point I mixed up. The id is the mapping part and not the name (like FFAgent)… I’ve changed it and all is working fine now :grinning: The channel of the switch is triggered and even some unexpected issues with some temperature sensors are now gone.
Thank you very much for your help on that!!!


1 Like

Hello I have the same issue. BUT I don´t see the solution in the comment. Can you explain it lttle bit deeper


@franzda can you be more specific on your problem? Maybe start a new request. I don’t fully understand your question.

I would like to integrate the Xiaomi Smart Switch WXKG01LM into my OH 2.5 9.

I already have a ZigBee network with 7 sensors.

My ZigBee network is set up via USB stick deConz and Lumi and Osram sockets as repeater.

So far, everything is largely stable.

As an extension, the Xiaomi Smart Switch WXKG01LM is now to be added.

The botton was parameterized by the system and Thing and the items could be created via VSCode without problems and communication is also running, but the interface does not seem to be correct.
The button only knows one change, but it cannot be undone.
But if I send a command from OH to the button via Rule then this change is accepted

As far as I know there are also double clicks and other commands that I really wanted to use
The trigger is also not addressed.
Date of change and battery is received correctly

Thank you for your intention to answer me

For double clicks you will need a rule do you have one?