Roon module for Home Assistant

Hi Dan,

There is - I have mine doing exactly what you ask (working with single press, double press and long press). What you need to is the latest firmware on your IKEA device…

The shipped firmware doesn’t send the messages needed.

So you need to update your firmware version. Unfortunately that is a bit of a hassle

I did mine when I was still using deconz (before I switched to ZHA) - but if you look carefully at the link you posted above you will see some advice (and a link) that others have found helpful.

Look for ZHA OTA Firmware Update / Upgrade

I just realised you may already have the buttons working.

In that case your question is really about home assistant automations.

What I would do is to look at helpers - which are sort of like global variables - you can create a helper that can be the name of the media player you want to control.

And then you can use a template in your automation that gets the media player from the helper.

Once you have a soft coded version of the automation - you can then think about how to get the buttons to change the helper.

I have a roon alarm clock that does something similar using three helpers, which may help you get started.

You can see the play_media command gets the name of the entity to use via a template from the helper called input_select.alarm_zone

alias: Hi Fi - Alarm Clock
description: ""
trigger:
  - platform: time
    at: input_datetime.alarm_clock
condition:
  - condition: state
    entity_id: input_boolean.alarm_clock_enable
    state: "on"
action:
  - service: media_player.play_media
    data:
      media_content_id: My Live Radio/BBC Radio 4
      media_content_type: music
      entity_id: media_player.{{states.input_select.alarm_zone.state}}
mode: single

This depends on the blueprint accepting a template instead of a hardcoded media player - but I expect that will work (although you may need to edit in yaml instead of using the gui).

And if you haven’t used templates before - take a look at Developer Tools / Templates - which allows you to try template code live on your running HA - so you can easily write them.

Thanks a lot Greg - you’re throwing me at the deep end here, but I’ll try to swim :slight_smile:

First, the dot buttons don’t seem to work - I added an action (toggle a light) and it didn’t do anything. So I suppose I need to update the firmware first - I did see that guide on how to do that under the ZHA integration but I thought I’d give it a try first and the main functions work without an update. Probably the update is only adding the dots buttons. I’ll give that a try.
Then if I get the buttons to work I’ll go on and try the other bits you suggested. Thanks for taking the time to help with this!

1 Like

I had the same experience - everything worked except the dot controls on the older firmware.

The firmware stuff is no doubt a hassle, sadly not much upside

The HA automation experience will get you well grounded in HA - and will no doubt come in useful.

If you get stuck - let me know and I’ll try and help.

I’m actually updating the firmware right now using the Ikea Home Smart app - I have a tradfri hub, I reset the remote, paired with the hub and now it’s updating. Looks like it will take a while - I’ll leave it overnight - but it’s almost zero hassle. When it’s done I’ll just reset it again and pair it with the Zigbee controller and take it from there :slight_smile:

2 Likes

That sound a lot easier!

I don’t know what it’s like doing firmware updates with ZHA, but it takes Z2M hours to update one of those Ikea controllers. It took just a few minutes to update a Philips Tap Hue Dial, though. Hopefully easier and more reliable to do it the way you’re doing it with the Ikea app.

This may sound a bit crazy but chatGPT is very good at helping with this sort of thing. You can give it very long prompts and it will give you very specific and helpful responses. You can say “Here’s a blueprint I’m using in Home Assistant {blueprint}. I’d like to create a custom automation that responds to the triggers used in this blueprint but I’d like my automation to make button 1 cycle through different media players using an input helper. How do I do this?”

You will be surprised at what you get back. I pay for chatGPT and, in my opinion, it’s worth it for this sort of thing alone.

1 Like

My firmware updates via deconz took many hours too.

Amazing on Chat GPT!

1 Like

Just in case you don’t believe me, I just entered the exact prompt I described above and pasted in the blueprint that @DanMtsn is using.

Here’s what I got. See what I mean?

Creating a custom automation in Home Assistant that responds to triggers from your IKEA Symfonisk sound controller and cycles through different media players using an input helper involves a few steps. You’ll need to define an input helper to store the current state, update it with each button press, and then use that state to control different media players. Here’s a general guide on how to set this up:

  1. Define an Input Select Helper:
    First, create an input select helper in Home Assistant to keep track of which media player is currently selected. You can do this in the Home Assistant UI under Configuration → Helpers → Add Helper → Dropdown.

    Example:

    input_select:
      selected_media_player:
        name: Selected Media Player
        options:
          - media_player.player1
          - media_player.player2
          - media_player.player3
        initial: media_player.player1
    
  2. Create a Script or Automation to Cycle Through Media Players:
    Next, create a script or an automation that changes the value of this input select to the next media player in the list each time it’s triggered.

    Example:

    alias: Cycle Through Media Players
    sequence:
      - service: input_select.select_next
        target:
          entity_id: input_select.selected_media_player
    mode: single
    
  3. Modify Your Custom Automation:
    In your custom automation, add an action that calls the script or directly changes the input select when button 1 is pressed.

    Example:

    # Part of your custom automation
    - conditions:
        - '{{ command == "short_release" }}'
        - '{{ endpoint_id == 2 }}'
      sequence: 
        - service: script.cycle_through_media_players
    
  4. Control the Media Player Based on the Selected Input:
    Finally, add or modify actions in your automations to control the media player based on the currently selected media player in your input select. You can use template data to dynamically target the media player.

    Example:

    - service: media_player.play_media
      target:
        entity_id: "{{ states('input_select.selected_media_player') }}"
      data:
        media_content_id: 'some_content'
        media_content_type: 'music'
    

