Lovelace: Mini Media Player

When using notify.alexa.media you need to provide a target device:

alias: test
description: 
trigger: []
condition: []
action:
  - service: notify.alexa_media
    data:
      target: Echo Office2
      data:
        type: announce
      message: Hello All
mode: single

or, you call it like this:

alias: test
description: 
trigger: []
condition: []
action:
  - service: notify.alexa_media_echo_office2
    data:
      message: Hello All
      data:
        type: announce
mode: single

Hello Joerg, thank you so much for your efforts. A little bit awkward, I played with the new alexa switches and didnā€™t recognize that the do_not_disturb_switch was activated. :woozy_face: So now Iā€™ve learned that that switch only affects on type: announce.

Hello,
so it does work for you without a target?
Here it doesnā€™t.

Ah, no, it wonā€™t. You are right.

okay. thanks.

How about using conditional cards, which is what theyā€™re literally for :wink:
:point_right: Conditional Card - Home Assistant

Put each mini-media-player-card inside a conditional card and define the states it needs to show (follow the steps in the doc I linked).

Or maybe use the speaker group option of mini-media-player.

I use swipe-card myself and have conditional cards inside it, which each a speaker nested (I use Logitech Media Server with multiroom syncing). When everything is off, nothing shows. If one is playing, I see one media_player card. When more than one is playing, I still see one, but there is a bullet point that shows there are more slides. Then I can just slide between the players.

edit: added example of my card

See for swipe-card example :point_right: Imgur: The magic of the Internet

3 Likes

Thank you for the quick reply @ASNNetworks, I did think in that direction, but as far as I can see, the state of the sonos speakers donā€™t change if I group it through the speaker group option. And therefore I canā€™t set a condition.

I also tried the swipe card, to keep things less cluttered, but the dropdown, when choosing favorites is being restricted by the border of the swipe card. I have maybe 10 playlists and radio stations in my favorites list. So there is only room for the 1st one.

Will the players show theyā€™re synced in the attributes? If you go to your HA instance, then developer-tools/state in the url, check out what all attributes are while in and out of a sync group.

Then you could use those attributes to create template binary sensors. And then use those as the entity in the conditional card states. When in a sync group > binary sensor turns on, which means card will hide. And vice versa.

Most likely you can also achieve this without needing to create binary sensors for each speaker, if you use config-template-card. Then you can use templates (like attributes) in your conditional card. But will require some more work to first understand it.

Both options should allow you to achieve what you want though :slight_smile:

Ah, that is fantastic input!

When I look, I get this for the dining room speaker (which is currently grouped with kitchen speaker)

(...)
sonos_group:
  - media_player.dining_room
  - media_player.kitchen
(...)

Compared to living room speaker which is playing on itā€™s own:

sonos_group:
  - media_player.living_room

So the logic should be, if there are >1 entities in that list, they are grouped.
And I would probably make a binary sensor for each speaker, as I am not that skilled.
And then 4 conditional cards (1 for each speaker), that only shows if group binary sensor is true for each and their own speaker. And of course only show the current 4 cards, if group=no.

Would this be an viable approach? Sounds like a fun small project!

Yes, so you need to create a template binary sensor for each speaker. For media_player.kitchen you need to create a template that checks if the attribute sonos_group has other entities other than media_player.kitchen inside it. Or maybe you can use a count template for that. If attribute sonos_group has more than one option inside it, then return as on, otherwise return as off I think that would be a lot easier.

Do that for each speaker. Each binary sensor basically tells you: hey this speaker is in a group. Then use the binary sensor you created for each speaker as the entity in the conditional card you use for each speaker. Set it as state: 'off' (do not forget the quotes around 'off' if you use YAML). Then the media player will only show if the binary sensor you created for it is off, which means the speaker is not in a group.

Unfortunately my templating skills are lacking, so I canā€™t help you with that. I would ask this through the Discord channel to get some help :wink:

1 Like

I actually found a guide earlier in this thread!

Testing it out as we speak!

And that solution is actually a bit more elegant, as I can just add a condition to the existing 4 cards, so they disappear if they are grouped, but not master.

Edit: it works!

2 Likes

Can you make a blank button? i.e. a button that is only used for spacing out other buttons

Iā€™m having trouble getting the Grouped Cards to work. When I use the code below (from the GitHub example) in the card configuration, I just get an error code that says ā€œNo type provided.ā€

I can create cards all day long using the visual editor so Iā€™m assuming this isnā€™t an installation issue. Any thoughts?

- type: entities
  entities:
    - type: custom:mini-media-player
      entity: media_player.allplayers
      group: true
      source: icon
      info: short
      hide:
        volume: true
        power: true
    - type: custom:mini-media-player
      entity: media_player.mediaplayer_1
      group: true
      hide:
        controls: true
    - type: custom:mini-media-player
      entity: media_player.mediaplayer_2
      group: true
      hide:
        controls: true

Leave out the first hyphen:

type: entities

sure enough. those dang hyphens

Is there possibility to use entity or attribute state as a button name?
E.g.

buttons:
  - icon: mdi:youtube
    name: {{ states('input_select.ytube_music_player_playlist') }}
  ...

I am trying to use this card so I can control the volume of my Vizio SmartCast Soundbar. However, once I create a basic card for the soundbar (code below), the volume slider does not perform a volume ā€œsetā€ action like I would expect - instead, my setting the volume of the soundbar only adjusts the volume down slightly.

For instance, if my volume on the soundbar is set to 75% of maximum, and I move the Mini Media Player slider down to 10% - the result on the soundbar is for the volume to maybe move down to 70%. This setting of 70% is then reflected on the Mini Media Player slider after about 1 second. Any ideas for a solution, or is this soundbar simply not supported? I am able to set the volume of this speaker using the automation of media_player.volume_set.

type: custom:mini-media-player
entity: media_player.vizio_smartcast
name: Vizio Soundbar

I want to add a list selection that should choose what speaker to output the media to. I have this so farā€¦ But it just wont work when it comes to the source select. It just plays on the kitchen speaker all the time.

type: custom:mini-media-player
entity: media_player.kitchen_speaker
source: icon
hide:
  volume: false
  source: false
  power_state: false
artwork: material
shortcuts:
  columns: 3
  list:
    - name: Play in kitchen
      type: source
      id: media_player.kitchen_speaker
    - name: Play in office
      type: source
      id: media_player.office_speaker
  buttons:
    - name: P3
      type: music
      id: https://sverigesradio.se/topsy/direkt/164-hi.mp3
    - name: P4
      type: music
      id: https://sverigesradio.se/topsy/direkt/221-hi.mp3
    - name: Spotify
      type: service
      id: spotcast.start
      data:
        entity_id: media_player.kitchen_speaker
        uri: spotify:playlist:6kCXbV91V2I5eYcHvknB4Y

Bit of a long shot this but is there any way of having some kind of background overlay behind the media player element itself when using full cover art?

What iā€™d like is some translucent shading behind the controls/text at the bottom for when the image behind makes it hard to read.

Have a look at the customization possibilities:

https://github.com/kalkih/mini-media-player#theme-variables

You could play around with the overlay variables. Put it in your theme file or use Card-Mod.

1 Like