INTERACT FORUM

Windows => Third Party Plug-ins, Programs, and Skins => Topic started by: mattkhan on January 10, 2024, 02:35:43 am

Title: Home Assistant integration for jriver
Post by: mattkhan on January 10, 2024, 02:35:43 am
I've published an initial 0.0.1 release of this

The readme provides full details of supported features and installation instructions https://github.com/3ll3d00d/jriver_homeassistant/blob/main/README.md

Feel free to log feature requests or bugs either here or on github
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 10, 2024, 02:37:15 am
in case anyone notices there are no jriver icons shown, that depends on https://github.com/home-assistant/brands/pull/5071 being approved and merged
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 13, 2024, 12:34:26 pm
pushed some updates, includes access key support + some additional sensors + support for a wol based service using the MAC addresses pulled from MC (i.e. simpler config of a wake call), see https://github.com/3ll3d00d/jriver_homeassistant/releases for details


this also includes ability to specify additional library fields to surface in media player as attributes (and in those sensors), for me the intent here is being able to do things like detect an aspect ratio change so switch the projector installation mode which moves my lens into place but obviously you can use this for whatever you like (change lighting for different music or whatever)
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 14, 2024, 08:02:01 am
another update adds relative seeking (HA media player cards seem really weak on this point so this enables you to add buttons using the jriver.relative_seek service
Title: Re: Home Assistant integration for jriver
Post by: hoyt on January 14, 2024, 01:20:42 pm
I just opened an issue on GitHub related to the API Key change, but another thing I noticed, which I wasn't sure if it was just not working how I thought...

I don't get the "Device Per Zone" question on setup. I do have multiple zones - just player and the other is a DLNA zone. Does that not make it qualify? I'd like the DLNA zone to be it's own device because I never actually use the Player zone on my server. I noticed this because I hit playback at some point and realized it had queued up files in the Player zone instead of my DLNA zone I was expecting.

Thanks!
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 14, 2024, 02:12:21 pm
I don't get the "Device Per Zone" question on setup. I do have multiple zones - just player and the other is a DLNA zone. Does that not make it qualify? I'd like the DLNA zone to be it's own device because I never actually use the Player zone on my server. I noticed this because I hit playback at some point and realized it had queued up files in the Player zone instead of my DLNA zone I was expecting.
if you check that box then you get n media_player entities, 1 per zone, so you can control them independently
if it's unchecked, you get one and it shows the currently active zone (and assumes you control this separately, i.e. using zoneswitch)

atm it excludes zones marked as DLNA though, I could change that
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 14, 2024, 02:23:48 pm
for the api key issue, try 0.0.6
Title: Re: Home Assistant integration for jriver
Post by: hoyt on January 14, 2024, 02:49:48 pm
if you check that box then you get n media_player entities, 1 per zone, so you can control them independently
if it's unchecked, you get one and it shows the currently active zone (and assumes you control this separately, i.e. using zoneswitch)

atm it excludes zones marked as DLNA though, I could change that

I installed the new version, and I see more devices now (I'm assuming because of the DLNA zone change), which is good.

When I said "I don't get" I meant, it doesn't show up for me when going through the configure screens, not that I didn't understand it :) I see 1 - Options (the views), 2 - Enable WOL, 3 - Additional Library Fields, then done.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 14, 2024, 03:11:43 pm
ah sorry, I see what you mean

I haven't added configuration of zones into options yet (HA initial configuration and options are 2 entirely separate sets of data and forms for reasons I don't understand, seems to lead to a load of duplication of code) so there's no way to edit that after initial setup atm (added https://github.com/3ll3d00d/jriver_homeassistant/issues/11)

it also only shows that screen if there is >1 zone and now that (in 0.0.6) it's not filtering out dlna zones then it should be available to you if you delete and add from scratch, does it?

if not, something unexpected going on and I'll need a bit more detail about your setup... the output of /MCWS/v1/Playback/Zones will probably do
Title: Re: Apparently Functional Integration with HomeAssistant
Post by: hoyt on January 14, 2024, 05:12:22 pm
After updating, all of my other zones just showed up as individual players, without having set that option (and without remove/readding the integration). That's ok by me, because that's what I wanted, but I never checked a box that said "make a player per zone."

