Sonoff SNZB-01P Automation single, double, long press missing

I have a Sonoff SNZB-01P Zigbee button, and I’m using it with the Sonoff Zigbee Bridge Pro. I first paired the button using the eWeLink app, and then integrated it into Home Assistant using the SonoffLAN integration.

The device shows up in Home Assistant, but when I try to create an automation, I can only use battery status as a trigger — there are no options for button presses (single, double, long press, etc).

Is there any way to capture button press events using SonoffLAN and the Zigbee Bridge Pro?

Show us the device view. And I would use the device trigger, rather state trigger. So please check if your device has a action or event or any other entity in the device (give us screen)


here

I believe you have to make a trigger on the “SNZB-01P” sensor.
How does this entity change state if you press the button physically?

When I press the button, it appears in the Home Assistant logbook as ‘SNZB-01P changed to single’.

OK this looks exactly as you would want to.

Make an automation and as a trigger use entity, not device.

This is how I have it for SNZB-01 (non-P version)

triggers:
  - trigger: state
    entity_id:
      // here change the entity to your one
      - event.bathroom_washing_machine_button_action
    attribute: event_type
    to: single
conditions:
actions:
  ... my actions here
mode: single

But I use the Zigbee2MQTT without Sonoff bridge, so you need to inspect your device.

“Alright, I was able to get a trigger from the button this way. But there’s only a single trigger for single, double, and hold presses. Is there a way to handle this?”

Use an entity-based State trigger, not a Device trigger.

triggers:
  - trigger: state
    entity_id: sensor.snzb_01p #or whatever your actual entity ID is

Use Conditions (also known as “And If” in the Automation editor). You will need to use a Template condition like:

conditions:
  - alias: Check if it was a single press.
    condition: template
    value_template: "{{ trigger.to_state.state == 'single' }}"

If you want, you could use the conditions within a Choose action instead of in the general Condition block, so that one automation covers all the different button press types.

You can have an automation with multiple triggers and then use the trigger id in the automation to detect which one it was.

i use this yaml for single double and long press:

alias: Bedroom button
description: ""
triggers:
  - domain: mqtt
    device_id: a31f819c41c37795d15d6fc21e627ae6
    type: action
    subtype: single
    metadata: {}
    trigger: device
    id: single
  - domain: mqtt
    device_id: a31f819c41c37795d15d6fc21e627ae6
    type: action
    subtype: double
    metadata: {}
    trigger: device
    id: double
  - domain: mqtt
    device_id: a31f819c41c37795d15d6fc21e627ae6
    type: action
    subtype: long
    metadata: {}
    trigger: device
    id: long
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - single
        sequence:
          - type: toggle
            device_id: 7d79d9bf232561f84aca82b03ce5cb37
            entity_id: 4c1c05ba98ba64a2345a3adbd3e0166b
            domain: light
      - conditions:
          - condition: trigger
            id:
              - double
        sequence:
          - action: fan.toggle
            metadata: {}
            data: {}
            target:
              entity_id: fan.bedroom_fan
      - conditions:
          - condition: trigger
            id:
              - long
        sequence:
          - type: turn_off
            device_id: 49cc237088c38bea9e33b326a237ec56
            entity_id: 09a1100b39a98ce6a7c9385bfa636529
            domain: light
          - type: turn_off
            device_id: e335f5bfd523758512c066f102cd45a5
            entity_id: 6a754bfb753fa427fc6668c86fa474a7
            domain: light
          - type: turn_off
            device_id: 3bc61405a74f1d126952b402691fb3b0
            entity_id: 0303c66399c0bf32fa268e28d2a2d3c6
            domain: light
mode: single

For you to read: Why and how to avoid device_ids in automations and scripts

Save yourself the hassle of writing the automation yourself. Someone has already made a blueprint (two, actually) for this.

Pick whichever one you like most: