controllerx: Multiple Sonos speakers (group) can't be fully controlled without multiple ControllerX apps

Use of Sonos SINGLE speaker works with current beta without need for any ‘tweaks’ 👍😊

But as Sonos group behaviour is somewhat unique, control of grouped speakers will only work with use of extra controllers (apps)

Volume control of Sonos speakers is individual - EVEN if grouped ! So changing one grouped speakers volume, won’t change volume for remaining speakers in group. A manual created Sonos speakers group in HA can overcome this issue. But then ControllerX app has no way of reading a source_list and hence can’t change in between these with left/right_arrow_hold key.

A source_list (Favourites. Could be playlists, radio stations, podcasts etc.) is present for each single entity in HA. First entry in this list is always the ‘master’ speaker, followed by the ‘slave’ speakers. This list is dynamic and will update if changes are made in Sonos app or throught HA’s Sonos integration (join/unjoin service calls). If no group is active (all single speakers) then source_list will contain the individual speakers entity only. If group contains two speakers out of three, then the speaker not grouped will still contain own entity in source_list.

Change to new source from source_list on one grouped speaker, will affect ALL grouped speakers. It doesn’t matter whether it’s the ‘master’ or any ‘slave’ speakers that the change has been made on.

So this sums up to:

  • ControllerX needs to know a speaker entity in order to read the source_list. So if single Sonos entity is used as media_player in eg. class E1810MediaPlayerController, then source_list can be changed. But volume changes will ONLY affect that single speaker and NOT the whole group.

  • If HA Sonos group is used instead, then volume will be applied to all speakers in group. But ControllerX can’t change inbetween entries in source_list, as list is not exposed through the manual HA Sonos group. One downside of this is also if speakers in group are changed, then volume changes will still be applied to the ‘original’ static HA Sonos group. This could be solved in HA though, as changes to groups can be made via group service calls.

For now I’ve overcome this issue, by separating the source_list changes (left/right clicks in my setup) from a MediaPlayerController to a CustomMediaPlayerController (see below). This way I can (through MediaPlayerController) control volume for whole group (group is still a ‘static’ HA group) and use pause/play. Flipping back/forth in source_list is handled by the CustomMediaPlayerController.

Wish:

  • Solution to fully control grouped Sonos speakers with MediaPlayerController class, without the need for extra apps.
  • Applying dynamic handling of Sonos groups in MediaPlayerController.
  • Generic solution that would work for other grouped speakers that are integrated in HA ?

Pheeww, hopefully the above description makes sence ?? 😉

Additional information

Devices involved: Model: IKEA E1810 as MediaPlayerController Integration: z2m AppDaemon version: v4.0.1 ControllerX version: v2.3.0b6 HACS version: v0.21.5 Home Assistant Core version: v0.105.3

AppDaemon app configuration

sonos_media:
  module: controllerx
  class: E1810MediaPlayerController
  controller: sensor.0x90fd9ffffe0cbd69_action
  integration: z2m
  volume_steps: 20
  media_player: group.sonos_all
  actions:
    - toggle
    - brightness_up_click
    - brightness_down_click
  #  - arrow_left_click
  #  - arrow_right_click
  #  - arrow_left_hold
  #  - arrow_right_hold
    - brightness_up_hold
    - brightness_up_release
    - brightness_down_hold
    - brightness_down_release

sonos_source:
  module: controllerx
  class: CustomMediaPlayerController
  controller: sensor.0x90fd9ffffe0cbd69_action
  integration: z2m
  media_player: media_player.stue
  mapping:
    arrow_left_click: previous_source
    arrow_right_click: next_source

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (23 by maintainers)

Most upvoted comments

Glad you liked it, Xavi 😉

I thought that it would really be a shame, if users never understood the full potential to actually control Sonos groups with you app. So I made an effort to describe how easy it can be done.

AFAIK there’s NO other means accomplishing what ControllerX can do with lights/speakers - with just a small initial setup.

Have a lovely weekend ! 🍻😎😁

So am I, Xavi.

Otherwise my ControllerX button in the kitchen wouldn’t survive a week 😁

If I everyday had to explain the wife why some speakers suddenly were off or out of sync (not grouped) when using the Ikea ControllerX remote ?

You know it’s the ‘BUTTONS’ fault it’s not working properly, when non-tech wifes are involved 😉

Ciao !

Why the hell does THIS work, Xavi ?? I don’t get it - but it WORKS !! 😎😎😎

Thanks a million (once again, Xavi) 👍🍻🍻

Thought that this small automation could also help other Sonos users, if they’re using ControllerX with groups of Sonos players ?

When there’s several members in a family, all playing during the day from their Sonos apps or Spotify, you NEVER know what the group settings actually are, when pushing the ControllerX button to play some Radio. With this automation, it doesn’t matter 😁

Cheers Henning

Omg… that is very weird. Maybe, could you try:

alias: test_gruppeskift
trigger:
  platform: state
  entity_id: sensor.gruppe
action:
  - service: group.set  
    data_template:
      object_id: sonos_all
      entities: "{{ state_attr('media_player.kitchen', 'sonos_group') | join(',') }}"

If this does not work, mybe you will need to ask in the community forum, you will have more chances there to be helped.

Glad to hear it is all working as expected then. Regarding the flipping functionality for the E1810 when working as Media Player controller, you can do it with CustomMediaPlayerController. Here it is how you can do it, so you do not have to change ControllerX code.

sonos_speaker:
  module: controllerx
  class: CustomMediaPlayerController
  controller: sensor.0x90fd9ffffe0cbd69_action
  integration: z2m
  media_player: group.sonos_all
  mapping:
    toggle: play_pause
    brightness_up_click: click_volume_up
    brightness_down_click: click_volume_down
    brightness_up_hold: hold_volume_up
    brightness_down_hold: hold_volume_down
    brightness_up_release: release
    brightness_up_release: release
    arrow_right_click: next_source
    arrow_left_click: previous_source
    arrow_right_hold: next_track
    arrow_left_hold: previous_track

I leave this issue closed.