I have created an esphome device that rings my existing chime that is triggered when somebody pushes the Reolink video doorbell. The hardware is based on an esp8266 (d2 mini). This device is connected using D2 to a relay. The relay triggers the chime.
The device is triggered by an automation that publishes an mqtt message. Only an On message is send. The chime turns itself off.
alias: Doorbel on
description: ""
trigger:
- type: turned_on
platform: device
device_id: xxx
entity_id: binary_sensor.reolink_video_doorbell_poe_visitor
domain: binary_sensor
condition: []
action:
- service: mqtt.publish
data:
qos: "2"
retain: false
topic: doorchime/button
payload: "On"
mode: single
The Esphome is code is below.
The chime automatically turn off after a programmable delay.
I have replaced some of the keys with ā***ā that were generated when the device was created.
esphome:
name: doorchime
friendly_name: Doorchime
esp8266:
board: d1_mini
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Doorchime Fallback Hotspot"
password: "***"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "***"
ota:
password: "***"
mqtt:
broker: mqttbroker
birth_message:
topic: doorchime/status
payload: online
will_message:
topic: doorchime/status
payload: offline
time:
- platform: homeassistant
id: homeassistant_time
text_sensor:
- platform: version
name: Chime ESPHome Version
- platform: wifi_info
ip_address:
name: Chime IP
ssid:
name: Chime SSID
bssid:
name: Chime BSSID
- platform: mqtt_subscribe
name: button
id: button
topic: doorchime/button
on_value:
then:
- lambda: |-
ESP_LOGD("main", "Received doorbell request: %s", x.c_str());
if (strcmp(x.c_str(), "On") == 0) {
ESP_LOGD("main", "Turn doorbell ON");
if (id(chime_active).state)
id(relay).turn_on();
else
ESP_LOGD("main", "The doorbell is not active");
} else {
ESP_LOGD("main", "Turn doorbell OFF");
id(relay).turn_off();
}
sensor:
- platform: uptime
name: Chime Uptime
- platform: wifi_signal
name: Chime WiFi Signal
update_interval: 60s
globals:
- id: chime
type: bool
restore_value: true
initial_value: 'true'
switch:
- platform: gpio
name: "Chime Relay"
id: relay
pin:
number: GPIO05 #D1
inverted: true
# internal: true
icon: mdi:alarm-bell
on_turn_on:
- delay: 200ms
- switch.turn_off: relay
- platform: restart
name: "Chime Restart"
- platform: template
name: 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);