Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@a8ree

This comment has been minimized.

Copy link

@a8ree a8ree commented Mar 17, 2021

Hi
I'm trying to set up this project but something is going wrong when I write

INFO Reading configuration config/frontdoor_doorbell.yaml...
INFO Detected timezone 'GMT' with UTC offset 0 and daylight savings time from 28 March 01:00:00 to 31 October 02:00:00
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d config/doorbell
Processing doorbell (board: esp01_1m; framework: arduino; platform: espressif8266@2.6.2)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
PACKAGES: 
 - framework-arduinoespressif8266 3.20704.0 (2.7.4) 
 - tool-esptool 1.413.0 (4.13) 
 - tool-esptoolpy 1.20800.0 (2.8.0) 
 - toolchain-xtensa 2.40802.200502 (4.8.2)
Library Manager: Installing Update
Library Manager: Already installed, built-in library
Dependency Graph
|-- <ESPAsyncTCP-esphome> 1.2.3
|   |-- <ESP8266WiFi> 1.0
|-- <ESP8266WiFi> 1.0
|-- <ESP8266mDNS> 1.2
|   |-- <ESP8266WiFi> 1.0
|-- <ESPAsyncWebServer-esphome> 1.2.7
|   |-- <ESPAsyncTCP-esphome> 1.2.3
|   |   |-- <ESP8266WiFi> 1.0
|   |-- <Hash> 1.0
|   |-- <ESP8266WiFi> 1.0
|   |-- <ArduinoJson-esphomelib> 5.13.3
|-- <ArduinoJson-esphomelib> 5.13.3
Retrieving maximum program size .pioenvs/doorbell/firmware.elf
Checking size .pioenvs/doorbell/firmware.elf
RAM:   [=====     ]  47.7% (used 39088 bytes from 81920 bytes)
Flash: [====      ]  43.2% (used 442680 bytes from 1023984 bytes)
========================= [SUCCESS] Took 2.46 seconds =========================
INFO Successfully compiled program.
INFO Running:  esptool.py --before default_reset --after hard_reset --baud 460800 --chip esp8266 --port /dev/cu.usbserial-A50285BI write_flash 0x0 config/doorbell/.pioenvs/doorbell/firmware.bin
esptool.py v2.8
Serial port /dev/cu.usbserial-A50285BI
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 60:01:94:0e:4a:c1
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 1MB
Compressed 446832 bytes to 305385...
Wrote 446832 bytes (305385 compressed) at 0x00000000 in 7.1 seconds (effective 501.8 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from /dev/cu.usbserial-A50285BI with baud rate 115200

It doesn't ever boot / join wifi.

any ideas?

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment