Smart doorbell with Xiaomi Aqara button and Google Home

Smart doorbell with Xiaomi Aqara button and Google Home

So I have several Xiaomi Aqara buttons. Today I want to explain how to use this button as a smart doorbell that will play sound to your Google Home device through Home Assistant.

All my Aqara ZigBee devices are connected to Home Assistant via ConBee II and deCONZ.

First of all, let’s create a script that will be executed when the button is pressed. In your scripts.yaml:

doorbell:
  alias: Doorbell
  sequence:
  - data:
      entity_id: media_player.googlehome4615 #Your Google Home device
    service: media_player.turn_on
  - delay: 00:00:03 #To make sure we are connected to Google Home
  - data:
      entity_id: media_player.googlehome4615 #Your Google Home device
      media_content_id: https://your.homeassistant.domain:8123/local/doorbell.mp3
      media_content_type: music
    service: media_player.play_media
  - delay: 00:00:05  #The same as doorbell.mp3 file ledgth
  - data:
      entity_id: media_player.googlehome4615
    service: media_player.turn_off

To make doorbell.mp3 available by that URL you need to place it to /config/www in your Home Assistant.

Now we need to create a handler of the Aqara button in automations.yaml:

- id: doorbell_notify
  alias: Doorbell notify
  trigger:
  - entity_id: script.doorbell
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      message: "Someone near your front door"
    service: notify.push