I just created my first blueprint for those very cheap single buttons identified as TS004F using the ZHA integration. Manufacturer is TZ3000_ja5osu5g and it is sold as eWeLink ZB-K1.
It supports:
Single press
Double press
Long press
It works by listening specifically to the press_type command sent by the device and filters out the extra noise from other events like toggle or remote_button_short_press.
Let me know what you think, and feel free to suggest improvements.
blueprint:
name: ZHA - 1-Button (TS004F)
description: |
Handle single, double and long presses from 1-button devices identified as TS004F button using ZHA.
domain: automation
input:
remote:
name: TS004F 1-Button Device
description: Select the TS004F 1-button
selector:
device:
integration: zha
model: TS004F
single_press_action:
name: Single Press
description: Action to run on single press
default: []
selector:
action: {}
double_press_action:
name: Double Press
description: Action to run on double press
default: []
selector:
action: {}
long_press_action:
name: Long Press
description: Action to run on long press
default: []
selector:
action: {}
mode: single
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input remote
command: press_type
action:
- variables:
press_type: "{{ trigger.event.data.args[0] | int }}"
- choose:
- conditions:
- condition: template
value_template: "{{ press_type == 0 }}"
sequence: !input single_press_action
- conditions:
- condition: template
value_template: "{{ press_type == 1 }}"
sequence: !input double_press_action
- conditions:
- condition: template
value_template: "{{ press_type == 2 }}"
sequence: !input long_press_action
Very nice! I tried to use the long press function to change the brightness, but that long_press event is just too short to make sense for changing brightness significantly (changed just about 10% or so)
So I got carried away a bit and did the following:
short_press: switch on or off (toggle)
double_press: increase brightness in 4 steps
long_press: decrease brightness in 4 steps
for the increase and decrease I used a scripts and a helper, but see yourself: