-
-
Save frenck/0af30b05f7c98d17219548b46a03df21 to your computer and use it in GitHub Desktop.
--- | |
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 |
Hello Frenck,
I like your way of presenting this hardware project a lot. But when I validate the yaml code, there is a option "restore_state" used which is not valid anymore. What should I change to get it working?
Thank you for all your effort in sharing !!
I get this error when validating :
INFO ESPHome 2023.11.4
INFO Reading configuration /config/esphome/Doorbell.yaml...
INFO Detected timezone 'Europe/Amsterdam'
Failed config
switch.template: [source /config/esphome/Doorbell.yaml:81]
platform: template
name: Doorbell Chime Active
id: chime_active
The restore_state option has been removed in 2023.7.0. Use the restore_mode option instead.
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);
@Flipperkastje I've managed to fix the issue by just editing line 81 to be
restore_mode: 'RESTORE_DEFAULT_OFF'
This seems to at least make the code compile which is nice but I'm unsure if this actually is a "fix" for the issue as I'm unsure what the original option even does
@hax4dazy thanks for posting the above, I hit exactly the same problem as @Flipperkastje during Yaml Validation.
@frenck are you aware of the above coding problem? It looks like v2023.7.0 has changes which invalidate the "restore_state" command
@Flipperkastje I've managed to fix the issue by just editing line 81 to be
restore_mode: 'RESTORE_DEFAULT_OFF'
perfect thanks
Good day, even if I edit line 81, it still says this:
INFO ESPHome 2024.6.6
INFO Reading configuration /config/esphome/doorbell.yaml...
ERROR Error while reading config: Invalid YAML syntax:
while parsing a block collection
in "/config/esphome/doorbell.yaml", line 66, column 3
expected , but found '?'
in "/config/esphome/doorbell.yaml", line 81, column 3
please what about it???
Hi Frenck, this page seems unavailable [(https://frenck.dev/diy-smart-doorbell-for-just-2-dollar/)]
Cheers.