Home automation: Doorbells!

I order a lot of electronics from China. It’s not a problem, I’m just in denial. In a previous post, I described how I linked our mailbox up with Home Assistant (at that time, it was OpenHAB but the connections are the same), so I could be notified when we get mail. We recently bought a house, so my home automations can now be installed permanently.

Goals of this automation:

  • Catch door bell rings
  • If we’re watching TV, pause it
  • If we’re home, provide feedback that we’re on the way (turn a light on)
  • Future: do something in a security context if we are not home (toggle some lights or something)
  • If we’re not home, notify us that the door was rung
  • Future: if we’re expecting a package, and we recognize the delivery person via Bluetooth or wifi, open the garage door

The Hardware

My Doorbell runs on 8V AC. I confirmed this first by checking the transformer built into our fuse box, as well as with a multimeter. I wanted the ESP to be completely isolated from the doorbell system, so I opted for an optocoupler to perform the bridge between the two areas.  A schematic is below:

 

The Software

I chose Tasmota firmware. This is a great firmware where no code changes are required if you want to do additional items. I just hooked the output which is triggered when the doorbell rings to GPIO4, and declared this as a switch. 

This results in an MQTT message like this, every time the doorbell is rung:

 

 

The Configuration

Home Assistant will need to pick up on these MQTT messages, and then take appropriate action. Below is the configuration for pausing TV and showing why the TV was paused

- id: pause-on-doorbell
  alias: "Pause TV on Doorbell"
  trigger:
    - platform: mqtt
      topic: /places/ba6/general/Doorbell/cmnd/POWER
      payload: TOGGLE
  condition:
    - condition: state
      entity_id: media_player.kodi
      state: "playing"
  action:
    - service: media_player.media_pause
      data:
        entity_id: media_player.kodi
    - service: notify.kodi
      data:
        title: "Home Assistant Message"
        message: "There's somebody at the door"
        data:
          displaytime: 30000
          icon: "warning"

The Future

In the future I want to add a security system. Since home assistant already knows if we’re home or not, I want to be able to take