INTERACT FORUM

Please login or register.

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

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

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #100 on: October 19, 2024, 09:40:49 am »

Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101
Re: Home Assistant integration for jriver
« Reply #101 on: October 20, 2024, 07:36:31 pm »

latest version includes 2 additional sets of sensors

sensor.<mediaserver>_<zone>_audio_is_direct
a boolean showing whether audio playback is direct or not

sensor.<mediaserver>_<zone>_playlist
a sensor with extra attributes which is a list of items from the current playlist in that zone

I'm not sure if this format is ideal for rendering, it's probably usable in a markdown card using some template or you could install https://community.home-assistant.io/t/flex-table-card/461173 like so

Code: [Select]
views:
  - title: Home
    cards:
      - type: custom:flex-table-card
        entities:
          include:
            - sensor.paradroid_music_playlist
        columns:
          - name: Artist
            data: entries
            modify: x.Artist
          - name: Album
            data: entries
            modify: x.Album
          - name: '#'
            data: entries
            modify: 'x[''Track #'']'
          - name: Name
            data: entries
            modify: x.Name
    type: custom:vertical-layout

if there's some other format that makes more sense and/or some good card to use for it then do share that

Thanks mattkhan - this looks great - my only suggestion would be to try to add a play icon in a separate column where the track/item is playing now. I've tried doing this with a few different cards, including this one and unfortunately haven't been able to figure it out. (In response to your next post - agree it would be great to have access to the image file somehow)
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #102 on: October 21, 2024, 04:35:14 am »

Perhaps, you could probably do that yourself by creating an extra column formatted as appropriate
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #103 on: October 22, 2024, 03:04:27 am »

another way to handle this playing now situation is via https://yabb.jriver.com/interact/index.php/topic,139901.0.html if that gets implemented
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #104 on: October 22, 2024, 03:16:34 am »

latest version adds ImageURL as an attribute on each entry (which gives a url to get a small thumbnail so you can include the pic in the playlist if you want to)
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #105 on: October 26, 2024, 02:50:34 am »

