Homeassistant + alexa/google voice + control Roon playback

hello,
is there away to do that - at least execute simple play/stop commands via voice?

thanks

At least with Google Home or Nest Audio devices, the voice commands pause, resume, louder, quieter, and stop work. You still have to initiate play through a Roon Remote, though.

1 Like

I imagine you can run a HA script via a voice command. So you could probably play a playlist.

But it’s not “Play John Coltrane in the kitchen”

ah okay ;/ then its useless… and i assume there is no plan for a voice support in roon at all?

There is. I use my Echo Dot for basic (play/pause, prev/next track) control of Roon but I’m using my Harmony hub based remote with the Roon Deep Harmony extension to do it.

You might be able to do something similar with just the Roon integration in HA.

What I did is create momentary switches in HA (using an add-on; couldn’t figure out how to do this without it) and shared them with Alexa. For example, I created a momentary switch for play/pause with an automation triggered by this switch to send play/pause to my Roon Core device in Harmony. I then used a voice triggered routine with multiple aliases in Alexa so the speaking is natural (say “play” instead of “play on”).

I use momentary switches like this for a whole lot more than controlling devices added to Harmony. For example, I use them to operate Zigbee door locks and garage doors without having to enter a PIN.

As mentioned above, you can’t get Roon to play a particular album or track via a voice command using the Roon HA Integration. But you can get it to play a named playlist, radio station or genre based on the path to that resource in Roon if you hardcode it upfront in a HA script.

For example, these are some of the entries I have in my HA scripts.yaml file.

media_player.livingroompi is my media player, media_content_id is effectively the path to a resource in Roon.

# Roon playlist 
mellow_mix:
  alias: "Mellow Playlist"
  sequence:
    - service: media_player.play_media
      entity_id: media_player.livingroompi
      data:
        media_content_id: "Playlists/Mellow"
        media_content_type: "playlist"

# Roon radio          
world_service:
  alias: "World Service"
  sequence:
    - service: media_player.play_media
      entity_id: media_player.livingroompi
      data:
        media_content_id: "My Live Radio/BBCWorldService"
        media_content_type: "radio"

# Roon genres
jazz:
  alias: "Jazz"
  sequence:
    - service: media_player.play_media
      entity_id: media_player.livingroompi
      data:
        media_content_id: "Genres/Genre/Jazz"
        media_content_type: "genre"

In terms of triggering those, along with start/stop, next/prev and volume control, via Alexa in HA you have several options:

  1. Use the the paid for Home Assistant Cloud Intergration as described here. This has the downside of a monthly cost/subscription.
  2. Use the Emulated Hue Intergration to emulate a virtual Phillips Hue bridge, which you then can control via Alexa. This has the downside that everything appears as a lightbulb.
  3. Use the HA Amazon Alexa Smart Home Skill. This is free and flexible, but has the dual downside that it’s both fairly involved to setup/configure and also requires you to open your HA to the outside world (so that AWS can connect to it). Although once setup you can easily expose your Roon endpoints/media_players (for start/stop, next/prev and volume control) along with any scripts you have set to control playlists/genres/radio stations. See below for a basic example entry that would go in your configuration.yaml file. Post setup these entities and scripts will all appear in Alexa allowing you to utter ‘Alexa, play mellow playlist in Living Room HiFi’ or ‘Alexa, increase volume in Living Room HiFi’ via your Echo device,

I’ve only attempted the last of these options. It works well, but certainly isn’t a 1-click setup. It’s probably an evening work for someone already fairly familiar with Home Assistant.

btw. Alexa struggles with Roon vs Room, so better to name your HiFi / Stereo as something more recognisable.

# Alexa
# https://www.home-assistant.io/integrations/alexa.smart_home/#configure-filter
Alexa:
  smart_home:
    locale: en-GB
    endpoint: https://api.eu.amazonalexa.com/v3/events
    client_id: amzn1.application-oa2-client.####
    client_secret: ###
      include_domains:
        - script
      include_entities:
        - media_player.livingroompi

entity_config:
   media_player.livingroompi:
   name: "Living Room HiFi"
   description: "HiFi (Living Room)"
   display_categories: MUSIC_SYSTEM

That’s very cool!

Strictly speaking you can do artists - something like (I haven’t tested the code below)

play_miles_davis:
  alias: "Play Miles Davis"
  sequence:
    - service: media_player.play_media
      entity_id: media_player.livingroompi
      data:
        media_content_id: "Library/Artists/Miles Davis"
        media_content_type: "music"

You can use templates to get variable parameters - and scripts can even have parameters - but I don’t know if there is a way to get the artist parameter from the voice recognition that would make this useful.

So an example (again I haven’t tested this)

play_artist:
  alias: "Play Artist"
  fields:
      artist:
        name: Artist
        description: "The artist you'd like to play"
        required: TRUE
  sequence:
    - service: media_player.play_media
      entity_id: media_player.livingroompi
      data:
        media_content_id: "Library/Artists/{{artist}}"
        media_content_type: "media"

Yes, that would be perfect, although I seem to remember (it’s been a while since I looked into it) that you couldn’t (at least easily) get Amazon to parse out say the artist name parameter and pass that back to Home Assistant.

Looking at BlueOS they seem to be limited by the same restriction ie. you can get Alexa to trigger an existing command (which has been pre-registered with Alexa like a genre or preset) but you can’t extract a parameter from the spoken text and pass it to a command.

Sonos manages to achieve tighter level of integration that allows playback of artists / tracks by name. But like so many of Sonos’ exclusive integrations they probably have the market share to persuade Amazon to make an exception to the rule.

Love to hear if someone does figure out how the (artist/track) parameter could be extracted and passed back to Home Assistant as that would be the final piece of the puzzle.

The best (workaround) I can think of for now would be for Home Assistant to query Roon for a list of Genre, Playlists and Radio stations (and possibly even artists, although I think Alexa has a limit on commands) and expose them all as entities to Alexa via a HA script.

1 Like

Try it by Siri