Skip to content

Instantly share code, notes, and snippets.

@bonelifer
Forked from frenck/doorbell.yaml
Created May 3, 2020 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonelifer/c59d2facdb11fcbf2c78097aa8a3fab1 to your computer and use it in GitHub Desktop.
Save bonelifer/c59d2facdb11fcbf2c78097aa8a3fab1 to your computer and use it in GitHub Desktop.
Blog: For just $2, convert any existing wired doorbell into a smart doorbell; using ESPHome and Home Assistant: https://frenck.dev/diy-smart-doorbell-for-just-2-dollar/
---
esphome:
name: doorbell
platform: ESP8266
board: esp01_1m
# WiFi connection, correct these
# with values for your WiFi.
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable logging.
logger:
# Enable Home Assistant API.
api:
# Enable over-the-air updates.
ota:
# Enable Web server.
web_server:
port: 80
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
# Text sensors with general information.
text_sensor:
# Expose ESPHome version as sensor.
- platform: version
name: Doorbell ESPHome Version
# Expose WiFi information as sensors.
- platform: wifi_info
ip_address:
name: Doorbell IP
ssid:
name: Doorbell SSID
bssid:
name: Doorbell BSSID
# Sensors with general information.
sensor:
# Uptime sensor.
- platform: uptime
name: Doorbell Uptime
# WiFi Signal sensor.
- platform: wifi_signal
name: Doorbell WiFi Signal
update_interval: 60s
# Global to store the on/off state of the chime
globals:
- id: chime
type: bool
restore_value: true
initial_value: 'true'
# Exposed switches.
switch:
# Switch to restart the doorbell.
- platform: restart
name: Doorbell Restart
# Switch to turn on/off the chime.
- platform: gpio
id: relay
inverted: true
name: Doorbell Chime
pin: GPIO0
# Switch to turn on/off chime when
# doorbell button is pushed.
#
# It creates a "virtual" switch based
# on a global variable.
- platform: template
name: Doorbell Chime Active
id: chime_active
restore_state: false
turn_on_action:
- globals.set:
id: chime
value: 'true'
turn_off_action:
- globals.set:
id: chime
value: 'false'
lambda: |-
return id(chime);
# Binary sensor representing the
# Doorbell button push.
binary_sensor:
- platform: gpio
id: button
name: Doorbell Button
pin:
# Connected to GPIO on the ESP-01S.
number: GPIO2
mode: INPUT_PULLUP
inverted: true
filters:
# Small filter, to debounce the button press.
- delayed_on: 25ms
- delayed_off: 25ms
on_press:
# Only turn on the chime when it is active.
then:
if:
condition:
- switch.is_on: chime_active
then:
- switch.turn_on: relay
on_release:
# On release, turn of the chime.
- switch.turn_off: relay
---
# This automation triggers when the doorbell button is pushed
# and out the front door camera stream to the tv.
#
automation:
- alias: "Doorbell Camera"
trigger:
platform: state
entity_id: binary_sensor.doorbell_button
to: 'on'
action:
- service: camera.play_stream
data:
entity_id: camera.front_door
media_player: media_player.living_room_tv
---
# Turns off the doorbell chime after 8pm.
# Turns it on again in the morning @ 7am.
#
automation:
- alias: "Doorbell off after 8pm"
trigger:
platform: time
at: "20:00:00"
action:
service: switch.turn_off
entity_id: switch.doorbell_chime_active
- alias: "Doorbell on after 7am"
trigger:
platform: time
at: "07:00:00"
action:
service: switch.turn_on
entity_id: switch.doorbell_chime_active
---
# This automation triggers when the doorbell button is pushed
# and sends out a notification to our Apple iPhones/watches.
#
automation:
- alias: "Doorbell Notifications"
trigger:
platform: state
entity_id: binary_sensor.doorbell_button
to: 'on'
action:
- service: notify.mobile_app_frencks_iphone
data:
title: Doorbell
message: Ding dong! Someone is at the door!
data:
attachment:
content-type: jpeg
url: http://tiptag.com.ar/wp-content/uploads/2018/06/timbre1.jpg
- service: notify.mobile_app_ninja_iphone
data:
title: Doorbell
message: Ding dong! Someone is at the door!
data:
attachment:
content-type: jpeg
url: http://tiptag.com.ar/wp-content/uploads/2018/06/timbre1.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment