Roon module for Home Assistant

(Wouter du Toit) #41

Figured it out, service should be play_media, not media_play…haha

(Wouter du Toit) #42

I am experiencing some issues with Room discovery. When my Zones leave and come back they don’t appear and I can no longer control them. i did update to latest version.

So when HASS starts, take a while for the dropdowns to get populated, but then everything works. After 30 minutes only my BlueSound and Appletv was in the list, and I couldn’t get my iMac sources to display. Same goes for the group.roon_players.

Not sure if it is HASS not getting the updates from Roon-api-proxy, or the api-proxy not seeing the correct lists in Roon. When I look at the Zone list in Roon all the zones are there.

(Mike C) #43

Just wanted to say that I am looking at installing this today on my HASS hassio setup, many thanks for making this happen. Would also be interested to see if we can get it working with the Google Home/Assistant integration in HASS.

Mike C

(Marcel van der Veldt) #44

It will work out of the box with Google Assistant, Siri (homebridge) and Amazon Alexa. Home assistant will take care of that for you

(Mike C) #45

First Bump
When trying to install Node.js on Ubuntu 16.04 the script could not find the “node” command
I symlinked the command to get by this

sudo ln -s /usr/bin/nodejs /usr/bin/node

Now I am getting a syntax error on the script

Node version is 4.26, I think I need 4.7?
edit: I see the API docs say you need 5.X or higher

        let curZones = msg.zones.reduce((p,e) => (p[e.zone_id] = e) && p, {});

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

(Marcel van der Veldt) #46

Yes, you need a newer version of node.

(Mike C) #47

Reply to myself.
Upgraded to latest node.js from these instructions

node.js version 8.9.4

and hey presto its now up and running, next step is HASS

(Mike C) #48

This is now working on Hassio on a Raspberry Pi

Many thanks for this, will test and look to set up to work with Google Home

Mike C

(Mike C) #49

Hi Marcel

One small problem I’m seeing is that the album playing info is not being updated when I change tracks or albums.
It stays with whatever it sees when HASS first starts.
My Roon core server is running on a different machine to HASS. Also endpoint is yet another machine.

Mike C

(Marcel van der Veldt) #50

Will provide an update later today in which this is fixed, also fix for the issue reported by @Wouter_du_Toit

(Marcel van der Veldt) #51

new version is on GitHub

(Wouter du Toit) #52

Thanks, upgraded!

(Wouter du Toit) #53

Thanks @Marcel_van_der_Veldt it is has been working really well with the updated version…after 3 hours all my “rooms” are still in the list!


(Mike C) #54

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:

    name: Volume
    icon: mdi:volume-high
    min: 0
    max: 1
    step: 0.01
    name: 'Playlist:'
      - Selecteer playlist
    initial: Selecteer playlist
    icon: mdi:spotify
    name: 'Ruimte:'
      - 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:

  name: Muziek spelers
    - 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:

  name: Muziek
  view: yes
    - 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;

    alias: "Playlist Radio"
      - service: media_player.play_media
          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
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-
at Transport.transport.onmessage.msg [as onmessage] (/home/mike/Downloads/roon-extension-
at (/home/mike/Downloads/roon-extension-api-proxy-
at WebSocket.onMessage (/home/mike/Downloads/roon-extension-api-proxy-
at emitTwo (events.js:126:13)
at WebSocket.emit (events.js:214:7)
at Receiver.onbinary (/home/mike/Downloads/roon-extension-api-proxy-
at /home/mike/Downloads/roon-extension-api-proxy-
at Receiver.applyExtensions (/home/mike/Downloads/roon-extension-api-proxy-
at /home/mike/Downloads/roon-extension-api-proxy-

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).

# 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

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

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.

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.