Roon module for Home Assistant


(Mike C) #54

Upgraded
Media info now updating.

Track next and previous work, volume works but the pause button is not behaviour I was expecting.

Pause seems to be the same as turning off. ie the album art and track information disappears and play button greys out. You have to press the power button to resume play.
Is this the expected behaviour?

Also any chance you can post your configuration.yaml? Not sure I have the playlists widget right as per your notes on github.

What I would like to be able to do is to have Roon go to the Radio playlist (not internet radio) when I turn it on in HASS. This would link to Google Home (which currently only maps to Switches) so that I can say “Hey Google turn on Roon” and it goes straight into the radio play list and starts playing.

Mike C


(Marcel van der Veldt) #55

Software players (Roonbridge or client on pc/mac) do not have a power button/function so you can never turn them off. The Roon API returns these players as not supporting standby. Hardware players however (or players with additional source control) do have a power control so these can be turned off.

I was struggling a bit with this for a while because my family couldn’t understand why a zone was still listed as “powered on” in home assistant while it was not playing. So, I came up with a workaround by showing the players that do not support standby which are pauses/stopped as powered off.

Offcourse this is a personal preference for my own situation so I will append a configuration toggle for this behaviour in next update.

This is the configuration I have in place for the playlist widget:

input_number:
  roon_volume:
    name: Volume
    icon: mdi:volume-high
    min: 0
    max: 1
    step: 0.01
input_select:
  roon_playlists:
    name: 'Playlist:'
    options:
      - Selecteer playlist
    initial: Selecteer playlist
    icon: mdi:spotify
  roon_players:
    name: 'Ruimte:'
    options:
      - Selecteer ruimte
    initial: Selecteer ruimte
    icon: mdi:speaker-wireless

Note that I used dutch phrases for the names, you can name those whatever you want.
In my views (groups section of hass), I’ve added this group:

roon_actions:
  name: Muziek spelers
  entities:
    - input_select.roon_players
    - input_select.roon_playlists
    - input_number.roon_volume

And this group is added to a view I created for all music related stuff:

muziek:
  name: Muziek
  view: yes
  entities:
    - group.roon_actions
    - group.roon_players

Now to make it even more complete, I’ve added each individual player to each “room view” in hass but that’s more personal taste I guess.

If you want to use hass to say “Turn on playlist Radio” or something like that with Google Assistant or Alexa, the most easy way (atm) is by using a script. Just add a script to your home assistant section;

script:
  playlist_radio:
    alias: "Playlist Radio"
    sequence:
      - service: media_player.play_media
        entity_id: media_player.kitchen
        data:
          media_content_id: "My playlist name in Roon"
          media_content_type: "playlist"

I don’t know about Google Assistant but Alexa picks up these scripts as available entities so you can just control them like your lights.

Offcourse a real integration between Google and/or Alexa would be even better but for now you can already do a lot with using hass in between.


(Mike C) #56

Hi Marcel, a toggle should do it.
I have both Alexa and Google Home here so will play with these and report back

Mike C


(Mike C) #57

Hi Marcel

Just another small item.

The Playlist / Radio stations list in the Bonus widget is not updating when changes are made in Roon.
Again not sure if this is expected behaviour. When I reload the HASS core it updates, not a big issue as I don’t think I will change these too much once set up.

The Room selections work as expected ie when a Roon endpoint is removed or added it updates (this is really nice by the way).

A more serious issue is I’m getting crashes in the NodeJS server occasionally

Here is output from the console

[mike@ThinkPad-T410 roon-extension-api-proxy-master]# node .
Listening on port: 3006
/home/mike/Downloads/roon-extension-api-proxy-master/node_modules/node-roon-api/moo.js:187
let cb = this.requests[msg.request_id].cb;
                                       ^

TypeError: Cannot read property 'cb' of undefined
at Moo.handle_response (/home/mike/Downloads/roon-extension-api-proxy-
master/node_modules/node-roon-api/moo.js:187:44)
at Transport.transport.onmessage.msg [as onmessage] (/home/mike/Downloads/roon-extension-
api-proxy-master/node_modules/node-roon-api/lib.js:411:27)
at WebSocket.Transport.ws.onmessage (/home/mike/Downloads/roon-extension-api-proxy-
master/node_modules/node-roon-api/transport-websocket.js:30:14)
at WebSocket.onMessage (/home/mike/Downloads/roon-extension-api-proxy-
master/node_modules/ws/lib/WebSocket.js:442:14)
at emitTwo (events.js:126:13)
at WebSocket.emit (events.js:214:7)
at Receiver.onbinary (/home/mike/Downloads/roon-extension-api-proxy-
master/node_modules/ws/lib/WebSocket.js:848:10)
at /home/mike/Downloads/roon-extension-api-proxy-
master/node_modules/ws/lib/Receiver.js:628:18
at Receiver.applyExtensions (/home/mike/Downloads/roon-extension-api-proxy-
master/node_modules/ws/lib/Receiver.js:371:5)
at /home/mike/Downloads/roon-extension-api-proxy-
master/node_modules/ws/lib/Receiver.js:604:14

Mike C


(Marcel van der Veldt) #58

Hi Mike, the playlists/radios are updated every 5 minutes, the players are updated instantly indeed as changes are actively pushed by the web sockets.
The crash appears to be happening in the API library itself but I’ll see if I can reproduce. Make sure that the node module (or docker container) is auto restarted when it happens for the time being.


(Mike C) #59

Thanks Marcel

I have created the following script that restarts the service for anyone else that needs it (Ubuntu 16.04).

#!/bin/bash
# NodeJS respawn script, replace path for node with location where you downloaded the code

until node /home/mike/Downloads/roon-extension-api-proxy-master; do
    date +"%r"
    echo "Server 'nodejs' crashed with exit code $?.  Respawning.." >&2
sleep 1
done

exit 0

I had a load of crashes (exit code1) when it was just sitting there and Roon was not playing or active.

Also I see this problem is also here

https://community.roonlabs.com/t/roon-extension-manager-v0-5-1-now-on-github/26632/94

Looks like an API Issue as you say.

On the update, every 5 Mins is that what Roon updating or you are polling every 5Mins?

Otherwise, this works great and I love being able to select a Roon endpoint and a playlist or radio from HASS and it just plays. I’m finally going to look at the G-home connections now.

Cheers
Mike C


(Marcel van der Veldt) #60

@Oldbloke I am polling every 5 minutes for the playlists and web radios. Player updates are received instantly by the web sockets connection.


(Marcel van der Veldt) #61

BTW: there’s an updated version online with the fix for the players showed as off.


#62

I am having some issues with this and not sure where the issue lies. I have followed the setup instructions and installed the Extension on Roon (has been enabled too), copied across the roon.py file into the custom-components/media_player folder and added the entry to the configuration.yaml file but I am not seeing anything show up on Hass.

Looking at the HA log the only roon messages are -

WARNING (MainThread) [custom_components.media_player.roon] input_number and input_select objects do not (yet) exist. Skip playlist generation...

Cant see anything else though so not sure what the issue could be?


(Marcel van der Veldt) #63

Did you point the config in hass for roon to the api proxy you installed ?


#64

Yeah here is the configuration.yaml entry -

  - platform: roon
    host: 192.168.1.26
    port: 3006

Just to note, the api proxy is setup on the same computer as the Roon Core


(Sjee) #65

@Marcel_van_der_Veldt this is really great! and very well done. Got it up and running in 5 minutes!


#66

@Marcel_van_der_Veldt Got this up and running last week. So far everything has been working great, thanks for your work on this!

I’ve got Roon running on an i5 Intel Nuc with all other software in docker containers (including home assistant). I setup ha-dockermon which lets me control my docker containers in home assistant with switches. I created an automation so that when Roon starts playing, all my docker containers (excluding HASS) shut down so I have adequate system resources for DSP. It’s a pretty slick feature, for those with home assistant in docker I would highly recommend implementing it.


(Marcel van der Veldt) #67

Great, thanks for the feedback!

I have exactly the same setup with an i5 NUC running docker for some stuff like Plex and Roon.
So far I did not yet needed to shutdown docker images to properly run Roon with DSP but thanks for the tip.


(Marcel van der Veldt) #68

sorry for the late reply. Did you manage to get it running or not yet ?


#69

Not yet - have been having tackling some radiator devices so haven’t had time to really look into this, that being said I am not really sure where I would even start with this as there doesn’t seem to be any errors or anything like that. Any ideas?


#70

Just wanted to say I managed to get mine working now, moved the Core to another PC and that seemed to work out the issue…not sure what the cause was though.

Going to have a look at getting it nicely integrated but I can see all the endpoints at least so thats a good start. Was wondering whether there was any development on the tts/announcement stuff you were working on? That would be amazing to get going…was really disappointed it wasn’t something that could be done through the iTunes extension


(Kian) #71

Hi Marcel,

great extension you built here.

it appears to work on my HASS, but scripts do not work at all.

After following your instructions, I can see the mediaplayer for Roon within HASS and everything I am playing on Roon is correctly shown in HASS and I can also fully control the roon media player component.

However, I would also like to use HASS for playing a radio station from within Roon, but it only runs into an error:

Log Details (ERROR)
Mon Aug 27 2018 13:03:22 GMT+0100 (Western European Summer Time)

Error executing service <ServiceCall media_player.play_media (c:b15d158f232243a19ac5295f5517aeae): media_content_id=1Live, media_content_type=radio, entity_id=[‘media_player.d220’]>
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/core.py”, line 1117, in _event_to_service_call
await service_handler.func(service_call)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/media_player/init.py”, line 442, in async_service_handler
await getattr(player, method[‘method’])(**params)
TypeError: object generator can’t be used in ‘await’ expression

thats the script I defined within HASS:

roon_music:  
  alias: Play Roon Radio
  sequence:
    -  service: media_player.play_media
       entity_id: media_player.d220
       data_template:
         media_content_id: 1Live
         media_content_type: radio

I tried, using quotes around id and type as well. And as content_id I am using the name of the station as mentioned within Roon -> Internet Radio -> 1Live (Name of the station):


(Marcel van der Veldt) #72

I’ve built a new version of the hass module, now no longer dependent of the proxy as I managed to get it talking directly to Roon instead. I’ll update GH later today with the new code. I’m al;so planning to submit it to hass for official inclusion.


(Wouter du Toit) #73

Great work!

Thanks!