custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.93k stars 233 forks source link

Add metadata in servic_data #641

Open 2-MAdD opened 1 year ago

2-MAdD commented 1 year ago

Checklist

Describe the bug When using this custom:button-card with call-service, service:media_player.play_media you cannot set metadata like in scripts

Version of the card Version: v3.4.2

To Reproduce This is the configuration I used:

name: GPR Dance
show_name: false
show_icon: true
type: custom:button-card
show_entity_picture: true
entity_picture: https://grandprixradio.nl/cache/GPR%20dance%20hits%20logo-5a0b070a.jpeg
size: 75px
tap_action:
  action: call-service
  service: media_player.play_media
  service_data:
    media_content_id: aac://https://22663.live.streamtheworld.com:443/GPRDANCEAAC.aac
    media_content_type: music
    entity_id: |
      [[[
        var player = states["input_select.radio"].state;
        if ([player] == 'IT Room') return 'media_player.sonos_kantoor';
        if ([player] == 'Huiskamer') return 'media_player.sonos_huiskamer';
      ]]]

code in script is:

  - service: media_player.play_media
    target:
      entity_id: media_player.sonos_kantoor
    data:
      media_content_id: [FV:2/2](aac://https://22663.live.streamtheworld.com:443/GPRDANCEAAC.aac)
      media_content_type: music
    metadata:
      title: Grand Prix Radio Dance Hits
      thumbnail: >-
        https://sali.sonos.radio/image?w=60&image=https%3A%2F%2Fcdn-profiles.tunein.com%2Fs211502%2Fimages%2Flogog.jpg%3Ft%3D1&partnerId=tunein
      media_class: genre
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: favorites
          media_content_id: ""
        - media_content_type: favorites_folder
          media_content_id: object.item.audioItem.audioBroadcast

Screenshots with script: script

With custom:button-card: button

Expected behavior With script, you have a background in the player. When using the custom:button-card note. Also missing the title next to the device

Desktop (please complete the following information): all

Smartphone (please complete the following information): all

Additional context As you miss the option to set the metadata you dont see in the player the title and background. As with scripts you can see it, you know directly which music station you are listing to.

RomRider commented 1 year ago

That should work in the latest beta, I think as it can now use the default HA services calls (with the same syntax as your script)