Zone Specific Announce Misbehaving

I’m not sure when this started occurring, but the announce end point appears to be doing weird things with the zones parameter. I’m running 0.4.4:

{
  "media": "/home/pi/Music/bird.mp3"
, "vol_f":0
, "zones":[0]

}

When I do this in the API window, in the UI I see announce kick off for:

Group 0 (which is zone 0 + zone 1), and Zones 2-5 (every zone).

{
  "media": "/home/pi/Music/bird.mp3"
, "vol_f":0
, "zones":[1]

}

Outputs on zones 1, 2, 3, 4 and 5. That is the same if I do "zones":[2 - 5], skipping zone 0.

Hmm that is odd. We fixed a similar problem earlier this year in Fix: Zones playing audio on source used for announcement are not muted… by linknum23 · Pull Request #700 · micro-nova/AmpliPi · GitHub. Would you mind sharing your config file, dowloaded before an announcement is played? Feel free to email it to support@micro-nova.com.

Sent! Along with a video showing the extra zones popping up in the GUI. Thanks!

It looks like a previous announcement got stuck on? Can you click the ‘x’ on that to stop it?

Just did that, then re-triggered from the API and the same outcome (all zones pop up in the new announce). For what it’s worth, I had rebooted the Amplipi at some point after posting this as well.

Good to know. We were unable to reproduce this issue with our in house configuration. I’m trying it with your configuration on a normal 0.4.4 release now.

Aha! All of those zones (that are supposed to not be announced to) were left connected to source 3 which is being used for the announcement. They get muted, but the UI still sees them as playing the announcement.

It looks like an announcements needs to set their source_id to -1 before the announcement. I’ve made an issue here: Zones not being announced to that are connected to announcement source, look like they are being announced to · Issue #977 · micro-nova/AmpliPi · GitHub.

In the meantime you can workaround this problem with the UI.

  1. Use the plus button to select the RCA 4 stream and add all of the zones to it.
  2. Click on one of the zones names RCA 4 is playing on to bring up the zones modal, uncheck all of the zones (this sets their source_id to -1)
  3. Click the X button on RCA 4 to disconnect the stream (we don’t need it anymore)

After this an announcement should look normal. We’ll try and have this fixed in the next release!

1 Like

Thanks for the quick investigation!

That work around did the trick in the UI. I have various announces from HA, and some do go to all zones, so will one of those automations revert it to this behavior?

HA could if it fire multiple announcements one over another, the system does not handle that case well yet. The other way this can happen if something (not an announcement) is played back on source 3 to all of the zones.

Ah yes, I do in fact do that with HA. I have an automation that sees someone on my front porch and it announces to the Amplipi. Then I have an automation that triggers off someone pushing the doorbell. At some point I realized I was missing doorbell “knocks” if someone ran up to my door, because the person detected was still running. So my second automation (doorbell pressed) now does a null announce to stop it first:

Action rest_command:

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

Automation:

actions:
  - alias: Play nothing (this stops Person Detected)
    data:
      type: null
      volume: 0.8
    action: rest_command.amplipi_announce
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 100
  - data:
      type: door-knock
      volume: 0.8
    alias: Play door knock on speakers
    action: rest_command.amplipi_announce

Oh this tries to cancel an announcement with another announcement. Currently, cancelling an announcement is not something that is possible with the current announcement interface. As mentioned here: Bug: Volume changing after multiple overlapping announcements · Issue #485 · micro-nova/AmpliPi · GitHub we will probably need to upgrade the system to make announcements asynchronous for fancy things like overlapping/queued/cancel-able announcements to be feasible.

Correct. In this case, when my doorbell is rung, I want the announce to be an immediate priority, interrupting all others. It would be great if announce had some form of priority: Immediate (halt all other announces) or Queued. If I don’t do the null announce first, I feel like the second one wasn’t even getting played at all.

Hey crushing- sorry to piggyback off this issue but I’ve been asking about how to send announcements to only a handful of zones or groups and haven’t gotten much traction. Would you mind explaining a bit about how you navigate the different automations? From what I can tell you may be triggering api calls? I’m thinking it would be nice to play certain audio files when doors open or doorbell rings or stuff like that, but don’t want them to hit certain speakers depending on time of day or just in general.

Crushing1523 is using the underlying announce endpoint of AmpliPis API. Here’s the docs for it: API - Announcement. Make sure to check out the schema for the different fields available.

It looks like they added several audio files to their units folder /home/pi/Music and are using those for the media to play.

As for announcing to individual zones they are using the zones field to specify a list of zones to announce to by their zone id. You can find the zone’s ids by looking at the zones portion of status or directly with API - Zones. It will look something like this:

{
"zones": [
{
"disabled": false,
"id": 0,
"mute": true,
"name": "Upstairs Main Bath",
"source_id": 2,
"vol": -56,
"vol_f": 0.28,
"vol_max": -20,
"vol_min": -70
},
{
"disabled": false,
"id": 1,
"mute": true,
"name": "Upstairs Living Room",
"source_id": 3,
"vol": -49,
"vol_f": 0.42,
"vol_max": -20,
"vol_min": -70
},
{
"disabled": false,
"id": 2,
"mute": true,
"name": "Upstairs Dining",
"source_id": 0,
"vol": -66,
"vol_f": 0.08,
"vol_max": -20,
"vol_min": -70
},
{
"disabled": false,
"id": 3,
"mute": true,
"name": "Upstairs Laundry",
"source_id": 0,
"vol": -66,
"vol_f": 0.08,
"vol_max": -20,
"vol_min": -70
},
{
"disabled": false,
"id": 4,
"mute": true,
"name": "Upstairs Kitchen High",
"source_id": 0,
"vol": -45,
"vol_f": 0.5,
"vol_max": -20,
"vol_min": -70
},
{
"disabled": false,
"id": 5,
"mute": true,
"name": "Upstairs Kitchen Low",
"source_id": 0,
"vol": -23,
"vol_f": 0.94,
"vol_max": -20,
"vol_min": -70
}
]
}

Say we wanted to make a doorbell chime using an announcement with 60% volume to the dining room and both portions of the kitchen. You would make a POST call to http://amplipi.local/api/announce with the following data payload:

{
  "media": "https://cdn.freesound.org/previews/275/275068_4486188-lq.mp3",
  "vol_f":0.6,
  "zones":[2,4,5]
}

Crushing1523 is using a rest_command action that defines the announcement api call and has volume and type parameters. This is the plumbing that they use to connect a doorbell event to an announcement.

I hope this helps!

1 Like

Makes sense! I played around a bit last night and got a working template with it, but this definitely helps. Do you think it would be better to run the audio from HA or from Amplipi directly? Currently I set it to come from HA, but that was only because I couldn’t remember how to store it on Amplipi haha :slight_smile:

I would suggest using HA to manage the audio files since it is designed for that use case.

Stupid question - how would you do that?

@matchmee - Sorry for the delay, but here is what I have in my HA Config file:

rest_command:
  amplipi_announce_zone:
    url: "http://192.168.2.20/api/announce"
    method: post
    payload: '{ "media":"/home/pi/Music/{{ type }}.mp3" , "vol_f" : {{ volume }} , "zones" : [ {{ zones }} ] }'
    headers:
      content-type: 'application/json'

Then an example automation is like this:

alias: Front Gate - Motion Detected
description: "When motion is detected at the front gate, turn on the porch light. If the office is occupied (noted by the office desk being on), play bird sounds to the office speakers."
triggers:
  - entity_id:
      - binary_sensor.front_gate_motion
    to: "on"
    from: "off"
    trigger: state
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: light.porch_switch
    alias: Turn on Porch Light
  - choose:
      - conditions:
          - condition: state
            entity_id: switch.office_desk
            state: "on"
            alias: If Office Desk is on
        sequence:
          - action: rest_command.amplipi_announce_zone
            data:
              type: bird
              volume: 0.2
              zones: 2
            alias: Play birds to Office
mode: single
max_exceeded: silent

No stupid questions!

I store my audio files in HA inside the www folder. And my calls look like this then:

rest_command:
  amplipi_announce:
    url: "http://192.168.1.242/api/announce"
    method: post
    payload: '{"media": "https://url.url/local/{{ file_name }}","vol_f": {{ volume }},"zones": {{ zones }}}'
    headers:
      content-type: 'application/json'

Gotcha. I thought you meant you were using the media_player functions to somehow trigger an announce.

I’m sorry if this isn’t related, but I’m running into an issue that when I specify an announcement for a couple zones, I find that it turns the zones up and unmuted before playing the announcement. The issue with that is that I have something on Source 3 already (the radio option) so for example when the doorbell rings, (but everything is currently silent in the house) Source 3 radio starts playing and then doesn’t mute and plays the announcement (a doorbell sound) on top of it.

My automation:

- id: '1731208509446'
  alias: amplipi doorbell daytime
  description: Doorbell Announcement
  trigger:
  - platform: state
    entity_id:
    - binary_sensor.doorbell_doorbell
    to: 'on'
  condition:
  - condition: state
    entity_id: select.doorbell_chime_type
    state: Mechanical
  - condition: time
    before: '20:00:00'
  action:
  - action: rest_command.amplipi_announce
    data:
      file_name: Doorbell.wav
      volume: 0.69
      zones:
      - 10
      - 13
      - 14
      - 16
      - 17
  mode: single

I’m on 4.4 as well.