diff --git a/appdaemon/settings/apps/doorbells/intercom.py b/appdaemon/settings/apps/doorbells/intercom.py index 1186645..cc3dd5c 100644 --- a/appdaemon/settings/apps/doorbells/intercom.py +++ b/appdaemon/settings/apps/doorbells/intercom.py @@ -29,7 +29,14 @@ class Intercom(hass.Hass): self.ringtone = self.args['ringtone'] self.listen_event(self.domofon_call, "domofon_call") self.listen_event(self.receive_telegram_callback, 'telegram_callback') - # self.domofon_call(None, None, None) + self.listen_state(self.sensor_trigger, self.args['sensor']) + + def sensor_trigger(self, entity, attribute, old, new, kwargs): + if new != "off": + return + self.log("domofon_call") + self.domofon_call(None, None, None) + def domofon_call(self, event_id, event_args, kwargs): self.log("domofon_call") diff --git a/appdaemon/settings/apps/doorbells/intercom.yaml b/appdaemon/settings/apps/doorbells/intercom.yaml index 634b371..74087a4 100644 --- a/appdaemon/settings/apps/doorbells/intercom.yaml +++ b/appdaemon/settings/apps/doorbells/intercom.yaml @@ -5,6 +5,7 @@ intercom: module: intercom class: Intercom notify: telegram + sensor: binary_sensor.domofon_incoming_call gw_mac: !secret aqara1_mac chat_id: !secret telegram_group_chat global_dependencies: diff --git a/appdaemon/settings/apps/notifiers/watchdog.yaml b/appdaemon/settings/apps/notifiers/watchdog.yaml index a2e3ea1..1f05549 100644 --- a/appdaemon/settings/apps/notifiers/watchdog.yaml +++ b/appdaemon/settings/apps/notifiers/watchdog.yaml @@ -19,9 +19,9 @@ watchdog_wemos_uptime: module: watchdog constraint: input_boolean.watchdog_report entities: - # - sensor.uptime_airfresher + - sensor.airfresher_uptime - sensor.uptime_bath - - sensor.uptime_domofon + - sensor.domofon_uptime - sensor.uptime_kitchen_led - sensor.uptime_nest - sensor.uptime_salt_lamp diff --git a/esphome/settings/domofon.yaml b/esphome/settings/domofon.yaml new file mode 100644 index 0000000..42da3e6 --- /dev/null +++ b/esphome/settings/domofon.yaml @@ -0,0 +1,119 @@ +esphome: + name: domofon + platform: ESP8266 + board: d1_mini + +wifi: + ssid: !secret wifi_24_name + password: !secret wifi_24_pass + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Domofon Fallback Hotspot" + password: !secret esphome_captive_pass + +captive_portal: + +# Enable Home Assistant API +api: + password: !secret esphome_pass + +ota: + password: !secret esphome_pass + +logger: + +binary_sensor: + - platform: gpio + pin: + number: 14 + mode: INPUT_PULLUP + inverted: true + name: "Domofon incoming call" + id: incoming_call + device_class: lock + on_press: + then: + - script.execute: state_call + +sensor: + - platform: uptime + name: Domofon Uptime + +switch: + - platform: gpio + pin: + number: 13 + inverted: yes + id: trubka + + - platform: gpio + pin: + number: 12 + inverted: yes + id: door + + # Automatically open door switch + - platform: template + name: "Domofon automatically open" + id: auto_open + icon: "mdi:door-open" + optimistic: true + restore_state: true + on_turn_on: + - switch.turn_off: auto_open_once + + # Automatically open door once switch + - platform: template + name: "Domofon automatically open once" + id: auto_open_once + icon: "mdi:door-open" + optimistic: true + restore_state: true + on_turn_on: + - switch.turn_off: auto_open + + - platform: template + name: "Domofon force open" + id: open_force + icon: "mdi:door-open" + turn_on_action: + - script.execute: call_accept + + - platform: template + id: domofon_call_emulation + name: "Domofon call emulation" + turn_on_action: + - script.execute: state_call + +script: + # Accept incoming call + - id: call_accept + then: + - logger.log: "Accept call" + - delay: 1000ms #mandatory 1s delay between hang-on - bacause system goes to error otherwise + - switch.turn_on: trubka + - delay: 200ms + - switch.turn_on: door + - delay: 200ms + - switch.turn_off: door + - delay: 100ms + - switch.turn_off: trubka + - delay: 200ms + + # Call state + - id: state_call + then: + - logger.log: "Set state 'Incoming call'" + - if: + condition: + switch.is_on: auto_open + then: + script.execute: call_accept + - if: + condition: + switch.is_on: auto_open_once + then: + - script.execute: call_accept + - delay: 1s + - switch.turn_off: auto_open_once \ No newline at end of file diff --git a/hass/settings/configuration/switch/domofon_mode.yaml b/hass/settings/configuration/switch/domofon_mode.yaml deleted file mode 100644 index ef8c8c9..0000000 --- a/hass/settings/configuration/switch/domofon_mode.yaml +++ /dev/null @@ -1,7 +0,0 @@ -- platform: mqtt - name: domofon_mode - state_topic: "home/domofon/domofon/mode" - command_topic: "home/domofon/domofon/mode/set" - payload_on: "1" - payload_off: "2" - retain: true \ No newline at end of file diff --git a/hass/settings/configuration/switch/domofon_open.yaml b/hass/settings/configuration/switch/domofon_open.yaml deleted file mode 100644 index 5e49fe8..0000000 --- a/hass/settings/configuration/switch/domofon_open.yaml +++ /dev/null @@ -1,7 +0,0 @@ -- platform: mqtt - name: domofon_open - state_topic: "home/domofon/domofon/open" - command_topic: "home/domofon/domofon/open/set" - payload_on: "1" - payload_off: "2" - retain: false \ No newline at end of file diff --git a/hass/settings/ui-lovelace.yaml b/hass/settings/ui-lovelace.yaml index 3bc35d3..df185cc 100644 --- a/hass/settings/ui-lovelace.yaml +++ b/hass/settings/ui-lovelace.yaml @@ -14,7 +14,7 @@ views: - alarm_control_panel.ha_alarm - switch.water_valve - vacuum.xiaomi_vacuum_cleaner - - switch.domofon_open + - switch.domofon_force_open - switch.wifi_socket - type: entities title: "Гостиная" @@ -345,7 +345,8 @@ views: - input_boolean.water_control - input_boolean.water_leak_control - input_boolean.mainroom_climate_control - - switch.domofon_mode + - switch.domofon_automatically_open + - switch.domofon_automatically_open_once - type: entities title: "Настройки отчетов" show_header_toggle: true @@ -369,9 +370,9 @@ views: title: "Аптайм" show_header_toggle: false entities: - - sensor.uptime_airfresher + - sensor.airfresher_uptime - sensor.uptime_bath - - sensor.uptime_domofon + - sensor.domofon_uptime - sensor.uptime_kitchen_led - sensor.uptime_nest - sensor.uptime_bathlight