ESP32 Mediaplayer issues

Hi,

I recently purchased a Raspiaudio Muse Lux in persuit of letting Home Assistant give me TTS messages. For example to tell me if the Front Door opens whan I am in my bedroom etc. Today I use the Alexa Media Player integration for this but I would rather have it locally than depending on the Internet and the cloud.

I first installed the Muse Lux ESPHome Media Player from ESPHome Media Players according to instructions, adopted it in Home Assistant and in the ESPHome addon. It had an IP and I could controll the Muse in every way except playing any audio. Not from TTL or from a local mp3 that I uploaded to HA for testing.

Both my Home Assistant and the Muse are on the same network and subnet, no firewalls etc. I can play audio from server (Roon) to devices fine on the network. I can also control other Media Players, for example my Ropieee XL from Home Assistant. After some elaboration I finally gave up the ESPHome Media Player and instead reflashed the Muse with the Squeezelite-ESP32 firmware and the SlimProto Player integration on HA.

It is basically the same behaviour there, although it gives me no options to control for example the local LED on the Muse as I could with the ESPHome MediaPlayer firmware. Local media doesnt work and TTS doesnt work. I can put the Muse On and Off from Home assistant, and I hear a faint white noice from its speakers when I turn it on. Since Squeezelite has Spotify service, I tested to control it from my iphones spotify app which went perfect.

However the Media Player does not present what I am playing in Home Assistant as all my other Media Players does. If I start a spotify song from my phone I can however pause it from the HA Media Player card. If I start it again it starts play the spotify tune a few seconds but it soon gets replaced by a loud white noice.

I think I can pretty much rule out harware problem on the Muse, since it worked as a bluetooth player when it came and that it plays music from Spotify with Squeezelite.

I have read about people experiencing the same thing, with the noice etc and many people seems so fail getting any sound from it from Home Assistant. Does anybody recognize it, or have ideas on what it can be?

Here is two logs that I found among the HA logs:

Logger: homeassistant.components.media_player
Source: components/media_player/init.py:1259
Integration: Mediaspelare (documentation, issues)
First occurred: 15:44:30 (2 occurrences)
Last logged: 15:44:30

Browse Media should use new BrowseMedia class

Logger: homeassistant.helpers.frame
Source: helpers/frame.py:77
First occurred: 15:40:16 (1 occurrences)
Last logged: 15:40:16

Detected integration that calls media_source.async_resolve_media without passing an entity_id. Please report issue for media_source using this method at homeassistant/components/media_source/init.py, line 147: report(“calls media_source.async_resolve_media without passing an entity_id”)

However, as TTS works fine to Alexa with the integration, I dont seem to be able to do TTS or play local media on HA to any other Media Player than to my laptop browser

Hmm. Just installed the Radio Browser integration. It places itself as a Media Source for Media Players. It plays fine from Home Assistant to my Muse Lux with Squeezelite. Can it be just that TTS and Local Media didnt want to play to neither ESPHome Media Player nor to Squeezelite? How come if so?

Having exactly the same issues… the folks over at raspiaudio on their forum are pointing to a network issue, but I am banging my head trying to get the ESPHOME mediaplayer to work on this ESP MUSE Lux…

Edit: Crossing subnets does not work (ooh, the joys of unifi) and media_player / mode: stereo will not work either (produces white noise).

Reflashed with following esphome yaml (on same subnet as HA instance) and all is fine now:

substitutions:
  name: "raspiaudio-muse-luxe"
  friendly_name: "RaspiAudio Muse Luxe"

esphome:
  name: "${name}"
  name_add_mac_suffix: false
  project:
    name: raspiaudio.muse-luxe
    version: "1.0"

esp32:
  board: esp-wrover-kit
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

# Enable over-the-air updates
ota:

# Enable Web server
web_server:
  port: 80

i2c:
  sda: GPIO18
  scl: GPIO23

# dashboard_import:
#   package_import_url: github://esphome/media-players/raspiaudio-muse-luxe.yaml@main

wifi:
  networks:
  - ssid: !secret wifi_ssid
    password: !secret wifi_pw
#  use_address: 192.168.12.127

improv_serial:

external_components:
  - source: github://pr#3552
    components: [es8388]
    refresh: 0s

media_player:
  - platform: i2s_audio
    name: ${friendly_name}
    dac_type: external
    i2s_lrclk_pin: GPIO25
    i2s_dout_pin: GPIO26
    i2s_bclk_pin: GPIO5
#    i2s_lrclk_pin: GPIO33
#    i2s_dout_pin: GPIO22
#    i2s_bclk_pin: GPIO19
    mode: mono    # stereo will not work as of ESPHOME v. 2022.12
    mute_pin:
      number: GPIO21
      inverted: true

es8388:

sensor:
 - platform: adc
   pin: GPIO33
   name: ${name} Battery
   icon: "mdi:battery-outline"
   device_class: voltage
   state_class: measurement
   unit_of_measurement: V
   update_interval: 15s
   accuracy_decimals: 3
   attenuation: 11db
   raw: true
   filters:
    - multiply: 0.00173913 # 2300 -> 4, for attenuation 11db, based on Olivier's code
    - exponential_moving_average:
        alpha: 0.2
        send_every: 2
    - delta: 0.002
 - platform: wifi_signal
   name: ${friendly_name} WiFi Signal
   update_interval: 60s
 - platform: uptime
   name: ${friendly_name} Uptime
   id: uptime_s
   update_interval: 60s

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO19
      inverted: true
      mode:
        input: true
        pullup: true
    name: ${friendly_name} Volume Up
    on_click:
      - media_player.volume_up:
  - platform: gpio
    pin:
      number: GPIO32
      inverted: true
      mode:
        input: true
        pullup: true
    name: ${friendly_name} Volume Down
    on_click:
      - media_player.volume_down:
  - platform: gpio
    pin:
      number: GPIO12
      inverted: true
      mode:
        input: true
        pullup: true
    name: ${friendly_name} Play Button
    on_click:
      - media_player.toggle:

light:
  - platform: fastled_clockless
    name: ${friendly_name}
    pin: GPIO22
    chipset: SK6812
    num_leds: 1
    rgb_order: grb

text_sensor:
  - platform: wifi_info
    ip_address:
      name: ${name}_ip
    ssid:
      name: ${name}_ssid
    bssid:
      name: ${name}_bssid
  - platform: version
    name: ${friendly_name} ESPHome Version
  - platform: template
    name: ${friendly_name} Uptime (formatted)
    lambda: |-
      uint32_t dur = id(uptime_s).state;
      int dys = 0;
      int hrs = 0;
      int mnts = 0;
      if (dur > 86399) {
        dys = trunc(dur / 86400);
        dur = dur - (dys * 86400);
      }
      if (dur > 3599) {
        hrs = trunc(dur / 3600);
        dur = dur - (hrs * 3600);
      }
      if (dur > 59) {
        mnts = trunc(dur / 60);
        dur = dur - (mnts * 60);
      }
      char buffer[17];
      sprintf(buffer, "%ud %02uh %02um %02us", dys, hrs, mnts, dur);
      return {buffer};
    icon: mdi:clock-start
    update_interval: 60s

switch:
  # Switch to restart the device
  - platform: restart
    name: ${name}_restart

stereo mode now works under ESPHome 2022.12.8