domofon moved to esphome

This commit is contained in:
Your Name
2019-12-01 21:48:35 +03:00
parent 089ecc0858
commit 59ec8b2790
7 changed files with 135 additions and 21 deletions
@@ -29,7 +29,14 @@ class Intercom(hass.Hass):
self.ringtone = self.args['ringtone'] self.ringtone = self.args['ringtone']
self.listen_event(self.domofon_call, "domofon_call") self.listen_event(self.domofon_call, "domofon_call")
self.listen_event(self.receive_telegram_callback, 'telegram_callback') 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): def domofon_call(self, event_id, event_args, kwargs):
self.log("domofon_call") self.log("domofon_call")
@@ -5,6 +5,7 @@ intercom:
module: intercom module: intercom
class: Intercom class: Intercom
notify: telegram notify: telegram
sensor: binary_sensor.domofon_incoming_call
gw_mac: !secret aqara1_mac gw_mac: !secret aqara1_mac
chat_id: !secret telegram_group_chat chat_id: !secret telegram_group_chat
global_dependencies: global_dependencies:
@@ -19,9 +19,9 @@ watchdog_wemos_uptime:
module: watchdog module: watchdog
constraint: input_boolean.watchdog_report constraint: input_boolean.watchdog_report
entities: entities:
# - sensor.uptime_airfresher - sensor.airfresher_uptime
- sensor.uptime_bath - sensor.uptime_bath
- sensor.uptime_domofon - sensor.domofon_uptime
- sensor.uptime_kitchen_led - sensor.uptime_kitchen_led
- sensor.uptime_nest - sensor.uptime_nest
- sensor.uptime_salt_lamp - sensor.uptime_salt_lamp
+119
View File
@@ -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
@@ -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
@@ -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
+5 -4
View File
@@ -14,7 +14,7 @@ views:
- alarm_control_panel.ha_alarm - alarm_control_panel.ha_alarm
- switch.water_valve - switch.water_valve
- vacuum.xiaomi_vacuum_cleaner - vacuum.xiaomi_vacuum_cleaner
- switch.domofon_open - switch.domofon_force_open
- switch.wifi_socket - switch.wifi_socket
- type: entities - type: entities
title: "Гостиная" title: "Гостиная"
@@ -345,7 +345,8 @@ views:
- input_boolean.water_control - input_boolean.water_control
- input_boolean.water_leak_control - input_boolean.water_leak_control
- input_boolean.mainroom_climate_control - input_boolean.mainroom_climate_control
- switch.domofon_mode - switch.domofon_automatically_open
- switch.domofon_automatically_open_once
- type: entities - type: entities
title: "Настройки отчетов" title: "Настройки отчетов"
show_header_toggle: true show_header_toggle: true
@@ -369,9 +370,9 @@ views:
title: "Аптайм" title: "Аптайм"
show_header_toggle: false show_header_toggle: false
entities: entities:
- sensor.uptime_airfresher - sensor.airfresher_uptime
- sensor.uptime_bath - sensor.uptime_bath
- sensor.uptime_domofon - sensor.domofon_uptime
- sensor.uptime_kitchen_led - sensor.uptime_kitchen_led
- sensor.uptime_nest - sensor.uptime_nest
- sensor.uptime_bathlight - sensor.uptime_bathlight