Sonoff switch SNZB-01 (Zigbee) is missing entities

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

Thanks Jeffrey,

The problem i have though the entity is not showing as a ZHA event but as a state changed event instead. I’m thinking the only way around this may be to flash my sonoff bridge with tasmota and see if this would make any difference.

Michael

It’s difficult to choose the best option, because there are many. I eventually chose for the conbee 2 stick with ZHA.
I also have a sonoff zigbee bridge witch now I have disconnected

ok, made some progress. I may have to write 3 separate automations I believe.

Below is working automation for “Single” press.

I read in blogs that switch press is not an entity, just an event. But somhow state status is retained in the entity of switch (which only has battery and friendly name otherwise).

There is templating, but that is not something i will be able to do.

Conditional actions also failed (probably because I do not now how to write them properly) .

But i think I got a start, its time for HA geniuses to jump in

alias: New Automation
description: ‘’
trigger:

  • platform: event
    event_type: state_changed
    event_data:
    entity_id: sensor.sonoff_a440002d17
    condition:
  • condition: or
    conditions:
    • condition: state
      entity_id: sensor.sonoff_a440002d17
      state: single
      action:
  • service: climate.turn_on
    data: {}
    entity_id: climate.daikin_ac
    mode: single
1 Like

I just got one of these, added to ZHA and was trying to find 'triggers` like my lumi.sensor_switch added:

Trigger:
"remote_button_short_press" button pressed

and Google sent me to this thread.
I listened to events, created an automation which works but I heard another device relay clicking. Somehow, this new button is triggering this device by itself without any automations…

I also added a sonoff zigbee button to ZHA, as via the sonoff integration I could only use single press.

But, since adding to HA through ZHA, I used this blueprint, which works perfectly

I use conbee too. I configered the same way. I can click to each automatisation and its working perfectly. When I press the snzb-0, it starts turn-on two lights at the same time, toggles between the two lights. Only the third light (3 sec hold) works correctly. I have no idea why.

I’m using conbee 2 without the sonoff bridge. Personally, I don’t use the ZHA integration, I’m using deCONz and sensing the button presses from deconz_events referencing the unique_id of the switch.
And using the event number to differentiate toggle, on or hold.

1002 is single click
1004 is double click (On)
1003 is 3 sec hold

For Example, I have a switch under my coffee table to control different lights and scenes.

I have 1 automation for each type of action (toggle, on, hold)
In this example of one of my automations I am using the single press (toggle) code of 1002 as the trigger portion of the automation;

` alias: Coffee Table Button (Single)
description: ‘’
trigger:

  • platform: event
    event_type: deconz_event
    event_data:
    unique_id: 00:12:4b:00:22:41:96:2c
    event: 1002
    condition: []
    action:
  • service: light.toggle
    data: {}
    entity_id: light.lounge_light
    mode: single`

Hope this helps

Thanks a lot. I’m using only the conbee 2 too.
This is my double click, to switch on a plug. it’s only not correct working with the snbzb-01.

alias: snzb-01 2 x
description: ‘’
trigger:

  • platform: event
    event_type: deconz_event
    event_data:
    unique_id: ‘00:12:4b:00:22:41:99:b8’
    event: 1004
    condition: []
    action:
  • type: toggle
    device_id: fefdcbd9e535db03c058589322361fe4
    entity_id: switch.on_off_plug_in_unit_4
    domain: switch
    mode: single

Hmmmmmm. Try this and see if it makes a difference;

alias: snzb-01 2 x
description: ‘’
trigger:

  • platform: event
    event_type: deconz_event
    event_data:
    unique_id: ‘00:12:4b:00:22:41:99:b8’
    event: 1004
    condition: []
    action:
  • service: switch.toggle
    data: {}
    entity_id: switch.on_off_plug_in_unit_4
    mode: single

Thanks. Here, what happens:
I have 2 Zigbee Plugs, 1 WiFi-Plug and 1 Zigbee Light
I defined the 3 Plugs.
when I press 1 x --> Light and Plug 1 turns on/off
when I press 2 x --> Light and Plug1, Plug 2 turns on, pressing 2 x again, plug 2 turns off
long press --> Plug 3 turns on/off (WiFi Tuya)

