Sonoff switch SNZB-01 (Zigbee) is missing entities

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

3 Likes

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.

9 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}]
7 Likes

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

9 Likes

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

5 Likes

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.

3 Likes

Hey
Thanks for your help!
If you want, you can also add a double click :wink:

Simple click

- platform: event
    event_type: zha_event
    event_data:
      device_ieee: 'XX:XX:XX:XX:XX:XX:XX:XX'
      command: toggle

Double click

- platform: event
    event_type: zha_event
    event_data:
      device_ieee: 'XX:XX:XX:XX:XX:XX:XX:XX'
      command: on

Long click

- platform: event
    event_type: zha_event
    event_data:
      device_ieee: 'XX:XX:XX:XX:XX:XX:XX:XX'
      command: off

I hope this will help you

5 Likes

one press is “toggle” doublepress is on and hold for 3 sec is off

device_ieee: '00:12:4b:00:1f:91:99:c5'
unique_id: '00:12:4b:00:1f:91:99:c5:1:0x0006'
device_id: 949b68fd1c6bffe9861bde128afd1825
endpoint_id: 1
cluster_id: 6
command: toggle
args: []

THANKS!!! i use that on event data with diferent commands and works!!!

Glad this has helped a few folks out there! I was going to come back and post about the 3 commands with the switch but it looks like that is taken care of too. Keep up the great work all!

1 Like

i have the same issue, but connected with deconz. i created a automation like described an changed “zha_event” to “deconz_event”. but no success. the button has response in deconz overview. any idea?

my automation:

alias: Sonoff Button Toggle
description: ''
trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      device_ieee: '00:12:4b:00:22:42:26:b5'
      command: toggle
condition: []
action:
  - type: toggle
    device_id: 2e9ac4a5647b882733621b18930dd40a
    entity_id: light.shelly_shsw_1_40f52000f286
    domain: light
mode: single
1 Like

I had the same issue as Arthur, I’m using conbee usb with deconz.

This worked for me.
Using the appropriate event number
1002 is single click
1004 is double click
1003 is 3 sec hold

  alias: Sonoff Button Toggle
  description: ''
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      unique_id: '00:12:4b:00:22:42:26:b5'
      event: 1002
  condition: []
  action:
  - service: light.toggle
    data: {}
    entity_id: light.lounge_light
  mode: single
3 Likes

Hi Everyone,

I am new to Home assistant and i cant seem to get this little switch to work. I am using the sonoff LAN integration. When i listen in to my devices and click the switch i get the below code:

"event_type": "state_changed",
    "data": {
        "entity_id": "sensor.sonoff_a480003d75",
        "old_state": {
            "entity_id": "sensor.sonoff_a480003d75",
            "state": "single",
            "attributes": {
                "friendly_name": "test Light Switch",
                "icon": "hass:switch"
            },
            "last_changed": "2021-02-03T16:26:34.155098+00:00",
            "last_updated": "2021-02-03T16:26:34.155098+00:00",
            "context": {
                "id": "f4ecf0e542c0ea58eb42e219a32cbb97",
                "parent_id": null,
                "user_id": null
            }
        },
        "new_state": {
            "entity_id": "sensor.sonoff_a480003d75",
            "state": "",
            "attributes": {
                "friendly_name": "test Switch",
                "icon": "hass:switch"
            },
            "last_changed": "2021-02-03T16:26:34.662251+00:00",
            "last_updated": "2021-02-03T16:26:34.662251+00:00",
            "context": {
                "id": "510cacf3ed55726a9da9fda69e2ed117",
                "parent_id": null,
                "user_id": null
            }
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-02-03T16:26:34.662251+00:00",
    "context": {
        "id": "510cacf3ed55726a9da9fda69e2ed117",
        "parent_id": null,
        "user_id": null
    }
}

So on that information, i tried creating an automation with this code but no matter what i do or change i cant get it to trigger. I think its something stupid but i’ve ran out of ideas.

alias: Test Switch
description: ''
trigger:
  - platform: event
    event_data:
      entity_id: sensor.sonoff_a480003d75
      old_state: single
      new_state: null
    event_type: state_changed
    context: {}
condition: []
action:
  - type: turn_on
    device_id: 22be2b77afb5fd2a8367f6ef31f43761
    entity_id: light.bfd1e32f8b320afa4aygbm
    domain: light
mode: single

Your help guys would be greatly appreciated.

Michael

Hi Michael, I am also stuck at same place. Have you had any progress ?

Hi there,

I managed to use my sonoff button so I can control (toggle) 3 items, but I created 3 separate files for that.
I hoped that I could integrate it into 1 file, but nevertheless this works
(I have my automations in a separate folder : automation jja: !include_dir_list …/automations)

My files :
hk_schakelaar_zithoek_one.yaml

alias: zithoek schakelaar 1 click
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      command: 'toggle'
      device_ieee: 00:12:4b:00:21:35:ae:22

condition: []
action:
  - data: {}
    entity_id: input_boolean.hk_sfeerverlichting
    service: input_boolean.toggle
mode: single

hk_schakelaar_zithoek_double.yaml :

alias: zithoek schakelaar 2 click
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      command: 'on'
      device_ieee: 00:12:4b:00:21:35:ae:22

condition: []
action:
  - data: {}
    entity_id: switch.sonoff_hk_grootlicht_voor
    service: switch.toggle
mode: single

hk_schakelaar_zithoek_long.yaml :

alias: zithoek schakelaar long press
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      command: 'off'
      device_ieee: 00:12:4b:00:21:35:ae:22

condition: []
action:
  - data: {}
    entity_id: switch.sonoff_hk_grootlicht_achter
    service: switch.toggle
mode: single
1 Like