INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]   Go Down

Author Topic: Home Assistant integration for jriver  (Read 8269 times)

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #50 on: April 14, 2024, 10:13:03 am »

Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #51 on: April 14, 2024, 10:24:19 am »

in fact, I'd say it's an MC bug so keep an eye on https://yabb.jriver.com/interact/index.php/topic,138671.0.html
Logged

flac.rules

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1268
Re: Home Assistant integration for jriver
« Reply #52 on: April 17, 2024, 03:46:09 am »

Sorry, I am a bit confused after reading the bug thread and the answer. I want to browse and play my playlists. Is that something i should be able to do with the plugin now?
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #53 on: April 17, 2024, 04:03:15 am »

Not via browsing no, I have to add a workaround as MC won't change their api
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #54 on: July 04, 2024, 04:12:43 pm »

finally got round to this, I think latest version (0.2.7) should allow playlist selection
Logged

casper3127

  • Recent member
  • *
  • Posts: 18
Re: Home Assistant integration for jriver
« Reply #55 on: August 09, 2024, 02:38:45 am »

I’ve been using Home Assistant for a while now, and integrating it with different applications has been a game-changer for my setup.

I checked out your GitHub page and the integration looks promising. If you’re new to Home Assistant or looking for a guide on setting it up, https://www.mklibrary.com/how-to-install-home-assistant-on-synology/ has some useful info that could help with the initial setup.
Logged

sjhilton

  • Junior Woodchuck
  • **
  • Posts: 86
Re: Home Assistant integration for jriver
« Reply #56 on: September 02, 2024, 07:15:54 am »

Hi Matt - I just wanted to say thank you for developing this. Only discovered your work on this integration today. Works really well. I did find an issue with pausing and resuming playback. For whatever reason playback my client refuses to restart after pause from the Home Assistant interface. Might be an issue with my setup.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #57 on: September 02, 2024, 11:07:21 am »

I guess it might depend on which widget you use in the front end assuming this is driven by user control rather than some automation?
Logged

sjhilton

  • Junior Woodchuck
  • **
  • Posts: 86
Re: Home Assistant integration for jriver
« Reply #58 on: September 03, 2024, 05:10:54 am »

I guess it might depend on which widget you use in the front end assuming this is driven by user control rather than some automation?
Thanks Matt. It's the default media control card. I've noticed that pushing the power button freezes the player as well. In your experience is there a better card (custom or otherwise) to use?
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #59 on: September 03, 2024, 06:24:45 am »

Not sure about but I use https://github.com/kalkih/mini-media-player combined with the built in one for it's browse function (which I rarely use tbh as it has no search feature and is not customisable) and a bunch of other buttons for convenience

I will post that config later to illustrate

Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #60 on: September 03, 2024, 09:07:50 am »

here's a snippet of my ui