EDIT: Nevermind, those were the sensors that were added, not players... I'll remove/ re-add now.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 16, 2024, 02:14:47 pm
in case anyone notices there are no jriver icons shown, that depends on https://github.com/home-assistant/brands/pull/5071 being approved and merged
this is now fixed, logos are present and visible
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 20, 2024, 04:22:51 am
there's a new release up but just internal changes so I can get it into hacs proper + unit tests
Title: Re: Apparently Functional Integration with HomeAssistant
Post by: mattkhan on January 20, 2024, 04:23:12 am
After updating, all of my other zones just showed up as individual players, without having set that option (and without remove/readding the integration). That's ok by me, because that's what I wanted, but I never checked a box that said "make a player per zone."
did you get it working?
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 27, 2024, 02:54:02 pm
0.1.1 is out

fixed a bug that was preventing seeking working

made use of new MCWS endpoint (thanks Matt!) added in MC32 to remove the need to manually populate the configuration of the browse tree, that entire config screen disappears if you're using MC32 and it now loads the entire config (except for playlists which seems like a bug, reported separately). It attempts to parse the search field to work out what the media type is for each node. This last bit might be risky as parsing MC search expressions seems slightly tricky to me so let me know if something blows up.

HA frontend is really limited in terms of how that browse function works so I was thinking of making it load a field (something like "HA Name") which, if it's present, would be used in place of the standard name field.

I can't see a better way to customise what is displayed atm, examples of how to use this would be things like indicating aspect ratio for a film, whether something is 4k/1080p etc and so on. HA UI doesn't, as far as I can see, provide any support for rich info about the media so this would be a quick hack to surface a bit more info without needing to add another custom component.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 27, 2024, 02:56:01 pm
also submitted this to hacs proper but the PR has been pending for quite a while now

the HA & HACS model for adding integrations seems fairly broken to me so I doubt I'll pursue getting it into HA itself, just seems way too hard to get things updated
Title: Re: Home Assistant integration for jriver
Post by: hoyt on January 28, 2024, 10:45:28 am
I just installed the new version, at first it failed to setup, but then I realized my JRiver VM was still asleep. Once I booted it up, it worked great. The browse seemed to work well right away too.

Have you noticed that the coverart doesn't pull through to the player? This is what I see in the attributes of my JRiver media_player instance:

Code: [Select]
supported_features: 456639
friendly_name: serv01b - House Speakers (dlna)
volume_level: 1
is_volume_muted: false
media_content_id: 1020301
media_content_type: music
media_title: El Camino
media_artist: Amos Lee
media_album_name: Mission Bell
media_album_artist: Amos Lee
entity_picture_local: /api/media_player_proxy/media_player.serv01b_house_speakers_dlna?token=<redacted>&cache=b174ae145172cebc
zone_name: House Speakers (dlna)
entity_picture: http://192.168.3.202:52199/MCWS/v1/File/GetImage?File=1020301
media_duration: 242
media_position: 57

But when I look at the actual media_player, there's no image. I'm outputting to a DLNA zone, which also has a media_player instance in my HA and I see this when I look at that one:

Code: [Select]
volume_level: 1
is_volume_muted: false
media_content_id: http://192.168.3.202:52100/Music/F1020301.wav
media_duration: 242
media_position: 3
media_position_updated_at: 2024-01-28T16:41:03.239397+00:00
media_track: 1
shuffle: false
repeat: off
friendly_name: Kitchen Speakers - DLNA
supported_features: 397839
media_content_type: music
media_title: El Camino
media_artist: Amos Lee
media_album_name: Mission Bell
entity_picture: /api/media_player_proxy/media_player.kitchen_speakers_dlna?token=<redacted>&cache=17333a371a604331

The quality of the picture on the DLNA one is particular poor, but at least it's there. I wrote an automation on track change to get the picture from entity_picture and place it somewhere that my tablet will pick it up, but it's 5 seconds or so delayed.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 28, 2024, 02:25:54 pm
thanks for noticing, I'd forgotten to add the token to the image url. It should be fixed in 0.1.2 but lmk if any problems
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on January 29, 2024, 02:34:16 pm
another release to workaround https://yabb.jriver.com/interact/index.php/topic,138016.0.html (only applies if you have multiple zones and rely on zoneswitch)
Title: Re: Home Assistant integration for jriver
Post by: bob on January 29, 2024, 05:16:23 pm
I can't get the integration going with HACS. Not sure where the issue is. Installed HACS via the instructions.
Added the integration repo though I can't tell if it sticks.
When I try to open the integration I get an error.
Title: Re: Home Assistant integration for jriver
Post by: hoyt on January 29, 2024, 07:02:30 pm
I can't get the integration going with HACS. Not sure where the issue is. Installed HACS via the instructions.
Added the integration repo though I can't tell if it sticks.
When I try to open the integration I get an error.

