Rofo
(Ro)
February 18, 2025, 10:52am
1
I am experimenting with the the esp32 audio kit boards, which you can get for cheap from aliexpress:
https://www.aliexpress.com/item/1005004949068471.html?spm=a2g0o.order_list.order_list_main.11.4c0b1802vUDOVu
I’ve flashed one with the squeezelite firmware from here:
https://sle118.github.io/squeezelite-esp32-installer/
And the other I’ve adopted into esphome and am using the code found from the forums here:
I’m trying to decide whether to go the squeeze route, or esphome.
On the surface, the esphome code exposes more entities (The media player, the buttons, the amp, and a switch for the headphone jack), but the squeeze lite is only detected as a media player.
The squeeze lite is not detected in esphome, but via either the LMS integration:
Or via Music Assistant which also auto detects the players when you have them configured.
My use case is pretty simple. I want to be able to use an automation to trigger audio to play tts or music in the area in which the player is located. Both squeeze and esphome media player achieve this.
The only pro I can see with the squeeze route is that you don’t actually need to have HA installed at all, and could just use a standalone LMS server to stream music to them, but for me, thats not important.
Does anyone have any thoughts on either approach ?
pepe59
(Pepe59)
February 18, 2025, 1:25pm
2
I went the squeeze and LMS route.
I don’t regret it, independent of HA and integrated into HA where I use players for both TTS announcements and for playing local music and radio. It works without problems with the LMS server that I have been running on Rpi4 for a few years.
Rofo
(Ro)
February 18, 2025, 1:31pm
3
I’ve just been testing a bit more, and noticed that the squeeze lite firmware seems to output a very low audio signal when outputting via the headphone jack. Not sure why. Are you using the speaker connections on the board itself, or the headphone output ?
pepe59
(Pepe59)
February 18, 2025, 1:34pm
4
I use the speaker connection on the motherboard.
Rofo
(Ro)
February 18, 2025, 1:38pm
5
With the ESP home code, there is an entity exposed called ‘Aux Output’, which when switched on, massively increases the volume of the headphone jack. I’m sure there is a way to do with with the web interface on the squeeze lite, I just cant find the setting.
Rofo
(Ro)
February 18, 2025, 1:50pm
6
The other thing that I’ve noticed is that if I try to use the media extractor integration:
No audio plays with the esphome code, unless I route the media player into Music Assistant first as a player provider, and then use music assistants media player, (it usually has the same entity id but with an _2 on the end). I think this might be to do with the audio codec supported on the esphome device, which music assistant is fixing in the background.
EDIT:- I suspect the above issue is related to this bug which I think is still open :
opened 09:09PM - 14 Nov 23 UTC
closed 12:08PM - 19 Jun 24 UTC
integration: media_extractor
stale
### The problem
A previous issue was raised and fixed by @joostlek regarding … playing youtube audio from media_extractor
It seems i'm experiencing a similar issue whereby my Sonos device will not play audio from youtube links. If my understanding is correct media_extractor should search for audio in youtube links, however, despite modifying media_extractor configuration.yaml it still tries to play the video mp4 url to sonos (which obviously fails given it's an audio device) --> `Error calling SonosMediaPlayerEntity._play_media on media_player.sonos_chambre: UPnP Error 714 received: Illegal MIME-Type`
I tried the following configuration.yaml for media_extractor:
```
media_extractor:
default_query: best
customize:
media_player.sonos_chambre:
music: bestaudio[ext=mp3]
```
also tried : `bestaudio[ext=mp3]` `bestaudio[ext=m4a]` `bestaudio[ext=ogg]`
Here's the error log output Service Call :
`Error executing service: <ServiceCall media_player.play_media (c:01HF7SPG1HCYCF2CMBD0JQDNBD): extra=, entity_id=['media_player.sonos_chambre'], media_type=music, media_id=https://rr3---sn-4gxx-25gee.googlevideo.com/videoplayback?expire=1700016739&ei=A95TZZqGJ6u9xN8Pv_WY-AU&ip=2a01%3Ae0a%3Ab51%3A1881%3A%3A758&id=o-ANDoVZOYQPRD9eFecMeZZYSQ5dis8oJbme__SLHEfPRv&itag=22&source=youtube&requiressl=yes&mh=4N&mm=31%2C29&mn=sn-4gxx-25gee%2Csn-4gxx-25gy&ms=au%2Crdu&mv=m&mvi=3&nh=EAE%2CEAE&pl=49&gcr=fr&initcwndbps=837500&spc=UWF9f3ksna66yPJfg5R5tlQkMj_Jasg&vprv=1&svpuc=1&mime=video%2Fmp4&cnr=14&ratebypass=yes&dur=280.566&lmt=1679738956453811&mt=1699994724&fvip=3&fexp=24007246&beids=24350018&c=ANDROID&txp=4532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=ANLwegAwRgIhAKJX4v021cEPTwDENpC0rKfpWwXIZGEZlUDXYDVsnOWPAiEAuJFJ5OMnGaiJP9TrD4knIyXWfw0kEWTqXQEBLtf_bto%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cnh%2Cpl%2Cinitcwndbps&lsig=AM8Gb2swQwIgCJOm_XExUAvulkk8qa7H3GcUVI6lGxskqgAcfyByPlkCH3_DH6lyvN1F2bfTQ6C73t_EA_JpQV8SSNELSHQ7xw0%3D>
Error executing service: <ServiceCall media_player.play_media (c:01HF7SZ48YHD6GSMZCZRAQQ30E): extra=, entity_id=['media_player.sonos_chambre'], media_type=music, media_id=https://rr3---sn-4gxx-25gy.googlevideo.com/videoplayback?`
more specifically we can see media_extractor trying to pass mp4 video through to Sonos ; `&mime=video%2Fmp4`
this results in a MIME Type error.
Here's my service payload:
```
service: media_extractor.play_media
data:
media_content_id: https://www.youtube.com/watch?v=9bFHsd3o1w0
media_content_type: music
target:
entity_id: media_player.sonos_chambre
```
If anyone's able to shed som elight on this it'd be much appreciated, thanks!! Sleinous
Note: Only music & playlist seem to work, MUSIC, PLAYLIST, audio/youtube etc don't work and aren't accepted by Sonos.
### What version of Home Assistant Core has the issue?
core-2023.11.2
### What was the last working version of Home Assistant Core?
_No response_
### What type of installation are you running?
Home Assistant OS
### Integration causing the issue
media extractor
### Link to integration documentation on our website
https://www.home-assistant.io/integrations/media_extractor/
### Diagnostics information
_No response_
### Example YAML snippet
```yaml
service: media_extractor.play_media
data:
media_content_id: https://www.youtube.com/watch?v=9bFHsd3o1w0
media_content_type: music
target:
entity_id: media_player.sonos_chambre
```
### Anything in the logs that might be useful for us?
```txt
Logger: homeassistant.core
Source: core.py:2051
First occurred: 21:52:20 (2 occurrences)
Last logged: 21:57:03
Error executing service: <ServiceCall media_player.play_media (c:01HF7SPG1HCYCF2CMBD0JQDNBD): extra=, entity_id=['media_player.sonos_chambre'], media_type=music, media_id=https://rr3---sn-4gxx-25gee.googlevideo.com/videoplayback?expire=1700016739&ei=A95TZZqGJ6u9xN8Pv_WY-AU&ip=2a01%3Ae0a%3Ab51%3A1881%3A%3A758&id=o-ANDoVZOYQPRD9eFecMeZZYSQ5dis8oJbme__SLHEfPRv&itag=22&source=youtube&requiressl=yes&mh=4N&mm=31%2C29&mn=sn-4gxx-25gee%2Csn-4gxx-25gy&ms=au%2Crdu&mv=m&mvi=3&nh=EAE%2CEAE&pl=49&gcr=fr&initcwndbps=837500&spc=UWF9f3ksna66yPJfg5R5tlQkMj_Jasg&vprv=1&svpuc=1&mime=video%2Fmp4&cnr=14&ratebypass=yes&dur=280.566&lmt=1679738956453811&mt=1699994724&fvip=3&fexp=24007246&beids=24350018&c=ANDROID&txp=4532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=ANLwegAwRgIhAKJX4v021cEPTwDENpC0rKfpWwXIZGEZlUDXYDVsnOWPAiEAuJFJ5OMnGaiJP9TrD4knIyXWfw0kEWTqXQEBLtf_bto%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cnh%2Cpl%2Cinitcwndbps&lsig=AM8Gb2swQwIgCJOm_XExUAvulkk8qa7H3GcUVI6lGxskqgAcfyByPlkCH3_DH6lyvN1F2bfTQ6C73t_EA_JpQV8SSNELSHQ7xw0%3D>
Error executing service: <ServiceCall media_player.play_media (c:01HF7SZ48YHD6GSMZCZRAQQ30E): extra=, entity_id=['media_player.sonos_chambre'], media_type=music, media_id=https://rr3---sn-4gxx-25gy.googlevideo.com/videoplayback?expire=1700017022&ei=Ht9TZa6LJb2NxN8Pqs2toAI&ip=2a01%3Ae0a%3Ab51%3A1881%3A%3A758&id=o-AGpFQApzvoyp_kVzCZB60kKK7DeE-cvpZQ0u2dgwm0dK&itag=22&source=youtube&requiressl=yes&mh=4N&mm=31%2C26&mn=sn-4gxx-25gy%2Csn-5hnekn7l&ms=au%2Conr&mv=m&mvi=3&nh=EAE%2C&pl=49&gcr=fr&initcwndbps=931250&spc=UWF9fzeIFy9Kc6RMOpq2cVPhUE-Cjyg&vprv=1&svpuc=1&mime=video%2Fmp4&cnr=14&ratebypass=yes&dur=280.566&lmt=1679738956453811&mt=1699994969&fvip=2&fexp=24007246&beids=24350018&c=ANDROID&txp=4532434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cgcr%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Ccnr%2Cratebypass%2Cdur%2Clmt&sig=ANLwegAwRQIgFBrLnS393yeV6HmhvC0EUdmZr0EcFrEdXsP4x0UMf2MCIQCxoMUoleJdCzx7NFx8QKbI2VwgyxeWoVVcLB18AV82hA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cnh%2Cpl%2Cinitcwndbps&lsig=AM8Gb2swRAIgLK_KeJgxYEPhf-SYbqwZueu1wVr-9IXVKjMaxupnK8wCIA6xwcP7pv8MVljmcsAmQlyMTGtFTSaEyzn2_J5aEhl2>
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/sonos/helpers.py", line 64, in wrapper
result = funct(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sonos/media_player.py", line 625, in _play_media
soco.play_uri(media_id, force_radio=is_radio)
File "/usr/local/lib/python3.11/site-packages/soco/core.py", line 148, in inner_function
return function(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/soco/core.py", line 825, in play_uri
self.avTransport.SetAVTransportURI(
File "/usr/local/lib/python3.11/site-packages/soco/services.py", line 206, in _dispatcher
return self.send_command(action, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/soco/services.py", line 514, in send_command
self.handle_upnp_error(response.text)
File "/usr/local/lib/python3.11/site-packages/soco/services.py", line 567, in handle_upnp_error
raise SoCoUPnPException(
soco.exceptions.SoCoUPnPException: UPnP Error 714 received: Illegal MIME-Type from 192.168.2.176
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/core.py", line 2051, in _run_service_call_catch_exceptions
await coro_or_task
File "/usr/src/homeassistant/homeassistant/core.py", line 2072, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
return await service.entity_service_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 876, in entity_service_call
response_data = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sonos/media_player.py", line 542, in async_play_media
await self.hass.async_add_executor_job(
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sonos/helpers.py", line 78, in wrapper
raise SonosUpdateError(message) from err
homeassistant.components.sonos.exception.SonosUpdateError: Error calling SonosMediaPlayerEntity._play_media on media_player.sonos_chambre: UPnP Error 714 received: Illegal MIME-Type from 192.168.2.176
```
### Additional information
_No response_
I think music assistant can handle the video format but if sent directly to the esphome device it barfs.
Rofo
(Ro)
February 18, 2025, 3:54pm
7
One final addition. When power cycling the audio kit board, it does retain the ‘aux output’ state using the esphome code, but the audio isn’t as loud as normal, and slightly muffled. Toggled the aux output switch fixes this.
Dao
(Leonard Becker)
February 19, 2025, 3:28pm
8
Here’s the list of pros for squeezelite vs esphome as I see it:
squeezelize-esp32
synced multiroom audio
bluetooth, spotify and airplay sink
esphome media player
basic single-room media player
everything else esphome can do including microwakeword
In many rooms I need/want both, multiroom audio and wakeword, so I actually have two esp32 side by side…
Rofo
(Ro)
February 20, 2025, 12:14pm
9
@Dao - Hi there.
Can’t you do multi room audio via music assistant or some simple automations that target multiple players at once ?
The bluetooth possibility is interesting. I’ve not tested that out yet.
Downside to the squeeze is that you don’t (as far as I am aware) get access to the button entities in home assistant, and the headphone output is super low, so you are basically forced to use the on board speaker connections (which is not a huge deal).
EDIT: Turns out fixing the headphone issue was as simple as choosing the right hardware board:
For me at least, there appears to be no obvious difference betwen variant 1 and 2.