Lovelace: Mini Media Player

@kalkih, thank you very much. You were correct, I incorrectly assumed the card would need modification.

Actually not sure, I’m not up to date on how custom_updater handles things nowadays, it’s been a while since I last used it and I know there have been some major changes to it. Check out the custom_updater docs.

I don’t use custom updater but I was getting errors (object not supported) with the mini player js file in a subdirectory of /www. Works fine in /www.
It’s the only custom card I have that seems to require this.

It shouldn’t require being in the root, it should make no difference as long as your resource reference points to the correct location of the bundle and it’s inside of /www of course.

If you continue having issues like that make sure the file isn’t corrupt and/or file/directory permissions aren’t screwed up.

Does shortcuts accept variables somehow? I would like to forward some variables to a script, so that I dont have to make a script for each speaker.

Not at the moment, could possibly add in the future for convenience.

1 Like

Just released a new version, shortcuts now support sending variables to script with the use of the new data option.

# example of script variables in shortcuts
...
shortcuts:
  buttons:
    - icon: mdi:cat
      type: script
      id: media_source
      data:
        entity: avr_bedroom
        source: CHROMECAST

v1.1.0 Changelog

The new version includes major refactoring of the code, so if anyone have issues please report them here or in the Github repo, thanks!

ADDED

  • New option attribute for shortcut object, to determine & display active/selected shortcut from an attribute, see README

  • New option label for shortcuts object, specify a custom shortcut list dropdown label

  • New parameter sound_mode for shortcut type option

  • New option data for shortcut object, specify extra service data (useful for script variables)

FIXED

  • Various layout & alignment fixes

CHANGED

  • Shortcut list dropdown is now aligned to the right (instead of left)

  • Removed the underline from the shortcut dropdown

  • Changed default shortcut list dropdown label from Select Media... to Shortcuts...

  • Mute button is now only visible if supported by the media player, replace_mute option will override this and can still be utilized

  • Major refactoring of the source code

REMOVED

  • icon_state option

  • title option (wasn’t really working anyways :person_shrugging:‍)

3 Likes

This option to send variables to a script looks promising but I’m a little unsure how to use it. I have the below script where it grabs info from some input_select menu’s. Is it possible to create a shortcut button which sends: 1) the speaker group, and 2) the media_content (as per the last 2 options in my script) to the script in one hit? That would be awesome!

script:
  radio:
    alias: Play Radio on Chromecast Audio
    sequence:
    - service: media_player.volume_set
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Lounge") %} media_player.lounge_speakers
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom
          {% elif is_state("input_select.chromecast_radio", "Office") %} media_player.chromecastaudio3249
          {% elif is_state("input_select.chromecast_radio", "Lounge and Office") %} media_player.lounge_and_office
          {% elif is_state("input_select.chromecast_radio", "House") %} media_player.house
          {% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.everywhere
          {% endif %}
        volume_level: '{{  states.input_number.volume_radio.state  }}' 
    - service: media_player.play_media
      data_template:
        entity_id: >
          {% if is_state("input_select.chromecast_radio", "Lounge") %} media_player.lounge_speakers
          {% elif is_state("input_select.chromecast_radio", "Bedroom") %} media_player.bedroom
          {% elif is_state("input_select.chromecast_radio", "Office") %} media_player.chromecastaudio3249
          {% elif is_state("input_select.chromecast_radio", "Lounge and Office") %} media_player.lounge_and_office
          {% elif is_state("input_select.chromecast_radio", "House") %} media_player.house
          {% elif is_state("input_select.chromecast_radio", "Everywhere") %} media_player.everywhere
          {% endif %}
        media_content_id: >
          {% if is_state("input_select.radio_station", "Hit 92-9") %} http://ic6ti.scahw.com.au/6ppm_128
          {% elif is_state("input_select.radio_station", "Nova 93-7") %} http://streaming.novaentertainment.com.au/nova937
          {% elif is_state("input_select.radio_station", "Mix 94-5") %} http://sc01.scahw.com.au/6mix_32
          {% elif is_state("input_select.radio_station", "96FM") %} https://icy.ihrcast.arn.com.au/au_012_icy
          {% elif is_state("input_select.radio_station", "80's") %} http://19173.live.streamtheworld.com/T_RAD_80S_S01AAC_SC
          {% elif is_state("input_select.radio_station", "OldSkool Hits") %} http://sc01.scahw.com.au/loveland_32
          {% elif is_state("input_select.radio_station", "Old Skool Anthems") %} http://nebula.shoutca.st:8075/stream
          {% elif is_state("input_select.radio_station", "Raw FM (dance)") %} http://stream.rawfm.com.au:8004/;stream/1
          {% elif is_state("input_select.radio_station", "181FM Power (Todays Hits)") %} http://listen.181fm.com/181-power_128k.mp3?
          {% elif is_state("input_select.radio_station", "181FM 90's Dance") %} http://listen.181fm.com/181-90sdance_128k.mp3
          {% elif is_state("input_select.radio_station", "181FM Star 90's") %} http://listen.181fm.com/181-star90s_128k.mp3
          {% elif is_state("input_select.radio_station", "181FM The Breeze") %} http://listen.181fm.com/181-breeze_128k.mp3
          {% elif is_state("input_select.radio_station", "Heat Radio (RnB)") %} http://174.37.159.206:8106/stream
          {% elif is_state("input_select.radio_station", "Fresh 92-7") %} http://live.fresh927.com.au/freshmp3
          {% elif is_state("input_select.radio_station", "DI Chill & Tropical House") %} http://pub1.diforfree.org:8000/di_chillntropicalhouse_hi
          {% elif is_state("input_select.radio_station", "DI Disco House") %} http://pub1.diforfree.org:8000/di_discohouse_hi
          {% elif is_state("input_select.radio_station", "DI Funky House") %} http://pub1.diforfree.org:8000/di_funkyhouse_hi
          {% elif is_state("input_select.radio_station", "DI Liquid D&B") %} http://pub1.diforfree.org:8000/di_liquiddnb_hi
          {% elif is_state("input_select.radio_station", "Aloha Joe's Relaxation Island") %} http://s2.voscast.com:7932/
          {% elif is_state("input_select.radio_station", "Spectrum Fit") %} http://51.255.235.165:5292/
          {% elif is_state("input_select.radio_station", "Energy FM Australia") %} http://s3.viastreaming.net:8502/
          {% elif is_state("input_select.radio_station", "Jazz Relax") %} http://199.195.194.94:8036/stream
          {% elif is_state("input_select.radio_station", "Australian Country") %} https://streaming.radio.co/s5ea3fdd1c/listen
          {% elif is_state("input_select.radio_station", "Rebel FM") %} https://au1.fastcast4u.com/proxy/rblgc?mp=/stream
          {% endif %}
        media_content_type: 'audio/mp4'

Yes.
If we skip the volume part of your script the script would look something like this:

# Example radio script
radio:
  alias: play media on entity
  sequence:
    - service: media_player.play_media
      data_template:
        entity_id: "media_player.{{ entity }}"
        media_content_id: "{{ content }}"
        media_content_type: audio/mp4

And the shortcut buttons, you could use the list shortcuts as well.

# Example shortcuts for script with variables 
buttons: 
  - name: some radio station
    type: script
    id: radio
    data:
      entity: chromecast_group
      content: http://ic6ti.scahw.com.au/6ppm_128
  - name: another radio station
    type: script
    id: radio
    data:
      entity: chromecast_group
      content: http://streaming.novaentertainment.com.au/nova937
2 Likes

Ah right, I understand how you are doing that now. Thanks for the example

1 Like

Yaaaay!! Thanks for adding it so fast. \o/

Hello there

I have been reading through this topic but not found a solution for me or just not seen it.

But i have my homeassistant installed on a ubuntu in a virtual venv with python 3.
I have got lovelace working and with yaml just. then, when i have to use mini-media-player, it says that i have to place it in a folder called /local/ but i dont have a folder called that, unless i go futher back into some more system specific files.

Anybody knows where I should place it when it is not called local?

I know the interface and desktop is on this location when comming from the folder i can go the furthest back to: /home/“user”/

Karl, been working away with your latest, thank you!

One thing got me stumped is how to use a entity attribute with conditional cards. Realize this is not a player issue. Similar queston for state-switch. Have you gotten away with this? I get “Error in card configuration.”

> - type: conditional
>     conditions:
>       - entity: media_player.erik_receiver
>         state: 'on'
>       - condition: template
>         value_template: "{{ is_state_attr('erik_receiver', 'source', 'DirecTV') }}"
>     card:
>       type: 'custom:vertical-stack-in-card'
>       cards:
>         - entity: media_player.erik_directv

config/www/

If /www does not exist, create it and restart HA.

would you say it doens’t matter where i create this folder? :smiley:

No I would not say that. Because it is not true. /www must be in your /config folder.

hmm… ok
thats also a problem, because every folder that have something with homeassistant or at least where i enter to go to configuration.yaml, does not have a folder called config…

Every HA instance has a /config folder. It’s where your configuration.yaml file is.

Edit: I learned something today.

hmmm… ok, my folder where configuration.yaml is, is called “.homeassistant”. And i have just tried creating a new folder called www in that one and placed the bundle there and in the config folder itself, and changed the directory in the yaml-file. but nothing happened? :smiley:

Did you restart HA?

And my apologies. According to this:

The place your /www folder should be is in ~/.homeassistant