Code: [Select]
- type: entities
  show_header_toggle: false
  entities:
    - card_type: vertical-stack
      type: custom:hui-element
      cards:
        - card_type: horizontal-stack
          type: custom:hui-element
          cards:
            - name: -5m
              tap_action:
                service: jriver.seek_relative
                target:
                  entity_id: media_player.paradroid
                data:
                  seek_duration: -300
              template: thin_button
              type: custom:button-card
            - name: -30s
              tap_action:
                service: jriver.seek_relative
                target:
                  entity_id: media_player.paradroid
                data:
                  seek_duration: -30
              template: thin_button
              type: custom:button-card
            - name: -1s
              tap_action:
                service: jriver.seek_relative
                target:
                  entity_id: media_player.paradroid
                data:
                  seek_duration: -1
              template: thin_button
              type: custom:button-card
            - name: +1s
              tap_action:
                service: jriver.seek_relative
                target:
                  entity_id: media_player.paradroid
                data:
                  seek_duration: 1
              template: thin_button
              type: custom:button-card
            - name: +30s
              tap_action:
                service: jriver.seek_relative
                target:
                  entity_id: media_player.paradroid
                data:
                  seek_duration: 30
              template: thin_button
              type: custom:button-card
            - name: +5m
              tap_action:
                service: jriver.seek_relative
                target:
                  entity_id: media_player.paradroid
                data:
                  seek_duration: 300
              template: thin_button
              type: custom:button-card
        - type: custom:stack-in-card
          cards:
          - type: custom:mini-media-player
            entity: media_player.paradroid
            max_volume: 80
            volume_step: 1
            artwork: full-cover
            hide:
              jump: false
              play_stop: false
              runtime: false
              runtime_remaining: false
              power_state: false
            view_layout:
              grid-area: media
            shortcuts:
              columns: 5
              buttons:
                - icon: mdi:power-plug-off
                  type: script
                  id: script.stop_all_playback_in_cinema
                - icon: mdi:alpha-a-box-outline
                  type: script
                  id: script.hdr_mode_auto
                - icon: mdi:numeric-1-box-outline
                  type: script
                  id: script.hdr_mode_one
                - icon: mdi:numeric-2-box-outline
                  type: script
                  id: script.hdr_mode_two
                - icon: mdi:numeric-3-box-outline
                  type: script
                  id: script.hdr_mode_three
            card_mod:
              style:
                .: |
                  ha-card div.mmp-player {
                   padding-bottom: 0px;
                  }
                  ha-card div.mmp-player__adds {
                   margin-left: 48px !important;
                  }
          - type: media-control
            entity: media_player.paradroid
            card_mod:
              style: |
                mwc-linear-progress {
                  display: none;
                }
                div.media-info {
                  display: none;
                }
                div.top-info {
                  display: none;
                }
                div.background {
                  display: none;
                }
                ha-icon-button {
                  display: none;
                }
                ha-icon-button.browse-media {
                  display: block;
                  padding-right: 10px;
                }
                mwc-icon-button {
                  padding-top: 0px;
                }
                div.title-controls {
                  padding: 0 0 0px;
                }
                .no-progress.player {
                  padding-bottom: 16px !important;
                }
                div.player {
                  color: inherit !important;
                }
                div.off {
                  display: none;
                }
        - card_type: horizontal-stack
          type: custom:hui-element
          cards:
            - name: -5dB
              tap_action:
                service: jriver.adjust_volume
                target:
                  entity_id: media_player.paradroid
                data:
                  delta: -5
              template: thin_button
              type: custom:button-card
            - name: -3dB
              tap_action:
                service: jriver.adjust_volume
                target:
                  entity_id: media_player.paradroid
                data:
                  delta: -3
              template: thin_button
              type: custom:button-card
            - name: -1dB
              tap_action:
                service: jriver.adjust_volume
                target:
                  entity_id: media_player.paradroid
                data:
                  delta: -1
              template: thin_button
              type: custom:button-card
            - name: +1dB
              tap_action:
                service: jriver.adjust_volume
                target:
                  entity_id: media_player.paradroid
                data:
                  delta: 1
              template: thin_button
              type: custom:button-card
            - name: +3dB
              tap_action:
                service: jriver.adjust_volume
                target:
                  entity_id: media_player.paradroid
                data:
                  delta: 3
              template: thin_button
              type: custom:button-card
            - name: +5dB
              tap_action:
                service: jriver.adjust_volume
                target:
                  entity_id: media_player.paradroid
                data:
                  delta: 5
              template: thin_button
              type: custom:button-card

