1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-26 20:53:50 +00:00

[binary_sensor] Optimize MultiClickTrigger with FixedVector

This commit is contained in:
J. Nick Koston
2025-10-21 10:50:29 -10:00
parent 8e8a2bde95
commit 9e693335b6
2 changed files with 70 additions and 4 deletions

View File

@@ -70,3 +70,69 @@ binary_sensor:
- delay: 10s
time_off: 200ms
time_on: 800ms
# Test on_multi_click with single click
- platform: template
id: multi_click_single
name: "Multi Click Single"
on_multi_click:
- timing:
- state: true
min_length: 50ms
max_length: 350ms
then:
- logger.log: "Single click detected"
# Test on_multi_click with double click
- platform: template
id: multi_click_double
name: "Multi Click Double"
on_multi_click:
- timing:
- state: true
min_length: 50ms
max_length: 350ms
- state: false
min_length: 50ms
max_length: 350ms
- state: true
min_length: 50ms
max_length: 350ms
then:
- logger.log: "Double click detected"
# Test on_multi_click with complex pattern (5 events)
- platform: template
id: multi_click_complex
name: "Multi Click Complex"
on_multi_click:
- timing:
- state: true
min_length: 50ms
max_length: 350ms
- state: false
min_length: 50ms
max_length: 350ms
- state: true
min_length: 50ms
max_length: 350ms
- state: false
min_length: 50ms
max_length: 350ms
- state: true
min_length: 50ms
then:
- logger.log: "Complex pattern detected"
# Test on_multi_click with custom invalid_cooldown
- platform: template
id: multi_click_cooldown
name: "Multi Click Cooldown"
on_multi_click:
- timing:
- state: true
min_length: 100ms
max_length: 500ms
invalid_cooldown: 2s
then:
- logger.log: "Click with custom cooldown"