Help: how to set up Sonos in Hassio?

I really like the look and feel of Mini_Media_Player. What I want to achieve is to use Mini_Media_Player control my Sonos but control the power on/off by a Sonoff Basic (I already have many Sonoff basic in my house). Tried a couple of days but couldn’t figure it out. I couldn’t find the my sonos speakers in the entities section (under Developer Tools tab). Guess my sonos integration or code is not accurate. Any help will be highly appreciated!!

Code in my configuration.yaml:

sonos:
  media_player:
    hosts:
      - 10.41.1.230
      - 10.41.1.231
      - 10.41.1.232

media_player:
  - platform: sonos  

Code in my ul-lovelace.yaml:

resources:
  - url: /local/mini-media-player-bundle.js
    type: module
.........
         
          - type: horizontal-stack
            cards:
              - entity: media_player.sonos_one 
                type: custom:mini-media-player
                name: Sones One 
                source: icon
                info: short
                artwork: cover
                icon: mdi:speaker-wireless
                toggle_power: false
                tap_action:
                  action: call-service
                  service: switch.toggle
                  service_data:
                    entity_id: switch_sonos.livingroom

I have a working setup using the automated SONOS discovery in HA and then I have some old RF433 MHz wall plugs which I use to manage the power of the Sonos speakers.

As you can see, I have a (group) switch to turn the Sonos speakers on…

…and my Sonos Lovelace mini-player layout…

Thanks @mrmaceurope! Looks like you use RF remote to power on/off the Sonos. I am trying to use a Sonoff Basic to power on/off the Sonos and have that Sonoff Basic controlled by the power button on mini_media_player. Wondering whether anyone did that and can share the configuration code (e.g., configuration.yaml, ui_lovelace.yaml) on how to do it. Also, would you mind sharing your configuration file for Sonos?

Thanks a lot for your generous help,

Hi @chenghs,

I haven’t done any manual configuration of the Sonos speakers, they where all auto-discovered by HA. However you need to ensure that your HA are on the same network zone/segment as your Sonos speakers, otherwise there can be issues discovering.

Remember, if you try the autodiscovery again, to remove ALL of the Sonos manual configurations in the YAML files.

Below the speakers which have been discovered by HA automatically (which I guess doesn’t serves as much help to you).