[SOLVED] Zigbee2mqtt and Xiaomi WXKG02LM, trigger rule on second press

  • Platform information:
    • RPi 3b, OH 2.5M4, cc2531 with zigbee2mqtt

I’ve got a Aqara double key wireless wall switch paired to zigbee2mqtt. It all works fine, the switch is publishing to mqqt like a charme, but the rule won’t be triggered if i press the same button twice.
e.g. i turn on the kitchen light with a right click and i want to turn it off with another right click again.
The switch sends the payload

{"linkquality":89,"battery":100,"voltage":3055,"click":"right"}

everytime i press the button, but my rule only triggers on change, so nothing happens after pressing the same button again.
I tried everything i found in the forum, Channel triggered, on received command/update …

My Thing

Thing mqtt:topic:doubleSwitchKitchen "doubleSwitchKitchen" (mqtt:broker:mosquitto) {
    Channels:
        Type string : click "Click"     [ stateTopic="zigbee2mqtt/DoubleSwitchKitchen", transformationPattern="JSONPATH:$.click", trigger=true]
        Type number : voltage "Voltage" [ stateTopic="zigbee2mqtt/DoubleSwitchKitchen", transformationPattern="JSONPATH:$.voltage"]
        Type number : battery "Battery" [ stateTopic="zigbee2mqtt/DoubleSwitchKitchen", transformationPattern="JSONPATH:$.battery"]
       
}

My Items

String   DoubleSwitchKitchenClick     "Click"     {channel="mqtt:topic:doubleSwitchKitchen:click"}
Number   DoubleSwitchKitchenVoltage   "Voltage"   {channel="mqtt:topic:doubleSwitchKitchen:voltage"}
Number   DoubleSwitchKitchenBattery   "Battery"   {channel="mqtt:topic:doubleSwitchKitchen:battery"}

RULES

rule "rule name"
when Channel "mqtt:topic:doubleSwitchKitchen:click" triggered
    
then
   logInfo("Switch", "Channel triggered") 
end


rule "React on Change"
when
    Item DoubleSwitchKitchenClick changed 
then
    logInfo("Switch", "Item DoubleSwitchKitchenClick changed to "+ DoubleSwitchKitchenClick.state)    
end

The second rules is only triggering if a pressed another button before…
The first one never triggers.
Does anyone have an idea how i can solve this problem?

Thank you in advance

Do this:
Change the trigger

rule "React on Update"
when
    Item DoubleSwitchKitchenClick received update
then
    logInfo("Switch", "Item DoubleSwitchKitchenClick changed to "+ DoubleSwitchKitchenClick.state)    
    if (mySwitch.state == OFF) mySwitch.sendCommand(ON)
    else mySwitch.sendCommand(ON)
end

Thank you, I was sure i tried it… But now it works fine!