mirror of
https://github.com/Anonym-tsk/smart-domofon.git
synced 2025-12-06 03:26:58 +03:00
call_start_detect_delay fix & action sensor
This commit is contained in:
@@ -97,19 +97,15 @@
|
||||
После этого плата перезагружается и подключается к вашему WiFi.
|
||||
Home assistant обычно обнаруживает подключение автоматически. Если не обнаружил, то можно подключить через интеграции. Пароль для интеграции `esphome`
|
||||
|
||||
<!--
|
||||
При принятии или отклонении вызова в Home Assistant отправляются события
|
||||
`esphome.domofon_call_accept` и `esphome.domofon_call_reject` соответственно,
|
||||
которые можно использовать в качестве триггеров для автоматизаций:
|
||||
При принятии или отклонении вызова в Home Assistant обновляется сенсор `Domofon Action`. Возможные значения:
|
||||
|
||||
```yaml
|
||||
trigger:
|
||||
- platform: event
|
||||
event_type: esphome.domofon_call_accept
|
||||
- platform: event
|
||||
event_type: esphome.domofon_call_reject
|
||||
```
|
||||
-->
|
||||
* `none` – значение по-умолчанию
|
||||
* `open_sw` – открыт программно
|
||||
* `open_hw` – открыт аппаратной кнопкой
|
||||
* `open_auto` – открыт автоматически
|
||||
* `reject_sw` – отклонен программно
|
||||
* `reject_hw` – отклонен аппаратной кнопкой
|
||||
* `reject_auto` – отклонен автоматически
|
||||
|
||||
## Уведомления в Telegram через Home Assistant
|
||||
|
||||
|
||||
@@ -59,45 +59,6 @@ globals:
|
||||
restore_value: yes
|
||||
initial_value: 'false'
|
||||
|
||||
sensor:
|
||||
- platform: template
|
||||
name: "${board_name} Heap Size"
|
||||
lambda: "return ESP.getFreeHeap();"
|
||||
update_interval: 20s
|
||||
unit_of_measurement: bytes
|
||||
accuracy_decimals: 0
|
||||
entity_category: "diagnostic"
|
||||
|
||||
- platform: uptime
|
||||
internal: true
|
||||
id: uptime_sensor
|
||||
update_interval: 60s
|
||||
on_raw_value:
|
||||
then:
|
||||
- text_sensor.template.publish:
|
||||
id: uptime_human
|
||||
state: !lambda |-
|
||||
int seconds = round(id(uptime_sensor).raw_state);
|
||||
int days = seconds / (24 * 3600);
|
||||
seconds = seconds % (24 * 3600);
|
||||
int hours = seconds / 3600;
|
||||
seconds = seconds % 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
return (
|
||||
(days ? to_string(days) + "d " : "") +
|
||||
(hours ? to_string(hours) + "h " : "") +
|
||||
(minutes ? to_string(minutes) + "m " : "") +
|
||||
(to_string(seconds) + "s")
|
||||
).c_str();
|
||||
|
||||
text_sensor:
|
||||
- platform: template
|
||||
id: uptime_human
|
||||
name: "${board_name} Uptime"
|
||||
icon: mdi:clock-start
|
||||
entity_category: "diagnostic"
|
||||
|
||||
substitutions:
|
||||
# Ge1mer board
|
||||
board: esp12e
|
||||
@@ -117,4 +78,5 @@ packages:
|
||||
switch: !include switch.yaml
|
||||
button: !include button.yaml
|
||||
light: !include light.yaml
|
||||
sensor: !include sensor.yaml
|
||||
binary_sensor: !include binary_sensor.yaml
|
||||
|
||||
@@ -9,8 +9,8 @@ binary_sensor:
|
||||
mode: INPUT_PULLUP
|
||||
inverted: True
|
||||
filters:
|
||||
delayed_on: $call_start_detect_delay
|
||||
delayed_off: $call_end_detect_delay
|
||||
- delayed_on: $call_start_detect_delay
|
||||
- delayed_off: $call_end_detect_delay
|
||||
on_press:
|
||||
then:
|
||||
script.execute: state_call
|
||||
@@ -52,6 +52,7 @@ binary_sensor:
|
||||
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;
|
||||
@@ -69,6 +70,7 @@ binary_sensor:
|
||||
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)) {
|
||||
|
||||
@@ -10,6 +10,7 @@ button:
|
||||
then:
|
||||
lambda: |-
|
||||
if (id(incoming_call).state) {
|
||||
id(last_action).publish_state("open_sw");
|
||||
id(call_accept).execute();
|
||||
} else {
|
||||
ESP_LOGD("main", "No incoming call");
|
||||
@@ -23,6 +24,7 @@ button:
|
||||
then:
|
||||
lambda: |-
|
||||
if (id(incoming_call).state) {
|
||||
id(last_action).publish_state("reject_sw");
|
||||
id(call_reject).execute();
|
||||
} else {
|
||||
ESP_LOGD("main", "No incoming call");
|
||||
|
||||
@@ -11,6 +11,7 @@ script:
|
||||
id(relay_mute).turn_off();
|
||||
}
|
||||
id(relay_answer).turn_off();
|
||||
id(last_action).publish_state("none");
|
||||
|
||||
# Connected answer resistor
|
||||
- id: state_answer
|
||||
@@ -43,10 +44,6 @@ script:
|
||||
- globals.set:
|
||||
id: mode_mute_once
|
||||
value: 'false'
|
||||
# - homeassistant.event:
|
||||
# event: esphome.domofon_call_accept
|
||||
# data:
|
||||
# entity_uid: $mdns_name
|
||||
|
||||
# Reject incoming call
|
||||
- id: call_reject
|
||||
@@ -59,10 +56,6 @@ script:
|
||||
- globals.set:
|
||||
id: mode_mute_once
|
||||
value: 'false'
|
||||
# - homeassistant.event:
|
||||
# event: esphome.domofon_call_reject
|
||||
# data:
|
||||
# entity_uid: $mdns_name
|
||||
|
||||
# Call state
|
||||
- id: state_call
|
||||
@@ -70,10 +63,13 @@ script:
|
||||
- lambda: |-
|
||||
ESP_LOGD("main", "Incoming call");
|
||||
if (id(mode_auto_reject)) {
|
||||
id(last_action).publish_state("reject_auto");
|
||||
id(call_reject).execute();
|
||||
} else if (id(mode_auto_open)) {
|
||||
id(last_action).publish_state("open_auto");
|
||||
id(call_accept).execute();
|
||||
} else if (id(mode_auto_open_once)) {
|
||||
id(last_action).publish_state("open_auto");
|
||||
id(call_accept).execute();
|
||||
id(mode_auto_open_once) = false;
|
||||
}
|
||||
|
||||
46
ge1mer/esphome/packages/sensor.yaml
Normal file
46
ge1mer/esphome/packages/sensor.yaml
Normal file
@@ -0,0 +1,46 @@
|
||||
sensor:
|
||||
- platform: template
|
||||
name: "${board_name} Heap Size"
|
||||
lambda: "return ESP.getFreeHeap();"
|
||||
update_interval: 20s
|
||||
unit_of_measurement: bytes
|
||||
accuracy_decimals: 0
|
||||
entity_category: "diagnostic"
|
||||
|
||||
- platform: uptime
|
||||
internal: true
|
||||
id: uptime_sensor
|
||||
update_interval: 60s
|
||||
on_raw_value:
|
||||
then:
|
||||
- text_sensor.template.publish:
|
||||
id: uptime_human
|
||||
state: !lambda |-
|
||||
int seconds = round(id(uptime_sensor).raw_state);
|
||||
int days = seconds / (24 * 3600);
|
||||
seconds = seconds % (24 * 3600);
|
||||
int hours = seconds / 3600;
|
||||
seconds = seconds % 3600;
|
||||
int minutes = seconds / 60;
|
||||
seconds = seconds % 60;
|
||||
return (
|
||||
(days ? to_string(days) + "d " : "") +
|
||||
(hours ? to_string(hours) + "h " : "") +
|
||||
(minutes ? to_string(minutes) + "m " : "") +
|
||||
(to_string(seconds) + "s")
|
||||
).c_str();
|
||||
|
||||
text_sensor:
|
||||
- platform: template
|
||||
id: uptime_human
|
||||
name: "${board_name} Uptime"
|
||||
update_interval: never
|
||||
icon: mdi:clock-start
|
||||
entity_category: "diagnostic"
|
||||
|
||||
- platform: template
|
||||
id: last_action
|
||||
name: "${board_name} Action"
|
||||
update_interval: never
|
||||
icon: mdi:clock-time-eight-outline
|
||||
entity_category: "diagnostic"
|
||||
Reference in New Issue
Block a user