mirror of
https://github.com/Anonym-tsk/smart-domofon.git
synced 2025-12-06 03:26:58 +03:00
Performance optimizations
This commit is contained in:
@@ -7,12 +7,19 @@ esphome:
|
||||
esp8266_restore_from_flash: true
|
||||
project:
|
||||
name: "espdomofon.ru"
|
||||
version: "1.6.1"
|
||||
version: "1.6.2"
|
||||
platformio_options:
|
||||
build_flags: -DBEARSSL_SSL_BASIC -DMMU_IRAM_SIZE=0xC000 -DMMU_ICACHE_SIZE=0x4000 -DMMU_IRAM_HEAP
|
||||
on_boot:
|
||||
priority: -100
|
||||
then:
|
||||
- script.execute: state_ready
|
||||
- script.execute: state_no_call
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
effect: "Domofon"
|
||||
|
||||
dashboard_import:
|
||||
package_import_url: github://Anonym-tsk/smart-domofon/blob/master/ge1mer/domofon.yaml
|
||||
|
||||
wifi:
|
||||
ssid: $wifi_ssid
|
||||
|
||||
@@ -13,9 +13,6 @@ binary_sensor:
|
||||
on_press:
|
||||
then:
|
||||
script.execute: state_call
|
||||
on_release:
|
||||
then:
|
||||
script.execute: state_no_call
|
||||
|
||||
# Accept HW button
|
||||
- platform: gpio
|
||||
@@ -35,62 +32,56 @@ binary_sensor:
|
||||
- ON for $short_click_time_from to $short_click_time_to
|
||||
- OFF for at least 200ms
|
||||
then:
|
||||
- logger.log: "Double Click"
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_off: incoming_call
|
||||
then:
|
||||
lambda: |-
|
||||
if (id(mode_mute_once)) {
|
||||
id(mode_mute) = true;
|
||||
id(mode_mute_once) = false;
|
||||
} else {
|
||||
id(mode_mute) = false;
|
||||
id(mode_mute_once) = true;
|
||||
}
|
||||
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:
|
||||
- logger.log: "Single Long Click"
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_on: incoming_call
|
||||
then:
|
||||
script.execute: call_reject
|
||||
else:
|
||||
- lambda: |-
|
||||
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;
|
||||
- delay: 10ms
|
||||
- script.execute: led_blink_blue_once
|
||||
lambda: |-
|
||||
ESP_LOGD("main", "Single Long Click");
|
||||
if (id(incoming_call).state) {
|
||||
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:
|
||||
- logger.log: "Single Short Click"
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_on: incoming_call
|
||||
then:
|
||||
script.execute: call_accept
|
||||
else:
|
||||
lambda: |-
|
||||
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;
|
||||
}
|
||||
lambda: |-
|
||||
ESP_LOGD("main", "Single Short Click");
|
||||
if (id(incoming_call).state) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
# - <<: !include includes/binary_sensor.captive.yaml
|
||||
|
||||
@@ -7,23 +7,23 @@ button:
|
||||
name: "${board_name} accept call"
|
||||
icon: "mdi:door-open"
|
||||
on_press:
|
||||
if:
|
||||
condition:
|
||||
binary_sensor.is_on: incoming_call
|
||||
then:
|
||||
script.execute: call_accept
|
||||
else:
|
||||
logger.log: "No incoming call"
|
||||
then:
|
||||
lambda: |-
|
||||
if (id(incoming_call).state) {
|
||||
id(call_accept).execute();
|
||||
} else {
|
||||
ESP_LOGD("main", "No incoming call");
|
||||
}
|
||||
|
||||
# Reject call
|
||||
- platform: template
|
||||
name: "${board_name} reject call"
|
||||
icon: "mdi:door-closed-lock"
|
||||
on_press:
|
||||
if:
|
||||
condition:
|
||||
binary_sensor.is_on: incoming_call
|
||||
then:
|
||||
script.execute: call_reject
|
||||
else:
|
||||
logger.log: "No incoming call"
|
||||
then:
|
||||
lambda: |-
|
||||
if (id(incoming_call).state) {
|
||||
id(call_reject).execute();
|
||||
} else {
|
||||
ESP_LOGD("main", "No incoming call");
|
||||
}
|
||||
|
||||
@@ -9,118 +9,116 @@ light:
|
||||
id: rgb_led
|
||||
name: "${board_name} led"
|
||||
internal: true
|
||||
restore_mode: ALWAYS_OFF
|
||||
restore_mode: ALWAYS_ON
|
||||
default_transition_length: 0ms
|
||||
red: led_red
|
||||
green: led_green
|
||||
blue: led_blue
|
||||
effects:
|
||||
- automation:
|
||||
name: "Blink Blue"
|
||||
sequence:
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 40%
|
||||
blue: 100%
|
||||
- delay: 200ms
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: 1%
|
||||
red: 0%
|
||||
green: 40%
|
||||
blue: 100%
|
||||
- delay: 2800ms
|
||||
- automation:
|
||||
name: "Blink Green"
|
||||
sequence:
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
- delay: 200ms
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: 1%
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
- delay: 2800ms
|
||||
- automation:
|
||||
name: "Blink Red"
|
||||
sequence:
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
- delay: 200ms
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: 1%
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
- delay: 2800ms
|
||||
- automation:
|
||||
name: "Red Blink Blue"
|
||||
sequence:
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
- delay: 2800ms
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 40%
|
||||
blue: 100%
|
||||
- delay: 200ms
|
||||
- automation:
|
||||
name: "Green Blink Blue"
|
||||
sequence:
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
- delay: 2800ms
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 40%
|
||||
blue: 100%
|
||||
- delay: 200ms
|
||||
- automation:
|
||||
name: "Blink Green Blue"
|
||||
sequence:
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
- delay: 200ms
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 40%
|
||||
blue: 100%
|
||||
- delay: 200ms
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: 1%
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
- delay: 2600ms
|
||||
- lambda:
|
||||
name: "Domofon"
|
||||
update_interval: 200ms
|
||||
lambda: |-
|
||||
static int tick = 0;
|
||||
static bool old_incoming = false;
|
||||
static bool old_mute = false;
|
||||
static bool old_mute_once = false;
|
||||
static bool old_auto_open = false;
|
||||
static bool old_auto_open_once = false;
|
||||
static bool old_auto_reject = false;
|
||||
|
||||
float brigtness = id(led_brightness).state / 10;
|
||||
|
||||
bool incoming = id(incoming_call).state;
|
||||
bool mute = id(mode_mute);
|
||||
bool mute_once = id(mode_mute_once);
|
||||
bool auto_open = id(mode_auto_open);
|
||||
bool auto_open_once = id(mode_auto_open_once);
|
||||
bool auto_reject = id(mode_auto_reject);
|
||||
|
||||
const bool state_updated = incoming != old_incoming
|
||||
|| mute != old_mute
|
||||
|| mute_once != old_mute_once
|
||||
|| auto_open != old_auto_open
|
||||
|| auto_open_once != old_auto_open_once
|
||||
|| auto_reject != old_auto_reject;
|
||||
|
||||
auto call = id(rgb_led).turn_on();
|
||||
|
||||
if (initial_run || state_updated) {
|
||||
tick = 0;
|
||||
}
|
||||
|
||||
if (tick == 0) {
|
||||
if (incoming || auto_reject) {
|
||||
call.set_rgb(1.0, 0.0, 0.0); // red
|
||||
call.set_brightness(brigtness);
|
||||
} else if (mute && auto_open_once) {
|
||||
call.set_rgb(0.0, 0.4, 1.0); // blue
|
||||
call.set_brightness(brigtness);
|
||||
} else if (auto_open || auto_open_once) {
|
||||
call.set_rgb(0.0, 1.0, 0.0); // green
|
||||
call.set_brightness(brigtness);
|
||||
} else if (mute || mute_once) {
|
||||
call.set_rgb(0.0, 0.4, 1.0); // blue
|
||||
call.set_brightness(brigtness);
|
||||
} else {
|
||||
call.set_brightness(0.01);
|
||||
}
|
||||
} else if (tick == 1) {
|
||||
if (incoming) {
|
||||
call.set_brightness(0.01);
|
||||
} else if (mute && auto_open_once) {
|
||||
call.set_rgb(0.0, 1.0, 0.0); // green
|
||||
call.set_brightness(brigtness);
|
||||
} else if (mute || mute_once) {
|
||||
if (auto_open || auto_open_once || auto_reject) {
|
||||
call.set_rgb(0.0, 0.4, 1.0); // blue
|
||||
call.set_brightness(brigtness);
|
||||
} else if (mute_once) {
|
||||
call.set_brightness(0.01);
|
||||
}
|
||||
} else if (auto_open) {
|
||||
call.set_rgb(0.0, 1.0, 0.0); // green
|
||||
call.set_brightness(brigtness);
|
||||
} else if (auto_open_once) {
|
||||
call.set_brightness(0.01);
|
||||
} else if (auto_reject) {
|
||||
call.set_rgb(1.0, 0.0, 0.0); // red
|
||||
call.set_brightness(brigtness);
|
||||
} else {
|
||||
call.set_brightness(0.01);
|
||||
}
|
||||
} else if (tick == 2) {
|
||||
if (incoming) {
|
||||
call.set_brightness(0.01);
|
||||
} else if (auto_reject) {
|
||||
call.set_rgb(1.0, 0.0, 0.0); // red
|
||||
call.set_brightness(brigtness);
|
||||
} else if (auto_open) {
|
||||
call.set_rgb(0.0, 1.0, 0.0); // green
|
||||
call.set_brightness(brigtness);
|
||||
} else if (mute) {
|
||||
call.set_rgb(0.0, 0.4, 1.0); // blue
|
||||
call.set_brightness(brigtness);
|
||||
} else {
|
||||
call.set_brightness(0.01);
|
||||
}
|
||||
} else if (tick == 7 && incoming) {
|
||||
call.set_rgb(1.0, 0.0, 0.0); // red
|
||||
call.set_brightness(brigtness);
|
||||
} else if (tick == 8 && incoming) {
|
||||
call.set_brightness(0.01);
|
||||
}
|
||||
|
||||
call.perform();
|
||||
if (++tick == 14) {
|
||||
tick = 0;
|
||||
}
|
||||
|
||||
old_incoming = incoming;
|
||||
old_mute = mute;
|
||||
old_mute_once = mute_once;
|
||||
old_auto_open = auto_open;
|
||||
old_auto_open_once = auto_open_once;
|
||||
old_auto_reject = auto_reject;
|
||||
|
||||
@@ -10,15 +10,6 @@ number:
|
||||
min_value: 0
|
||||
max_value: 10
|
||||
step: 1
|
||||
on_value:
|
||||
then:
|
||||
if:
|
||||
condition:
|
||||
light.is_on: rgb_led
|
||||
then:
|
||||
light.control:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return x > 0 ? x / 10 : 0.01;"
|
||||
|
||||
# Delay before answer call
|
||||
- platform: template
|
||||
|
||||
@@ -10,27 +10,28 @@ script:
|
||||
id(relay_phone).turn_on();
|
||||
id(relay_mute).turn_off();
|
||||
}
|
||||
- output.turn_off: relay_answer
|
||||
id(relay_answer).turn_off();
|
||||
|
||||
# Connected answer resistor
|
||||
- id: state_answer
|
||||
then:
|
||||
- output.turn_on: relay_answer
|
||||
- output.turn_off: relay_phone
|
||||
- output.turn_off: relay_mute
|
||||
- lambda: |-
|
||||
id(relay_answer).turn_on();
|
||||
id(relay_phone).turn_off();
|
||||
id(relay_mute).turn_off();
|
||||
|
||||
# Disconnected all
|
||||
- id: state_open
|
||||
then:
|
||||
- output.turn_off: relay_answer
|
||||
- output.turn_off: relay_phone
|
||||
- output.turn_off: relay_mute
|
||||
- lambda: |-
|
||||
id(relay_answer).turn_off();
|
||||
id(relay_phone).turn_off();
|
||||
id(relay_mute).turn_off();
|
||||
|
||||
# Accept incoming call
|
||||
- id: call_accept
|
||||
then:
|
||||
- logger.log: "Accept call"
|
||||
- script.execute: state_no_call
|
||||
- delay: !lambda "return id(relay_before_answer_delay).state;"
|
||||
- script.execute: state_answer
|
||||
- delay: !lambda "return id(relay_answer_on_time).state;"
|
||||
@@ -51,7 +52,6 @@ script:
|
||||
- id: call_reject
|
||||
then:
|
||||
- logger.log: "Reject call"
|
||||
- script.execute: state_no_call
|
||||
- delay: !lambda "return id(relay_before_answer_delay).state;"
|
||||
- script.execute: state_answer
|
||||
- delay: !lambda "return id(relay_answer_on_time).state;"
|
||||
@@ -64,164 +64,16 @@ script:
|
||||
# data:
|
||||
# entity_uid: $mdns_name
|
||||
|
||||
# No call state
|
||||
- id: state_no_call
|
||||
then:
|
||||
- logger.log: "Set state 'No call'"
|
||||
- lambda: |-
|
||||
if (id(mode_auto_open_once)) {
|
||||
if (id(mode_mute) || id(mode_mute_once)) {
|
||||
id(led_green_and_blue_blink).execute();
|
||||
} else {
|
||||
id(led_blink_green_on).execute();
|
||||
}
|
||||
} else if (id(mode_auto_open)) {
|
||||
if (id(mode_mute) || id(mode_mute_once)) {
|
||||
id(led_green_on_blue_blink).execute();
|
||||
} else {
|
||||
id(led_green_on).execute();
|
||||
}
|
||||
} else if (id(mode_auto_reject)) {
|
||||
if (id(mode_mute) || id(mode_mute_once)) {
|
||||
id(led_red_on_blue_blink).execute();
|
||||
} else {
|
||||
id(led_red_on).execute();
|
||||
}
|
||||
} else if (id(mode_mute)) {
|
||||
id(led_blue_on).execute();
|
||||
} else if (id(mode_mute_once)) {
|
||||
id(led_blink_blue_on).execute();
|
||||
} else {
|
||||
id(led_off).execute();
|
||||
}
|
||||
|
||||
# Call state
|
||||
- id: state_call
|
||||
then:
|
||||
- logger.log: "Set state 'Incoming call'"
|
||||
- lambda: |-
|
||||
if (id(mode_auto_reject)) {
|
||||
id(call_reject).execute();
|
||||
} else if (id(mode_auto_open)) {
|
||||
id(call_accept).execute();
|
||||
} else if (id(mode_auto_open_once)) {
|
||||
id(call_accept).execute();
|
||||
id(mode_auto_open_once) = false;
|
||||
} else {
|
||||
id(led_blink_red_on).execute();
|
||||
}
|
||||
|
||||
# Permanent blink green led
|
||||
- id: led_blink_green_on
|
||||
then:
|
||||
- logger.log: "Led green blink"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
effect: "Blink Green"
|
||||
|
||||
# Permanent blink blue led
|
||||
- id: led_blink_blue_on
|
||||
then:
|
||||
- logger.log: "Led blue blink"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
effect: "Blink Blue"
|
||||
|
||||
# Once blink blue led
|
||||
- id: led_blink_blue_once
|
||||
then:
|
||||
- logger.log: "Led blue once"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 0%
|
||||
blue: 100%
|
||||
transition_length: 100ms
|
||||
- delay: 200ms
|
||||
- script.execute: led_off
|
||||
|
||||
# Permanent on green led
|
||||
- id: led_green_on
|
||||
then:
|
||||
- logger.log: "Led green on"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 100%
|
||||
blue: 0%
|
||||
transition_length: 100ms
|
||||
|
||||
# Permanent blink red led
|
||||
- id: led_blink_red_on
|
||||
then:
|
||||
- logger.log: "Led red blink"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
effect: "Blink Red"
|
||||
|
||||
# Permanent on red led with
|
||||
- id: led_red_on
|
||||
then:
|
||||
- logger.log: "Led red on"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 100%
|
||||
green: 0%
|
||||
blue: 0%
|
||||
transition_length: 100ms
|
||||
|
||||
# Permanent on blue led
|
||||
- id: led_blue_on
|
||||
then:
|
||||
- logger.log: "Led blue on"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
brightness: !lambda "return id(led_brightness).state / 10;"
|
||||
red: 0%
|
||||
green: 40%
|
||||
blue: 100%
|
||||
transition_length: 100ms
|
||||
|
||||
# Permanent on red led and blink blue led
|
||||
- id: led_red_on_blue_blink
|
||||
then:
|
||||
- logger.log: "Led red on blue blink"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
effect: "Red Blink Blue"
|
||||
|
||||
# Permanent on green led and blink blue led
|
||||
- id: led_green_on_blue_blink
|
||||
then:
|
||||
- logger.log: "Led green on blue blink"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
effect: "Green Blink Blue"
|
||||
|
||||
# Blink green and blue leds
|
||||
- id: led_green_and_blue_blink
|
||||
then:
|
||||
- logger.log: "Led green and blue blink"
|
||||
- script.execute: led_off
|
||||
- light.turn_on:
|
||||
id: rgb_led
|
||||
effect: "Blink Green Blue"
|
||||
|
||||
# Turn off leds
|
||||
- id: led_off
|
||||
then:
|
||||
- light.turn_off:
|
||||
id: rgb_led
|
||||
transition_length: 0ms
|
||||
- lambda: |-
|
||||
ESP_LOGD("main", "Incoming call");
|
||||
if (id(mode_auto_reject)) {
|
||||
id(call_reject).execute();
|
||||
} else if (id(mode_auto_open)) {
|
||||
id(call_accept).execute();
|
||||
} else if (id(mode_auto_open_once)) {
|
||||
id(call_accept).execute();
|
||||
id(mode_auto_open_once) = false;
|
||||
}
|
||||
|
||||
@@ -15,15 +15,9 @@ switch:
|
||||
id: mode_auto_open
|
||||
value: 'false'
|
||||
on_turn_on:
|
||||
- globals.set:
|
||||
id: mode_auto_open_once
|
||||
value: 'false'
|
||||
- globals.set:
|
||||
id: mode_auto_reject
|
||||
value: 'false'
|
||||
- script.execute: state_no_call
|
||||
on_turn_off:
|
||||
- script.execute: state_no_call
|
||||
- lambda: |-
|
||||
id(mode_auto_open_once) = false;
|
||||
id(mode_auto_reject) = false;
|
||||
|
||||
# Automatically open door once switch
|
||||
- platform: template
|
||||
@@ -41,15 +35,9 @@ switch:
|
||||
id: mode_auto_open_once
|
||||
value: 'false'
|
||||
on_turn_on:
|
||||
- globals.set:
|
||||
id: mode_auto_open
|
||||
value: 'false'
|
||||
- globals.set:
|
||||
id: mode_auto_reject
|
||||
value: 'false'
|
||||
- script.execute: state_no_call
|
||||
on_turn_off:
|
||||
script.execute: state_no_call
|
||||
- lambda: |-
|
||||
id(mode_auto_open) = false;
|
||||
id(mode_auto_reject) = false;
|
||||
|
||||
# Automatically reject call switch
|
||||
- platform: template
|
||||
@@ -67,15 +55,9 @@ switch:
|
||||
id: mode_auto_reject
|
||||
value: 'false'
|
||||
on_turn_on:
|
||||
- globals.set:
|
||||
id: mode_auto_open
|
||||
value: 'false'
|
||||
- globals.set:
|
||||
id: mode_auto_open_once
|
||||
value: 'false'
|
||||
- script.execute: state_no_call
|
||||
on_turn_off:
|
||||
script.execute: state_no_call
|
||||
- lambda: |-
|
||||
id(mode_auto_open) = false;
|
||||
id(mode_auto_open_once) = false;
|
||||
|
||||
# Mute sound switch
|
||||
- platform: template
|
||||
@@ -93,16 +75,14 @@ switch:
|
||||
id: mode_mute
|
||||
value: 'false'
|
||||
on_turn_on:
|
||||
- globals.set:
|
||||
id: mode_mute_once
|
||||
value: 'false'
|
||||
- output.turn_on: relay_mute
|
||||
- output.turn_off: relay_phone
|
||||
- script.execute: state_no_call
|
||||
- lambda: |-
|
||||
id(mode_mute_once) = false;
|
||||
id(relay_mute).turn_on();
|
||||
id(relay_phone).turn_off();
|
||||
on_turn_off:
|
||||
- output.turn_on: relay_phone
|
||||
- output.turn_off: relay_mute
|
||||
- script.execute: state_no_call
|
||||
- lambda: |-
|
||||
id(relay_phone).turn_on();
|
||||
id(relay_mute).turn_off();
|
||||
|
||||
# Mute sound once switch
|
||||
- platform: template
|
||||
@@ -120,13 +100,11 @@ switch:
|
||||
id: mode_mute_once
|
||||
value: 'false'
|
||||
on_turn_on:
|
||||
- globals.set:
|
||||
id: mode_mute
|
||||
value: 'false'
|
||||
- output.turn_on: relay_mute
|
||||
- output.turn_off: relay_phone
|
||||
- script.execute: state_no_call
|
||||
- lambda: |-
|
||||
id(mode_mute) = false;
|
||||
id(relay_mute).turn_on();
|
||||
id(relay_phone).turn_off();
|
||||
on_turn_off:
|
||||
- output.turn_on: relay_phone
|
||||
- output.turn_off: relay_mute
|
||||
- script.execute: state_no_call
|
||||
- lambda: |-
|
||||
id(relay_phone).turn_on();
|
||||
id(relay_mute).turn_off();
|
||||
|
||||
Reference in New Issue
Block a user