I wanted to have an audio device that primarily works as a simple radio, but also provides all the benefits of a speaker fully integrated into Music Assistant.
I came quite far, but am now stuck on a core issue… let me walk you through it.
(Basically the same as this guide: Squeezebox ESP32 Multi-room Audio System – Systems Lab)
I bought an ESP32-A1S Audio-Kit and matching 4 Ohm 3 Watt speakers
I was able to install squeezelite-esp32 via the web-installer:
https://sle118.github.io/squeezelite-esp32-installer/
In Music Assistant, I added the “Squeezelite (slimproto players)” player provider.
Once entered the server IP on the squeezelite player, it connected to Music Assistant.
Music playback works. I can send TTS notifications from Home Assistant. This is my first squeezelite player, but I assume synchronized playback would work - absolutely beautiful!
I plugged in a KY-040 rotary encoder with push-button to the ESP32-A1S board. After struggeling with finding the correct documentation, I ended up with this configuration, if anyone is curious:
- enable NVS Editor
- set “actrls_config” to “buttons”
- add new key “buttons” with this entry:
[
{"gpio": 5, "type": "BUTTON_LOW", "pull": true, "normal": {"pressed": "ACTRLS_TOGGLE"}},
{"gpio": 19, "type": "BUTTON_LOW", "pull": true, "normal": {"pressed": "ACTRLS_NEXT"}},
{"gpio": 13, "type": "BUTTON_LOW", "pull": true, "normal": {"pressed": "ACTRLS_PREV"}},
{"gpio": 36, "type": "BUTTON_LOW", "pull": true, "normal": {"pressed": "ACTRLS_NONE"}}
]
- set “rotary_config” to “A=18,B=23,volume”
Now the volume can be controlled with turing the knob, and pressing it toggles music playback. Nice!
Now we get to the issue:
I expect to put this device somewhere, press the knob to start the radio playback (i.e. the last loaded playlist), and then push again when I am done.
What I get: If I resume playback after a short while (in the range of minutes), the web radio stream was paused, and is now delayed. This is irritating when the news announces the current time, etc. After longer pauses the stream has timed out or something, and no playback would start at all.
On a related note: Whenever Home Assistant shows the music player as “idle”, pushing the physical button on the device will NOT start the playback, regardless if something is in the queue or not.
I wrote an automation called “Keep paused radio stream fresh” which triggers every 30 seconds to check if the player is paused and has been playing a radio station, stops playback to remove the old radio buffer and then starts playback of my radio station for 5 seconds, before pausing it again. The 5 seconds are required to wait for the buffering of the new stream. I need to run this every 30 seconds because if I pause the player in home assistant, its state always switches from “paused” to “idle” after exactly 30 seconds. And then the physical button has no effect anymore.
This feels very inappropriate and error-prone.
What I would need:
- Make the physical button resume playback, even in an “idle” state.
- Would this be appropriate as an issue at the squeezelite-esp32 GitHub?
- Allow me to catch the button press as an event in home assistant, to refresh the radio stream and start playback
- Is there a logic for catching events of connected players from music assistant that I did not discover yet?
- The squeezelite-esp32 documentation explains the NVS parameter “lms_ctrls_raw”, where the button are sent to the logitec media server as code, instead of performing the functions locally (if I understand correctly). Will this somehow help me?
This post suggests that adding the “SlimProto Player” Addon allows to catch button press events in home assistant.
But that was in 2023, before Music Assistant, and the Music Assistant documentation explicitly states “Make sure that you do not have the “slimproto” (Squeezebox players) integration running in Home Assistant”.
I realized I could also buy and configure a simple esp32 with just my button, run esphome on it and use its events for triggering the playback on the ESP32-A1S via Home Assistant. I guess I would do it, if I found a way to not run two USB cables into my case - can the ESPs somehow share power?
This has become quite the branching topic, any ideas are appreachiated. I can’t be the first to want this behaviour