I have a Seeed Studio Xiao ESP32-C3 that I want to connect to a DFplayer mini as part of a bigger project. Just testing the DFPlayer component, I can successfully compile the project as long as I leave out any use of ANY lambda in the api service calls to control the DFPlayer.
This an extract from the failed install log
...
Archiving .pioenvs/aa-test/lib47c/libnoise-c.a
Archiving .pioenvs/aa-test/lib2b5/libsodium.a
Linking .pioenvs/aa-test/firmware.elf
/data/cache/platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: .pioenvs/aa-test/src/main.o: in function `esphome::api::APINoiseContext::set_psk(std::array<unsigned char, 32u>)':
/data/build/aa-test/src/esphome/components/api/api_noise_context.h:14: undefined reference to `long esphome::api::get_execute_arg_value<long>(esphome::api::ExecuteServiceArgument const&)'
/data/cache/platformio/packages/toolchain-riscv32-esp/bin/../lib/gcc/riscv32-esp-elf/8.4.0/../../../../riscv32-esp-elf/bin/ld: .pioenvs/aa-test/src/main.o: in function `esphome::api::ListEntitiesServicesArgument::ListEntitiesServicesArgument()':
/data/build/aa-test/src/esphome/components/api/api_pb2.h:847: undefined reference to `esphome::api::enums::ServiceArgType esphome::api::to_service_arg_type<long>()'
collect2: error: ld returned 1 exit status
*** [.pioenvs/aa-test/firmware.elf] Error 1
...
========================= [FAILED] Took 66.04 seconds =========================
In the ESPHome logs I get this
...
2023-10-30 22:31:21,590 INFO 304 GET /devices (0.0.0.0) 6.13ms
2023-10-30 22:31:25,414 INFO 200 GET /edit?configuration=aa-test.yaml (0.0.0.0) 1.97ms
2023-10-30 22:31:25,492 INFO 200 GET /static/js/esphome/monaco-editor/esm/vs/editor/editor.worker.js (0.0.0.0) 1.85ms
2023-10-30 22:31:25,503 INFO 101 GET /ace (0.0.0.0) 1.23ms
2023-10-30 22:31:25,519 INFO Running command 'esphome --dashboard -q vscode --ace /config/esphome'
2023-10-30 22:31:25,528 INFO 200 GET /static/js/esphome/c.5cd5d307.js (0.0.0.0) 1.29ms
2023-10-30 22:31:32,738 INFO 200 GET /static/schema/substitutions.json (0.0.0.0) 1.77ms
2023-10-30 22:35:05,923 INFO 200 GET /devices (0.0.0.0) 6.47ms
...
My current stripped down test yaml is
substitutions:
name: "aa-test"
friendly_name: "AA Test"
uart_tx_pin: GPIO21 # D6 - GPIO07
uart_rx_pin: GPIO20 # D7 - GPIO10
uart_baud_rate: "9600"
uart_parity: NONE
uart_stop_bits: "1"
esphome:
name: ${name}
friendly_name: ${friendly_name}
platformio_options:
board_build.flash_mode: dio
esp32:
board: esp32-c3-devkitm-1 #seeed_xiao_esp32c3
variant: esp32c3
framework:
type: esp-idf
api:
encryption:
key: !secret api_encryption_key
services:
- service: dfplayer_next
then:
- dfplayer.play_next:
- service: dfplayer_previous
then:
- dfplayer.play_previous:
- service: dfplayer_play
variables:
file: int
then:
- dfplayer.play: !lambda 'return file;'
- service: dfplayer_set_device_tf
then:
- dfplayer.set_device: TF_CARD
- service: dfplayer_set_device_usb
then:
- dfplayer.set_device: USB
- service: dfplayer_sleep
then:
- dfplayer.sleep
- service: dfplayer_reset
then:
- dfplayer.reset
- service: dfplayer_start
then:
- dfplayer.start
- service: dfplayer_pause
then:
- dfplayer.pause
- service: dfplayer_stop
then:
- dfplayer.stop
- service: dfplayer_random
then:
- dfplayer.random
- service: dfplayer_volume_up
then:
- dfplayer.volume_up
- service: dfplayer_volume_down
then:
- dfplayer.volume_down
ota:
password: !secret ota_key
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "AA Test Fallback Hotspot"
password: !secret ap_password
logger:
hardware_uart: USB_SERIAL_JTAG #UART0
level: DEBUG
captive_portal:
web_server:
uart:
id: uart_to_mp3
tx_pin: ${uart_tx_pin}
rx_pin: ${uart_rx_pin}
baud_rate: ${uart_baud_rate}
dfplayer:
on_finished_playback:
then:
- logger.log: "Playback finished"
The above code fails, however, if I remove the following lines, it links successfully
- service: dfplayer_play
variables:
file: int
then:
- dfplayer.play: !lambda 'return file;'
Is this a Seeed Studio issue, DFPlayer issue, lambda or just my my bad YAML? I have tried various configurations and this is where I am at the moment. Any ideas?