Lovelace: Mini Media Player

Yes correct I’m using your custom component for it… If you need help in testing, let me know. Anyway, my code as above works now, so I’m happy!

Thanks a lot!

1 Like

That’s great! The HEOS “hack” currently populates the group attribute like this:

heos_group: media_player.heos5_office,media_player.heos1_kitchen

Is the Sonos doing it differently? Should it be inside [] as an array or something to working similarly as the Sonos? Or could it be a space missing after the comma? Guess it would be wise for the HEOS-integration to do it similar to Sonos since it seems to be more commonly integrated with other stuff.

Nice, it’s possible that it’s an array, just displayed as a comma separated in the dev-state view if it’s there you’re looking.

If it’s in fact an array, then that’s how the Sonos component does it, additionally Sonos has the master speaker listed as the first entry in that list. Idk if HEOS works the same where you have a master/slaves.

Is there support for group management service calls in that custom component as well?

Yes, you’re right. It is an array already, I was fooled by the presentation in the dev-state view. Heos also has a master, and it is also listed as the first one in the array. So it should be the same then. Service calls are also implemented. I’ll test a bit with the suggestions above, then let’s see :slight_smile:

Neat!
Would you mind testing this cards built-in group management if you haven’t already. If the implementation is the same as Sonos it should work, make sure to specify the platform as heos.

- type: custom:mini-media-player
  entity: media_player.heos_office
  speaker_group:
    platform: heos
    show_group_count: true
    entities:
      - entity_id: media_player.heos_office
        name: Office
      - entity_id: media_player.heos_livingroom
        name: Livingroom
      - entity_id: media_player.heos_kitchen
        name: Kitchen
      - entity_id: media_player.heos_bathroom
        name: Bathroom
      - entity_id: media_player.heos_bedroom
        name: Bedroom

It’s working perfectly, or rather the other way around, it was designed to work with the card :wink: Although I think I just found some kind of bug in my code this evening with the “leave” button, but it’s not a big thing. Will look into it tho…

1 Like

Nice, did you code the custom component? Mind linking it?

Edit: nvm I saw your link above and the other thread, nice work! :+1:

@heartkingz, The color is currently hard coded as rgba(255,255,255,0.25) unfortunately.

But I will change it to a variable in the next release.

2 Likes

Thank you! That would be great.

1 Like

Yeah, well, I did the grouping thing, but it’s all thanks to @andrewsayre’s great work on both Pyheos as well as the home assistant integration of HEOS. Without the working features of the Pyheos, I would be completely lost, but I managed to hack together something that seems to be working well. Hopefully, someone with better skills than me will be able to implement the group support to the official integration.

For anyone who has an interest: https://github.com/tmjo/custom_components/tree/master/heos

1 Like

Could someone kindly point this humble noob in the right direction?

So I got my '‘custom:mini-media-player’ to work. umm, after fumbling around with it for 4 hours. Mostly my issue was I feel that I could have shortened the code but EVERY rendition I tried would not work. So I gave up on my dreams making the code shorter. Anyways…

My actual question if possible could someone please show me a way to HIDE a ‘media-player’ device if it is not currently playing/powered on??

type: entities
entities:
  - type: 'custom:mini-media-player'
    name: Whole House Audio Group
    icon: null
    entity: media_player.group_whole_house_audio
    group: true
    controls: play_pause
    hide: null
    artwork: cover
    tts:
      platform: google_translate
    info: scroll
    source: icon
  - type: 'custom:mini-media-player'
    name: Inside House Audio Group
    icon: null
    entity: media_player.group_inside_house_audio
    group: true
    controls: play_pause
    hide:
      power_state: false
    artwork: cover
    tts:
      platform: google_translate
    info: scroll
    source: icon
  - type: 'custom:mini-media-player'
    entity: media_player.kitchen_display
    name: null
    icon: 'mdi:monitor-speaker'
    artwork: none
    group: true
    show_group_count: false
    hide:
      controls: true
      power: true
      info: true
      progress: true
  - type: 'custom:mini-media-player'
    entity: media_player.g3_living_room_speaker
    name: null
    icon: 'mdi:cast-audio'
    artwork: none
    group: true
    show_group_count: false
    hide:
      controls: true
      power: true
      info: true
      progress: true
  - type: 'custom:mini-media-player'
    entity: media_player.g3_dinning_room_speaker
    name: null
    icon: 'mdi:cast-audio'
    artwork: none
    group: true
    show_group_count: false
    hide:
      controls: true
      power: true
      info: true
      progress: true
  - type: 'custom:mini-media-player'
    entity: media_player.g3_google_mini_01
    name: null
    icon: 'mdi:google-home'
    artwork: none
    group: true
    show_group_count: false
    hide:
      controls: true
      power: true
      info: true
      progress: true
  - type: 'custom:mini-media-player'
    entity: media_player.g3_google_mini_02
    name: null
    icon: 'mdi:google-home'
    artwork: none
    group: true
    show_group_count: false
    hide:
      controls: true
      power: true
      info: true
      progress: true
  - type: 'custom:mini-media-player'
    entity: media_player.g3_shed_tuner_speaker
    name: null
    icon: 'mdi:cast-audio'
    artwork: none
    group: true
    show_group_count: false
    hide:
      controls: true
      power: true
      info: true
      progress: true

I suggest to have a look at the conditional cards :

You will have to create one card per media player entity.

