Dashboard: Sonos card

@PunxsutawneyPhil

Sorry for bringing this up in this thread. But I only use your Sonos Card for our whole house audio system, and I would guess that this Spotify Playlist issue must be affecting other Sonos Card users as well.

Hopefully the Official Spotify integration update next month will fix the issue. But maybe Sonos Card could use help from Spotify Plus to offer a more robust Spotify media browser from within Sonos Card?

@thlucas I’ll head over to the Spotify Plus thread to try and answer your questions. But as I stated above, I only use Sonos devices and the Sonos Card in my system. Spotify Plus on its own has very limited use in my situation, but I’m happy to try and help in any way I can.

Loving this card, thank you!

I’ve been playing around with some card-mod code to change what the card looks like, but I haven’t been able to find a few options. I’m not great at CSS and I can see what some elements are called, but my mods don’t seem to work.

This is what I have:

image

card_mod:
  style:
    sonos-player$ sonos-player-controls$: |
      .icons * {    
        --mdc-icon-button-size: 3rem !important;
        --mdc-icon-size: 2rem !important;
        color: pink;
      }
    sonos-player$ sonos-player-controls$ sonos-volume$: |
      ha-control-slider {
        height: 10px;
      }
      .volume-level, ha-icon-button {
        display:none !important;
      }

I’m changing the size of the volume bar and hiding the mute button, and setting the icon and button sizes of the controls, plus setting a color.

I found mentions of setting transparency for the overlays, and they need to be in themes, I can look into that later.

Questions.

  • How do I resize the bottom overlay? I’d like it to be probably 60-70% narrower, or even more in line with the top overlay. Since my buttons are small, I don’t need it to be this big
    image
  • How do I hide some of the buttons in the card? I never use repeat or shufflet, I’d like to only keep previous, pause and next.
  • How do I hide the Entity/Group name? I use this card in my Office Dashboard so I don’t need to know what speakers are being used. Would help make it shorter without needing to scroll.

bottom overlay:

card_mod:
  style:
    sonos-player$: |
      .controls {
        margin: 0 3rem !important;
      }

hide buttons: not possible as far as I know

hide entity group name:

    sonos-player$ sonos-player-header$: |
      .entity {
        display: none;
      }
1 Like

I am suddenly getting tons of these errors regarding, i suppose, the sonos card:

2024-04-03 21:24:50.451 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-03 21:30:05.055 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-03 21:31:20.484 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-03 21:31:50.604 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-03 21:35:50.553 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-03 21:43:11.674 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-03 21:43:11.723 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-03 21:49:41.809 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-03 21:49:41.859 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)

From what it depends and how to fix?

Thank you!

@motoridersd @PunxsutawneyPhil
Here’s the Sonos Card player yaml I have been testing with - see the card_mod section for selectors to show / hide any of the control deck buttons. It took me awhile to figure out the selectors, due to the whole #shadow-root thing documented here.

Adjust the sonos-player$ selector \ background-color \ 0.4 value to change the background alpha / opacity.

type: custom:sonos-card
sections:
  - player
entities:
  - media_player.spotifyplus_todd_l
showVolumeUpAndDownButtons: true
showNonSonosPlayers: true
showAudioInputFormat: true
artworkAsBackground: true
card_mod:
  debug: false
  style:
    .: ''
    sonos-player$: |
      .controls {
        background-color: rgba(var(--rgb-card-background-color), 0.4) !important;
      }

    sonos-player$ sonos-player-controls$: |
      .icons * {    
        --mdc-icon-button-size: 3rem !important;
        --mdc-icon-size: 2rem !important;
      } 
      ha-icon-button {
        display: none !important;
      }

    sonos-player$ sonos-player-controls$ sonos-ha-player$ more-info-content$ more-info-media_player$: |
      ha-icon-button[action="shuffle_set"] {
        display: none !important;
      }
      ha-icon-button[action="media_previous_track"] {
        display: inline !important;
      }

    sonos-player$ sonos-player-controls$ sonos-ha-player+sonos-ha-player+sonos-ha-player$ more-info-content$ more-info-media_player$: |
      ha-icon-button[action="repeat_set"] {
        display: none !important;
      }
      ha-icon-button[action="media_next_track"] {
        display: inline !important;
      }

    sonos-player$ sonos-player-controls$ sonos-volume$: |
      ha-control-slider {
        height: 14px !important;
      } 
      ha-icon-button {
        --mdc-icon-button-size: 2rem !important;
        --mdc-icon-size: 1.5rem !important;
      }      