The first few things with HA are confusing, much like JRiver :)

I'm a bit confused where you're stuck and it's been a long time since I setup HACS, so my memory of all the steps might be rusty. Do you have HACS showing in your sidebar on the left? If not, then step 1 is to get that working correctly. Is this the page you mentioned you followed? https://hacs.xyz/docs/configuration/basic/

When you add a HACS integration, you add the repo in HACS, reboot, then you install the integration in the core HA integration page.

If you do have HACS showing in the sidebar and you're stuck with the JRiver integration, if you click on HACS on the left, you should then see a choice of integrations/ frontend/ add-ons. Under Integrations, you should see any repos that you've added (HACS.png attachment). Every time you load this page, it'll show a bunch of new things, I always hit dismiss to see what I have instead of what's new. If you've just installed the JRiver integration, HACS will give you some red banner that says you need to reboot. Once you've done that, then you should be able to add the intrgration using the main HA integration page (Settings > Devices & Services > Add Integration > JRiver).
Title: Re: Home Assistant integration for jriver
Post by: hoyt on January 29, 2024, 07:57:10 pm
thanks for noticing, I'd forgotten to add the token to the image url. It should be fixed in 0.1.2 but lmk if any problems

This is working great.

In case people are looking for ideas on how this can be used: I'm much closer to being able to have an HA tablet in my kitchen that can replace some of the Google Home uses. I now have it showing what's playing and a quick button to kick off a script that calls MCWS and triggers a smart playlist to go at 40% volume on the kitchen speakers (this part pre-dates the integration, but now I can get feedback and see that it starts). I also just added an automation that double clicking my Inovelli light switch next to the sink changes the volume up or down (double click on vs double click off) if the media_player's state is playing.
Title: Re: Home Assistant integration for jriver
Post by: bob on January 31, 2024, 08:55:06 pm
The first few things with HA are confusing, much like JRiver :)

I'm a bit confused where you're stuck and it's been a long time since I setup HACS, so my memory of all the steps might be rusty. Do you have HACS showing in your sidebar on the left? If not, then step 1 is to get that working correctly. Is this the page you mentioned you followed? https://hacs.xyz/docs/configuration/basic/

When you add a HACS integration, you add the repo in HACS, reboot, then you install the integration in the core HA integration page.

If you do have HACS showing in the sidebar and you're stuck with the JRiver integration, if you click on HACS on the left, you should then see a choice of integrations/ frontend/ add-ons. Under Integrations, you should see any repos that you've added (HACS.png attachment). Every time you load this page, it'll show a bunch of new things, I always hit dismiss to see what I have instead of what's new. If you've just installed the JRiver integration, HACS will give you some red banner that says you need to reboot. Once you've done that, then you should be able to add the intrgration using the main HA integration page (Settings > Devices & Services > Add Integration > JRiver).
I've carefully followed the instructions. Added HACS. It's in the left bar. Most of the time the integration tab doesn't even show up. I've uninstalled, reinstalled, rebooted each time. Not really any luck.
I do the upper right ... and add the custom repo https://github.com/3ll3d00d/jriver_homeassistant.git as Integration. It shows up there but nothing else changes. If I reboot it's gone again.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 01, 2024, 01:52:57 am
What version of HA? And HACS?
Anything in the logs?
Does it actually download the repo into the custom_components dir?
Title: Re: Home Assistant integration for jriver
Post by: bob on February 01, 2024, 09:43:02 am
What version of HA? And HACS?
Anything in the logs?
Does it actually download the repo into the custom_components dir?
Version info attached.
I don't see anything other than hacs in custom_components.
Title: Re: Home Assistant integration for jriver
Post by: jmone on February 03, 2024, 02:35:49 am
FWIW - I'm the same as Bob.  I've tried a half dozen times over the last month and this integration is not added to the custom_compenents dir (and I already have a couple).
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 03, 2024, 05:57:28 am
I run HA core only via docker so I created a new VM to run it as HA OS with a fresh HACS installation, followed the instructions in my readme (i.e. add custom repo, download it,
 restart, add integration) and everything shows up as expected. I suppose you need to increase the log level to try to see what is going on and why it's not working for you as there's just not enough info provided to comment further, it seems like a HACS problem to me anyway.
