MMP: Shortcuts - Attribute

Hi all,

I’m using the attribute object which lights up my source buttons when they are selected. I noticed, in my Sonos environment, that any favourites from music services like Amazon or Apple don’t get a nice highlighted button. I’m assuming this is something to do with what the music services are returning opposed to what Sonos returns natively. Is there a workaround ?

Thanks !

Are you referring to the source_list attribute on Sonos devices?

Thanks Bill. No, this seems to be just for the shortcuts object. Name is attribute, type is string. The text says:
Specify any attribute exposed by the media player entity. The attribute value (if exists) is compared with shortcut id 's to distinguish selected/active shortcut. Examples, source for active source or sound_mode for active sound mode.

So, in my code I use ‘attribute: source’ This is will highlight the selected source button but only if its a Sonos playlist or radio station, not if its an external music source even though its within Sonos.

Sorry, not a coder, just trying to stumble my way through !

1 Like

Could you perhaps add a few screenshots to illustrate? At least to me it is not really clear.

1 Like

Thanks Philip. Here’s the code (work in progress) and attached is a screenshot showing the radio station LBC as the selected, playing source. If you select a source from and external service like Amazon or Apple Music, the button highlight doesn’t work. Bear in mind all my sources are via Sonos.

Does this help ?

type: vertical-stack
cards:
  - type: 'custom:mini-media-player'
    entity: media_player.study
    artwork: full-cover
    hide:
      power: true
      controls: true
      volume: true
      name: true
      progress: true
      info: true
      icon: true
      source: true
      toggle_power: false
  - type: 'custom:mini-media-player'
    entity: media_player.study
    shortcuts:
      buttons:
        - name: LBC
          type: source
          id: LBC London
        - name: 4 Xtra
          type: source
          id: BBC Radio 4 Extra
        - name: Christian
          type: source
          id: Christian Praise & Worship
        - name: Steely D
          type: source
          id: Steely Dan Essentials
        - name: Clapton Insp.
          type: source
          id: Inspired by Eric Clapton
      attribute: source

Seems that in such cases the media player entity attributes do not return the “source”, but artist and title instead. I guess that may be the reason.

1 Like

Thank you @suxlala

Thank you. I’ve now done that :slight_smile: