Roon module for Home Assistant

I’ve done a little testing. I don’t know if I’m doing something wrong, but I had issues with the scenes approach. Essentially music randomly started playing again on all outputs because for whatever reason it decided I was “turning off” my scene.

The button that sends mdi:speaker-pause to all my roon zones is working perfectly, thanks for the idea!

1 Like

Glad you got it working.

Roon endpoints in HA can’t exactly reproduce their state so I can imagine that scenes might have problems.

For kicks…here’s what I did for bi-directional transfer using a Lutron pico remote, though any trigger will do. I’m lousy at HA and YAML - I’m sure there are better ways to do it.

alias: gUniti <-> gFiiO
description: ""
trigger:
  - platform: device
    device_id: e5f110c13e234b7afb94f741339bc1b0
    domain: lutron_caseta
    type: press
    subtype: stop
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: media_player.guniti
            state: playing
        sequence:
          - service: roon.transfer
            data:
              transfer_id: media_player.gfiio
            target:
              device_id: 5c85d4211163cd8d12e0a27e0ddac57d
              entity_id: media_player.gfiio
      - conditions:
          - condition: state
            entity_id: media_player.gfiio
            state: playing
        sequence:
          - service: roon.transfer
            data:
              transfer_id: media_player.guniti
            target:
              device_id: 6a9249325e8ab5687a744a990d03a5c7
              entity_id: media_player.guniti
mode: single
1 Like

