Sonoff switch SNZB-01 (Zigbee) is missing entities

Tags: #<Tag:0x00007f7395c13008>

Hi folks,

I have a switch that I bought with the Sonoff Zigbee bridge, The model on the box is SNZB-01. I have paired the device to the bridge using the ZHA interface. If I look at the list of devices, I am shown Device: Garden Switch, Manufacturer: eweLink, Model: WB01

The only entity shown is: Garden Switch power (which is 100%, as it is new).

How do I find out when the button is pressed?

Go to developer tools -> events, enter * under listen to events,hit start listening, and start pressing your button.

Thanks Francis,

I get a response of:

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "00:12:4b:00:1f:8a:bb:08",
        "unique_id": "00:12:4b:00:1f:8a:bb:08:1:0x0006",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "toggle",
        "args": []
    },
    "origin": "LOCAL",
    "time_fired": "2020-09-11T17:08:15.050880+00:00",
    "context": {
        "id": "6151f12bf45111ea8729dfba13d0a3cb",
        "parent_id": null,
        "user_id": null
    }

I am not quite sure how I am supposed to build a trigger from that. Have you any ideas?

It took me a while to find out there is no entities associated with these (apart from the battery) as the button creates events.You need to monitor for the events to make use of the button.
If you use Node Red you can easily filter the button events.
Create a "Events all" node with the event type set as "zha_event".
Create a switch node (if you have more than one button) and set the property as "payload.event.unique_id" and put the unique_id from from your switch.
Create a switch node and set the property to "payoad.event.command" and set it to the command. This switch has toggle, on and off available for press, double press and long press.
Then create a call service node to do the action you want.

There is probably a fairly trivial way to use these events in home assistant directly, but I haven’t got that far yet.

3 Likes

Thanks Steve, I shall look into it

see this comment

@SteveM363 is right, an entity is not created for a button, because the button press itself is treated as an event.

I found that the best solution was to manage the button press events in NodeRed and I got the idea from jimford in this post:

Sonoff zigbee button SNZB-01 issue (only in cloud mode)?

And if you’re interested, here is a stripped back version of my NodeRed button management flow for my 8x SN-ZB01 buttons:

