various esphome changes
This commit is contained in:
77
esphome/common/multiclick_pushbutton_common.yaml
Normal file
77
esphome/common/multiclick_pushbutton_common.yaml
Normal file
@@ -0,0 +1,77 @@
|
||||
substitutions:
|
||||
local_gpioinvert: "True"
|
||||
local_singleclick_duration: "300000" # 5 minutes in ms
|
||||
# local_doubleclick_duration: "1800000" # 30 minutes in ms
|
||||
# local_tripleclick_duration: "7200000" # 2 hours in ms
|
||||
|
||||
#globals:
|
||||
# - id: single_click_delay
|
||||
# type: long
|
||||
# restore_value: no
|
||||
# initial_value: ${local_singleclick_duration}
|
||||
# - id: double_click_delay
|
||||
# type: long
|
||||
# restore_value: no
|
||||
# initial_value: ${local_doubleclick_duration}
|
||||
# - id: triple_click_delay
|
||||
# type: long
|
||||
# restore_value: no
|
||||
# initial_value: ${local_tripleclick_duration}
|
||||
|
||||
binary_sensor:
|
||||
- platform: gpio
|
||||
pin:
|
||||
number: ${local_gpio}
|
||||
mode: INPUT
|
||||
inverted: ${local_gpioinvert}
|
||||
name: ${local_name}
|
||||
on_multi_click:
|
||||
# Single Click: one press (short press/release)
|
||||
- timing:
|
||||
- ON for at most 1s
|
||||
- OFF for at least 0.5s
|
||||
then:
|
||||
- lambda: |-
|
||||
if (id(Relay_3).state) {
|
||||
ESP_LOGD("button3", "Single click: Relay_3 is on, turning it off.");
|
||||
id(Relay_3).turn_off();
|
||||
} else {
|
||||
ESP_LOGD("button3", "Single click: Relay_3 is off, turning it on for %d ms.", id(single_click_delay));
|
||||
id(Relay_3).turn_on();
|
||||
delay(id(single_click_delay));
|
||||
id(Relay_3).turn_off();
|
||||
}
|
||||
# # Double Click: two quick press/release cycles
|
||||
# - timing:
|
||||
# - ON for at most 1s
|
||||
## - OFF for at most 1s
|
||||
# - ON for at most 1s
|
||||
# - OFF for at least 0.5s
|
||||
# then:
|
||||
# - lambda: |-
|
||||
# ESP_LOGD(${local_gpio}, "Double click detected: turning ",${local_relay_id}," on for %d ms.", ${local_doubleclick_duration});
|
||||
## ${local_relay_id}->turn_on();
|
||||
# delay(${local_doubleclick_duration});
|
||||
# ${local_relay_id}->turn_off();
|
||||
# # Triple Click: three quick press/release cycles
|
||||
## - timing:
|
||||
# - ON for at most 1s
|
||||
## - OFF for at most 1s
|
||||
# - ON for at most 1s
|
||||
# - OFF for at most 1s
|
||||
# - ON for at most 1s
|
||||
# - OFF for at least 0.5s
|
||||
# then:
|
||||
# - lambda: |-
|
||||
# ESP_LOGD(${local_gpio}, "Triple click detected: turning ",${local_relay_id}," on for %d ms.", ${local_tripleclick_duration});
|
||||
# ${local_relay_id}->turn_on();
|
||||
# delay(${local_tripleclick_duration});
|
||||
# ${local_relay_id}->turn_off();
|
||||
# # Hold: button held for at least 4 seconds
|
||||
# - timing:
|
||||
# - ON for at least 4s
|
||||
|
||||
## then:
|
||||
# - lambda: |-
|
||||
# ESP_LOGD(${local_gpio}, "Hold detected: turning ",${local_relay_id}," on indefinitely.");
|
||||
# ${local_relay_id}->turn_on();
|
Reference in New Issue
Block a user