pic attached (usually there's a background image there, looks like someone watching something before tags had been updated to add art)


Logged

sjhilton

  • Junior Woodchuck
  • **
  • Posts: 86
Re: Home Assistant integration for jriver
« Reply #61 on: September 04, 2024, 12:34:27 am »

Thanks Matt - I'll give that a go and do some tinkering. Certainly the play/pause functionality works with that player. I might also try to build a file info tile that picks up the playing now attributes.
Logged

beatonnz

  • Recent member
  • *
  • Posts: 6
Re: Home Assistant integration for jriver
« Reply #62 on: September 28, 2024, 11:34:48 pm »

Hi Matt:  Thanks for this Home Assistant Integration.  I looked at Home Assistant some years back but found it was too unfriendly and learning curve was steep - plus I am a long time user of MC and have four servers running on Raspberry Pi's these days which have worked flawlessly and thus no desire to move away from MC.  Previously I did not see how I could use MC with Home Assistant so just dropped the whole idea but have come back to it and it is more friendly now and your integration solves my inability to bring MC into Home Assistant.  Followed your instructions and it set up nicely.  Changed over to the mini-media-player you recommended which does have working play/pause/back/forward.

I have two problems to overcome:

  1) Even with new min-media-player pushing the power button still freezes up MC server.  I tried toggling the button off in settings but it didn't make any difference.  Looked to see if I could find the button in YAML to see if I could comment it out but couldn't find anything.  It will be important for me to fix this before I roll it out for whole house use as my family users are bound to use the power button to try and stop it.  Have you found a way to do this?
  2) I do have version 0.2.7 which you noted has working playlists but my playlists are not showing up anywhere - is there something I have to add to get them to show up?
I am a noob on Home Assistant but trying hard to learn it.  A little better on Linux/MC.
Thanks for your integration and assistance.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #63 on: September 29, 2024, 04:31:28 am »

What version of MC are you using?
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #64 on: September 29, 2024, 04:04:49 pm »

assuming the media player calls media_player.turn_off then this is implemented as calling the following

Playback/StopAll
MCC 20007,0

which works fine here so not sure why it would freeze for you
Logged

beatonnz

  • Recent member
  • *
  • Posts: 6
Re: Home Assistant integration for jriver
« Reply #65 on: September 29, 2024, 05:59:47 pm »

Thanks for the quick response.  Because I am running on pi3b+ I have stayed with MC29 so I am a little behind current releases as I believe pi3 has a hard time supporting bullseye/bookworm releases.
I retried the "pushing" the power button on the same recommended mini-media-player card while watching the server over VNC connection.  It definitely stops MC but leaves it hung in a state where it shows as still playing and won't respond to any commands.  Only solution seems to be a reboot.

I will build a MC33 on a pi4 or pi 5 and give that a try to see if it resolves the issues. 

Thanks for your help.
 

 
Logged

sjhilton

  • Junior Woodchuck
  • **
  • Posts: 86
Re: Home Assistant integration for jriver
« Reply #66 on: September 29, 2024, 07:48:48 pm »

Hi beatonnz - confirming I have a similar issue runnning the HA integration with my Raspberrypi clients. I use the following to hide power, which works for me.

hide:
  power: true

I am running MC33 on all clients and the server.
Logged

sjhilton

  • Junior Woodchuck
  • **
  • Posts: 86
Re: Home Assistant integration for jriver
« Reply #67 on: September 29, 2024, 08:10:10 pm »

Hi all - I just thought I'd share what my HA JRiver integration looks like (see attachment). I use the mini-media-player as well and I've developed a file info panel with my favourite attributes. I've also used a REST command to MCWS to create sensors that indicate bit depth, sample rate and whether playback is direct or not. I think this is better than relying on the file attributes which may not indicate resampling. I've also integrated Tidal in a similar way via Media Assistant playing to JRiver by DLNA (this was a bit tricky to resolve). Happy to share code if anyone is interested.
Logged

beatonnz

  • Recent member
  • *
  • Posts: 6
Re: Home Assistant integration for jriver
« Reply #68 on: September 29, 2024, 10:09:12 pm »

Thanks sjhilton:
Your solution re hiding the power button worked perfectly. 
I would be interested in your JRiver code which will facilitate my own learning in how I can improve my own install.
 
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #69 on: September 30, 2024, 02:04:39 am »

Thanks for the quick response.  Because I am running on pi3b+ I have stayed with MC29 so I am a little behind current releases as I believe pi3 has a hard time supporting bullseye/bookworm releases.
I retried the "pushing" the power button on the same recommended mini-media-player card while watching the server over VNC connection.  It definitely stops MC but leaves it hung in a state where it shows as still playing and won't respond to any commands.  Only solution seems to be a reboot.

I will build a MC33 on a pi4 or pi 5 and give that a try to see if it resolves the issues. 

Thanks for your help.
It may be a bug in handling that MCC command on Linux I guess, you could test it directly (ie just make that call from command line or via browser) and see if it hangs