[{"id":"6a4f25f2.3d2c5c","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"4ad6f054.f3c1e","type":"switch","z":"6a4f25f2.3d2c5c","name":"","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"toggle","vt":"str"},{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":590,"y":260,"wires":[[],[],[]],"outputLabels":["Single Click","Double Click","Long Press"]},{"id":"7574d4ac.64adcc","type":"server-events","z":"6a4f25f2.3d2c5c","name":"zigbee event monitor","server":"666b1cf9.686414","event_type":"zha_event","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"x":160,"y":260,"wires":[["4e4f077.88b18f8","d0f6905c.d78e1","7eb800a8.92f91","a2f56e19.d45e3","67dff8c3.23ea38","2238c1a.6a4763e","6f02eee6.c2ec8","a9713657.7faa18","abfef768.f2b758"]]},{"id":"4e4f077.88b18f8","type":"switch","z":"6a4f25f2.3d2c5c","name":"Button A","property":"payload.event.unique_id","propertyType":"msg","rules":[{"t":"eq","v":"00:12:4b:00:1f:91:61:71:1:0x0006","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":260,"wires":[["4ad6f054.f3c1e"]]},{"id":"fa465d17.b23ba","type":"comment","z":"6a4f25f2.3d2c5c","name":"Zigbee button payload List ....","info":"single click payload command = \"toggle\"\ndouble click payload command = \"on\"\nlong press payload command = \"off\"\n","x":180,"y":120,"wires":[]},{"id":"d0f6905c.d78e1","type":"switch","z":"6a4f25f2.3d2c5c","name":"Button B","property":"payload.event.unique_id","propertyType":"msg","rules":[{"t":"eq","v":"00:12:4b:00:1f:91:4a:c5:1:0x0006","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":340,"wires":[["2428b3f1.a73ddc"]]},{"id":"7eb800a8.92f91","type":"switch","z":"6a4f25f2.3d2c5c","name":"Button C","property":"payload.event.unique_id","propertyType":"msg","rules":[{"t":"eq","v":"00:12:4b:00:1f:91:60:f0:1:0x0006","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":420,"wires":[["7c8ff1f5.284f"]]},{"id":"a2f56e19.d45e3","type":"switch","z":"6a4f25f2.3d2c5c","name":"Button D","property":"payload.event.unique_id","propertyType":"msg","rules":[{"t":"eq","v":"00:12:4b:00:1f:8a:9a:e3:1:0x0006","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":500,"wires":[["665a1e7e.94864"]]},{"id":"2428b3f1.a73ddc","type":"switch","z":"6a4f25f2.3d2c5c","name":"","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"toggle","vt":"str"},{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":590,"y":340,"wires":[[],[],[]],"outputLabels":["Single Click","Double Click","Long Press"]},{"id":"7c8ff1f5.284f","type":"switch","z":"6a4f25f2.3d2c5c","name":"","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"toggle","vt":"str"},{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":590,"y":420,"wires":[[],[],[]],"outputLabels":["Single Click","Double Click","Long Press"]},{"id":"665a1e7e.94864","type":"switch","z":"6a4f25f2.3d2c5c","name":"","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"toggle","vt":"str"},{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":590,"y":500,"wires":[[],[],[]],"outputLabels":["Single Click","Double Click","Long Press"]},{"id":"67dff8c3.23ea38","type":"debug","z":"6a4f25f2.3d2c5c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":130,"y":340,"wires":[]},{"id":"2238c1a.6a4763e","type":"switch","z":"6a4f25f2.3d2c5c","name":"Button E","property":"payload.event.unique_id","propertyType":"msg","rules":[{"t":"eq","v":"00:12:4b:00:1f:8a:aa:fd:1:0x0006","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":580,"wires":[["20a964b3.391ebc"]]},{"id":"20a964b3.391ebc","type":"switch","z":"6a4f25f2.3d2c5c","name":"","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"toggle","vt":"str"},{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":590,"y":580,"wires":[[],[],[]],"outputLabels":["Single Click","Double Click","Long Press"]},{"id":"6f02eee6.c2ec8","type":"switch","z":"6a4f25f2.3d2c5c","name":"Button F","property":"payload.event.unique_id","propertyType":"msg","rules":[{"t":"eq","v":"00:12:4b:00:1f:91:99:44:1:0x0006","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":660,"wires":[["ede71452.3468c8"]]},{"id":"ede71452.3468c8","type":"switch","z":"6a4f25f2.3d2c5c","name":"","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"toggle","vt":"str"},{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":590,"y":660,"wires":[[],[],[]],"outputLabels":["Single Click","Double Click","Long Press"]},{"id":"a9713657.7faa18","type":"switch","z":"6a4f25f2.3d2c5c","name":"Button G","property":"payload.event.unique_id","propertyType":"msg","rules":[{"t":"eq","v":"00:12:4b:00:1f:90:c8:54:1:0x0006","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":740,"wires":[["b6c095e4.f66a68"]]},{"id":"b6c095e4.f66a68","type":"switch","z":"6a4f25f2.3d2c5c","name":"","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"toggle","vt":"str"},{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":590,"y":740,"wires":[[],[],[]],"outputLabels":["Single Click","Double Click","Long Press"]},{"id":"abfef768.f2b758","type":"switch","z":"6a4f25f2.3d2c5c","name":"Button H","property":"payload.event.unique_id","propertyType":"msg","rules":[{"t":"eq","v":"00:12:4b:00:1f:91:99:4e:1:0x0006","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":820,"wires":[["1f4e7205.c0edfe"]]},{"id":"1f4e7205.c0edfe","type":"switch","z":"6a4f25f2.3d2c5c","name":"","property":"payload.event.command","propertyType":"msg","rules":[{"t":"eq","v":"toggle","vt":"str"},{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":590,"y":820,"wires":[[],[],[]],"outputLabels":["Single Click","Double Click","Long Press"]},{"id":"666b1cf9.686414","type":"server","z":"","name":"Home Assistant","addon":true}]
1 Like

Hey guys, just thought I would share what I have done for this. I’m quite new still to everything, so my approach may not be the best, but it’s working for me! I haven’t made my way through the use of node red just yet, only been playing with it. I wanted to get this working with automations through HA directly for now. First off, thank you for the tip on the events! I didn’t know how get toggle command from the switch till I read this.

Anyways, looked up the event and captured the device_ieee below and just added that in the automations.


Event 14 fired 8:42 AM:
{
“event_type”: “zha_event”,
“data”: {
“device_ieee”: “00:12:4b:00:1f:91:5a:b6”,
“unique_id”: “00:12:4b:00:1f:91:5b:a6:1:0x0006”,
“endpoint_id”: 1,
“cluster_id”: 6,
“command”: “toggle”,
“args”: []
},
“origin”: “LOCAL”,
“time_fired”: “2020-10-22T12:42:53.433819+00:00”,
“context”: {
“id”: “1a3bba55146411eba6d6b5af29daad55”,
“parent_id”: null,
“user_id”: null
}
}

111Capture

Then just set the device or whatever to toggle.

Hope this helps!
Chad

1 Like

Thanks Chad

I ended up in the same place and got things moving.

Awesome! glad to have helped being a newbie here!

To add to Chad’s excellent info, to cater for the single click and longpress events in HA Automations, you can add the ‘command:’ data as well:
HA Trigger Short push SNZB-01
for the single click, and:
HA Trigger Long push SNZB-01
for the long press.

Hope this helps you even further!
Greetz, djawizha

1 Like

In addition to those filters, you can also catch “double click” by filtering command:“on”.

To add to all the great people above, you can also find the ieee for the button you are trying to configure by going to Configuration --> Devices and open your button’s device info page.

2 Likes