Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Always On Configuration Option (@Cassock) #74

Closed
thlucas1 opened this issue Jan 9, 2025 · 10 comments
Closed

Add Always On Configuration Option (@Cassock) #74

thlucas1 opened this issue Jan 9, 2025 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@thlucas1
Copy link
Owner

thlucas1 commented Jan 9, 2025

Problem Description

The HA Spotify integration does not support the turn_on / turn_off feature, so it is "always on" if you will. It can take anywhere between 1 - 30 seconds for it to detect changes from other Spotify Connect player clients.

The SpotifyPlus integration supports the turn_on / turn_off feature, and is "off" by default. More info on why that is can be found in the FAQ - Why does the media player support turn_on / turn_off wiki.

The SpotifyPlus media player has to be turned on in order for it to detect changes from other Spotify Connect player clients. When the media player is turned on, the Polling Scan Interval integration configuration option controls how fast the changes are detected. This can be as quick as 4 seconds, or as long as 60 seconds.

Describe the solution you'd like

Add configuration option to always keep the player turned on.

@thlucas1 thlucas1 added the enhancement New feature or request label Jan 9, 2025
@thlucas1 thlucas1 self-assigned this Jan 9, 2025
@thlucas1 thlucas1 changed the title Add Always On Configuration Option Add Always On Configuration Option (@Cassock) Jan 9, 2025
@mwilky
Copy link

mwilky commented Jan 9, 2025

Great add on btw, just add to this, could calling play_media on a SpotifyPlus entity automatically turn the media player on if it's off?

Music still starts playing even if it's "off" when I call it, just the media player still shows as off and you don't get the album art etc.

And is a service for play_pause at at possible?

@thlucas1
Copy link
Owner Author

thlucas1 commented Jan 9, 2025

@mwilky
Calling the play_media service does switch the player state to ON (if media type is valid and no enqueue specified), though the turn_on service is not called. Note that the turn_on service will execute the turn on script, verify the selected source, etc. - none of that occurs when the play_media is called while the player state is OFF.

Once the player state is switched to ON, it will then start polling Spotify for updates.

Also note that the player state remains OFF if play is initiated by a Spotify player outside of HA.

I am currently in the process of adding the same "auto-power" feature to the other services that can start / resume playing media: player_media_play_context, player_media_play_track_favorites, player_media_play_tracks, and player_media_resume, media_play (e.g. start / resume playback).

@mwilky
Copy link

mwilky commented Jan 9, 2025

@mwilky
Calling the play_media service does switch the player state to ON, though the turn_on service is not called. Note that the turn_on service will execute the turn on script, verify the selected source, etc. - none of that occurs when the play_media is called while the player state is OFF.

Once the player state is switched to ON, it will then start polling Spotify for updates.

Also note that the player state remains OFF is play is initiated by a Spotify player outside of HA.

Thank you, so I guess when calling play_media whilst the player state is off, it will take the 30 seconds poll interval to grab the album art etc and display that in the UI?

@thlucas1
Copy link
Owner Author

thlucas1 commented Jan 9, 2025

@mwilky
Sorry, was busy updating my earlier comment and you replied.

The polling should begin immediately once the HA play_media service executes, which means it should be grabbing the cover art within a second or 2. The 30 second delay comes into focus when play is initiated outside of HA (via Spotify mobile player for example).

@mwilky
Copy link

mwilky commented Jan 9, 2025

@mwilky
Sorry, was busy updating my earlier comment and you replied.

The polling should begin immediately once the HA play_media service executes, which means it should be grabbing the cover art within a second or 2. The 30 second delay comes into focus when play is initiated outside of HA (via Spotify mobile player for example).

No problem at all. I will double check when I'm back at home. If I remember correctly, I called the play_media service and the music starts playing. My card didn't show the album art (waited around 5-10) seconds. I had to find the SpotifyPlus media player entity and press the power button to toggle it on, and then the card showed the album art.

@thlucas1
Copy link
Owner Author

thlucas1 commented Jan 9, 2025

What card are you using for your media player? Some cards may take longer to publish the update than others.

Also ... there is a SpotifyPlus Card Dashboard that I wrote, which is a front-end to the SpotifyPlus integration. Just thought I would mention it in case you weren't aware.

@mwilky
Copy link

mwilky commented Jan 9, 2025

What card are you using for your media player? Some cards may take longer to publish the update than others.

Also ... there is a SpotifyPlus Card Dashboard that I wrote, which is a front-end to the SpotifyPlus integration. Just thought I would mention it in case you weren't aware.

I am using https://github.com/kalkih/mini-media-player as the card. It updates instantly when the power toggle has been toggled prior, and skipping songs the album art changes instantly.

From what I remember though, calling the play_media service didn't turn the power toggle on on the media player entity within the 5-10 I was checking the card for album art though, so this may be the issue I am seeing.

@thlucas1
Copy link
Owner Author

thlucas1 commented Jan 9, 2025

@mwilky
I just released SpotifyPlus integration v1.0.85.

[ 1.0.85 ] - 2025/01/09

  • Added configuration option to specify the player state is to remain turned on at all times (True) or if TURN_ON / TURN_OFF features are enabled (False, default).
  • Added "auto-power on" processing to various services that can start / resume playing media: player_media_play_context, player_media_play_track_favorites, player_media_play_tracks, player_media_resume, and media_play (e.g. start / resume playback). This feature was already available for the play_media service, but only if a supported media_type was specified and no enqueueing.

Thanks - Todd

@mwilky
Copy link

mwilky commented Jan 9, 2025

@mwilky I just released SpotifyPlus integration v1.0.85.

[ 1.0.85 ] - 2025/01/09

  • Added configuration option to specify the player state is to remain turned on at all times (True) or if TURN_ON / TURN_OFF features are enabled (False, default).
  • Added "auto-power on" processing to various services that can start / resume playing media: player_media_play_context, player_media_play_track_favorites, player_media_play_tracks, player_media_resume, and media_play (e.g. start / resume playback). This feature was already available for the play_media service, but only if a supported media_type was specified and no enqueueing.

Thanks - Todd

Just noticed thank you, will do some testing and will open a seperate issue if required!

Thanks for your efforts mate

@thlucas1
Copy link
Owner Author

Assuming this met your requirements; if not please re-open and I will revisit.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants