core icon indicating copy to clipboard operation
core copied to clipboard

Jellyfin integration doesn't use a persistent device id

Open nielsvanvelzen opened this issue 2 years ago • 5 comments

The problem

The Jellyfin integration doesn't use a persistent device id. This causes the integration to register a new device in the Jellyfin server each time HA is restarted. The issue appears to be in this specific line:

https://github.com/home-assistant/core/blob/bc5594e26363e1bd6b80a09f59e51d13299ad1c9/homeassistant/components/jellyfin/client_wrapper.py#L48

The device id should be unique for the user+device combination. For example, in the Android TV app we use a unqiue id that is set by our Kotlin SDK ^1 and then combine it with the username for the active user ^2. The second part is only required for multi-user support. As there can be only 1 access token granted to a device id.

What version of Home Assistant Core has the issue?

core-2022.4.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Jellyfin

Link to integration documentation on our website

https://www.home-assistant.io/integrations/jellyfin/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

nielsvanvelzen avatar Apr 15 '22 20:04 nielsvanvelzen

Hey there @j-stienstra, mind taking a look at this issue as it has been labeled with an integration (jellyfin) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

Hi @nielsvanvelzen, thanks for bringing this up. I hadn't noticed this yet, but indeed my own Jellyfin instance was flooded with different client registrations. I've created a PR to fix this by saving the client id on configuration of the integration, which keeps the id persistent across restarts.

j-stienstra avatar May 11 '22 12:05 j-stienstra

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 09 '22 13:08 github-actions[bot]

Still an issue. Jellyfin dashboard is spammed with Home Assistant devices.

nielsvanvelzen avatar Aug 09 '22 13:08 nielsvanvelzen

Hey @ctalkington is this fixed now with #79840?

nielsvanvelzen avatar Oct 12 '22 14:10 nielsvanvelzen

@nielsvanvelzen so with recent changes, there should be a persistent client device id sent from config flow setup through to actual integration config entry coordinators. This is persistent per config entry (right now we only have single entry allowed but I hope to review that allow multiple soon).

due to the significant overhauls, this only be available in the next beta/monthly release (not a bugfix)

ctalkington avatar Oct 12 '22 23:10 ctalkington

@nielsvanvelzen also I did have a related question for you, with the jellyfin SupportsPersistentIdentifier device capability. Am I correct in that most the official clients don't support this because they support multiple users and they rely on streaming device sdk to provide an id that can be reset by user or the streaming device os?

I ask because I'm trying to finalize initial media_player platform feature and not sure if we really should care about the persistent bit when creating device registry entries if it's generally retained for some time unless a user resets it? This relates to how we would create devices in the device registry based on that flag (in initial media pull request.). I don't want the reverse of this issue where we spam HA with devices but I also feel like the roku or android ids are going to be mostly unique/persistent?

ctalkington avatar Oct 12 '22 23:10 ctalkington

The way authentication currently works is not great so most clients use hacks to get it working. For example, you can only have a single access token per device id so to support multiple users we generate a unique device id per user (instead of per device) in the clients.

For Android this unique device uses a combination of the username hash and a unique id generated by the platform (which may be reset when you reinstall the app or update your system or clear data). But generally those identifiers should persist for quite a while.

Since I work primarily on our Android apps I can't tell you too much about how the other clients work. Feel free to join our Matrix/Discord or open a discussion on the server repository for any questions.

nielsvanvelzen avatar Oct 13 '22 18:10 nielsvanvelzen