Title: Re: Home Assistant integration for jriver
Post by: bob on February 03, 2024, 11:35:33 am
Got it by installing the custom_components/jriver and associated manually.
Title: Re: Home Assistant integration for jriver
Post by: hoyt on February 10, 2024, 08:33:52 pm
Have you noticed that the media_player entity goes to unavailable somewhat regularly, mid-song? I've noticed this because I have a tablet with Fully Kiosk on it. I made an automation that when the track changes, turn the display on for 30 seconds. This happens well, but then consistently a minute 30 into a track, it will turn on again with a blank screen (because the player is unavailable). In the attachment, you can see that it flips from Playing to Unavailable to Playing.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 11, 2024, 03:23:54 am
anything in the logs at that time?
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 11, 2024, 05:02:49 am
I have seen some sort of jitter myself, looking at the network log in the browser then I can see that every now and again, it loses a particular piece of info which would cause this. I'm not sure if this causes your problem but will look at fixing this.

if you're able to gather some info locally to see if it's the same then that would be useful (albeit not sure how easy that will be) otherwise perhaps just retry after I fix this as I guess it probably has same root cause
Title: Re: Home Assistant integration for jriver
Post by: hoyt on February 11, 2024, 11:43:46 am
anything in the logs at that time?

That would have been useful to check... I was going to replicate it and watch the logs, but then I saw this:

Code: [Select]
Logger: homeassistant.setup
Source: setup.py:221
First occurred: 9:09:56 AM (1 occurrences)
Last logged: 9:09:56 AM

Setup failed for custom integration 'jriver': Requirements for jriver not found: ['hamcws==0.1.29'].

I rebooted HA, but same issue after restart. So I re-downloaded via HACS, disabled then re-enabled the integration, followed by another HA reboot. Any additional suggestions? Not sure what changed that caused this, but I did upgrade HA to 2024.2.1 recently.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 11, 2024, 12:17:17 pm
seems strange, 0.1.29 is available https://pypi.org/project/hamcws/0.1.29/ & I haven't made a new release for a week or two anyway

I'm also on 2024.2.1 btw
Title: Re: Home Assistant integration for jriver
Post by: hoyt on February 11, 2024, 02:18:14 pm
seems strange, 0.1.29 is available https://pypi.org/project/hamcws/0.1.29/ & I haven't made a new release for a week or two anyway

I'm also on 2024.2.1 btw

When I search the logs for hamcws, I'm seeing this:

Code: [Select]
Logger: homeassistant.util.package
Source: util/package.py:122
First occurred: 12:13:21 PM (3 occurrences)
Last logged: 12:13:48 PM

Unable to install package hamcws==0.1.29: ERROR: Ignored the following versions that require a different python version: 0.0.10 Requires-Python >=3.11,<3.12; 0.0.11 Requires-Python >=3.11,<3.12; 0.0.12 Requires-Python >=3.11,<3.12; 0.0.13 Requires-Python >=3.11,<3.12; 0.0.14 Requires-Python >=3.11,<3.12; 0.0.15 Requires-Python >=3.11,<3.12; 0.0.16 Requires-Python >=3.11,<3.12; 0.0.17 Requires-Python >=3.11,<3.12; 0.0.18 Requires-Python >=3.11,<3.12; 0.0.19 Requires-Python >=3.11,<3.12; 0.0.20 Requires-Python >=3.11,<3.12; 0.0.21 Requires-Python >=3.11,<3.12; 0.0.22 Requires-Python >=3.11,<3.12; 0.0.23 Requires-Python >=3.11,<3.12; 0.0.24 Requires-Python >=3.11,<3.12; 0.0.25 Requires-Python >=3.11,<3.12; 0.0.26 Requires-Python >=3.11,<3.12; 0.0.27 Requires-Python >=3.11,<3.12; 0.0.28 Requires-Python >=3.11,<3.12; 0.0.29 Requires-Python >=3.11,<3.12; 0.0.30 Requires-Python >=3.11,<3.12; 0.0.31 Requires-Python >=3.11,<3.12; 0.0.32 Requires-Python >=3.11,<3.12; 0.0.33 Requires-Python >=3.11,<3.12; 0.0.34 Requires-Python >=3.11,<3.12; 0.0.35 Requires-Python >=3.11,<3.12; 0.0.36 Requires-Python >=3.11,<3.12; 0.0.37 Requires-Python >=3.11,<3.12; 0.0.38 Requires-Python >=3.11,<3.12; 0.0.39 Requires-Python >=3.11,<3.12; 0.0.4 Requires-Python >=3.11,<3.12; 0.0.40 Requires-Python >=3.11,<3.12; 0.0.5 Requires-Python >=3.11,<3.12; 0.0.6 Requires-Python >=3.11,<3.12; 0.0.7 Requires-Python >=3.11,<3.12; 0.0.8 Requires-Python >=3.11,<3.12; 0.0.9 Requires-Python >=3.11,<3.12; 0.1.0 Requires-Python >=3.11,<3.12; 0.1.1 Requires-Python >=3.11,<3.12; 0.1.10 Requires-Python >=3.11,<3.12; 0.1.11 Requires-Python >=3.11,<3.12; 0.1.12 Requires-Python >=3.11,<3.12; 0.1.13 Requires-Python >=3.11,<3.12; 0.1.14 Requires-Python >=3.11,<3.12; 0.1.15 Requires-Python >=3.11,<3.12; 0.1.16 Requires-Python >=3.11,<3.12; 0.1.17 Requires-Python >=3.11,<3.12; 0.1.18 Requires-Python >=3.11,<3.12; 0.1.2 Requires-Python >=3.11,<3.12; 0.1.20 Requires-Python >=3.11,<3.12; 0.1.21 Requires-Python >=3.11,<3.12; 0.1.22 Requires-Python >=3.11,<3.12; 0.1.23 Requires-Python >=3.11,<3.12; 0.1.25 Requires-Python >=3.11,<3.12; 0.1.27 Requires-Python >=3.11,<3.12; 0.1.28 Requires-Python >=3.11,<3.12; 0.1.29 Requires-Python >=3.11,<3.12; 0.1.3 Requires-Python >=3.11,<3.12; 0.1.4 Requires-Python >=3.11,<3.12; 0.1.5 Requires-Python >=3.11,<3.12; 0.1.6 Requires-Python >=3.11,<3.12; 0.1.7 Requires-Python >=3.11,<3.12; 0.1.8 Requires-Python >=3.11,<3.12; 0.1.9 Requires-Python >=3.11,<3.12 ERROR: Could not find a version that satisfies the requirement hamcws==0.1.29 (from versions: none) ERROR: No matching distribution found for hamcws==0.1.29

One fo the changed for 2024.2 lists moving to Python 3.12. Could this be why?

https://github.com/home-assistant/core/pull/107175
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 11, 2024, 02:50:07 pm
ah yes, thanks

I pushed a new build, it also adds a little bit of debug logging which, if you activate debug logging, may help diagnose that flickering issue
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 12, 2024, 05:59:20 am
I have realised that the way the WOL service is implemented is useless because the service targets an entity and HA simply ignores you if you call a service on an unavailable entity (which is not exactly helpful behaviour but anyway). I'll have to implement that service in some different way.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 12, 2024, 02:35:01 pm
latest build has the above change, had to refactor a number of things so some chance of side effects, seems ok in my setup though
Title: Re: Home Assistant integration for jriver
Post by: hoyt on February 12, 2024, 03:04:49 pm
latest build has the above change, had to refactor a number of things so some chance of side effects, seems ok in my setup though

I took the latest build, it resolved the issue with hamcws dependencies, so that's great! I am still seeing the player flipping to Unavailable somewhat regularly. I do see more in the logs though, so perhaps this will help:

Code: [Select]
This error originated from a custom integration.

Logger: custom_components.jriver.coordinator
Source: helpers/update_coordinator.py:313
Integration: JRiver Media Center (documentation, issues)
First occurred: 11:38:30 AM (8 occurrences)
Last logged: 12:43:39 PM

