Working esphome-mediaplayer without jitter

Hello community

after rel. long research I have a running media-player config without anny jitter and stuff.

esphome:
  name: speaker4
  friendly_name: Speaker4

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: ""

ota:
  - platform: esphome
    password: ""

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Speaker4 Fallback Hotspot"
    password: ""

captive_portal:

web_server:
  port: 80
  version: 3

switch:
  - platform: gpio
    pin: 
      number: GPIO47
      inverted: False
    id: gpio_led
    

i2s_audio:
  - i2s_lrclk_pin: GPIO6
    i2s_bclk_pin: GPIO5
    id: i2s_audio_speaker

speaker:
  - platform: i2s_audio
    dac_type: external
    i2s_dout_pin: GPIO07
    channel: stereo
    bits_per_sample: 32bit
    i2s_audio_id: i2s_audio_speaker
    timeout: never
    buffer_duration: 100ms
    sample_rate: 48000
    id: myspeaker
  
  - platform: mixer
    id: mixing_speaker
    output_speaker: myspeaker
    num_channels: 2
    source_speakers:
      - id: announcement_mixing_input
        timeout: never
      - id: media_mixing_input
        timeout: never
  
  - platform: resampler
    id: announcement_resampling_speaker
    output_speaker: announcement_mixing_input
    sample_rate: 48000
    bits_per_sample: 16
  
  - platform: resampler
    id: media_resampling_speaker
    output_speaker: media_mixing_input
    sample_rate: 48000
    bits_per_sample: 16

media_player:
  - platform: speaker
    id: external_media_player
    name: Media Player
    internal: False
    volume_increment: 0.05
    volume_min: 0.4
    volume_max: 0.85
    announcement_pipeline:
      speaker: announcement_resampling_speaker
      format: FLAC     # FLAC is the least processor intensive codec
      num_channels: 1  # Stereo audio is unnecessary for announcements
      sample_rate: 48000
    media_pipeline:
      speaker: media_resampling_speaker
      format: FLAC     # FLAC is the least processor intensive codec
      num_channels: 2
      sample_rate: 48000
    on_announcement:
      - mixer_speaker.apply_ducking:
          id: media_mixing_input
          decibel_reduction: 20
          duration: 0.0s
 

playing streams (of internet-radio-stations) absolutely works, but I have to send the media-url with homeassistant. and thats not the optimum. now I wanted to give the select-component a try, but that doesn’t compile
here is my select:

select:
    - platform: template
      name: CHG-PRIO
      id: radio_preset
      options:
        - "Ö3"            # https://ors-sn03.ors-shoutcast.at/oe3-q1a
        - "Ö1"            # https://orf-live.ors-shoutcast.at/oe1-q2a
        - "Radio-ST"      # https://ors-sn08.ors-shoutcast.at/stm-q1a
        - "FM4"           # https://orf-live.ors-shoutcast.at/fm4-q2a
        - "ClassicRadio"  # https://ice-sov.musicradio.com/ClassicFMMP3
        - "Radio Paradise"
     
      optimistic: true 
      on_value:
        
          
        then:
        - lambda: |-
            if (id(radio_preset).state == "FM4") {
            id(external_media_player).play_media("https://orf-live.ors-shoutcast.at/fm4-q2a");
            } else if (id(radio_preset).state == "Ö1") {
              id(external_media_player).play_media("https://orf-live.ors-shoutcast.at/oe1-q2a");
            } else if (id(radio_preset).state == "Radio-ST") {
              id(external_media_player).play_media("https://ors-sn08.ors-shoutcast.at/stm-q1a");
            } else if (id(radio_preset).state == "Ö3") {
              id(external_media_player).play_media("https://ors-sn03.ors-shoutcast.at/oe3-q1a");

I am quite ssure, that anybody has already done that succesfully

regards
peter

1 Like