I don’t you need the `device_id, but if it works, that’s great.

This is mine in YAML


service: roon.transfer
data:
  transfer_id: media_player.bedroom
  entity_id: media_player.shower

You can make these in the visual editor

Interesting - my recollection was that it didn’t work without it but, given your example, I’m probably wrong. My quality bar for HA/YAML, though, is “it’s correct if it works” for I’m not going to screw with it :slight_smile:

1 Like

Thanks @GregD for the pointer. Here’s an improved version of this for the historical record :slight_smile:

This now transfers from one to the other only in the case where one zone is playing and the other isn’t. I appreciate the help!

alias: gUniti <-> gFiiO
description: "Transfer Roon playback between gUniti and gFiiO depending on which is playing"
trigger:
  - platform: device
    device_id: e5f110c13e234b7afb94f741339bc1b0
    domain: lutron_caseta
    type: press
    subtype: stop
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: media_player.guniti
            state: playing
          - condition: not
            conditions:
              - condition: state
                entity_id: media_player.gfiio
                state: playing
        sequence:
          - service: roon.transfer
            data:
              entity_id: media_player.guniti
              transfer_id: media_player.gfiio
      - conditions:
          - condition: state
            entity_id: media_player.gfiio
            state: playing
          - condition: not
            conditions:
              - condition: state
                entity_id: media_player.guniti
                state: playing
        sequence:
          - service: roon.transfer
            data:
              entity_id: media_player.gfiio
              transfer_id: media_player.guniti
mode: single

1 Like

That seems like a decent improvement, and with the not statements you’re clearly getting the hand of this!

1 Like

Home Assistant on off switch for Roon Rock

In case anyone is interested I’ve added a switch to my home assistant - which will turn on and off a Roon ROCK. I’ve set up an automation to turn mine off late at night - and turn back on early in the morning to try and save a little power.

This uses two home assistant integrations - neither of them roon specific! One allows you to send wake on lan packets - the other allows you to call rest services.

To send a wake on lan packet - you need to find the mac address of your ROCK/Nucleus. The easiest way to do this is via your router.

You should also set your ROCK to have a fixed IP address - again you should be able to do this in your router.

Then you can add the following to your home assistant configuration.yaml replacing the mac and ip addresses with your own.

switch:
- platform: wake_on_lan
  name: Elsden Rock
  mac: 9a:c6:91:xx:xx:xx
  host: 192.168.1.00
  broadcast_port: 50000
  turn_off:
      service: rest_command.turn_off_rock

rest_command:
  turn_off_rock:
    url: "http://192.168.1.00/1/poweroff"

There used to be a bug in my home assistant roon integration that after repeatedly trying to reconnect to a turned off roon core - would then fail to connect at all. I’ve had this working without any issues for a week now - turning off my ROCK overnight - and back on in the morning. It’s always reconnected fine so I’m pretty happy the bug is fixed.

Just remember that after you turn ROCK on - it can take a couple of minutes to start-up and re-connect to HA.

3 Likes

That’s clever, @GregD.

Have you used or played with ControllerX?

It seems like a potential path to getting a broad set of controllers to work with Roon. It solves for getting things set up in the first place but also for things like pressing and holding a volume control button. It requires AppDaemon, though, and I’m not sure how most HA users feel about that.

I may find time to play with it this weekend.

I haven’t tried it.

I have a couple a Philips hue dimmer I used to control one roon zone - but I mostly just use roon remote.

Let me know how you get on.

I’ve used an Ikea Symfonisk remote/dial with Controller X, for the most part it works pretty well.

1 Like

Thanks - I wasn’t following this thread when you made your initial post.

I went partway down this path yesterday - got SSH, HACS, AppDaemon, ControllerX all installed but not actually wired up to do anything. I backed out of it, all though, because I got got intrigued by the Controllers-Hooks approach which, coincidentally, is mentioned on the post following yours in the linked thread.

I have a SONOFF dongle and an Aqara switch supposedly arriving today. I’m going to see if I can get that approach working before I commit to ControllerX. The pre-reqs for ControllerX are steep, to say the least.

Looks like they might be phasing them out in the UK as well. Currently they are on sale for £5 :grinning: Which if you already have a Zigbee dongle is a bit of a bargain.

I think they’re replacing with a non-rotary version. If they had any in stock at that price here, I’d buy a bushel and go into business on eBay. :slight_smile:

I think this is the new version:

Continuing my Home Assistant and Roon integration journey.

I bought a $12 Tuna Zigbee knob on Amazon. I have it sort of functioning as a Roon remote. I say sort of functioning because I can control a Roon zone’s volume by rotating it. I say “sort of functioning” because it doesn’t seem to generate rotation events in a manner that maps to how you interact with it - it has little detents maybe every 10 degrees or so and you’d expect a rotation event as it passes each one, but that’s not what it does.

In the end, it works as long as you ignore the disconnect between the haptic feedback and the volume control behavior.

I have it up with MQTT and Zigbee2MQTT. Blueprints were a dead end, so just automating based on events.

This did, at least, force me to figure out how to get volume to step by 1 in an automation. Automation below. Maybe there’s a better way to do it but this was the best I could come up with.

All up, this is: RPi 4, Sonoff ZBDongle-P, MQTT, Zigbee2MQTT.

image

alias: SmartKnob - FiiO Increase Volume
description: ""
trigger:
  - platform: device
    domain: mqtt
    device_id: 8451f94282dbec0c3eecd5b26e257a61
    type: action
    subtype: rotate_right
    discovery_id: 0x003c84fffea4d15e action_rotate_right
condition: []
action:
  - service: media_player.volume_set
    data_template:
      entity_id: media_player.guniti
      volume_level: >-
        {{ (state_attr('media_player.guniti', 'volume_level') + 0.01) | round(2) }}
mode: single
1 Like

I’ve looked into that and it seems excessively complex to me.

I am able to configure an IKEA Symfonisk rotary remote (or pretty much any IKEA remote) to control pretty much anything in Roon, or anything really in my HA setup just with a Zigbee dongle and the ZHA integration.
Not sure what am I missing by not using Controller X/App Daemon but happy to learn - thank you.

I gave up on ControllerX. Complicated and couldn’t get it working well with the controller I was playing with.

Happen to have any wisdom or examples to share around how you use your IKEA controllers? Blueprints? Manually programming each button on each remote?

I have a couple of the new generation Symfonisk controllers shipping to me now, though they’ve been delayed in transit long enough for me to start wondering if they’re lost.

mostly blueprints, but not all of them work as advertised… some of them simply do nothing, or maybe just one action works etc.
for example this blueprint
ZHA - IKEA Symfonisk sound controller for media
works quite well for the rotary control, the only thing that’s not quite perfect is the volume control which works in too large steps… there is a setting for volume steps that I am yet to play with, maybe that allows better granularity. But this is not a huge deal for me and the playback control works very well and it is very stable - I have it working for a couple months already and it didn’t fail, unlike some other HA features that seem to have the habit of failing every now and then without apparent reason…

in any case, once the ZHA integration exposes the remote’s button functions to HA you can very easily program any button to do anything to any other device that is integrated with HA.

before I found a blueprint that worked I simply added an automation for each button, not an elegant solution but it does work exactly the same - the only difference is that you will see a ton of automations in your list…

Thanks. I’ve gone down the same path you have and have seen the same things including broken blueprints and issues with volume steps.

If you look up a couple of posts, you’ll see what I did to manually manage volume steps. That script hits a rounding error in some downstream piece of code which causes a behavior in which you can’t adjust the volume beyond some specific points (it’s a float thing, I think). If you want to play with it to get your rotary volume control more dialed in, let me know and I’ll post an updated version which works around the rounding issue.

1 Like

FWIW I’ve been using home assistant from well before blueprints - so have yet to try them!

Did you try the default volume_up and volume_down - works well with my hue - but I guess the steps may be too big.

It shouldn’t be too hard to add some rounding into that script, probably making the increment very slightly larger - 0.011 or 0.015) would do the trick.