diff --git a/ge1mer/README.md b/ge1mer/README.md index 333f1e7..af1854f 100644 --- a/ge1mer/README.md +++ b/ge1mer/README.md @@ -97,19 +97,15 @@ После этого плата перезагружается и подключается к вашему WiFi. Home assistant обычно обнаруживает подключение автоматически. Если не обнаружил, то можно подключить через интеграции. Пароль для интеграции `esphome` - +* `none` – значение по-умолчанию +* `open_sw` – открыт программно +* `open_hw` – открыт аппаратной кнопкой +* `open_auto` – открыт автоматически +* `reject_sw` – отклонен программно +* `reject_hw` – отклонен аппаратной кнопкой +* `reject_auto` – отклонен автоматически ## Уведомления в Telegram через Home Assistant diff --git a/ge1mer/esphome/packages/base.yaml b/ge1mer/esphome/packages/base.yaml index bf58e40..904eb2b 100644 --- a/ge1mer/esphome/packages/base.yaml +++ b/ge1mer/esphome/packages/base.yaml @@ -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 diff --git a/ge1mer/esphome/packages/binary_sensor.yaml b/ge1mer/esphome/packages/binary_sensor.yaml index ebad437..77790e1 100644 --- a/ge1mer/esphome/packages/binary_sensor.yaml +++ b/ge1mer/esphome/packages/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)) { diff --git a/ge1mer/esphome/packages/button.yaml b/ge1mer/esphome/packages/button.yaml index 12d5453..d8d6300 100644 --- a/ge1mer/esphome/packages/button.yaml +++ b/ge1mer/esphome/packages/button.yaml @@ -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"); diff --git a/ge1mer/esphome/packages/script.yaml b/ge1mer/esphome/packages/script.yaml index 9e243b5..4a0cdb4 100644 --- a/ge1mer/esphome/packages/script.yaml +++ b/ge1mer/esphome/packages/script.yaml @@ -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; } diff --git a/ge1mer/esphome/packages/sensor.yaml b/ge1mer/esphome/packages/sensor.yaml new file mode 100644 index 0000000..99c3f0d --- /dev/null +++ b/ge1mer/esphome/packages/sensor.yaml @@ -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"