ZHA - Tuya Smart Button TS004F (single)

I bought one of these buttons (Tuya Smart Button / Tuya_ZG-101ZL / TS004F), but the blueprint published by @lehenandmartin in this post gave me an error message. Inspired by the posts in that thread, I made my own blueprint, which lets you create an automation

  • selecting the button
  • setting actions for the three types of presses: single, double, long press
blueprint:
  name: TS004F Zigbee Button (ZHA)
  description: "Use TS004F Zigbee single button (single/double/long press) as trigger for your automations"
  domain: automation
  input:
    zigbee_button:
      name: TS004F 1-Button Device
      description: Select the TS004F single button
      selector:
        device:
          integration: zha
          model: TS004F
          multiple: false
    toggle_action:
      name: Single press action
      description: "Action for 'single press' command (default: do nothing)"
      default: []
      selector:
        action: {}
    on_action:
      name: Double press action
      description: "Action for 'double press' command (default: do nothing)"
      default: []
      selector:
        action: {}
    off_action:
      name: Long press action
      description: "Action for 'long press' command (default: do nothing)"
      default: []
      selector:
        action: {}

triggers:
  - trigger: event
    event_type: zha_event
    event_data:
      device_id: !input zigbee_button
      command: toggle
  - trigger: event
    event_type: zha_event
    event_data:
      device_id: !input zigbee_button
      command: "on"
  - trigger: event
    event_type: zha_event
    event_data:
      device_id: !input zigbee_button
      command: "off"

action:
  - variables:
      command: "{{ trigger.event.data.command | string }}"
  - choose:
      - conditions:
          - "{{ command == 'toggle' }}"
        sequence: !input toggle_action
      - conditions:
          - "{{ command == 'on' }}"
        sequence: !input on_action
      - conditions:
          - "{{ command == 'off' }}"
        sequence: !input off_action

mode: single

Install Blueprint

1 Like

Hello Jonyivy,
Welcome to the Home Assistant Forum!

Thanks for contributing to the community with a new Blueprint.

I have a suggestion for you. Many people who are not familiar with directory structures will have problems installing this without the Home Assistant MY tools.

Adding a MY link for this Blueprint to your top post would help them a lot.
Here is the link to make that.
Create a link – My Home Assistant

You need to be a trust level ‘member’ to edit a post. Understanding Discourse Trust Levels