52 lines
1.7 KiB
Markdown
52 lines
1.7 KiB
Markdown
---
|
||
slug: smart-doorbell-with-xiaomi-aqara-button-and-google-home
|
||
title: "Smart doorbell with Xiaomi Aqara button and Google Home"
|
||
tags: [smart home, Aqara, Xaomi, Home Assistant]
|
||
image: /img/blog/2019/02/doorbell.jpeg
|
||
---
|
||
|
||
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.
|
||
|
||
<!-- truncate -->
|
||
|
||
All my Aqara ZigBee devices are connected to Home Assistant via [ConBee II](https://phoscon.de/en/conbee2) and [deCONZ](https://www.home-assistant.io/integrations/deconz).
|
||
|
||
First of all, let’s create a script that will be executed when the button is pressed. In your `scripts.yaml`:
|
||
|
||
```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`:
|
||
|
||
```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
|
||
``` |