another update to support Playing Now in the remote view definitions (though it doesn't work properly yet due to a bug on the MC side) requires 33.0.37 to have this option available
Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101
Re: Home Assistant integration for jriver
« Reply #106 on: October 26, 2024, 09:13:06 pm »

I've developed a new playlist card. Playing now track is bold and current time elapsed displays in brackets. This is based on the new playlist sensor. You can also add a player entity at the top (generic HA one). If anyone's interested please let me know and I'll share the code. This uses custom:hui-element with a markdown card
Logged

avpman

  • Galactic Citizen
  • ****
  • Posts: 445
  • Dad to three beatuiful Boxers by rescue.
Re: Home Assistant integration for jriver - Playing Now
« Reply #107 on: October 27, 2024, 10:39:45 am »

Is there a Playing Now view available showing all the tracks queued? If so, I can't find it. It would be a great addition.

Did this get added? Sorry, I'm a little behind in the updates.
Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101
Re: Home Assistant integration for jriver
« Reply #108 on: October 29, 2024, 09:58:54 pm »

Hi mattkhan - I'm not sure if this is feasible, but it would be great to have either a search or filter function. Eg a filter function that could be applied to the 'browse media' popup when it opens. I've tried crafting my own with a variety of different custom cards and javascript, but it's proven quite difficult to get working. Just a thought.

That's probably the last thing I can think of from a usability perspective. The HA integration is certainly now my preferred way of interacting with MC and my library. Thanks for all of your work on this.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver - Playing Now
« Reply #109 on: October 30, 2024, 04:28:39 am »

Did this get added? Sorry, I'm a little behind in the updates.
the data is there, you need to configure some view yourself to display that
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #110 on: October 30, 2024, 04:30:21 am »

Hi mattkhan - I'm not sure if this is feasible, but it would be great to have either a search or filter function. Eg a filter function that could be applied to the 'browse media' popup when it opens. I've tried crafting my own with a variety of different custom cards and javascript, but it's proven quite difficult to get working. Just a thought.

yes definitely, this is a big gap in the media browse feature in the HA UI (along with the ability to customise what information is shown) and the main thing missing from my old custom UI. It's a moderately sized undertaking to create such a custom card though and I don't like javascript very much so haven't been inclined to make one yet.
Logged

avpman

  • Galactic Citizen
  • ****
  • Posts: 445
  • Dad to three beatuiful Boxers by rescue.
Re: Home Assistant integration for jriver - Playing Now
« Reply #111 on: October 30, 2024, 08:24:49 am »

the data is there, you need to configure some view yourself to display that

Hopefully, someone could share what they've done. I'm still relatively new to HomeAssistant and have no idea how to accomplish this.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver - Playing Now
« Reply #112 on: October 30, 2024, 08:28:41 am »

Hopefully, someone could share what they've done. I'm still relatively new to HomeAssistant and have no idea how to accomplish this.
there was a basic example in https://yabb.jriver.com/interact/index.php/topic,137808.msg969917.html#msg969917

sjhilton's version looks nicer (I made no attempt to format mine, it was just to illustrate)
Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101
Re: Home Assistant integration for jriver
« Reply #113 on: October 30, 2024, 09:36:28 pm »

Here is the code for mine. The square bracketed sections need to be completed with your player entity/custom text and the comments are for further explanation. Any questions please let me know.

(This should have the odd formatting fixed as well, which I fixed using https://onlineyamltools.com/minify-yaml and removing additional \n entries. I think this is a quirk of the YAML editor in HA.)

Code: [Select]
type: entities
entities:
  - entity: media_player.[entity] # this bit is optional if you wanted to have a player function integrated. I didn't include this in mine as I use mini media player. It could be improved.
    name: [insert text]
  - type: custom:hui-element # this custom card needs to be installed using HACS or manually
    card_type: markdown
    content: >
      ## [Your title]

      {% for track in state_attr('sensor.[name]_playlist',
      'entries') %} {% if is_state_attr('media_player.[name]',
      'media_title', track.Name) %} **{{ track.Name }}** <span
      style="margin-left: 10px; font-size: smaller; display: block; margin-top:
      -8px;">
        {{ track["Track #"] }} - {{ track.Artist }} - {{ track.Album }} - {{ '%02d:%02d' % (track.Duration // 60, track.Duration % 60) }} ({{ '%02d:%02d' % (state_attr('media_player.[name]', 'media_position') // 60, state_attr('media_player.[name]', 'media_position') % 60) }})
      </span> {% else %} {{ track.Name }} <span style="margin-left: 10px;
      font-size: smaller; display: block; margin-top: -8px;">
        {{ track["Track #"] }} - {{ track.Artist }} - {{ track.Album }} - {{ '%02d:%02d' % (track.Duration // 60, track.Duration % 60) }}
      </span> {% endif %} <br> {% endfor %}
visibility: # Completely optional - I made my playlist disappear if media isn't playing. Delete these lines if you don't want to do this.
  - condition: state
    entity: media_player.[name]
    state: playing
Logged

rhgh

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 302
Re: Home Assistant integration for jriver
« Reply #114 on: October 31, 2024, 05:26:10 am »

Home Assistant MC version 0.3.3
Media Center Windows 32.0.58
Since today the following error message
Setup failed, will try again: unhandled errors in a TaskGroup (1 sub-exception)
no devices and no entities.
Home Assistant log as attachment
Reinhard
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #115 on: October 31, 2024, 05:47:03 am »

looks like it is timing out when trying to talk to MC, implies problem at MC end

every error is during a call to MCWS/v1/Playback/Info

in your log you can see the timeout as

Code: [Select]
2024-10-31 11:23:26.054 DEBUG (MainThread) [custom_components.jriver.coordinator] Finished fetching jriver data in 5.638 seconds (success: False)

so it's sitting there blocked by jriver not responding

in my log, you can see a normal response time for comparison

Code: [Select]
2024-10-31 10:47:56.725 DEBUG (MainThread) [custom_components.jriver.coordinator] Finished fetching jriver data in 0.047 seconds (success: True)

Logged

rhgh

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 302
Re: Home Assistant integration for jriver
« Reply #116 on: October 31, 2024, 06:30:59 am »

looks like it is timing out when trying to talk to MC, implies problem at MC end

every error is during a call to MCWS/v1/Playback/Info

in your log you can see the timeout as

Code: [Select]
2024-10-31 11:23:26.054 DEBUG (MainThread) [custom_components.jriver.coordinator] Finished fetching jriver data in 5.638 seconds (success: False)

so it's sitting there blocked by jriver not responding

in my log, you can see a normal response time for comparison

Code: [Select]
2024-10-31 10:47:56.725 DEBUG (MainThread) [custom_components.jriver.coordinator] Finished fetching jriver data in 0.047 seconds (success: True)

I restarted MC, the configuration in HA was completed without errors.
But:
The PC with MC has been running for a week without restarting, MC too.
The PC only restarts when updates have been installed.
The error will then appear again at some point, right?

Reinhard
Logged

rhgh

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 302
Re: Home Assistant integration for jriver
« Reply #117 on: October 31, 2024, 07:18:41 am »

I restarted MC, the configuration in HA was completed without errors.
But:
The PC with MC has been running for a week without restarting, MC too.
The PC only restarts when updates have been installed.
The error will then appear again at some point, right?

Reinhard

Why doesn't the error occur with jremote?
The DLNA connection is the same.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #118 on: October 31, 2024, 09:08:09 am »

Why doesn't the error occur with jremote?
The DLNA connection is the same.
There's no dlna connection, I have no idea how jremote is implemented so can't comment on similarities or differences. I have never seen such an error so can't say if it will recur. MC logs can be hard to read but probably you need to look there for further clues.
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13931
Re: Home Assistant integration for jriver
« Reply #119 on: October 31, 2024, 09:39:42 am »

There's no dlna connection, I have no idea how jremote is implemented so can't comment on similarities or differences. I have never seen such an error so can't say if it will recur. MC logs can be hard to read but probably you need to look there for further clues.
JRemote uses MCWS calls, not DLNA.
Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72531
  • Where did I put my teeth?
Re: Home Assistant integration for jriver
« Reply #120 on: October 31, 2024, 11:22:06 am »


Media Center Windows 32.0.58
mattkahn,
Should that version of MC work?
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #121 on: October 31, 2024, 11:27:54 am »

mattkahn,
Should that version of MC work?
yes it should work ok
Logged

bob

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 13931
Re: Home Assistant integration for jriver
« Reply #122 on: October 31, 2024, 03:08:09 pm »

If I had a hand installed version of JRiver (0.2.7) how should I switch to the new HACS integration?
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #123 on: October 31, 2024, 03:13:55 pm »

Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101
Re: Home Assistant integration for jriver
« Reply #124 on: December 03, 2024, 09:18:12 pm »

Hi mattkhan,

I have this error pop-up consistently for one of my albums. Could it be a meta-data or file length issue? The album otherwise plays OK in MC.

Code: [Select]
Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:245
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 2:11:04 PM (1 occurrences)
Last logged: 2:11:04 PM

[140465782858384] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/jriver/entity.py", line 59, in wrapper
    await func(obj, *args, **kwargs)
  File "/config/custom_components/jriver/media_player.py", line 548, in async_play_media
    await _play_jriver_item()
  File "/config/custom_components/jriver/media_player.py", line 519, in _play_jriver_item
    _, node_id, _ = media_id.split("|", 3)
    ^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 3)
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #125 on: December 04, 2024, 02:48:21 am »

it's likely some unexpected format in the browse tree, perhaps a media type it don't understand?

not sure there's an easier way to debug than using chrome dev tools when using the browse function, go to the network tab, filter to WS only and type media_player as the filter, reload the page and you'll see a websocket entry, navigate through the browse tree till you get to the offending entry and you should see messages like in the pic going up for each one you click on

you'll see that I have to pack 3 pieces of info into a single string which is the id in the browse tree and the name

from your error, something is showing up there that does not have 3 tokens so need to find out where that comes from

Logged

sjhilton

  • World Citizen
  • ***
  • Posts: 101
Re: Home Assistant integration for jriver
« Reply #126 on: December 10, 2024, 04:59:00 am »

Thanks mattkhan - I figured it out - it was the '|' (pipe) in the album title that was the problem.
Logged

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4267
Re: Home Assistant integration for jriver
« Reply #127 on: December 10, 2024, 06:32:49 am »

Ah thanks, I picked | on "surely that won't be in any names" grounds :)
Logged
Pages: 1 2 [3]   Go Up