Files
smart-domofon/ge1mer/esphome/packages/binary_sensor.yaml
Nikolay Vasilchuk 317c4a89a4 8 clicks small fix
2022-10-28 15:36:47 +03:00

120 lines
3.6 KiB
YAML

binary_sensor:
# Call detection
- platform: gpio
name: "${board_name} incoming call"
id: incoming_call
device_class: sound
pin:
number: $pin_call_detect
mode: INPUT_PULLUP
inverted: True
filters:
- delayed_on: $call_start_detect_delay
- delayed_off: $call_end_detect_delay
on_press:
then:
script.execute: state_call
# Accept HW button
- platform: gpio
name: "${board_name} button"
id: button_hw
pin:
number: $pin_btn_accept
mode: INPUT
inverted: True
filters:
delayed_on: 25ms
on_multi_click:
# Double click - mute mode
- timing:
- ON for at most $short_click_time_to
- OFF for at most $short_click_time_to
- ON for $short_click_time_from to $short_click_time_to
- OFF for at least 200ms
then:
lambda: |-
ESP_LOGD("main", "Double Click");
if (!id(incoming_call).state) {
if (id(mode_mute_once)) {
id(mode_mute) = true;
id(mode_mute_once) = false;
} else {
id(mode_mute) = false;
id(mode_mute_once) = true;
}
}
# Long click - disable auto opening and mute
- timing:
- ON for at least $short_click_time_to
then:
lambda: |-
ESP_LOGD("main", "Single Long Click");
if (id(incoming_call).state) {
id(last_action).publish_state("reject_hw");
id(call_reject).execute();
} else {
id(mode_auto_open) = false;
id(mode_auto_open_once) = false;
id(mode_auto_reject) = false;
id(mode_mute) = false;
id(mode_mute_once) = false;
}
# Short click - open door or enable once auto opening
- timing:
- ON for at most $short_click_time_to
- OFF for at least 500ms
then:
lambda: |-
ESP_LOGD("main", "Single Short Click");
if (id(incoming_call).state) {
id(last_action).publish_state("open_hw");
id(call_accept).execute();
} else {
if (id(mode_auto_open_once)) {
id(mode_auto_open) = true;
id(mode_auto_open_once) = false;
id(mode_auto_reject) = false;
} else if (id(mode_auto_open)) {
id(mode_auto_open) = false;
id(mode_auto_open_once) = false;
id(mode_auto_reject) = true;
} else {
id(mode_auto_open) = false;
id(mode_auto_open_once) = true;
id(mode_auto_reject) = false;
}
}
# 8 clicks - forget wifi settings
- timing:
- ON for 5ms to 1s
- OFF for 5ms to 1s
- ON for 5ms to 1s
- OFF for 5ms to 1s
- ON for 5ms to 1s
- OFF for 5ms to 1s
- ON for 5ms to 1s
- OFF for 5ms to 1s
- ON for 5ms to 1s
- OFF for 5ms to 1s
- ON for 5ms to 1s
- OFF for 5ms to 1s
- ON for 5ms to 1s
- OFF for 5ms to 1s
- ON for 5ms to 1s
then:
lambda: |-
ESP_LOGW("DMF", "Erase settings and restart...");
id(mode_auto_open) = false;
id(mode_auto_open_once) = false;
id(mode_auto_reject) = false;
id(mode_mute) = false;
id(mode_mute_once) = false;
#ifdef USE_CAPTIVE_PORTAL
wifi::global_wifi_component->save_wifi_sta("-----", "");
#endif
App.safe_reboot();