Can someone explain me how icon_state is supposed to work ?
I added it to my config, but the result is the same as if it wasn’t present: the media player icon is changing to white when it’s playing, while an active icon is supposed to be blue based on my theme.
Is there any modification to bring to the theme so that it works ?

- entity: media_player.xyz
  type: custom:mini-media-player
  artwork: full-cover
  show_source: true
  show_progress: true
  hide:
    icon_state: false

Thanks!

Hello,
Yes as suggested, check out the conditional-card.

Some of your configs have invalid options or options specified in the wrong place of the config.

  - type: 'custom:mini-media-player'
    name: Whole House Audio Group
    icon: null # you don't need to set this if you don't want to override the default icon.
    entity: media_player.group_whole_house_audio
    group: true
    controls: play_pause # this is not a valid option
    hide: null # same here, you don't need to set this if you don't want to override the default.
    artwork: cover
    tts:
      platform: google_translate
    info: scroll
    source: icon
  - type: 'custom:mini-media-player'
    entity: media_player.kitchen_display
    name: null # same as before
    icon: 'mdi:monitor-speaker'
    artwork: none
    group: true
    show_group_count: false # not a valid option here
    hide:
      controls: true
      power: true
      info: true
      progress: true

Hello,
This isn’t available in a release yet, I must have pushed it to the master branch by mistake which is why you see it in the documentation.
It should work as you described in the next release, sorry for the confusion!

You could also check out decluttering-card, it basically lets you create card config templates, so you won’t have to repeat the same/similar config over and over.

Hi,

I see that the custom HEOS gives None (or null in the dev view) when a player is not grouped, and I believe that is the reason why @kalkih’s propsal for binary switches didn’t work. I guess it is expecting an emtpy array [] instead of None/null. Anyone with Sonos that may confirm this is the case?

Anyway, I updated the github with this change, it seems to be working fine and I managed to succesfully use the following binary switches (as proposed by kalkih):

binary_sensor:
  - platform: template
    sensors:
      heos1_flex_grouped_not_master:
        entity_id:
          - media_player.heos1_flex
        value_template: >
          {{ state_attr('media_player.heos1_flex', 'heos_group')[0] | string != 'media_player.heos1_flex'
            and state_attr('media_player.heos1_flex', 'heos_group') | length > 1 }}
      heos1_kitchen_grouped_not_master:
        entity_id:
          - media_player.heos1_kitchen
        value_template: >
          {{ state_attr('media_player.heos1_kitchen', 'heos_group')[0] | string != 'media_player.heos1_kitchen'
            and state_attr('media_player.heos1_kitchen', 'heos_group') | length > 1 }}
2 Likes

The heos hack seems not to be working with the “Leave” button (player which is not master), but it is working with the “Ungroup” button (for master player). Anyone see why? Here’s my log (not working and working):

2020-01-12 15:25:02 DEBUG (MainThread) Received {'type': 'call_service', 'domain': 'heos', 'service': 'unjoin', 'service_data': {}, 'id': 32}
2020-01-12 15:25:02 ERROR (MainThread) not a valid value for dictionary value @ data['entity_id']

2020-01-12 15:24:30 DEBUG (MainThread) Received {'type': 'call_service', 'domain': 'heos', 'service': 'unjoin', 'service_data': {'entity_id': ['media_player.heos5_office', 'media_player.heos1_flex']}, 'id': 28}
2020-01-12 15:24:30 DEBUG (MainThread) Bus:Handling <Event call_service[L]: domain=heos, service=unjoin, service_data=entity_id=['media_player.heos5_office', 'media_player.heos1_flex']>

Is the “Leave” button working with Sonos? I find the unjoin schemas quite similar between Sonos and Heos (both expecting entity_ids, although mine has a default=None there):

SONOS_UNJOIN_SCHEMA = vol.Schema({vol.Optional(ATTR_ENTITY_ID): cv.comp_entity_ids})

HEOS_UNJOIN_SCHEMA = vol.Schema({vol.Optional(ATTR_ENTITY_ID, default=None): cv.comp_entity_ids})

If I recall correctly I think an ungrouped Sonos will report the group as an array with one entry with the entry being its own entity_id.

The cards group check being:

And for the sake of the card it shouldn’t matter if the component returns the group attribute as an empty array, a null value or if the attribute isn’t set at all, the card will handle all those cases as an empty array internally.

Is this the service call when you press the leave button in the mini-media-player card? service_data shouldn’t be empty right?

I think there’s a bug/typo in my code.

this.player.entity_id isn’t a valid property and should result in undefined, the entity_id is defined in this.player.id.

I’ll fix this and hopefully that should solve the problem, I’ve not had any Sonos users reporting this issue but should be present there as well I believe.

Thanks!

1 Like

@Morgane

I forgot I did a release earlier this week, this feature should in fact work if you got the latest version fo the card v1.5.2.
If you’re using HACS and have had the card installed for some time, please check out this issue as it’s relevant for this card as well and could stop you from loading the updated versions of the card.

The active icon color is based on the theme variable --paper-item-icon-active-color as I think that’s what other state-badges in the UI are based on as well, but I could be wrong…
This feature will also not work if you use the option artwork:cover and there’s artwork present.

Here’s what it should look like.
dess

1 Like

@Hisma

Some time ago, you posted about grouping Russound. It looks like you have your Max2Play info at the top of the group. I can’t seem to figure out how to “attach” my Squeezebox player to my Russound inputs in the Mini-Media-Player card.

Any info would be appreciated.