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”):
(function(x){
var result = "none";
var json = JSON.parse (x);
try {
if (json.click == "left") {
//if (json.linkquality != 0) {
result = "ON";
//}
}
}
catch(e) {
result = "none";
}
return result;
})(input)
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
Thanks
Stephan