esphome / esphome/feature-requests

on_long_click/on_long_release

Open
#472 1 comment 1 reaction 0 assignees View on GitHub
component: binary_sensor
Dominant language
No language data
Stars
450
Forks
29
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem you have/What new integration you would like**
Similar to on_press/on_release, but with a min_length after which the trigger fires, and then fires an on_long_release when released.

**Please describe your use case for this integration and alternatives you've tried:**
I'd like to trigger events when the button is held down for at least a fixed period of time. The following work-around works OK, but it's pretty verbose:
```yaml
binary_sensor:
- platform: gpio
name: "Touch ${id} Button 1"
id: button0
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
on_click:
then:
- switch.toggle: relay0
on_multi_click:
- timing:
- ON for at least 1s
then:
- homeassistant.event:
event: esphome.click
data:
click_type: long_click_press
entity_id: !lambda 'return ("binary_sensor." + id(button0).get_object_id()).c_str();'
- timing:
- ON for at least 1s
- OFF for at least 0.2s
then:
- homeassistant.event:
event: esphome.click
data:
click_type: long_click_release
entity_id: !lambda 'return ("binary_sensor." + id(button0).get_object_id()).c_str();'
```

**Additional context**
Looking for parity with the Xiaomi Binary Sensors.
https://www.home-assistant.io/integrations/binary_sensor.xiaomi_aqara/

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.