Heos Group support

Yeah… See my latest post, can it be something funny with the names? Any special characters??

Do you have your logger level set to errors only? Perhaps it helps to set it to DEBUG because I have some info put into debug that I used when I was working on it (like you see on my post).

I’ve changed it to DEBUG, and this is what I get in the logs now:

2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, groupname: 1e verdieping
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, devices_in_group: ['1e verdieping']
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, self.name: Living Room
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Rebuilding group info, no groups found for this device: Living Room
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, groupname: 1e verdieping
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, devices_in_group: ['1e verdieping']
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, self.name: Dining Room
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Rebuilding group info, no groups found for this device: Dining Room
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, groupname: 1e verdieping
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, devices_in_group: ['1e verdieping']
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, groupname: 1e verdieping
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, devices_in_group: ['1e verdieping']
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, self.name: Living draagbaar
2019-11-27 22:42:00 INFO (MainThread) [custom_components.heos.media_player] HEOS Rebuilding group info, no groups found for this device: Living draagbaar
2019-11-27 22:43:58 ERROR (MainThread) [custom_components.heos.services] Unable to join: Missing Command arguments (3)
2019-11-27 22:43:59 ERROR (MainThread) [custom_components.heos.services] Unable to join: Missing Command arguments (3)

Here’s my log when it is successful:

2019-11-27 22:31:47 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.139758131676496] Received {'type': 'call_service', 'domain': 'heos', 'service': 'join', 'service_data': {'master': 'media_player.heos5_office', 'entity_id': 'media_player.heos1_flex'}, 'id': 45}
2019-11-27 22:31:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=heos, service=join, service_data=master=media_player.heos5_office, entity_id=media_player.heos1_flex>
2019-11-27 22:31:47 DEBUG (MainThread) [pyheos.connection] Command executed 'heos://group/get_groups?sequence=513': '{'command': 'group/get_groups', 'result': 'success', 'message': 'sequence=513'}'
2019-11-27 22:31:47 DEBUG (MainThread) [pyheos.connection] Command under process 'group/set_group': '{'heos': {'command': 'group/set_group', 'result': 'success', 'message': 'command under process&sequence=514&pid=615580468,-764010704'}}'
2019-11-27 22:31:48 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, groupname: HEOS5_office + HEOS1_flex
2019-11-27 22:31:48 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, devices_in_group: ['HEOS5_office', 'HEOS1_flex']
2019-11-27 22:31:48 INFO (MainThread) [custom_components.heos.media_player] HEOS Group info, self.name: HEOS1_flex
2019-11-27 22:31:48 INFO (MainThread) [custom_components.heos.media_player] HEOS Rebuilding group info, groupname: HEOS5_office + HEOS1_flex
2019-11-27 22:31:48 INFO (MainThread) [custom_components.heos.media_player] HEOS Rebuilding group info, grouplist: ['media_player.heos5_office', 'media_player.heos1_flex']

I’m not sure at all, but it could perhaps be something in my dirty code that doesn’t handle spaces in names or something? I’ll see if I am able to test it with other names on my devices later on. Not even sure it is relevant, but that’s the only difference I see right now.

