Lovelace: Mini Media Player

Hey @RomRider!
Unfortunately I don’t have any plans to add this kind of functionality at the moment, it would require quite a bit of extra code and add complexity.

If the amplifier actually was a media_player this could be solved quite easily by stacking two differently configured mini-media-player cards, like below.

- type: entities
  entities:
    - entity: media_player.sonos
      type: custom:mini-media-player
      name: Sonos Connect
      group: true
      artwork_border: true
      hide_volume: true
      hide_power: true
      show_shuffle: true
    - entity: media_player.amplifier
      type: custom:mini-media-player
      group: true
      hide_controls: true
      hide_info: true
      hide_power: true

1 Like

I use the broadlink custom component to control my 15 year old amplifier via IR and because its a media_player in HA, i am able to use it with this mini player. I’m wondering if a forked version of the broadlink component cuold be used to control RS232…? Its WAY out of my league but maybe something with coding skills could do. It would make the control lof your amp a $#!tload better!

@RomRider @sparkydave does this component help?

It seems you can make a virtual media player out of different components.

4 Likes

Thanks @nickrout! This might work. I always thought this component was to aggregate media_players together only, I didn’t remember that it had the possibility to use services and map attributes… :sweat_smile:

I managed to make it work with the universal component:

  • 1 switch for the power
  • 1 switch for the mute
  • 1 sensor for the volume state to reflect the volume of the amp in the right scale for the media_player component
  • 1 sensor with the real value of the volume
  • 1 input_number to set the volume on the amp (not the same range as the sensor)
media_player:
  - platform: universal
    name: sonos_universal
    children:
      - media_player.sonos_connect
    commands:
      volume_up:
        service: input_number.set_value
        data_template:
          entity_id: input_number.amp_volume
          value: '{{ states.input_number.amp_volume.state | float + 1 }}'
      volume_down:
        service: input_number.set_value
        data_template:
          entity_id: input_number.amp_volume
          value: '{{ states.input_number.amp_volume.state | float - 1 }}'
      volume_set:
        service: input_number.set_value
        data_template:
          entity_id: input_number.amp_volume
          value: '{{ volume_level * 100 - 80 | float }}'
      volume_mute:
        service: switch.toggle
        data:
          entity_id: switch.amp_muted
      select_source:
        service: media_player.select_source
        data_template:
          entity_id: media_player.sonos_connect
          source: '{{ source }}'
    attributes:
      state: media_player.sonos_connect
      is_volume_muted: switch.amp_muted
      volume_level: sensor.amp_volume_universal
      source: media_player.sonos_connect|source
      source_list: media_player.sonos_connect|source_list

The only caveat was that the volume is from 0.0 to 1.0 on a media_player component so I had to do some math to convert the -80dB - 12dB range of the amplifier to a 0.0 - 1.0 float.
Thanks a lot @nickrout !

2 Likes

Anyone using this in conjunction with the echo devices as a media player component?

That has a tts built-in which you call via media_player.alexa_tts service:
{ “entity_id”: “media_player.bedroom_echo”,
“message”: “message goes here” }
There is no tts component setup so not clear on how you would configure access with this player?

It’s not possible with this card. This cards does only support tts through the tts component.
You could however fork the source code and modify a few lines of code in the _handleTts function to make it work for your use case.

WHat’s the difference between the mini-media-player and the one that is in the latest release (bundle)?

Should I change my old config to the new one using the new js file and resource?

Yes, I recommend you to change over to the bundle version. Here’s a quote from earlier regarding this.

Thanks - sorry I didn’t catch that part during the reading :slight_smile:

1 Like

No worries, just happy to help! :slight_smile:

Thanks @kalkih! Nice trick, I wouldn’t have thought about this! Will keep that in mind. :slight_smile:
I managed to use the universal media player component to do what I want and it’s perfect now!

1 Like

For some reason when using: show_progress it doesn’t seem to display?
Am I the only one experiencing this?

It’s not supported by all media players.
The players backend component need to expose the following attributes:

  • media_duration
  • media_position
  • media_position_updated_at

You can check if the media player exposes these attributes in the dev panel while playing something on the media player.

HA is still new to me. But I already love lovelace and Mini Media Player.
Is there a way to make media players always visible. Almost all of them disappear when I turn the device off.

I’m only using it on the spotify media player, which I thought would work.
I just noticed it on the pictures you had in your examples, so I assumed it work on that :blush:

Sounds strange, I don’t think it’s an issue related to this card though.
What type of media players are the ones that disappear?

Yeah, the Spotify component doesn’t report media progress unfortunately.
The example pictures are actually just mock-ups made in Sketch. :wink:

Hi Guys,

H E L P … getting the same error that a few others reported and I can’t figure out what I am doing wrong

image

In ui-lovelace.yaml:
resources:
- url: /local/mini-media-player-bundle.js?v=0.9.2
type: module

I have all the files in my config/www folder and also dowloaded the directory from GIThub in this folder

Cleared my cache, rebooted HA and my desktop computer, tried different browsers, operating systems.

Appreciate any help.

Thanks Hermen

Looks like you are missing the mini-media-player-bundle.js file in the www folder.
You can grab it from here.

That’s the only file you need, you can delete all other files related to mini media player. :slight_smile:

I’m sorry… thought that with ‘bundle’ you meant all the files in the zip-file. Thank you very much… up and running. Awesome development Kalkih!!