Lovelace: Mini Media Player

Hi guys,
super new to HA, am in healthcare and don’t have a ton of coding knowledge but just getting started.
Got the spotify/spotcast plugins setup, those work great, just trying to get this media card setup to play on two alexas, either separately or grouped, from spotify.
Neither speaker will let me chose any source besides “local speaker”
Only way I can get spotify to play is by using a separate default media card and chosing media, then it plays just on the echo dot, and not on both. Nor can I ever get it to play on the other.

image

type: entities
entities:
type: ‘custom:mini-media-player’
entity: media_player.joseph_s_echo_dot
group: true
hide:
controls: true
type: ‘custom:mini-media-player’
entity: media_player.joseph_s_echo
group: true
hide:
controls: true

is the code for my current mini media player which shows both.
Ideas? Would love to learn more.

Sorry if this has already been asked before, but is there anyway to change the background opacity based on the state of the device?
I want to have the card at 60% opacity when the status is either unavailable, idle of off and noticed there is a --mini-media-player-background-opacity variable, but unsure how to actually make it work in code!!!

Does anyone know how to use the speaker group management with a dynamically changing “master” speaker? My goal is to only show the card that has the correct “master” speaker.
Currently I’m using the speaker group management along with a conditional card for my Sonos speakers. This allows me to only have the card display in lovelace when the speaking state is playing. I have created a card for each of my speakers as “master”. The issue is that I have to find which card has the “master” speaker as the main entity in order to control the grouping.
I’d like to find a way to only have the card display that has the appropriate “master” speaker as the main entity so I can control the grouping. Hopefully this question makes sense.

It’s a little messy, but you can create template binary sensors for each speaker:

- platform: template
  sensors:
    sonos_kitchen_is_controller:
      value_template: >
        {% if state_attr('media_player.sonos_kitchen', 'sonos_group') %}
            {{ state_attr('media_player.sonos_kitchen', 'sonos_group')[0] == 'media_player.sonos_kitchen' }}
        {% else %}
            False
        {% endif %}

Then you could add a conditional card for each speaker based on the appropriate binary_sensor with the speaker_group populated:

  - type: conditional
    conditions:
      - entity: binary_sensor.sonos_kitchen_is_controller
        state: 'on'
    card:
      artwork: cover
      entity: media_player.sonos_kitchen
      hide:
        icon: true
        power: true
      idle_view:
        after: 5
        when_idle: true
        when_paused: true
      speaker_group:
        entities:
          - entity_id: media_player.sonos_kitchen
          - entity_id: media_player.sonos_dining_room
          - entity_id: media_player.sonos_front_room
          - entity_id: media_player.sonos_basement
          - entity_id: media_player.sonos_bedroom
        show_group_count: true
      type: 'custom:mini-media-player'

I bet there’s a simpler and less verbose way, but this works well for me.

2 Likes

Thank you for sharing! I actually did figure this out in a very similar way using sensors instead of binary sensors to determine which speaker is the master. I had not posted my setup yet because Im still making tweaks to it. I might give your setup a go to see if it works any different / better than my current method.

I also found another discussion where someone used entity_filter card with regex state_filter. I had not heard of regex until just now so Im looking into that and also trying out their way of making the card.

bump bump :slight_smile:

Does anyone know how to change the media_title and entity picture of a media player using media_player.play_media with the shortcuts? In the media player documentation there is a section about extra attributes and I tried a lot but couldn’t find how to do it. This is the corresponding code:

shortcuts:
 columns: 4 # Max buttons per row
 buttons:
  - name: "538"
    type: service
    id: media_player.play_media
    data:
      entity_id: media_player.sonos
      media_content_id: http://22343.live.streamtheworld.com/RADIO538.mp3
      media_content_type: music
      extra:
        title: "538"

And a screenshot:

Screenshot 2021-05-20 at 11.40.03

Hi @Noxvia Did you find a solution to this problem as I am experiencing the same thing…
Thanks


type: 'custom:mini-media-player'
entity: media_player.echo_dotchen
source: icon
name: any name you like
shortcuts: 
…

Would you like to post your code? Maybe four eyes see more than two.

@Pedolsky I don’t think it’s my code , it’s the discovery of the alexa media players when trying to display them in the drop down tab

i mean dynamically, so the name changes to the name of the shortcut.

and it’s the subitle i mean. not the name

Hi,
did you have your devices discovered or did you define them with their ‘Alexa’ names in configuration.yaml like this?:

alexa_media:
  accounts:
  - email: your amazon email
    password: your amazon password
    url: amazon.com
    include_devices:
      - "Master Bedroom"
      - Stairs

Where in the docs can I find something about an extra option? Or do you mean the attribute option? If so, I would like to use it but it doesen‘t work ‚though the attribute exists.

No i mean in the media player docs: Media Player - Home Assistant at Service media_player.play_media it refers to a service_data attribute called extra. In this attribute you can use media_info and metadata but then you will need the datatype map. Further it refers to google dev pages. But i haven’t figured out the right syntax yet. New to this.

is it possible to ‘mix’ the group (for Sonos speakers) function with grouped cards?? To also have a volume slider per speaker ??

I try this, but its not working :frowning:

# card
type: custom:mini-media-player
entity: media_player.family_room
group: true
artwork: material
shuffle: true
hide:
  power: true
  source: true
speaker_group:
    platform: sonos
    show_group_count: true
    entities:
      - entity_id: media_player.family_room
        name: Sonos Woonkamer
        group: true
        hide:
        controls: true
      - entity_id: media_player.keuken
        name: Sonos Keuken
        group: true
        hide:
        controls: true
      - entity_id: media_player.slaapkamer
        name: Sonos slaapkamer
        group: true
        hide:
        controls: true
1 Like

Yes! I’d also like to know if there’s a way to include volume sliders for each individual room in a group. I tried to figure it out but couldn’t…

1 Like

Hello, I hope anyone can help me. How can show on mini media player card the source list and media browser icon? I see source list only. The media player view media browser icon, but can not view source list.