Control Sonos Equalizer via Python script

I have a python script that changes the equalizer settings for one of my Sonos boxes, like Bass volume, Loudness and Treble - it uses the SoCo library, that so far as I know, also Home Assistant itself uses to control Sonos - but it’s somehow not working, I get this error in the Log:

ERROR (MainThread) [homeassistant.components.shell_command] Error running command: `python3 /config/python_scripts/kitchen_silent_mode_on.py`, return code: 1
NoneType: None

This is the Python Script, that works fine on my Mac (after pip install soco):

from soco import SoCo

sonos = SoCo("192.168.178.46")

sonos.bass = -5
sonos.treble = 10
sonos.loudness = False

and that is in my configuration.yaml:

shell_command:
kitchen_silent_mode_on: 'python3 /config/python_scripts/kitchen_silent_mode_on.py'

Does anybody know why it is not working?

I’m interested in this as well. Ideally I would like to be able to control the equalizer setting in lovelace.

1 Like

I tried this solution and it help get the equalizer settings. Hope this helps