Lovelace: Mini Media Player

I’m not sure if this is an overall HA/Lovelace issue, or if there’s something in the card coding that can fix this. But when the card is to the left side, the source dropdown flies out “under” the side panel (regardless of if it’s minimized like in this example or not)

image

When the card is close to bottom of the page, list also drops below the edge… especially frustrating on the phone, as it means edge of the screen. Could we have source selection on top ofthe card (in full artowr mode), please? Or being aware about edge and opening up?

1 Like

Not sure if you were referencing my card, but f so. I don’t believe that I mentioned anything about doing it in one card. In my current layout I have multiple cards all fulfilling a different role.

Turns out this is due to the way Roku implements the “Space” in the source list. It’s not really a ‘space’ it’s a non-breaking space. Soo I had to use ALT-0160 instead of space when typing it out. Problem solved.

Is there a possibility with css to set max-width for info items? I have it combined with a button card and the title of song overlaps with the buttons.
Thank you!

edit: forr thos who want to know i found out

                              .entity__info {
                                max-width: 55% !important;
2 Likes

I am not sure if anyone answered your question or not, but below is how i achieved a similar layout.

The below code is for a single tile in the playlist selector.

entity_picture: 'https://i.scdn.co/image/ab67706f00000003c52557648b37b81cd1a05d10'
show_entity_picture: true
styles:
  card:
    - '--mdc-ripple-color': var(--switch-checked-button-color)
    - '--mdc-ripple-press-opacity': 0.5
  entity_picture:
    - width: 100%
  grid:
    - margin: '-10px'
tap_action:
  action: call-service
  service: script.1594217612531
  service_data:
    media_content_id: 'spotify:user:spotify:playlist:37i9dQZF1DXcF6B6QPhFDv'
    media_content_type: playlist
type: 'custom:button-card'

The script that is being called for the tap action is just to play the selected playlist on the media player that is in the input_select.
I am not sure if you can just use the Call-Service for a sonos media player, but it should work. I am using Logitech Media Server.

6 Likes

Euh i’m not sure what you mean?
Where’s your current layout?

Where di you see this? Would love to contact him and see his code

Would I be able to a relayed speaker switch. We live in a small house and use one sonos connect amp and a 4 way speaker switch for each room. I’d like to select which rooms are in use from this card. Planning on adding relays to my QED speaker selector.

So they wouldn’t be a media.player, but a switch, obviously no volume control.

I think you would be best to try a universal media player https://www.home-assistant.io/integrations/universal/

Not sure when this broke but I can no longer select a radio station using the buttons in the card:

      - type: "custom:mini-media-player"
        entity: media_player.portable_radio
        hide:
          source: true
          mute: true
          power_state: false
          controls: true
          volume: true
        speaker_group:
          platform: squeezebox
          show_group_count: true
          entities:
            - entity_id: media_player.portable_radio
              name: Kitchen
            - entity_id: media_player.bathroom
              name: Bathroom
            - entity_id: media_player.garden_room
              name: Garden room
        shortcuts:
          columns: 3
          buttons:
            - name: Radio 2
              type: playlist
              id: Radio_Radio_2
            - name: Soul
              type: playlist
              id: Radio_Magic_Soul
            - name: Gold
              type: playlist
              id: Radio_Gold

I can still use squeezebox.call_method with

entity_id: media_player.portable_radio
command: playlist
parameters:
  - play
  - Radio_Magic_Soul

and that works. Any ideas?

I also have this problem with this configuration:

          - type: 'custom:mini-media-player'
            artwork: cover
            entity: media_player.dachboden
            hide:
              icon: true
              power: false
              volume: false
            info: short
            name: Dachboden
            scale: 0.9
            source: icon
            shortcuts:
              buttons:
                - id: http://opml.radiotime.com/Tune.ashx?id=sxxxxxx&formats=aac,ogg,mp3&partnerId=xx&serial=2b4xxxxxxxxxxxxxxxxxxxx
                  name: 
                  image: /hacsfiles/lms-bilder/NDR 2.png
                  type: playlist
              columns: 4

I am getting this error in the log:

2020-10-20 10:41:20 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2746982040] Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 138, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1335, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1370, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 470, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 655, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 507, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/squeezebox/media_player.py", line 483, in async_play_media
    content = json.loads(media_id)
  File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The media player is a LMS server.

totally unrelated but what editor are you using in the second screenshot

Sorry to answer for someone else, but I think it is Visual Studio Code.

Hopefully a simply question that is driving me mad that I can’t find the answer: how can I create a shortcut button that plays a Spotify playlist via my Sonos?

So far I’ve got the playlist saved as a favourite in Sonos and tried the URIs I’ve seen in the examples. Everything I try gets me an error in the logs like ’ Could not find a Sonos playlist named “spotify:user:spotify:playlist:37i9dQZF1DWXF8Nf1uycDZ” ’

In the example below, tests 1-3 don’t work. Test 4 works because I created an actual Sonos playlist called ‘Test’ with a track in it. So maybe it only works with Sonos playlists?

shortcuts:
  columns: 4
  buttons:
    - name: TEST1
      type: playlist
      id: 'spotify:playlist:37i9dQZF1DWXF8Nf1uycDZ'
    - name: TEST2
      type: playlist
      id: 'spotify:user:spotify:playlist:37i9dQZF1DWXF8Nf1uycDZ'
    - name: TEST3
      type: playlist
      id: 37i9dQZF1DWXF8Nf1uycDZ
    - name: TEST4
      type: playlist
      id: Test

Use

buttons:
    - id: name of your sonos playlist
      name: alias you want to use for your paylist
      type: source

Just started using this to improve upon the Hue HDMI Sync Box card. Since it is not a conventional media player, I wish there were a way to change the background image based on the power state.

Hey!

I would love to add buttons to my card. I use Youtube Music, but can’t seem to add a working button?

This is what I add:

buttons:
                - name: Punk Rock
                  type: source
                  id: https://music.youtube.com/watch?playlist=RDAMPLPLnp6Uw3EtqkkqyOF0B90-L7YDxaWY4NaW

The spaces are correct in my yaml editor

And your log says?

Hi, is there anyway to add a hot key to the Mini Media Player? I want to basically be able to press m to mute the media player.

Got the idea from the new Quick Bar capability released for entitities and commands.