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