Help for DFPlayer

Hi everyone,

I’m new with HA and i want to use a DFPlayer with a esp32-C3.

But, when i try to build my code, i have an error for just one APIservice to remote the DFPlayer :

  - service: dfplayer_play
    variables:
      file: int
    then:
      - dfplayer.play: !lambda 'return file;'

And my error is :

FO Reading configuration /config/esphome/wemos-pico.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing wemos-pico (board: esp32-c3-devkitm-1; framework: espidf; platform: platformio/espressif32 @ 3.3.2)
--------------------------------------------------------------------------------
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
 - framework-espidf @ 3.40302.0 (4.3.2) 
 - tool-cmake @ 3.16.9 
 - tool-ninja @ 1.10.2 
Reading CMake configuration...
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- noise-c @ 0.1.4
|   |-- libsodium @ 1.10018.1
Compiling /data/wemos-pico/.pioenvs/wemos-pico/src/main.o
Linking /data/wemos-pico/.pioenvs/wemos-pico/firmware.elf
/data/cache/platformio/packages/toolchain-riscv-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /data/wemos-pico/.pioenvs/wemos-pico/src/main.o: in function `void esphome::api::UserServiceBase<long>::execute_<0>(std::vector<esphome::api::ExecuteServiceArgument, std::allocator<esphome::api::ExecuteServiceArgument> >, esphome::seq<0>)':
/config/esphome/.esphome/build/wemos-pico/src/esphome/components/api/user_services.h:56: undefined reference to `long esphome::api::get_execute_arg_value<long>(esphome::api::ExecuteServiceArgument const&)'
/data/cache/platformio/packages/toolchain-riscv-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: /data/wemos-pico/.pioenvs/wemos-pico/src/main.o: in function `esphome::api::ListEntitiesServicesArgument::ListEntitiesServicesArgument()':
/config/esphome/.esphome/build/wemos-pico/src/esphome/components/api/api_pb2.h:796: undefined reference to `esphome::api::enums::ServiceArgType esphome::api::to_service_arg_type<long>()'
collect2: error: ld returned 1 exit status
*** [/data/wemos-pico/.pioenvs/wemos-pico/firmware.elf] Error 1
========================= [FAILED] Took 136.18 seconds =========================

So, because of that, i can’t try my DFPlayer with HA (the others APIservices seems ok but i can’t play a song with these services in my YAML)

Here my YAML (build ok) :

esphome:
  name: wemos-pico
  platformio_options:
    board_build.flash_mode: dio
  

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf
    platform_version: 3.3.2
    sdkconfig_options:
      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y

uart:
  tx_pin: GPIO4
  rx_pin: GPIO5
  baud_rate: 9600

dfplayer:

  on_finished_playback:
    then:
      logger.log: 'Somebody press play!'


         

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "DxBtcVUodE+AsnZ226eVS5jI6n2ZbHJAsxLNWJjeFFc="    
  
  services:
    - service: dfplayer_next
      then:
        - dfplayer.play_next:

    - service: dfplayer_previous
      then:
        - dfplayer.play_previous:   

    - service: dfplayer_start
      then:
      - dfplayer.start
      
    - service: dfplayer_play
      variables:
        file: int
      then:
        - dfplayer.play: !lambda 'return file;'
ota:
  password: "2c77524645aaea56d8e697bdd02016e7"

wifi:
  power_save_mode: LIGHT
  fast_connect: true
  ssid: "Redmi Note 8 Pro"
  password: "***************" 

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

esp32_ble_tracker:
sensor:

  - platform: adc
    name: "Battery voltage"
    pin: GPIO3
    accuracy_decimals: 2
    update_interval: 2s
    attenuation: 11dB
    filters:
      - multiply: 2.0  # The voltage divider requires us to multiply by 2

  # RSSI based on MAC address
  - platform: ble_rssi
    mac_address: ****************
    name: "SmartWatch RSSI value"

I tried to clean the build files and create a new composant but both failed.

Anyone an idea ?

(Sorry for my bad english :D)

Tkank’s :slight_smile:

Nobody ?

I don’t find a solution.

I ran into the same issue when testing something, also on an ESP32-C3. Changing the variable from int to float did the trick for me, your mileage may vary though.

1 Like

@hasselhoff Been struggling with a DFPlayer on a Xiao ESP32C3 and this solved the problem!

Thank you!