maykar / plex_assistant

❱ Plex Assistant is a Home Assistant integration for casting Plex media to Google devices, Sonos devices, and Plex clients with Google Assistant, HA's conversation integration, and more.
MIT License
281 stars 59 forks source link

Delay in playing large playlists #114

Closed miketunes closed 3 years ago

miketunes commented 3 years ago

My All Music playlist has 28k tracks. There is a 60 second delay before the music starts when I say this: Tell plex to shuffle all music playlist. Is there anyway to speed this up or should it take that long? My plex server and media are hosted on a 7th generation i5 processor Windows pc. HA is on Raspberry Pi4.

trigger method: IFTTT install method: HACS logs: https://justpaste.it/93kuq

github-actions[bot] commented 3 years ago

Important:

Issues that don't provide the information requested in the troubleshooting docs may not get a reply and may be closed until the info is provided. Please, include as much of the requested info as possible so that I can replicate and investigate your issue.

When pasting in your config/code/errors always place 3 backticks ``` above the first line and after the last line. Doing this will format it correctly.

maykar commented 3 years ago

Depending on the specs of the Pi4 some operations may take a while, especially the lower models. In reference to your earlier related issue, and it might help with this one as well, there is no "all" command. Try saying "Tell plex to play random music" or "tell plex to play music shuffled".

maykar commented 3 years ago

Also, please do not post your entire debug log. It is well over 10,000 lines of information that have nothing to do with this project, turn on debug logs just for Plex Assistant and only post the relevant information.

maykar commented 3 years ago

While looking through the logs I also noticed that Plex Assistant sends the command to play the playlist to home assistant within a few seconds, from then on the delay is between HA and your device.

Try playing a playlist using the play_media service in developer tools and see if you see the same behavior. If that's the case, Plex Assistant isn't the culprit here.

miketunes commented 3 years ago

Thanks for the response. The tell plex to play random music still has a 1 minute delay. Would you recommend moving plex to the raspberry pi where HA is hosted instead of a Windows pc? I tried using the play_media service but it didn't seem to work, I was just guessing at the syntax though: https://imgur.com/a/2RAeaBl

I'll try to post cleaner logs, I had edited the configuration.yaml file with this: custom_components.plex_assistant: debug Is there a place that only shows the plex assistant logs?

maykar commented 3 years ago

Moving Plex to a raspberry pi would undoubtedly make things worse, don't do that.

To use the play_media service with plex media you would do so as explained here: https://www.home-assistant.io/integrations/plex/#service-play_media

More info on how to do it to chromecasts here: https://www.home-assistant.io/integrations/cast/#plex

YAML example below, but if using the UI editor: target would be entity_id or the device, content id would be media_content_id, and content type would be media_content_type

YAML example sending to a chromecast (requires the plex:// prefix in content id):

entity_id: media_player.chromecast
media_content_type: PLAYLIST
media_content_id: 'plex://{ "playlist_name": "all music", "shuffle": "1" }'

YAML example sending to a plex media player (will usually have a name that starts with plex):

entity_id: media_player.plex_plex_something_something
media_content_type: PLAYLIST
media_content_id: '{ "playlist_name": "all music", "shuffle": "1" }'

It seems as if you've configured the default log level of HA to debug instead of only Plex Assistant. More info on that here: https://www.home-assistant.io/integrations/logger/

Plex Assistant's debug logs will always start with something like: 2021-04-04 12:35:22 DEBUG (SyncWorker_0) [custom_components.plex_assistant.const]

miketunes commented 3 years ago

Ok trying to fix the logging, so instead of adding this to configuration.yaml: logger: logs: custom_components.plex_assistant: debug

I should change it to this instead?
logger: fatal logs: fatal custom_components.plex_assistant: debug

maykar commented 3 years ago

I'd do:

logger:
  default: warning
  logs:
    custom_components.plex_assistant: debug
miketunes commented 3 years ago

Tried using YAML, with your example but the call service is greyed out: https://imgur.com/a/RyuGQbn

maykar commented 3 years ago

Try this, also do you have a media_player entity called media_player.chromecast and a playlist called everything? media_player.chromecast was just an example.

service: media_player.play_media
target:
  entity_id: media_player.chromecast
data:
  media_content_type: PLAYLIST
  media_content_id: 'plex://{ "playlist_name": "everything", "shuffle": "1" }'
miketunes commented 3 years ago

Ok, I tried this command, I do have a playlist called everything and media_player.living_room is the media player entry.

service: media_player.play_media target: entity_id: media_player.living_room data: media_content_type: PLAYLIST media_content_id: 'plex://{ "playlist_name": "everything", "shuffle": "1" }'

come back with this error: Failed to call service media_player/play_media. Plex media not found using payload: '{ "playlist_name": "everything", "shuffle": "1" }'

maykar commented 3 years ago

Back to the speed issue, what does your CPU usage look like in Supervisor > System when idle and does it peak when making a call?

miketunes commented 3 years ago

Around 1% when idle, jumps to 25% when making call, then back to 1% when music starts playing

maykar commented 3 years ago

I'd still be interested in if this delay exists when using the service call, but I couldn't tell you why you're having issues when triggering it. If this is an issue when using the HA service call then it's not an issue with Plex Assistant.

miketunes commented 3 years ago

Gotcha, I think I'm going to give up and try Kodi instead of Plex. Plex handling of singles and various artists' albums is horrible.

On Tue, Apr 20, 2021 at 11:00 AM Ryan Meek @.***> wrote:

I'd still be interested in if this delay exists when using the service call, but I couldn't tell you why you're having issues when triggering it. If this is an issue when using the HA service call then it's not an issue with Plex Assistant.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/maykar/plex_assistant/issues/114#issuecomment-823345480, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKZYNAKIII7FCPKBZYRCW3LTJWJILANCNFSM42KLXYWQ .