Maybe my code is confusing entity name and friendly name as well, I see mine are identical (except for the leading media_player and some upper/lower case stuff that I remember I had to tweak in the code by forcing lower. Could be something like this that makes the code not recognize it.

Sounds like a possible cause… Let me know if I can test something…

I tried to rename my ‘HEOS5_office’ to ‘HEOS5 office’ with a space, then I got an error. So I guess there’s something there. So much for bullet proof code :slight_smile: If you don’t mind testing, you could try to change your friendly name (I did it in the HEOS app and hassio updated automatically. Try to set it as the same entity name in hassio, perhaps it magically works.

I’ll try to improve the code later.

Yes with names without spaces it works, but not always. I didn’t manage to group 3 together. Will test later again

I found a stupid error where I actually compare name with entity id, just didn’t find a good fix yet. in my setup I didn’t notice since they’re all the same (except capital letters). I’ll let u know once I’ve fixed it!

If I rename all my speakers in the HEOS app and replace the " " with an underscore, it works pretty well. The only thing what I found was that if you want to unjoin 1 single speaker, first all speakers are unjoined and you need to rejoin all speakers again…

And another feature request: can we rename in a way the grouped speakers (like we can in the app), instead of “Living Room + Dining Room + Kitchen + Outdoor”? Would be nice to have this in order to select easily the right speaker group via Spotify Connect.

Anyway, it works for now, so thanks a lot!

This should be possible according to the HEOS CLI documentation, as you can set the group_name

{
 "heos": {
 "command": "player/set_group ",
 "result": "success",
 "message": "gid='new group_id'&name='group_name'&pid='player_id_1, player_id_2,…,player_id_n'
 }
}

Hi! I updated the code if you feel like testing some more. It’s working better now I think, also with proper names. Same link as before.

About the group name, I tested it, but couldn’t get it to work. Also tested it with Putty directly to my HEOS, but the command is not succesful when including &name=‘aname’ so I’m not sure it is supported. In the CLI manual I’m looking at, it’s only referenced as a feedback/response and not a command. Not sure it is the latest though.

Seems to work very well now! Thanks a lot!
Will let you know if I encounter other issues…

Cadish

Hoo great !
Can you explain how to install this component ?
Actually, i clone the repo on /config/custom_component/heos.
I had the group option to my lovelace mini media player card.
When i click on a player, it says :slight_smile:

Failed to call service media_player/heos_JOIN. Unable to find service media_player/heos_join

yep, that’s what I have done as well (custom_component). not sure what’s happening on your end. did u do a restart of hassio?

check on developer tools -> services and see if you find the heos join service there. turn on some logging to check what it says.

cheers

Yes i restart hassio.
I see the heos.join service.
How do you enable more logs ?
I see nothing interesting in the developer tools logs.

what happens if you try to call the service manually?

there’s also a groupinfo service that should basically print some info to the logger. the logger level can be set by a service called logger.setlevel in hassio, it should be debug or info level to show what’s going on.

I changed the Heos configuration in my configuration.yaml. It was pointing to my AVR and it is a little buggy. So i pointed to a Heos 1 device.
Now, if i called the service manually, it’s working, and group modification is shown by the mini player card. But it’s not working with the mini player card, if i click on the some device or UNGROUP ALL.
The card seems to called the service “media_player/heos_JOIN” but it should be heos.join ?
There is no log
Here is my card configuration:

artwork: cover
entity: media_player.couloir
icon: 'mdi:speaker-wireless'
max_volume: 50
type: 'custom:mini-media-player'
speaker_group:
  entities:
    - entity_id: media_player.salon
      name: Salon
    - entity_id: media_player.couloir
      name: Couloir
    - entity_id: media_player.cuisine
      name: Cuisine
  expanded: true
  platform: heos
  show_group_count: true

Try to set logger level to info, I see most of the entries I make is set to this level. They (most of them anyway) starts with "HEOS " and some details. See if this helps you get some logger details. If it’s running it will be there, I find it easier to open in a good text browser and search for what I’m looking for.

What’s your hass.io version and version of media-card?

The groupinfo service call should give you a line like this (just spitting out some info about groups, so try to group with the HEOS app first to test it):
2019-12-10 19:36:05 INFO (MainThread) [custom_components.heos.services] HEOS Groups are: ['name: heos_stue + heos1_kitchenmembers: heos_stue,heos1_kitchen']

Yeah it’s working!
I was using an old entry for the mini media player card in my CCH config.
With this entry, it is working:

  - type: module
    url: /community_plugin/mini-media-player/mini-media-player-bundle.js

Thanks a lot for your help tormagj !

Perfect! That’s good news. Let me know if you find some bugs, but keep in mind this is more like a temporary hack until someone with better knowledge than me is able to implement it in the official version :slight_smile: