Sonos has snapshot and restore, but other media players don't. Here's my solution

I have a Monoprice 10761 six zone WHA amp/controller that is natively integrated with HomeAssistant as of .56. Thanks @etsinko! I love this thing, and I use it all the time for music. For sources, I have an old Airport Express for Airplay and a Chromecast Audio for casting. Works great for music, but I wanted to start using TTS announcements using @CCOSTAN’s speech engine.

The Chromecast Audio is great for TTS announcements, but then the music would stop playing and wouldn’t restart. The Sonos media player component has a snapshot and restore feature, but the Chromecast doesn’t. And besides that, the Chromecast is only a source. Well, the Monoprice has a PA input that when triggered by 12v sends source one to all zones. I didn’t want to screw around with that, so I bought another Chromecast Audio to dedicate to announcements. Another option would have been to get a mixer and mix announcements over the playing source, but I’d have to get a mixer and Chromecast Audio for each source.

I use a script to set each of the current Monoprice zone inputs to a separate input_number (ex input_slider) before triggering an announcement. When the announcement finishes, I use another script to restore the zone input (or turn it off again) from the input_numbers. It’s kind of hacky, but it works. Most of my music is streaming radio, so I don’t care that I miss a few seconds for the announcement.

wha_zone_inputs_set.yaml

wha_zone_inputs_set:
sequence:
- service: input_number.set_value
  data_template:
    entity_id: input_number.wha_attic_bath_state
    value: >
      {% if states.media_player.attic_bath.state == "off" %} 0
      {% elif states.media_player.attic_bath.attributes.source == "Airplay" %} 4
      {% elif states.media_player.attic_bath.attributes.source == "Chromecast" %} 5
      {% elif states.media_player.attic_bath.attributes.source == "CCA_TTS" %} 6
      {% endif %}

- service: input_number.set_value
  data_template:
    entity_id: input_number.wha_attic_sitting_state
    value: >
      {% if states.media_player.attic_sitting.state == "off" %} 0
      {% elif states.media_player.attic_sitting.attributes.source == "Airplay" %} 4
      {% elif states.media_player.attic_sitting.attributes.source == "Chromecast" %} 5
      {% elif states.media_player.attic_sitting.attributes.source == "CCA_TTS" %} 6
      {% endif %}

- service: input_number.set_value
  data_template:
    entity_id: input_number.wha_bedroom_landing_state
    value: >
      {% if states.media_player.bedroom_landing.state == "off" %} 0
      {% elif states.media_player.bedroom_landing.attributes.source == "Airplay" %} 4
      {% elif states.media_player.bedroom_landing.attributes.source == "Chromecast" %} 5
      {% elif states.media_player.bedroom_landing.attributes.source == "CCA_TTS" %} 6
      {% endif %}

- service: input_number.set_value
  data_template:
    entity_id: input_number.wha_office_state
    value: >
      {% if states.media_player.office.state == "off" %} 0
      {% elif states.media_player.office.attributes.source == "Airplay" %} 4
      {% elif states.media_player.office.attributes.source == "Chromecast" %} 5
      {% elif states.media_player.office.attributes.source == "CCA_TTS" %} 6
      {% endif %}

- service: input_number.set_value
  data_template:
    entity_id: input_number.wha_patio_state
    value: >
      {% if states.media_player.patio.state == "off" %} 0
      {% elif states.media_player.patio.attributes.source == "Airplay" %} 4
      {% elif states.media_player.patio.attributes.source == "Chromecast" %} 5
      {% elif states.media_player.patio.attributes.source == "CCA_TTS" %} 6
      {% endif %}

- service: input_number.set_value
  data_template:
    entity_id: input_number.wha_porch_state
    value: >
      {% if states.media_player.porch.state == "off" %} 0
      {% elif states.media_player.porch.attributes.source == "Airplay" %} 4
      {% elif states.media_player.porch.attributes.source == "Chromecast" %} 5
      {% elif states.media_player.porch.attributes.source == "CCA_TTS" %} 6
      {% endif %}

wha_zone_inputs_get.yaml

wha_zone_inputs_get:
sequence:
- service: media_player.select_source
  entity_id: media_player.attic_bath
  data_template:
    source: >
      {% if states.input_number.wha_attic_bath_state.state == "4.0" %} Airplay
      {% elif states.input_number.wha_attic_bath_state.state == "5.0" %} Chromecast
      {% elif states.input_number.wha_attic_bath_state.state == "6.0" %} CCA_TTS
      {% endif %}

- service: media_player.select_source
  entity_id: media_player.attic_sitting
  data_template:
    source: >
      {% if states.input_number.wha_attic_sitting_state.state == "4.0" %} Airplay
      {% elif states.input_number.wha_attic_sitting_state.state == "5.0" %} Chromecast
      {% elif states.input_number.wha_attic_sitting_state.state == "6.0" %} CCA_TTS
      {% endif %}

- service: media_player.select_source
  entity_id: media_player.bedroom_landing
  data_template:
    source: >
      {% if states.input_number.wha_bedroom_landing_state.state == "4.0" %} Airplay
      {% elif states.input_number.wha_bedroom_landing_state.state == "5.0" %} Chromecast
      {% elif states.input_number.wha_bedroom_landing_state.state == "6.0" %} CCA_TTS
      {% endif %}

- service: media_player.select_source
  entity_id: media_player.office
  data_template:
    source: >
      {% if states.input_number.wha_office_state.state == "4.0" %} Airplay
      {% elif states.input_number.wha_office_state.state == "5.0" %} Chromecast
      {% elif states.input_number.wha_office_state.state == "6.0" %} CCA_TTS
      {% endif %}

- service: media_player.select_source
  entity_id: media_player.patio
  data_template:
    source: >
      {% if states.input_number.wha_patio_state.state == "4.0" %} Airplay
      {% elif states.input_number.wha_patio_state.state == "5.0" %} Chromecast
      {% elif states.input_number.wha_patio_state.state == "6.0" %} CCA_TTS
      {% endif %}

- service: media_player.select_source
  entity_id: media_player.porch
  data_template:
    source: >
      {% if states.input_number.wha_porch_state.state == "4.0" %} Airplay
      {% elif states.input_number.wha_porch_state.state == "5.0" %} Chromecast
      {% elif states.input_number.wha_porch_state.state == "6.0" %} CCA_TTS
      {% endif %}
1 Like

This is such a great idea! I’ll get snapshots into monoprice platform as well. Hopefully by next release.

1 Like

This PR adds the snapshot functinality:

1 Like

This is really cool. Thanks @etsinko!