Hi! I’m yet another new HA/NodeRed newbie
I apologise for the not so good English - it’s not my first language. If clarification is required, I would be happy to provide it.
I am trying to create an automation that would allow me to control a lamp with the Sonoff SNZB-01 button. The button is connected via a Sonoff ZBBridge flashed with Tasmota firmware. I am using the ZigBee2Tasmota integration. The data is coming through the Mosquitto MQTT broker.
The button can produce three states depending on the press type: 2 - single press, 1 - double press, 0 - long press (longer than 4 seconds).
On press broker receives next data from Tasmota:
{"ZbReceived":{"0x0BF3":{"Device":"0x0BF3","0006!02":"","Power":2,"Endpoint":1,"LinkQuality":89}}}
Where “Power” defines press type.
The button is defined as a sensor:
- platform: mqtt
name: Switch
state_topic: "tele/zbbridge/0BF3/SENSOR"
value_template: >
{{ value_json['ZbReceived']['0x0BF3']['Power'] }}
qos: 0
I tried to find a way to control the lamp with this button. I tried connecting directly to the MQTT broker with MQTT in
node (this way is preferred way). MQTT node’s output is ok:
"{"ZbReceived":{"0x0BF3":{"Device":"0x0BF3","0006!02":"","Power":2,"Endpoint":1,"LinkQuality":58}}}"
But for some reason I can’t parse the value of Power
from it. Tried to do it with Switch
node, applying JSONata filter $.ZbReceived.'0x0BF3'.Power=2
in it. Filter produced empty value (tested it on https://try.jsonata.org - it works!).
Tried to use Template
node with template {{ ZbReceived.'0x0BF3'.Power }}
- no way.
I also tried to run automation with Trigger: State
or Event: State
nodes, but there were problems with the states not being reset after the button was pressed, and the next press not triggering.
What is my mistake? What is the correct way to connect these devices?