Control Sonos Playlist with Assist Voice Assistant

Hello All, with the wakeword now released and an existing Sonos Integration in HA, I am wondering if can use voice assistant to start playing a sonos playlist, pause or stop.

  1. I have added some Apple Music songs to a sonos playlist in Sonos App. I was wondering if there is a way to start playing this playlist with a voice command, say something like “play <my_playlist> on sonos”?

  2. Does the wakeword gets detected when there is music playing in the room ? How well trained is the open wakeword engine to detect the spoken wakeword when music is playing ? If not how can we train existing Home Assistant wakeword model by including some music and TV Sounds ? I know there is an option to train custom wakeword but I am looking to increase the accuracy of existing wake word engine implemented in HA to detect wakeword even when music or TV is playing at 50% volume ?

Bumping this … to get some help

I am using this with my Apple Music playlists. I do have to define the playlists as Sonos Favorites though, to make them visible in HASS.

custom_sentences/da/media.yaml

language: "da"
intents:

  SetSource:
    data:
      - sentences:
          - "Afspil [playlisten/playliste] {source} på {media_player}"

lists:
  media_player:
    values:
      - in: "stuen"
        out: "media_player.stue"
      - in: "stue"
        out: "media_player.stue"
      - in: "soveværelse"
        out: "media_player.sovevaerelse"

  source:
    values:
      - in: "P Tre"
        out: "DR P3"
      - in: "P3"
        out: "DR P3"
      - in: "Afslapning"
        out: "Afslapning"
      - in: "rock"
        out: "Rock"
      - in: "Toppen af poppen"
        out: "TOPPEN AF POPPEN 2021 & 2020 & 2019 & 2018 & 2017 & 2016 & 2015 & 2014 & 2013 & 2012 & 2011"

configuration.yaml

intent_script:
  SetSource:
    async_action: true
    action:
      service: "media_player.select_source"
      data:
        entity_id: "{{ media_player }}"
        source: "{{ source }}"
    speech: 
      text: >
        {% if source == 'TOPPEN AF POPPEN 2021 & 2020 & 2019 & 2018 & 2017 & 2016 & 2015 & 2014 & 2013 & 2012 & 2011' %}
          "Afspiller Toppen af poppen på {{ state_attr(media_player, 'friendly_name') }}"
        {% else %}
          "Afspiller {{ source }} på {{ state_attr(media_player, 'friendly_name') }}"
        {% endif %}

Only thing I miss is, that I don’t have to specify the room, but as far as I have heard, they are working on a solution, where we can automatically map a sattelite to a specific room or speaker, so I won’t go too custom here, even though I think someone have already posted a solution for this on the forums

Hope that helps :slight_smile:

1 Like

Thanks a lot @WonderMoose

Also are the names you mentioned in source as below are names of your playlists ? Sorry I dont understand Danish, so trying to confirm with you.

source:
    values:
      - in: "P Tre"
        out: "DR P3"
      - in: "P3"
        out: "DR P3"
      - in: "Afslapning"
        out: "Afslapning"
      - in: "rock"
        out: "Rock"
      - in: "Toppen af poppen"
        out: "TOPPEN AF POPPEN 2021 & 2020 & 2019 & 2018 & 2017 & 2016 & 2015 & 2014 & 2013 & 2012 & 2011

Also Bumping AGAIN, if someone can enlighten on above please

Yes that is the actual names of the sources. That is also why I have the “if” part in my intent_script, to stop it from saying all the years when replying to the Toppen af Poppen source :blush:

It also reacts when music is playing, often a bit to much but haven’t had time to adjust that yet. I chose Alexa, since “Ok Nabu” also triggered google Assistant. Didn’t make the full switch yet, but I am getting closer

1 Like

Awesome thanks for explaining that. Just curious what type is satellite you are using for HA voice assistant ? - a RPI or esp32 based ? I just got a M5Stack Atom echo speaker kit and planning to use it as a voice satellite for now !

I have exactly that one.
I haven’t tried other satellites since I want to make sure, that all my use cases are covered before buying too much hardware.

Biggest issue is, that it needs a restart quite a few times during the day, but I guess that is something that will be fixed. For testing purpose, it is fine as it is now

A plug for my mostly working automation that does this with sonos.

https://community.home-assistant.io/t/trying-to-use-voice-assist-to-play-music-from-sonos-libary/631451/2

1 Like

@cooljimy84 definitely will try your automation ! So thanks for this ! Just migrating my HA from an intel celeron NUC to Mac Mini 2011 this week and then will try this !