Unexpected error fetching jriver data: unhandled errors in a TaskGroup (1 sub-exception)
  + Exception Group Traceback (most recent call last):
  |   File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 313, in _async_refresh
  |     self.data = await self._async_update_data()
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "/config/custom_components/jriver/coordinator.py", line 142, in _async_update_data
  |     async with asyncio.TaskGroup() as tg:
  |   File "/usr/local/lib/python3.12/asyncio/taskgroups.py", line 145, in __aexit__
  |     raise me from None
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/usr/local/lib/python3.12/site-packages/hamcws/hamcws.py", line 527, in get_playback_info
    |     ok, resp = await self._conn.get_as_dict("Playback/Info", params=params)
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/usr/local/lib/python3.12/site-packages/hamcws/hamcws.py", line 380, in get_as_dict
    |     return await _get(self._session, self.get_mcws_url(path), _to_dict, lambda r: r.text(), params,
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/usr/local/lib/python3.12/site-packages/hamcws/hamcws.py", line 315, in _get
    |     async with session.get(url, params=params, timeout=timeout, auth=auth) as resp:
    |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
    |     self._resp = await self._coro
    |                  ^^^^^^^^^^^^^^^^
    |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 605, in _request
    |     await resp.start(conn)
    |   File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 961, in start
    |     with self._timer:
    |   File "/usr/local/lib/python3.12/site-packages/aiohttp/helpers.py", line 735, in __exit__
    |     raise asyncio.TimeoutError from None
    | TimeoutError
    +------------------------------------

It looks like this popped up in the logs 7 seconds after the player went unavailable.

Nevermind, at the same time, then again.

Code: [Select]
2024-02-12 12:43:32.511 ERROR (MainThread) [custom_components.jriver.coordinator] Unexpected error fetching jriver data: unhandled errors in a TaskGroup (1 sub-exception)
Code: [Select]
serv01b - House Speakers (dlna)  became unavailable
12:43:32 PM - 26 minutes ago
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 12, 2024, 05:02:59 pm
The error just says the call to MCWS timed out, ie MC doesn't respond. The timeout is 5s which is a pretty long time so I guess it suggests either a network issue or a problem in MC. Anything in MC logs?

I could add some tolerance to this, like give it a few retries before falling or make the timeout longer though that may have other side effects.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 13, 2024, 02:22:21 am
btw the other key point is how long it takes to recover, I think the ideal solution for working around that will vary on whether it's a brief hiccup or a prolonged one
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 13, 2024, 05:16:44 am
in my case, the flickering is in https://github.com/kalkih/mini-media-player and really seems like a bug in HA itself (when fresh data arrives, if the media player position hasn't updated then it tells the frontend that there's no such field so the component above reacts by removing the progress bar). I have made a change that avoids that in the latest build (0.2.2).
Title: Re: Home Assistant integration for jriver
Post by: hoyt on February 13, 2024, 11:14:24 am
The error just says the call to MCWS timed out, ie MC doesn't respond. The timeout is 5s which is a pretty long time so I guess it suggests either a network issue or a problem in MC. Anything in MC logs?

I could add some tolerance to this, like give it a few retries before falling or make the timeout longer though that may have other side effects.

Hmm, I'll do some more testing, but this morning, I used the core_ssh addon and did a wget loop to pull the MCWS/Alive. Then I watched the Media Player entity. At one point the media_player went to Not Available, but the wget loop was still getting responses back from MC within 0.1 s.

The only thing I see in the JRiver logs is potentially this, though that IP address is the IP of the client that was playing, not the MC or HA instance:

Code: [Select]
0055644: 4152: General: CDLNADeviceServiceCaller::CallServiceFunction: DLNA function call failed or timeout! url = http://192.168.6.227:52101/AVTransport/control function = GetPositionInfo execution time = 6036.03 ms of 6000 ms.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 13, 2024, 11:47:01 am
FWIW HA uses https://docs.aiohttp.org/en/stable/ as the basis for http comms with an asyncio event loop underneath. I'm not familiar with the internals of exactly how asyncio is implemented but it does open up the possibility that contention with something else going on in HA causes the timeout (NB: given the size of the connection pool used in HA, this seems fairly unlikely tbh). It's also worth noting that I have to hit MC with multiple requests to gather all the info required (Alive, UserInterface/Info, Playback/Zones and 1 Playback/Info per zone) so it's also possible that this causes some contention somewhere (in HA or in MC is hard to tell). At least these are reasons why a single hit in a loop with a separate process each time is not exactly equivalent to how HA behaves though it might suggest the problem is in HA somewhere.

It's not obviously something I can influence at my end though given it's a timeout, not sure what else I can add to debug it either.
Title: Re: Home Assistant integration for jriver
Post by: hoyt on February 13, 2024, 02:01:53 pm

It's not obviously something I can influence at my end though given it's a timeout, not sure what else I can add to debug it either.

I think you were right before when you indicated that it's probably something not in the HA integration, but within MC/ my server. I just happened to be interacting with the client, or my interaction with the client made it happen. I went to change the volume on the client (MC, not the HA integration), the client hung for a second and I got the Mac pinwheel. At that moment, the integration went to not-available. I had just cleared the logs, so I'm looking through now to see if I can figure out what's going on. Appreciate the help!
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 13, 2024, 02:18:02 pm
it would be interesting to know exactly how the webserver in MC operates and whether that operates in a non blocking mode, aka I have no clue how MC is threaded. For example, is MCWS serving the view of state available to the current thread or is it actively acquiring (via 1 or more locks) that state on demand?
Title: Re: Home Assistant integration for jriver
Post by: eve on February 15, 2024, 07:23:29 pm
I've seen JRiver (30 I believe) lock up because of HTTP requests sent to it. When I was having my client devices poll JRiver directly I'd every once in a while end up with an actual playback hiccup. I decided to log when every client polled, and sure enough, when a couple client's interval synced up *really* close, it had a chance of the 'hang' / interruption. Strangest thing. It convinced me to essentially make a single service for polling that the client devices could talk to.
Title: Re: Home Assistant integration for jriver
Post by: bob on February 16, 2024, 08:08:16 am
I've seen JRiver (30 I believe) lock up because of HTTP requests sent to it. When I was having my client devices poll JRiver directly I'd every once in a while end up with an actual playback hiccup. I decided to log when every client polled, and sure enough, when a couple client's interval synced up *really* close, it had a chance of the 'hang' / interruption. Strangest thing. It convinced me to essentially make a single service for polling that the client devices could talk to.
What data were you polling for in your requests? Anything specifically regarding remote zones?
Title: Re: Home Assistant integration for jriver
Post by: eve on February 16, 2024, 02:09:04 pm
What data were you polling for in your requests? Anything specifically regarding remote zones?
Just playback state and playback info (before playback state let you choose fields, or at least before I knew about that, IIRC). This was on a per system basis. I don't really use JRiver for its library / db anymore.

Title: Re: Home Assistant integration for jriver
Post by: mattkhan on February 24, 2024, 04:27:19 am
small update to add a new service - https://github.com/3ll3d00d/jriver_homeassistant/issues/17 - for direct setting of the volume
Title: Re: Home Assistant integration for jriver
Post by: flac.rules on April 13, 2024, 05:44:09 pm
Thanks a lot, maybe I don't understand the "additional services" quite right, but is it correct that in the "browse media" one can't choose playlists? Is there a way to play playlists via HA? I have a very large library so this is usually the easiest way to do it.
Title: Re: Home Assistant integration for jriver
Post by: mattkhan on April 14, 2024, 10:10:26 am
Thanks a lot, maybe I don't understand the "additional services" quite right, but is it correct that in the "browse media" one can't choose playlists? Is there a way to play playlists via HA? I have a very large library so this is usually the easiest way to do it.
do you mean using the HA UI and a media player card or do you mean via one of the provided services?

if you mean the latter then it would be something like the attached example from the developer screen

for the former, if you have playlists as an entry in the remote views then it should be possible to browse them and play them (just as panel does).

Title: Re: Home Assistant integration for jriver
Post by: mattkhan on April 14, 2024, 10:13:03 am
actually looks like a bug, added https://github.com/3ll3d00d/jriver_homeassistant/issues/18
Title: Re: Home Assistant integration for jriver
Post by: mattkhan 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
Title: Re: Home Assistant integration for jriver
Post by: flac.rules 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?
Title: Re: Home Assistant integration for jriver
Post by: mattkhan 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