esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

I2S Media Player (with MAX98357 DAC) does NOT play most Internet radios #4369

Open Maco65 opened 1 year ago

Maco65 commented 1 year ago

The problem

I2S Media Player is defined as per dokumentation with MAX98357 DAC module. Works very well playing local (from HA server) mp3 files and also with Text to Spech provided by Nabucasa. However when I want to play internet radio station (defined in HA and visible in Media folder it does not play. It does not do anything and there is very little (or none) information in logs. The same radio station works fine on Webbrowser media (in HA) and on other player so it must be related to this particular player

Which version of ESPHome has the issue?

2023.3.2

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.3.6

What platform are you using?

ESP32

Board

RPi4

Component causing the issue

I2S Media Player

Example YAML snippet

ESP32 configuration related to i2s media player.
The rest of the YAML is very basic.

media_player:
  - platform: i2s_audio
    name: ESPHome I2S Media Player
    dac_type: external
    i2s_lrclk_pin: GPIO33
    i2s_dout_pin: GPIO22
    i2s_bclk_pin: GPIO19
    mode: stereo

Anything in the logs that might be useful for us?

I have changed logs for VERY_VERBOSE and here is the part related to not functioning radio station:

[22:51:15][D][media_player:059]: 'ESPHome I2S Media Player' - Setting
[22:51:15][D][media_player:066]:   Media URL: https://stream.0nlineradio.com/80s-rock?ref=radiobrowser
[22:51:15][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
  key: 3210548230
  state: MEDIA_PLAYER_STATE_PLAYING
  volume: 1
  muted: NO
}
[22:51:15][V][component:204]: Component api took a long time for an operation (0.16 s).
[22:51:15][V][component:205]: Components should block for at most 20-30ms.
[22:51:15][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
  key: 3210548230
  state: MEDIA_PLAYER_STATE_IDLE
  volume: 1
  muted: NO
}

Additional information

Some similar cases of other users in this tops: https://community.home-assistant.io/t/esp-home-media-player-play-https-media-url/442000/16 No response

randybb commented 1 year ago

The other have some issues - like the device is crashing, but this stream I can play without any problems, at least with DAC NS4168.

Maco65 commented 1 year ago

So, do you suggest that there might be an issue with MAX98357? In such case how to explain that it plays local files and text to speech, which from logs also seem to be local (logs below)?

[18:01:56][D][media_player:059]: 'ESPHome I2S Media Player' - Setting
[18:01:56][D][media_player:066]:   Media URL: http://192.168.1.70:8123/api/tts_proxy/ecf3c86425b8e6b0b051f3b28a5b0e9b9d207455_en-us_a9c18110b0_cloud.mp3

And where to find (which logs, which changes/test) what is stopping ESPHome player to play Internet radio.

At the end if this is the chip MAX98357 related issue and cannot be fixed, then I believe it should be stated in ESPHome doc for I2S Media Player.

Maco65 commented 1 year ago

Strange enough, today trying to do some more test when I clicked on one radio station the player started to play it! Then I started to "randomly" click on radio stations (from Media there are is a lot of them) and one out of 10 worked. Below are the logs form the esphome with the stations url which are wotking fine:

[20:52:19][D][media_player:059]: 'ESPHome I2S Media Player' - Setting
[20:52:19][D][media_player:066]:   Media URL: http://212.34.233.78:8000/live

[20:52:59][D][media_player:059]: 'ESPHome I2S Media Player' - Setting
[20:52:59][D][media_player:066]:   Media URL: http://83.169.36.75:8000/stream

[20:55:40][D][media_player:059]: 'ESPHome I2S Media Player' - Setting
[20:55:40][D][media_player:066]:   Media URL: http://5.39.16.62:8004/tre

[20:57:13][D][media_player:059]: 'ESPHome I2S Media Player' - Setting
[20:57:13][D][media_player:066]:   Media URL: http://149.210.138.12:8000/nommeraadio

[20:58:18][D][media_player:059]: 'ESPHome I2S Media Player' - Setting
[20:58:18][D][media_player:066]:   Media URL: http://5.201.13.191/live

I hope this will help to isolate the issue and find the solution.

alfwro13 commented 1 year ago

I am seeing exactly the same issue - I have a node mcu 32 with the latest version of HA and esphome and relevant esphome config is:

i2s_audio:
  i2s_lrclk_pin: 21
  i2s_bclk_pin: 18

media_player:
  - platform: i2s_audio
    name: ${friendly_name}
    dac_type: external
    i2s_dout_pin: 19
    mode: stereo
    id: media_out

I can play mp3s from local media or HA dnla server but as soon as I try to play a radio station via the Radio Browser it crashes - here are my logs:

[13:02:41][I][app:102]: ESPHome version 2023.4.1 compiled on Apr 25 2023, 12:01:03
[13:02:41][C][status_led:019]: Status LED:
[13:02:41][C][status_led:020]:   Pin: GPIO2
[13:02:41][C][wifi:505]: WiFi:
[13:02:41][C][wifi:363]:   Local MAC: 78:21:84:9A:6C:DC
[13:02:41][C][wifi:364]:   SSID: [redacted]
[13:02:41][C][wifi:365]:   IP Address: [redacted]
[13:02:41][C][wifi:367]:   BSSID: [redacted]
[13:02:41][C][wifi:368]:   Hostname: 'workshop-speaker'
[13:02:41][C][wifi:370]:   Signal strength: -55 dB ▂▄▆█
[13:02:41][V][wifi:372]:   Priority: 0.0
[13:02:41][C][wifi:374]:   Channel: 12
[13:02:41][C][wifi:375]:   Subnet: 255.255.255.0
[13:02:41][C][wifi:376]:   Gateway: [redacted]
[13:02:41][C][wifi:377]:   DNS1: [redacted]
[13:02:41][C][wifi:378]:   DNS2: [redacted]
[13:02:41][C][logger:294]: Logger:
[13:02:41][C][logger:295]:   Level: VERY_VERBOSE
[13:02:41][C][logger:296]:   Log Baud Rate: 115200
[13:02:41][C][logger:297]:   Hardware UART: UART0
[13:02:42][C][mdns:108]: mDNS:
[13:02:42][C][mdns:109]:   Hostname: workshop-speaker
[13:02:42][V][mdns:110]:   Services:
[13:02:42][V][mdns:112]:   - _esphomelib, _tcp, 6053
[13:02:42][V][mdns:114]:     TXT: version = 2023.4.1
[13:02:42][V][mdns:114]:     TXT: mac = 7821849a6cdc
[13:02:42][V][mdns:114]:     TXT: platform = ESP32
[13:02:42][V][mdns:114]:     TXT: board = nodemcu-32s
[13:02:42][V][mdns:114]:     TXT: network = wifi
[13:02:42][C][ota:093]: Over-The-Air Updates:
[13:02:42][C][ota:094]:   Address: [redacted]:3232
[13:02:42][C][ota:097]:   Using Password.
[13:02:42][C][api:138]: API Server:
[13:02:42][C][api:139]:   Address: [redacted]:6053
[13:02:42][C][api:141]:   Using noise encryption: YES
[13:02:42][C][wifi_signal.sensor:009]: WiFi Signal 'Workshop Speaker WiFi Signal Sensor'
[13:02:42][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[13:02:42][C][wifi_signal.sensor:009]:   State Class: 'measurement'
[13:02:42][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dBm'
[13:02:42][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[13:02:42][V][wifi_signal.sensor:009]:   Unique ID: '7821849a6cdc-wifisignal'
[13:02:42][C][audio:190]: Audio:
[13:02:51][VV][api.service:731]: on_media_player_command_request: MediaPlayerCommandRequest {
  key: 2350453640
  has_command: NO
  command: MEDIA_PLAYER_COMMAND_PLAY
  has_volume: NO
  volume: 0
  has_media_url: YES
  media_url: 'http://live.str3am.com:2240/live'
}
[13:02:51][D][media_player:059]: 'Workshop Speaker' - Setting
[13:02:51][D][media_player:066]:   Media URL: http://live.str3am.com:2240/live
WARNING [redacted]: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for [redacted]
WARNING Disconnected from API
INFO Successfully connected to [redacted]
[13:03:15][D][api:102]: Accepted [redacted]
[13:03:16][VV][api.socket:696]: [redacted]: Handshake complete!
[13:03:16][VV][api.service:476]: on_hello_request: HelloRequest {
  client_info: 'Home Assistant 2023.4.6'
  api_version_major: 1
  api_version_minor: 7
}
[13:03:16][V][api.connection:943]: Hello from client: 'Home Assistant 2023.4.6' | API Version 1.7
[13:03:16][VV][api.service:013]: send_hello_response: HelloResponse {
  api_version_major: 1
  api_version_minor: 7
  server_info: 'workshop-speaker (esphome v2023.4.1)'
  name: 'workshop-speaker'
}
[13:03:16][VV][api.service:485]: on_connect_request: ConnectRequest {
  password: ''
}
[13:03:16][D][api.connection:961]: Home Assistant 2023.4.6 ([redacted]): Connected successfully
[13:03:16][VV][api.service:019]: send_connect_response: ConnectResponse {
  invalid_password: NO
}
[13:03:16][VV][api.service:530]: on_device_info_request: DeviceInfoRequest {}
[13:03:16][VV][api.service:049]: send_device_info_response: DeviceInfoResponse {
  uses_password: NO
  name: 'workshop-speaker'
  mac_address: '78:21:84:9A:6C:DC'
  esphome_version: '2023.4.1'
  compilation_time: 'Apr 25 2023, 12:01:03'
  model: 'nodemcu-32s'
  has_deep_sleep: NO
  project_name: ''
  project_version: ''
  webserver_port: 0
  bluetooth_proxy_version: 0
  manufacturer: 'Espressif'
  friendly_name: ''
  voice_assistant_version: 0
}
[13:03:16][VV][api.service:539]: on_list_entities_request: ListEntitiesRequest {}
[13:03:16][VV][api.service:132]: send_list_entities_sensor_response: ListEntitiesSensorResponse {
  object_id: 'workshop_speaker_wifi_signal_sensor'
  key: 927856380
  name: 'Workshop Speaker WiFi Signal Sensor'
  unique_id: '7821849a6cdc-wifisignal'
  icon: ''
  unit_of_measurement: 'dBm'
  accuracy_decimals: 0
  force_update: NO
  device_class: 'signal_strength'
  state_class: STATE_CLASS_MEASUREMENT
  legacy_last_reset_type: LAST_RESET_NONE
  disabled_by_default: NO
  entity_category: ENTITY_CATEGORY_DIAGN
[13:03:16][V][component:204]: Component api took a long time for an operation (0.05 s).
[13:03:16][V][component:205]: Components should block for at most 20-30ms.
[13:03:16][VV][api.service:316]: send_list_entities_media_player_response: ListEntitiesMediaPlayerResponse {
  object_id: 'workshop_speaker'
  key: 2350453640
  name: 'Workshop Speaker'
  unique_id: 'workshop-speakermedia_playerworkshop_speaker'
  icon: ''
  disabled_by_default: NO
  entity_category: ENTITY_CATEGORY_NONE
  supports_pause: YES
}
[13:03:16][VV][api.service:055]: send_list_entities_done_response: ListEntitiesDoneResponse {}
[13:03:16][VV][api.service:548]: on_subscribe_states_request: SubscribeStatesRequest {}
[13:03:16][VV][api.service:610]: on_subscribe_homeassistant_services_request: SubscribeHomeassistantServicesRequest {}
[13:03:16][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 927856380
  state: -54
  missing_state: NO
}
[13:03:16][VV][api.service:637]: on_subscribe_home_assistant_states_request: SubscribeHomeAssistantStatesRequest {}
[13:03:16][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
  key: 2350453640
  state: MEDIA_PLAYER_STATE_IDLE
  volume: 1
  muted: NO
}
[13:03:47][VV][api.service:731]: on_media_player_command_request: MediaPlayerCommandRequest {
  key: 2350453640
  has_command: NO
  command: MEDIA_PLAYER_COMMAND_PLAY
  has_volume: NO
  volume: 0
  has_media_url: YES
  media_url: 'http://live.str3am.com:2240/live'
}
[13:03:47][D][media_player:059]: 'Workshop Speaker' - Setting
[13:03:47][D][media_player:066]:   Media URL: http://live.str3am.com:2240/live
WARNING [redacted]: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for [redacted]
WARNING Disconnected from API
INFO Successfully connected to [redacted]
[13:04:42][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 927856380
  state: -56
  missing_state: NO
}
[13:04:59][VV][api.service:731]: on_media_player_command_request: MediaPlayerCommandRequest {
  key: 2350453640
  has_command: NO
  command: MEDIA_PLAYER_COMMAND_PLAY
  has_volume: NO
  volume: 0
  has_media_url: YES
  media_url: 'http://212.34.233.78:8000/live'
}
[13:04:59][D][media_player:059]: 'Workshop Speaker' - Setting
[13:04:59][D][media_player:066]:   Media URL: http://212.34.233.78:8000/live
[13:05:00][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
  key: 2350453640
  state: MEDIA_PLAYER_STATE_PLAYING
  volume: 1
  muted: NO
}
[13:05:00][V][component:204]: Component i2s_audio.media_player took a long time for an operation (0.69 s).
[13:05:00][V][component:205]: Components should block for at most 20-30ms.
[13:05:42][V][sensor:059]: 'Workshop Speaker WiFi Signal Sensor': Received new state -56.000000
[13:05:42][D][sensor:110]: 'Workshop Speaker WiFi Signal Sensor': Sending state -56.00000 dBm with 0 decimals of accuracy
[13:05:42][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 927856380
  state: -56
  missing_state: NO
}
[13:06:20][VV][api.service:731]: on_media_player_command_request: MediaPlayerCommandRequest {
  key: 2350453640
  has_command: NO
  command: MEDIA_PLAYER_COMMAND_PLAY
  has_volume: NO
  volume: 0
  has_media_url: YES
  media_url: 'http://64.202.98.33:2240/live'
}
[13:06:20][D][media_player:059]: 'Workshop Speaker' - Setting
[13:06:20][D][media_player:066]:   Media URL: http://64.202.98.33:2240/live
[13:06:20][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
  key: 2350453640
  state: MEDIA_PLAYER_STATE_PLAYING
  volume: 1
  muted: NO
}
[13:06:20][V][component:204]: Component api took a long time for an operation (0.38 s).
[13:06:20][V][component:205]: Components should block for at most 20-30ms.
WARNING [redacted]: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for [redacted]
WARNING Disconnected from API
INFO Successfully connected to [redacted]

(I have also tried playing radio streams using the "media player: play media" service but that made no difference) Out of several different streams I managed to find one that does play: http://212.34.233.78:8000/live

jumblies commented 1 year ago

As in the community forum thread, it seems that this lacks the ability to stream HTTPS although it is unclear where it is losing the stream.

Can anyone confirm that this happens with modules other than MAX98357?

I would think it would since the stream should be decoded and passed directly to i2s bus.

dwd1 commented 11 months ago

same error, very annoying its a Sonoff TX Ultimate T5-2C-86

media_player:
  - platform: i2s_audio
    id: media_out
    name: "Player"
    dac_type: external
    i2s_dout_pin: ${audio_sdata_pin}
    i2s_audio_id: audio_i2s
    i2s_comm_fmt: lsb    
    mode: mono

i2s_audio:
  id: audio_i2s
  i2s_lrclk_pin: ${audio_lrclk_pin}
  i2s_bclk_pin: ${audio_bclk_pin}
[09:23:52][VV][api.service:759]: on_media_player_command_request: MediaPlayerCommandRequest {
  key: 1069431850
  has_command: NO
  command: MEDIA_PLAYER_COMMAND_PLAY
  has_volume: NO
  volume: 0
  has_media_url: YES
  media_url: 'https://some.external.url:8123/api/tts_proxy/f68178ae9450d37a8ecdd7d8835afa1c16c9088f_en_-_google_translate.mp3'
}
[09:23:52][D][media_player:059]: 'Player' - Setting
[09:23:52][D][media_player:066]:   Media URL: https://some.external.url:8123/api/tts_proxy/f68178ae9450d37a8ecdd7d8835afa1c16c9088f_en_-_google_translate.mp3
[09:23:53][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
  key: 1069431850
  state: MEDIA_PLAYER_STATE_PLAYING
  volume: 1
  muted: NO
}
[09:23:53][W][component:204]: Component i2s_audio.media_player took a long time for an operation (0.57 s).
[09:23:53][W][component:205]: Components should block for at most 20-30ms.
[09:23:53][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
  key: 1069431850
  state: MEDIA_PLAYER_STATE_IDLE
  volume: 1
  muted: NO
}
[09:23:53][W][component:204]: Component i2s_audio.media_player took a long time for an operation (0.46 s).
[09:23:53][W][component:205]: Components should block for at most 20-30ms.

https://github.com/esphome/feature-requests/issues/2179

AT622CZ commented 3 months ago

image I found, I2S media player can play radios with specific IP address. I cannot play any with text URL. I have WT32-ETH01 board with MAX98357. This problem occurs only with ethernet connection, with wifi on same board I can play... Some DNS problem, or something like that?

Rackir commented 2 months ago

I have the same issue. I'm using ESP32-WROOM-32U connected to UDA1334A DAC. I can play local media without problems but I can't play any radio or youtube music with it. I don't know if it useful but, when I click to play a song from youtbe music, the speakers make a very low "clack" sound and nothing else.

I've seen some videos where they play radios without a problem, so I believe it is not a problem with https URLs. https://www.youtube.com/watch?v=WGeNLprIHN8&t=941s https://www.youtube.com/watch?v=cNPg8q7XwC8

Has anyone solved this problem?

arne182 commented 2 months ago

I am also running https and only get a click and the same Component i2s_audio.media_player took a long time for an operation (529 ms) error

arne182 commented 2 months ago

[20:58:51][W][component:237]: Component wifi took a long time for an operation (57 ms). [20:58:51][W][component:238]: Components should block for at most 30 ms. [20:58:51][W][component:170]: Component wifi cleared Warning flag [20:59:05][D][api:102]: Accepted 192.168.188.196 [20:59:05][W][component:170]: Component api cleared Warning flag [20:59:05][D][api.connection:1375]: Home Assistant 2024.6.4 (192.168.188.196): Connected successfully [20:59:07][D][media_player:061]: 'RaspiAudio Muse Luxe 1ee854' - Setting [20:59:07][D][media_player:065]: Command: PLAY [20:59:13][D][sensor:094]: 'Battery': Sending state 4.44017 V with 3 decimals of accuracy I had a similar problem with my ESP S3 box3 they were trying to connect to https://192.168.188.196 instead of https://homeassistant Not sure why but after adding homeassistant: external_url: https://homeassistant in the yaml they started to work.

arne182 commented 2 months ago

Giving it a dns1 and dns2 instead of just a static ip helped it to work but not perfect

arne182 commented 2 months ago

Now the streaming audio is droping out every few seconds and the TTS still is having trouble with the DNS finding

[21:44:55][D][media_player:068]: Media URL: https://homeassistant:8123/api/tts_proxy/fa00ae127054793dfdbe1f2ba481ba00f804d9f1_de-de_dd5f24498e_cloud.mp3 [21:44:55][D][media_player:074]: Announcement: yes [21:44:55][370806][E][WiFiGeneric.cpp:1438] hostByName(): DNS Failed for homeassistant [21:44:55][370806][E][WiFiClientSecure.cpp:135] connect(): start_ssl_client: -1

playing the file over the browser works perfectly

arne182 commented 2 months ago

Without the manual_ip DNS is finally working but the watchdog is triggered

[22:00:09][D][api.connection:1375]: Home Assistant 2024.6.4 (192.168.188.196): Connected successfully [22:00:18][D][media_player:061]: 'RaspiAudio Muse Luxe 1ee854' - Setting [22:00:18][D][media_player:068]: Media URL: https://homeassistant:8123/api/tts_proxy/fa00ae127054793dfdbe1f2ba481ba00f804d9f1_de-de_dd5f24498e_cloud.mp3 [22:00:18][D][media_player:074]: Announcement: yes [22:00:23]E (96570) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time: [22:00:23]E (96570) task_wdt: - loopTask (CPU 1) [22:00:23]E (96570) task_wdt: Tasks currently running: [22:00:23]E (96570) task_wdt: CPU 0: IDLE [22:00:23]E (96570) task_wdt: CPU 1: IDLE [22:00:23]E (96570) task_wdt: Aborting. [22:00:23] [22:00:23]abort() was called at PC 0x4012036c on core 0 [22:00:23] [22:00:23] [22:00:23]Backtrace:0x40084309:0x3ffbea9c |<-CORRUPTED [22:00:23] [22:00:23] [22:00:23] [22:00:23] [22:00:23]ELF file SHA256: 0000000000000000 [22:00:23] [22:00:23]Rebooting... [22:00:23]ets Jun 8 2016 00:22:57 [22:00:23] [22:00:23]rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT) [22:00:23]configsip: 0, SPIWP:0xee [22:00:23]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 [22:00:23]mode:DIO, clock div:2 [22:00:23]load:0x3fff0030,len:1184 [22:00:23]load:0x40078000,len:13132 [22:00:23]load:0x40080400,len:3036 [22:00:23]entry 0x400805e4 [22:00:23][I][logger:156]: Log initialized [22:00:23][C][safe_mode:079]: There have been 0 suspected unsuccessful boot attempts [22:00:23][D][esp32.preferences:114]: Saving 1 preferences to flash... [22:00:23][D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed [22:00:23][I][app:029]: Running through setup()... [22:00:23][I][i2c.arduino:218]: Performing I2C bus recovery