Aquara Wall Switch OH2.4 -> OH3.4 using MQTT Transformation

For some weeks I migrate from OH2.4 to OH3.4 and solved many problems. But the last problem is to migrate my Aquara Wall Switches. I use in background Zigbee2MQTT and a JS-Transformation. Here is my working OH2.4 setup:

Switch AquaraKuecheLeft    "LED Links"     (Aquara) ["Lighting"]     { mqtt="<[mosquitto:zigbee2mqtt/0x00158d00031e371c:command:JS(getZigbeeXiaomiLeftClick.js)]" }
Switch AquaraKuecheMiddle  "LED Mitte"     (Aquara) ["Lighting"]     { mqtt="<[mosquitto:zigbee2mqtt/0x00158d00031e371c:command:JS(getZigbeeXiaomiDoubleClick.js)]" }
Switch AquaraKuecheRight   "LED Rechts"    (Aquara) ["Lighting"]     { mqtt="<[mosquitto:zigbee2mqtt/0x00158d00031e371c:command:JS(getZigbeeXiaomiRightClick.js)]" }

The corresponding transformation looks like this (DoubleClick “both” instead of “left” and RightClick “right”):

  var result = "none";
  var json = JSON.parse (x);  
  try {
    if ( == "left") {
      //if (json.linkquality != 0) {
        result = "ON";
  catch(e) {
    result = "none";

  return result;

The message which I get via MQTT is for example:

zigbee2mqtt/0x00158d00031e371c {"battery":100,"voltage":3005,"linkquality":99,"click":"left"}
zigbee2mqtt/0x00158d00031e371c {"battery":100,"voltage":3005,"linkquality":94,"click":"right"}
zigbee2mqtt/0x00158d00031e371c {"battery":100,"voltage":3005,"linkquality":94,"click":"both"}

And now the OH3.4 setup, which does not work:

Type switch : AquaraKuecheLeft  "LED Links"           [ stateTopic="zigbee2mqtt/0x00158d00031e371c", transformationPattern="JS:getZigbeeXiaomiLeftClick.js" ]
Type switch : AquaraKuecheMiddle "LED Mitte"             [ stateTopic="zigbee2mqtt/0x00158d00031e371c", transformationPattern="JS:getZigbeeXiaomiDoubleClick.js" ]
Type switch : AquaraKuecheRight "LED Rechts"            [ stateTopic="zigbee2mqtt/0x00158d00031e371c", transformationPattern="JS:getZigbeeXiaomiRightClick.js" ]

It seems, that the JS-Transformation will not be called, because the assigned switch item is not switched nor receives any command/update. But I get warnings (also with right and left):

2023-01-15 13:59:21.150 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'both' from channel 'mqtt:topic:zigbee:AquaraKuecheRight' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.both

I tried also (without success):

  • direkt JSON access together with on:
on="left", transformationPattern="JSONPATH:$.click"
  • additional using of Regex:
on="left", transformationPattern="REGEX:(*left*)∩JSONPATH:$.click"

I need some ideas or hints, how I can migrate that. I dont want change my infrastructure using MQTT and Zigbee2MQTT


The error message is about the channel / thing, but you are looking into your item definition.

Maybe have a look into your mqtt thing definition.
I would apply the transformation at a channel level, then you should have no issues linking an item

The OP has shown their Thing definition, not the Item definition. Or more precisely: they’ve shown the Thing Channel configuration.

As an aside @Dojokun, are you aware that your example JSON seems to come from a different topic to that you’ve configured in openHAB?

Sorry. This is a copy paste error. The ID’s are the same. I will correct in my original post.

In openHAB, please go to Help & About → Technical Information → View details and copy and paste all the information here in between code fences.

  version: 3.4.0
  buildString: Release Build
locale: de-DE
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 11.0.17
  javaVendor: Azul Systems, Inc.
  javaVendorVersion: Zulu11.60+19-CA
  osName: Linux
  osVersion: 5.15.0-56-generic
  osArchitecture: amd64
  availableProcessors: 4
  freeMemory: 379318944
  totalMemory: 683671552
  startLevel: 100
  - amazonechocontrol
  - avmfritz
  - exec
  - fronius
  - livisismarthome
  - mqtt
  - network
  - ntp
  - openweathermap
  - tankerkoenig
  - telegram
  - tr064
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: true
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: windows
    pixelRatio: 1.25
    prefersColorScheme: light
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 4
    language: de-DE
      - de-DE
      - de
      - en-US
      - en
      - es
    onLine: true
    platform: Win32
    width: 1536
    height: 864
    colorDepth: 24
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: filled
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
    like Gecko) Chrome/ Safari/537.36
timestamp: 2023-01-17T09:07:36.972Z

You can do this with the transformation.

Thanks. The experimental switch, which is described there, works on my system. Now I have to deal with the new syntax.

It works. Had to rewrite my rules and change the items from switch to string.