alias: snzb-01 1 x
description: ‘’
trigger:

  • platform: event
    event_type: deconz_event
    event_data:
    unique_id: ‘00:12:4b:00:22:41:99:b8’
    event: 1002
    condition: []
    action:
  • service: switch.toggle
    data: {}
    entity_id: switch.on_off_plug_in_unit_4
    mode: single

alias: snzb-01 2 x
description: ‘’
trigger:

  • platform: event
    event_type: deconz_event
    event_data:
    unique_id: ‘00:12:4b:00:22:41:99:b8’
    event: 1004
    condition: []
    action:
  • service: switch.toggle
    data: {}
    entity_id: switch.on_off_plug_in_unit_5
    mode: single

alias: snzb-01 lang
description: ‘’
trigger:

  • platform: event
    event_type: deconz_event
    event_data:
    unique_id: ‘00:12:4b:00:22:41:99:b8’
    event: 1003
    condition: []
    action:
  • type: toggle
    device_id: 6b577c65c9a53a31ab0d83790d02caa0
    entity_id: switch.bf4498502c208aed8apwfv
    domain: switch
    mode: single

Thank you man !

I’m using SNZB-01 paired with sonoff zigbee bridge. Using sonoffLAN by AlexxIT give me ‘single’, ‘double’ and ‘hold’ state. It works great.

1 Like

just use blueprint , search for ZHA Sonoff Zigbee Switch ,add to your blueprint and make a new automation.

I’ve created quirk for this device. It’s currently waiting for merge. You can use it as custom quirk if you don’t want to wait: https://github.com/zigpy/zha-device-handlers/pull/1003

Guys … I’ve added the switch trough the sonoff gateway and then found it in HA with Sonoff Lan.
When I listen to all events (*) and I press the button, I got this feedback:

{
    "event_type": "state_changed",
    "data": {
        "entity_id": "sensor.sonoff_a48000919d",
        "old_state": {
            "entity_id": "sensor.sonoff_a48000919d",
            "state": "single",
            "attributes": {
                "friendly_name": "Switch1"
            },
            "last_changed": "2021-11-08T17:50:25.240460+00:00",
            "last_updated": "2021-11-08T17:50:25.240460+00:00",
            "context": {
                "id": "6fc782a8cd881b842a0045719c6207d3",
                "parent_id": null,
                "user_id": null
            }
        },
        "new_state": {
            "entity_id": "sensor.sonoff_a48000919d",
            "state": "",
            "attributes": {
                "friendly_name": "Switch1"
            },
            "last_changed": "2021-11-08T17:50:25.753798+00:00",
            "last_updated": "2021-11-08T17:50:25.753798+00:00",
            "context": {
                "id": "9814ffa0172a4452dbc6eab87e3721c7",
                "parent_id": null,
                "user_id": null
            }
        }
    },
    "origin": "LOCAL",
    "time_fired": "2021-11-08T17:50:25.753798+00:00",
    "context": {
        "id": "9814ffa0172a4452dbc6eab87e3721c7",
        "parent_id": null,
        "user_id": null
    }
}

Any idea of how to use this in an automation?
I’m really desperate!!

Thanks
Luca

thanks for sharing !

Thanks @SteveM363! Newish to HA, and your comment led me to install Node-Red. After a bit of familiarisation with it, I managed to quickly get my Sonoff switch working with all command types.
If anyone else finds this via google, this was pretty straightforward, and Node-Red looks amazing for automation.

1 Like

Hi there. Coming a bit late to the party but here we go:

I just flashed a sonoff zbbridge and added the ZHA integration. I have a few sonoff zb devices: plug, temperature sensor, motion sensor and button. I get all the right entities in HA but I only get the battery status for the button.

I think I shouldn’t have used the ZHA integration. After all, I am controlling all my other devices (wifi mostly) via MQTT.

The documentaiton saids:

" you cannot use any Zigbee commands in Tasmota console in this mode. All setup needs to be done from Home Assistant ZHA integration."

How do I disable ZHA and enable the zigbee events broadcasting on MQTT? I basically want to control my zigbee devices via MQTT. If I get that working, then it is very easy to setup inside HA via the MQTT integration.

Thank you,
-drd

Hi everyone,

Just letting you know that I ended up using Chad’s approach: finding the ieee of the device and then using that in the automation.

Thank you.