Zigbee2MQTT - Tuya TS0041 Scene Switch (Event Entity Support)

Hi everyone,

I created a blueprint for the Tuya TS0041 (1-Button Scene Switch) specifically for Zigbee2MQTT users who have enabled the new experimental_event_entities option.

Unlike older blueprints that rely on sensor state changes, this one uses the modern event entity domain (e.g., event.my_button_action), which is faster and cleaner.

Requirements:

  • Zigbee2MQTT
  • Setting experimental_event_entities: true in your Z2M configuration.

Supports:

  • Single Press
  • Double Press
  • Long Press (Hold)

Click the badge to import:

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint URL.

Or copy the code manually:

blueprint:
  name: Z2M - Tuya TS0041 Scene Switch (Event Entity)
  description: >
    Automate your Tuya TS0041 1-Button Scene Switch using Zigbee2MQTT.
    
    IMPORTANT: This blueprint requires 'experimental_event_entities: true' to be set in your Zigbee2MQTT configuration.
    It uses the modern 'event' entity domain (e.g., event.my_button_action) instead of the legacy sensor or device triggers.
  domain: automation
  input:
    switch_entity:
      name: Event Entity
      description: The event entity of the button (usually starts with 'event.' and ends with '_action').
      selector:
        entity:
          domain: event
          integration: mqtt
    action_single:
      name: Single Press
      description: Action to run on a single press.
      default: []
      selector:
        action: {}
    action_double:
      name: Double Press
      description: Action to run on a double press.
      default: []
      selector:
        action: {}
    action_hold:
      name: Long Press (Hold)
      description: Action to run on a long press.
      default: []
      selector:
        action: {}

mode: restart
max_exceeded: silent

trigger:
  - platform: state
    entity_id: !input switch_entity
    # Triggers on every state update of the event entity

action:
  - variables:
      event_type: "{{ trigger.to_state.attributes.event_type }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ event_type == 'single' }}"
        sequence: !input action_single
      - conditions:
          - condition: template
            value_template: "{{ event_type == 'double' }}"
        sequence: !input action_double
      - conditions:
          - condition: template
            value_template: "{{ event_type == 'hold' }}"
        sequence: !input action_hold

This works great for me, except the long press / hold. I see the long press getting accepted in MQTT so I know I’m doing that correctly (and it gets logged). No matter what action I put for hold / long press in this scene switch doesn’t happen though. single and double press work fine. any ideas?

I think long press did not work, because it is for the pairing mode.