Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Maco65 opened this issue Mar 29, 2023 · 6 comments
Open

Comments

@Maco65
Copy link

Maco65 commented Mar 29, 2023

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

@Maco65 Maco65 changed the title I2S Media Player (with MAX98357 DAC) doee not play Internet radio I2S Media Player (with MAX98357 DAC) does NOT play Internet radio Mar 29, 2023
@randybb
Copy link

randybb commented Mar 29, 2023

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
Copy link
Author

Maco65 commented Mar 29, 2023

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
Copy link
Author

Maco65 commented Mar 30, 2023

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.

@Maco65 Maco65 changed the title I2S Media Player (with MAX98357 DAC) does NOT play Internet radio I2S Media Player (with MAX98357 DAC) does NOT play most Internet radios Mar 31, 2023
@alfwro13
Copy link

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
Copy link

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
Copy link

dwd1 commented Oct 7, 2023

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.

esphome/feature-requests#2179

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants