Summary
I’ve had an old doorbell that was really frustrating, especially when I am sleeping, so I wanted a way to deactivate it easily. I didn’t change much, so it only costed the price of the Sonoff.
I noticed that the signal on my doorbell was 5V and the input was 230V AC, so I had to get creative. I bridged the doorbell signal with a wire so it would think that the button was pressed and I changed the status of the input so that when the doorbell booted, it would immediately “ring”.
Integration
Two sensors are exposed to HomeAssistant:
- switch.bell: Changes to ON when a button is pressed, but can be manually triggered to ring the bell.
-
switch.bell_active: This activates/deactivates the ringing, but the switch.bell sensor is triggered in case you want to use it on an automation.
In my case I am using the switch.bell so that it will send me a notification on my phone.
Hardware
- Sonoff device
- 230V Doorbell (mine is with chime)
- Buttons outside the door
You can see my connection diagram:
My home is using two buttons for ringing the doorbell, so I’ve implement them on my code. This can easily be removed if it doesn’t meet your needs.
Cables
- Red: Line (AC)
- Black: Neutral (AC)
- Blue: Doorbell Signal (5V DC)
- White: Sonoff Signal (3.5V DC)
Code
I’ve installed ESPHome on Sonoff which makes things easier change and share:
esphome:
name: doorbell
platform: ESP8266
board: esp01_1m
wifi:
networks:
- ssid: 'YOUR_SSID'
password: 'YOUR_PASSWORD'
api:
logger:
ota:
binary_sensor:
- platform: gpio # Up Button
pin:
number: GPIO09
inverted: true
mode: INPUT_PULLUP
id: ph_button3
on_press:
- script.execute: activate_doorbell
- platform: gpio # Down Button
pin:
number: GPIO00
inverted: true
mode: INPUT_PULLUP
id: ph_button4
on_press:
- script.execute: activate_doorbell
switch:
- platform: gpio # Output Relay
pin: GPIO12
id: relay
- platform: template
name: "Bell active"
id: bell_active
restore_state: true
optimistic: true
- platform: template
name: "Bell"
id: bell
restore_state: true
optimistic: true
turn_on_action:
- script.execute: activate_doorbell
script:
- id: activate_doorbell
mode: single
then:
- switch.turn_on: bell
- if:
condition:
switch.is_on: bell_active
then:
- switch.turn_on: relay
- delay: 5 sec
- switch.turn_off: relay
- switch.turn_off: bell