For playlists, the API call required to load them automatically is not in mc29 so either upgrade or specify which entries you want via the config screen
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13783
Re: Home Assistant integration for jriver
« Reply #70 on: September 30, 2024, 08:38:47 am »

Thanks for the quick response.  Because I am running on pi3b+ I have stayed with MC29 so I am a little behind current releases as I believe pi3 has a hard time supporting bullseye/bookworm releases.
I retried the "pushing" the power button on the same recommended mini-media-player card while watching the server over VNC connection.  It definitely stops MC but leaves it hung in a state where it shows as still playing and won't respond to any commands.  Only solution seems to be a reboot.

I will build a MC33 on a pi4 or pi 5 and give that a try to see if it resolves the issues. 

Thanks for your help.
A bit off topic but the IdPi runs bookworm on the 3b+ fine.
Logged

beatonnz

  • Recent member
  • *
  • Posts: 6
Re: Home Assistant integration for jriver
« Reply #71 on: September 30, 2024, 09:43:25 pm »

Thanks mattkahn & bob:
Upgraded pi3b+ to bullseye and then to MC33.  Playlists work as advertised and that plus sjhilton tip to hide the power button I am all good on running MC via home assistant.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #72 on: October 01, 2024, 02:15:39 am »

I tested MCC 20007,0 on linux and it simply kills the process which means any subsequent power on (implemented as 22009,0) does nothing as there's no server process responding

it's completely different behaviour to windows as the server stays alive and just the client is killed

10014 doesn't work on Linux either so I guess it would have to be 22009,-1000 to "turn off" but that seems a bit unpleasant, any other suggestions on how to handle this on linux?

Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13783
Re: Home Assistant integration for jriver
« Reply #73 on: October 01, 2024, 09:47:09 am »

I tested MCC 20007,0 on linux and it simply kills the process which means any subsequent power on (implemented as 22009,0) does nothing as there's no server process responding

it's completely different behaviour to windows as the server stays alive and just the client is killed

10014 doesn't work on Linux either so I guess it would have to be 22009,-1000 to "turn off" but that seems a bit unpleasant, any other suggestions on how to handle this on linux?
20007,0 should just close the UI if media server is running. I can take a look at that. I know that media server is somewhat different on linux than windows.
Logged

sjhilton

  • Junior Woodchuck
  • **
  • Posts: 86
Re: Home Assistant integration for jriver
« Reply #74 on: October 04, 2024, 06:56:57 am »

Thanks sjhilton:
Your solution re hiding the power button worked perfectly. 
I would be interested in your JRiver code which will facilitate my own learning in how I can improve my own install.

Not a problem. For the info card I use the following:

Code: [Select]
          - type: entities
            entities:
              - entity: sensor.[your player_zone]_playing_now
                type: attribute
                name: Album
                attribute: Album
                icon: mdi:album
              - entity: sensor.[your player_zone]_playing_now
                type: attribute
                name: 'Track #'
                attribute: 'Track #'
                icon: mdi:numeric-1-box-multiple
              - entity: sensor.[your player_zone]_playing_now
                type: attribute
                name: Duration
                attribute: Duration
                icon: mdi:timelapse
              - entity: sensor.[your player_zone]_playing_now
                type: attribute
                name: Year
                attribute: Date (year)
                icon: mdi:timer
              - entity: sensor.[your player_zone]_playing_now
                type: attribute
                name: Times played
                attribute: Number Plays
                icon: mdi:timer-play
              - entity: sensor.[your player_zone]_playing_now
                type: attribute
                name: Last Played
                attribute: Last Played
                icon: mdi:timeline-clock-outline
              - entity: input_text.bitdepth
                type: simple-entity
                name: Bit Depth
                icon: mdi:chart-bar-stacked
              - entity: input_text.samplerate
                type: simple-entity
                name: Sample Rate
                icon: mdi:waveform
              - entity: input_text.input_text_media_player_direct
                type: simple-entity
                name: Is output direct?

The last three entries rely on an MCWS command and a couple of automations.

You would need to insert some lines into configuration.yaml.

