Lovelace: Mini Media Player

Awesome!

Can you please elaborate on the sleep feature request?

so the Sonos component suggests that the sleep timer can been created using the service call

here

Configuration Variables

entity_id

(entity_id)(Optional)The speakers to separate from their coordinator speaker.

Service media_player.sonos_set_sleep_timer

Sets a timer that will turn off a speaker by tapering the volume down to 0 after a certain amount of time. Protip: If you set the sleep_time value to 0, then the speaker will immediately start tapering the volume down.

Configuration Variables

entity_id

(entity_id)(Required)The speakers that will have their timers set.

sleep_time

(integer)(Required)Number of seconds that the speaker should wait until it starts tapering. Cannot exceed 86399 (one day).

Service media_player.sonos_clear_sleep_timer

Clear the sleep timer on a speaker, if one is set.

its a set amount of time till the speaker turns off, say for example when playing music before you sleep.

I thought I would ask just in case others are interested in the feature

otherwise is it possible for me to incorporate it into you custom card some how .

Okay, that’s a cool feature, I’m trying to avoid adding too many platform specific features to the card.
But you can easily incorporate this into your card by utilising the shortcuts with a list and/or buttons and from there call a script.
You would have to set up a script that calls the media_player.sonos_set_sleep_timer service, then specify the script in your card configuration, like below.

- type: custom:mini-media-player
  entity: media_player.example
  shortcuts:
    buttons:
      - icon: mdi:hotel
        name: sleep
        type: script
        id: script.your_sonos_sleep_script

There’s more information about the shortcuts option in the GitHub repo, and here’s another example.

This is great! thanks for your help this is exactly why a community is great!

Out of interest for others with alternative speakers would it be possible to instead of using a sonos specific service call create a script that would call the service media_player.media_play_pause which I guess is the same for all speakers and create a timer in the script itself . thus providing the feature for all speaker types?

3 Likes

For sure, that should absolutely be possible, great idea.

2 Likes

Perhaps as a way to extend the ‘sleep’ feature it could have a set (definable) period of time to continue playing normally, then slowly decrease volume over another set (definable) period of time before stopping the playback altogether.

Just a thought. Why not use an automation or script for the sleep feature?
HA has all the stuff we need to achieve this, without making the mini player more complicated and therefore more prone to fail. My 2c :wink:

I was already thinking of doing this since it’s basically the reverse of a script I have for waking up to slowly increasing volume music but just thought I’d chime in on the already posted feature request. I guess that if it’s built into the media player it reduces the complexity of using that feature in multiple parts of our systems. ie: you don’t need to code it into each automation. but I get what you are saying also.

1 Like

As @lolouk44 said, this is pretty much a perfect fit for a script or an automation, you can then call the script from the media player shortcuts if you wish (as I described earlier).

1 Like

Hi all - does anyone know if / how i can have one mini media player card and be able to select which entity it controls rather than having a card per entity or each entity listed out in a card??

@bearded_bloke you could use the Lovelace conditional card and this hide and show players based on the selection of a button or input select.

1 Like

Yes, please consider conditional cards and an input select, should work great. You can find some information and config snippets for this approach here.

Instead of conditional cards, you could also try the new Templateable Lovelace card by @iantrich together with an input_select, should save you from having to add a conditional card for each entity.

1 Like

Another option is auto-entities, my config shows any players that are active, but an input-select might be usable to choose -

2 Likes

Is there anyway to hide this info from a sonos? (circled in red)

nevermind.

hide:
info: true

Hello guys,

is there a way to use own icons in ‘local’ folder ?
Thanks!

Hello there,

First of all thanks for this amazing card !

i have a request : i’ve setup a “source shortcut” to replace the big buttons i had previously.
the shorcuts does not reflect the state of source like my buttons did.
could that change ?

image

I also have an extra feature that would pause the player when i click on the activated source, but i would understand if you would not do that extra step.

Thanks !

Hi, not sure, but if you would like to use the fontawesome icons, take a look at this

I think you’ll have to continue using the button card if you want to display the current state unfortunately.

In order to add this feature we would have to keep track of every entity you use in the shortcuts config, which in my opinion is a bit out of scope for this project.

You could create a script where you change the source and pause the player, and then use that script in the shortcut button.

Well, in the case of “source” you already have the info available since there is a source dropdown ?

But that’s okay i’ll keep using my big buttons :slight_smile:

Yes, if it’s a source shortcut it should be possible to implement, I’ll see what I can do.

Such a great Card, I love it.

I am using Panel: True to stretch the media player across the top of my page as it my main volume control, is there any way to have the volume slider scale with the available width of the card as it can be a little small and fiddly when trying to control my quite powerful receiver in my home theater. A larger range to slide would make control more precise if possible.

Thanks for the great addition to HA