This setup allows you to cycle through your defined media players with each press of button 1 on your IKEA Symfonisk controller, and then control the selected media player accordingly.

Remember to reload your automations after making these changes. If you need more specific guidance or have further questions, feel free to ask!

2 Likes

That is really very impressive!

So I forgot about it overnight and all day today and it’s now updated to 1.0.35
The IKEA tradfri firmware update is very easy if you have an Ikea hub

Have you tried this and it works? It’s not that I don’t believe you :slight_smile:

I’m asking because I tried similar approaches with chat gpt for other things and while it gave very detailed instructions I found out that when trying to implement there were always little details that were wrong, or imprecise, or it assumed that I had certain frameworks or programming languages installed and eventually it was impossible for me to complete the task.

I’m definitely going to try those suggestions anyway, thanks for posting them!

Did I try the specific instructions it gave in my post above? Nope. But I know Home Assistant pretty well and those instructions are a fantastic starting point. It walked through creating the input helper, changing it, using it.

It’s probably wrong or inexact in a number of small ways but that guidance is a great starting point.

I use chatGPT daily for all sorts of technical and programming stuff. I use it iteratively. I ask it follow-up questions, tell it when it’s wrong and let it correct itself (or at least try). I ask it to code stuff to give me a starting point. If I don’t know a linux command for something, or I want a command that might be complex, I ask for it. Sometimes I paste raw data sets in and ask it to transform them.

Best USD$15 I spend on anything :slight_smile:

1 Like

Would be keen to know, with the year of the voice project in Home Assistant, if it is possible to use sentence wildcards i.e. “Play music by {artist}” where it will search Roon for the artist / song / album and play the closest search result, even when the wildcard is not an exact match.
I have had a play around and can only get part of the way.
Custom Sentence:

language: "en"
intents:
  PlayMusic:
    data:
      - sentences:
          - "(play|listen to) music by {artist}"
lists:
  artist:
    wildcard: true

Sentence Intent Trigger

intent_script:
  PlayMusic:
    action:
      service: "media_player.play_media"
      data:
        entity_id: media_player.system_output
        media_content_type: music
        media_content_id: Library/Artists/{{artist | title}}

This works with 80% of enquiries and only when there is an exact match (case sensitive as well). Also this only works at the moment for artist. I can see Roon Command Line would have the correct functionality I am searching for, but can’t for the life of me find a way to incorporate this into a call service that can be triggered from intent.

The home assistant roon integration has a Roon specific format to play media.

You basically need to specify a Roon specific path to the media you want to play.

You can see the basics here: RoonLabs music player - Home Assistant

There are two ways to work out a path, either use the media browser integrated into the roon media player in HA, or try an incorrect path and then look at the debugging info in the HA log - which shows the valid options at the point it failed.

Not sure how well this will work with voice, but I suggest using explicit play media calls to start with - and then try adapting them.

I’ve not tried this (I don’t use voice) - I don’t know if anyone else has.

@gTunes the new release of HA (2024.1.0) contains the volume truncation / rounding fix that I hope will help your Linn volume issues.

Hi, @GregD. I installed the update yesterday and saw the fix in the release notes but didn’t have time to look at until today.

The fix seems to have worked perfectly. Based on our private conversations and the spreadsheet that we put together, I thought there would be a few places in the 0-84 range where incrementing by 1 either had no effect or incremented by 2 but I’m not seeing that at all. It’s working perfectly.

I can dig into this further if you’re interested but I’d prefer to declare victory and move on :slight_smile:

Thank you for this fix and for supporting the integration!

1 Like

Perfect!

Thanks for the detailed bug report. Made it much easier to track down!

1 Like

I’ve discovered what I think is a bug in the volume handling of the Roon module.

When I try to change volume for the Roon player nothing happens. This occurs for me whether I clock on the device and then move the volume slider, or whether I use a script to directly set volume_level via media_player.volume_set .

This is occurring for several Roon devices, but I’ve found a workaround. For some reason if I mute the media player (via media_player.toggle ) all the volume commands then start working up until I reboot the HA Core.