Code: [Select]
hifiaudiopath:
    url: http://[yourip]:52199/MCWS/v1/Playback/AudioPath?Zone=-1&ZoneType=ID
    method: GET

And then the automations follow the form of:

Code: [Select]
alias: Set bitdepth, sample rate and filename
description: ""
mode: single
triggers:
  - seconds: /30
    trigger: time_pattern
conditions: []
actions:
  - action: rest_command.hifiplayback
    data: {}
    response_variable: hifiplayback
  - delay: "00:00:02"
  - action: input_text.set_value
    data:
      value: >-
        {{ (hifiplayback | regex_findall_index('<Item
        Name="Bitdepth">(.*?)</Item>')) }}
    target:
      entity_id: input_text.bitdepth
  - action: input_text.set_value
    data:
      value: >-
        {{ (hifiplayback | regex_findall_index('<Item
        Name="SampleRate">(.*?)</Item>')) }}
    target:
      entity_id: input_text.samplerate
  - action: input_text.set_value
    data:
      value: >-
        {{ (hifiplayback | regex_findall_index('<Item
        Name="Name">(.*?)</Item>')) }}
    target:
      entity_id: input_text.mediafilename

The next project will be to develop a card that displays the playlist/running times and hopefully shows the now playing track in bold or similar. That might be done by more sophisticated scraping of MC via MCWS.
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13783
Re: Home Assistant integration for jriver
« Reply #75 on: October 04, 2024, 07:49:19 am »

20007,0 should just close the UI if media server is running. I can take a look at that. I know that media server is somewhat different on linux than windows.
There isn't a real "server" mode on MC for linux as there is on mac and windows. The mode that best approximates that is when MC is started with the /mediaserver switch. With linux you should probably just minimize the UI instead.
Logged

sjhilton

  • Junior Woodchuck
  • **
  • Posts: 86
Re: Home Assistant integration for jriver
« Reply #76 on: October 06, 2024, 10:56:37 pm »

I've now developed a playlist display for my Home Assistant configuration. The coding is a bit messy as it depends upon creating a sensor for each track (a separate rest call to the MCWS playlist function on my server) and then a further sensor to determine if the sensors should display based on the total number of tracks. I've chosen an arbitrary limt of 20 tracks (as most of my albums wouldn't have more than this). I'm happy to share the code if anyone is interested. Picture attached.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4119
Re: Home Assistant integration for jriver
« Reply #77 on: October 07, 2024, 01:50:43 am »

why do you need a sensor for each track?
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42259
  • Shoes gone again!
Re: Home Assistant integration for jriver
« Reply #78 on: October 07, 2024, 09:30:20 am »

If there are MCWS functions we could add to make this easier for you, please let us know the details.  Thanks.
Logged
Matt Ashland, JRiver Media Center

sjhilton

  • Junior Woodchuck
  • **
  • Posts: 86
Re: Home Assistant integration for jriver
« Reply #79 on: Yesterday at 01:23:20 am »

Thanks mattkhan and Matt

Let me further explain how I've done this. I'm sure there is likely to be a better way. I do want to emphasise that the approach I've taken is mostly to work around limitations in Home Assistant rather than any issue with MCWS.

I'm calling http://[myserverip]:52199/MCWS/v1/Playback/Playlist?Zone=0&Action=JSON by rest and then creating sensors for each track and then attributes from each of the fields in my database (at the moment this is all of them, but I'll probably cut this back to the ones I actually need as it will fill the home assistant database). This refreshes every 30 seconds.

Each track is a tile card in home assistant. I tried to use the entities card initially, but I couldn't work out how to make this work. I wanted the play icons to be dynamic so that the currently playing track icon would change each time data was called via MCWS and there had been a track change.

I created a further set of sensors as template sensors so that I could determine if each of the track sensors should be displayed or not eg if total tracks in the album is less than or equal to track number the track sensor woud display and if not the relevant track sensor would be hidden.

Edit: I should also have mentioned that I'm using config-template-card add in to code the playlist cards (basically allows for JavaScript to be used in the card).
Logged
Pages: 1 [2]   Go Up