Example:

3 Likes

Please file a bug on GitHub :pray:

I just posted the issue…

@maurizio53 @PunxsutawneyPhil

maurizio53 - This may be due to an issue with the SpotifyPlus integration that you are working with.

The Problem
The issue is caused by the SpotifyPlus integration receiving a async_browse_media request with a media_content_type = favorites when using a Sonos Card with a media browser section. It appears the Sonos Card is trying to query some sort of favorites from the Sonos device. This does not work for non-Sonos media players (e.g. SpotifyPlus, SoundTouchPlus, etc). The SpotifyPlus integration processes the async_browse_media request and returns a null value. I believe the null value returned from async_browse_media is causing the issue.

The Fix
I updated the SpotifyPlus (and SoundTouchPlus) integration to return an empty BrowseMedia object, and that took care of the problem; at least there were no more Browse Media should use new BrowseMedia class or Cannot access ‘e’ before initialization entries showing up in the system log.

What To Do
Upgrade the SpotifyPlus integration to the latest (v1.0.15).
Upgrade the SoundTouchPlus integration to the latest version as well.

Apologies for the inconvenience. I am still trying to make the Sonos Card player work with SpotifyPlus (and SoundTouchPlus) integration, as I love the card UI.

1 Like

As a followup: I can confirm, at least in my case, the Spotify Playlist unknown error problem is fixed in the 2024.4.1 release of HA.

I have access to my Spotify playlists again from within the HA media browser, and as an extension, from Sonos Card.

Special thanks to @thlucas for identifying the issue, and reporting it to the official HA Core Spotify integration maintainer.

1 Like

What you mean with ‘extension’ in Sonos card?

@maurizio53
No extension required, just the official Spotify integration (not Spotify Plus) which is accessible from the standard HA media browser and accessible from within the Sonos Card

Ok, just a question: Do i need to Premium Spotify to play spotify songs in Sonos devices? I am asking this as i have a free account and cannot play anything from Spotify on my sonos devices with sonos card.

@maurizio53 I would think a free would work, but I have a paid premium account so I can’t confirm this for you.

Are you able to play anything from Spotify from the Sonos App? If so, you should be able to do so from the Sonos Card within HA too.

No, i can quietly play songs from spotify in sonos app, but with sonos card i get an error about upnp in the IP address of the device.

I am still getting tons of errors like this…

2024-04-06 13:12:23.771 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:25:53.834 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:26:53.811 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:29:44.563 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:29:53.963 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:35:09.678 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:38:24.663 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:39:07.552 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:40:23.774 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:43:23.714 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:45:31.360 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:45:31.724 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)
2024-04-06 13:47:31.587 ERROR (MainThread) [frontend.js.latest.202403070] Uncaught error from Chrome 123.0.0.0 on Windows 10
ReferenceError: Cannot access ‘e’ before initialization
Object.callback (/hacsfiles/custom-sonos-card/custom-sonos-card.js:358:980)
callback (node_modules/home-assistant-js-websocket/dist/connection.js:23:33)
forEach (node_modules/home-assistant-js-websocket/dist/connection.js:15:25)

I don’t have spotifyplus integration installed!

@maurizio53
Do you have SoundTouchPlus installed? If so, you will need to update it to the latest version as well. It had the same issue as the SpotifyPlus integration when used with the Sonos Card.

No, not installed SoundTouchPlus and Spotifyplus integration…

@maurizio53
In that case it probably is something in the Sonos Card that is causing it, though I can’t be sure. @PunxsutawneyPhil will have to assess what those messages mean.

Ok, hope fix all…