kalkih / mini-media-player

Minimalistic media card for Home Assistant Lovelace UI
MIT License
1.47k stars 206 forks source link

`id` as an attribute identifier only #399

Open agneevX opened 3 years ago

agneevX commented 3 years ago

I'm trying to set the state of a shortcut button on Spotify which plays playlists.

Spotify exposes the current playing playlist as media_playlist as the name of the playlist, not the ID, so currently there is no way for the state of the

What I'm proposing is to designate id as the state of the shortcut, where it must match the attribute, but should not be used for playlist. Currently, when attribute: cannot be used alongside type: service.

If a shortcut button calls a service, instead of...

shortcuts:
  buttons:
    - icon: 'mdi:sunglasses'
      id: media_player.play_media
      type: service
      data:
        entity_id: media_player.spotify
        media_content_id: 'spotify:playlist:xxxxx'
        media_content_type: playlist

My proposal:

shortcuts:
  attribute: media_playlist
  buttons:
    - icon: 'mdi:sunglasses'
      id: Dr Disrespect
      type: service
      service_name: media_player.play_media
      data:
        entity_id: media_player.spotify
        media_content_id: 'spotify:playlist:xxxxx'
        media_content_type: playlist

*_name for other types such as playlist or script.

leva3000 commented 3 years ago

@kalkih Hi. I have another case with a script where I pass the media URL as a variable:

  shortcuts:
    attribute: media_content_id
    buttons:
      - name: Radio Relax
        icon: 'mdi:panda'
        type: script
        id: play_radio
        data:
          entity_id: media_player.bathroom
          radio_url: 'http://ic7.101.ru:8000/v13_1'

So I need to compare media_content_id attribute not with id of the button, but with a variable of script. Could you suggest a solution, please?