I have two Zigbee devices, one maintains state to implement a toggling behavior, and another that just sends event messages when the button was pressed. The stateful one is here:
Type string : zigbeeKitchenSmall "Kitchen small button" [ stateTopic="zigbee2mqttHouse/0x00124b0022e96ad1", transformationPattern="REGEX:(.*action.*)∩JSONPATH:$.action" ]
It works fine.
For the other button I get:
{"action":"1_single","linkquality":114}
Am I required to write a rule that interprets an action triggered by an event message and do the toggling in the rule? I’m just wondering if there’s a shorter way to go about it these days.
I’m not sure right now, but I think you can add a channel to your MQTT item via the web interface. If you select the On/Off switch and click on “Show advanced” you can assign a “Custom On/Open Value” and “Custom Off/Closed Value”.
At “Incoming Value Transformations” then “JSONPATH:$.action”.
With this method, however, only two values can be processed, so you would have to create several if needed. But then the way over a rule would be easier.