Problem with MQTT and SONOFF Wireless Button

I am trying to figure out how to get the “action” from Zigbee2MQTT passed into an item in OpenHAB. I am able to read the battery level via MQTT, but I cannot figure out a way to get the “action” working. As I understand it, I will not be able to use a “switch”. I tried to use “string” without any luck.

Any idea what I am doing wrong?

action: single|double|long


UID: mqtt:topic:e90f42a7f8:7175c610f2
label: SONOFF Wireless button 1
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:e90f42a7f8
  - id: SONOFF_Wireless_button_1_action
    channelTypeUID: mqtt:string
    label: action
    description: null
      allowedStates: single,double,long
      stateTopic: zigbee2mqtt/0x00124b0022697442
      transformationPattern: JSONPATH:$.action
  - id: SONOFF_Wireless_button_1_battery
    channelTypeUID: mqtt:number
    label: Battery
    description: null
      stateTopic: zigbee2mqtt/0x00124b0022697442
      transformationPattern: JSONPATH:$.battery


This solved my problem. I am not able to create it in the GUI though.

Thing mqtt:topic:snzb01a "My Awesome Button" (mqtt:broker:e90f42a7f8) @ "Some Fancy Room" {
     Type string : action       "Action"       [ stateTopic="zigbee2mqtt/0x00124b0022697442", transformationPattern="REGEX:(.*action.*)∩JSONPATH:$.action"]
     Type number : linkquality  "Link Quality" [ stateTopic="zigbee2mqtt/0x00124b0022697442", transformationPattern="JSONPATH:$.linkquality"]
     Type number : battery      "Battery"      [ stateTopic="zigbee2mqtt/0x00124b0022697442", transformationPattern="JSONPATH:$.battery"]
     Type number : voltage      "Voltage"      [ stateTopic="zigbee2mqtt/0x00124b0022697442", transformationPattern="JSONPATH:$.voltage"]
}type or paste code here

Sonoff Zigbee (SNZB) Sensors & Switches with Zigbee2MQTT - Tutorials & Examples / Solutions - openHAB Community

can also be done in the GUI.
In the channel configuration click on “Advanced” and enter your transformation into
" Incoming Value Transformation"

I tried that, but without any luck. Configuriing the things in things-files works perfectly though. :slight_smile:

Well, I have about 50 Devices included by MQTT via GUI. So it works and you seem to configure something wrong.
Anyway, if you can live with the text based configuration, just keep it that way.

You were right. I am very new to MQTT and the transformation stuff. I am slowly starting to understand it. I am doing my things configuration in the GUI now. Thanks.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.