Home Assistant HACS Integration (PA)

I just got my Amplipi setup this weekend and am diving in a bit now into how it will integrate into Home Assistant. One of the pieces that I’m looking to use is the announce end point. I want to be able a state change on my cameras to trigger a doorbell sound over the Amplipi. I loaded an MP3 to the Amplipi and in the API try pages am able to test that it works.

The HACS integration says it’s supports “PA”, which I assume means the announce function, but I see nothing about how to trigger that within HA. Is this possible today with that integration, or do I need to write a standalone function to do that? Thanks!

Cool to hear it was easy to hook your camera’s into our announcements! That’s one of the main use cases we created them for.

As for the HomeAssistant’s PA integration. I honestly don’t know how the announcement infrastructure works in HA. My initial guess is that everything is just a generic media player that can be used for announcements. We’ll check into it soon and report back.

I just tested this with HA’s new create automation dialog: 2023.3: Dialogs! - Home Assistant

Here’s what I selected in the dialog:

  • Trigger: Time ( a couple minutes in the future)
  • Condition: Nothing
  • Action: Play Media
    • Player: Input 4
    • Media: Text to speech → Google → “Hello Lincoln, the time is 1201”

One thing that I found in this journey is it looks like only sources currently support playing an announcement. We will need to add support for zones (and groups) soon to make this really useful.

I did this for now and it seems to be working (and easy enough to deal with):

configuration.yaml:

rest_command:
  amplipi_announce:
    url: "http://amplipi.local/api/announce"
    method: post
    payload: '{ "media":"/home/pi/Music/{{ type }}.mp3" , "vol_f" : 0.7 }'
    headers:
      content-type: 'application/json'

Then in my automations:

service: rest_command.amplipi_announce
data:
  type: bell-ding
alias: Ding the Speakers
1 Like

I used the TTS briefly when playing around, but won’t that interrupt/ stop the media? That was always the issue I had trying to broadcast to the Google Home devices.

An announcement can stop the playback session if the media is playing on the same source used for the announcement. The default announcement source is source 4 (source_id=3) to attempt to mitigate this problem.

This would stop the audio for Spotify and Airplay if there was a session playing on Source 4. Other streams such as Pandora and internet radio start playing again after the announcement. We have a fix in the works for this.

1 Like

What kind of audio did you decide to use for this, and where did you store it? Locally on the AmpliPi or on HA - or a web link?

I’m trying to figure out a way to do something similar. Basically when my Ubiquiti Doorbell rings, it rings in all of my speakers.

I put the mp3 on the amplipi (i just SFTP’d it over to that path I made /home/pi/Music/). I found some mp3 online that’s someone knocking on a door for when the doorbell rings. And when my Unifi Protect flags a person in the front yard, it makes a different sound:

(It’s on repeat because I think originally I had it go knock-knock 2x)

2 Likes

I also changed the service since I posted the last screenshot to make the volume variable:

  amplipi_announce:
    url: "http://amplipi.local/api/announce"
    method: post
    payload: '{ "media":"/home/pi/Music/{{ type }}.mp3" , "vol_f" : {{ volume }} }'
    headers:
      content-type: 'application/json'