esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

ld2410 component switch not compiling #4832

Closed elminos closed 1 year ago

elminos commented 1 year ago

The problem

Following this issue now we can edit the settings of the sensor online while having engineering mode enabled.

As explained in the documentation we have to enable the engineering mode switch. As soon as I put:

switch:
  - platform: ld2410
    engineering_mode:
      name: "engineering mode"
    bluetooth:
      name: "control bluetooth"

The .yaml throws these errors in the log while compiling:

undefined reference to `esphome::switch_::Switch::turn_on()'
undefined reference to `esphome::switch_::Switch::turn_off()'

Which version of ESPHome has the issue?

2023.8.2

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.8.3

What platform are you using?

ESP32

Board

esp32dev

Component causing the issue

ld2410

Example YAML snippet

esphome:
  name: presencia-comedor
  friendly_name: Presencia-comedor

esp32:
  board: esp32dev
  framework:
    type: esp-idf

# Enable logging
logger:
#  level: VERBOSE

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

ota:
  password: REPLACEME

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Presencia-Comedor"
    password: !secret ap_password

#Communication with LD2410c
uart:
  id: ld2410_uart
  tx_pin: 1
  rx_pin: 3
  baud_rate: 256000
  parity: NONE
  stop_bits: 1

ld2410:
  uart_id: ld2410_uart
  throttle: 1500ms
  id: ld2410_comp

switch:
  - platform: ld2410
    engineering_mode:
      name: "engineering mode"
    bluetooth:
      name: "control bluetooth"

number:
  - platform: ld2410
    timeout:
      name: timeout
    light_threshold:
      name: light threshold
    max_move_distance_gate:
      name: max move distance gate
    max_still_distance_gate:
      name: max still distance gate
    g0:
      move_threshold:
        name: g0 move threshold
      still_threshold:
        name: g0 still threshold
    g1:
      move_threshold:
        name: g1 move threshold
      still_threshold:
        name: g1 still threshold
    g2:
      move_threshold:
        name: g2 move threshold
      still_threshold:
        name: g2 still threshold
    g3:
      move_threshold:
        name: g3 move threshold
      still_threshold:
        name: g3 still threshold
    g4:
      move_threshold:
        name: g4 move threshold
      still_threshold:
        name: g4 still threshold
    g5:
      move_threshold:
        name: g5 move threshold
      still_threshold:
        name: g5 still threshold
    g6:
      move_threshold:
        name: g6 move threshold
      still_threshold:
        name: g6 still threshold
    g7:
      move_threshold:
        name: g7 move threshold
      still_threshold:
        name: g7 still threshold
    g8:
      move_threshold:
        name: g8 move threshold
      still_threshold:
        name: g8 still threshold

binary_sensor:
  - platform: ld2410
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target
    out_pin_presence_status:
      name: out pin presence status

sensor:
  - platform: ld2410
    light:
      name: light
    moving_distance:
      name : Moving Distance
    still_distance:
      name: Still Distance
    moving_energy:
      name: Move Energy
    still_energy:
      name: Still Energy
    detection_distance:
      name: Detection Distance
    g0:
      move_energy:
        name: g0 move energy
      still_energy:
        name: g0 still energy
    g1:
      move_energy:
        name: g1 move energy
      still_energy:
        name: g1 still energy
    g2:
      move_energy:
        name: g2 move energy
      still_energy:
        name: g2 still energy
    g3:
      move_energy:
        name: g3 move energy
      still_energy:
        name: g3 still energy
    g4:
      move_energy:
        name: g4 move energy
      still_energy:
        name: g4 still energy
    g5:
      move_energy:
        name: g5 move energy
      still_energy:
        name: g5 still energy
    g6:
      move_energy:
        name: g6 move energy
      still_energy:
        name: g6 still energy
    g7:
      move_energy:
        name: g7 move energy
      still_energy:
        name: g7 still energy
    g8:
      move_energy:
        name: g8 move energy
      still_energy:
        name: g8 still energy

Anything in the logs that might be useful for us?

Here is the log:

INFO ESPHome 2023.8.2
INFO Reading configuration /config/esphome/presencia-comedor.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing presencia-comedor (board: esp32dev; framework: espidf; platform: platformio/espressif32@5.4.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - framework-espidf @ 3.40405.230623 (4.4.5) 
 - tool-cmake @ 3.16.4 
 - tool-ninja @ 1.7.1 
 - toolchain-esp32ulp @ 2.35.0-20220830 
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Reading CMake configuration...
Dependency Graph
|-- noise-c @ 0.1.4
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/api_connection.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/api_frame_helper.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/api_pb2.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/api_pb2_service.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/api_server.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/list_entities.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/proto.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/subscribe_state.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/user_services.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/binary_sensor/automation.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/binary_sensor/binary_sensor.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/binary_sensor/filter.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/esp32/gpio.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/esp32/preferences.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/ld2410.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/number/gate_threshold_number.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/number/light_threshold_number.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/number/max_distance_timeout_number.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/logger/logger.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/md5/md5.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/mdns/mdns_component.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/mdns/mdns_esp32.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/mdns/mdns_esp8266.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/mdns/mdns_host.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/mdns/mdns_rp2040.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/network/util.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/number/automation.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/number/number.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/number/number_call.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/number/number_traits.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ota/ota_backend_arduino_esp32.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ota/ota_backend_arduino_esp8266.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ota/ota_backend_arduino_rp2040.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ota/ota_backend_esp_idf.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ota/ota_component.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/sensor/automation.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/sensor/filter.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/sensor/sensor.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/socket/bsd_sockets_impl.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/socket/lwip_raw_tcp_impl.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/socket/socket.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/uart/uart.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/uart/uart_component.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/uart/uart_component_esp32_arduino.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/uart/uart_component_esp8266.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/uart/uart_component_esp_idf.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/uart/uart_component_rp2040.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/uart/uart_debugger.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/wifi/wifi_component.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/wifi/wifi_component_esp32_arduino.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/wifi/wifi_component_esp8266.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/wifi/wifi_component_esp_idf.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/wifi/wifi_component_pico_w.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/application.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/component.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/component_iterator.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/controller.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/entity_base.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/helpers.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/log.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/scheduler.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/string_ref.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/util.o
Compiling /data/presencia-comedor/.pioenvs/presencia-comedor/src/main.o
Linking /data/presencia-comedor/.pioenvs/presencia-comedor/firmware.elf
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection14switch_commandERKNS0_20SwitchCommandRequestE+0x8): undefined reference to `esphome::switch_::Switch::turn_on()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection14switch_commandERKNS0_20SwitchCommandRequestE+0xc): undefined reference to `esphome::switch_::Switch::turn_off()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/api/api_connection.o: in function `esphome::api::APIConnection::switch_command(esphome::api::SwitchCommandRequest const&)':
/config/esphome/.esphome/build/presencia-comedor/src/esphome/components/api/api_connection.cpp:485: undefined reference to `esphome::switch_::Switch::turn_on()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /config/esphome/.esphome/build/presencia-comedor/src/esphome/components/api/api_connection.cpp:487: undefined reference to `esphome::switch_::Switch::turn_off()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/ld2410.o:(.literal._ZN7esphome6ld241015LD2410Component21handle_periodic_data_EPhi+0x0): undefined reference to `esphome::switch_::Switch::publish_state(bool)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/ld2410.o:(.literal._ZN7esphome6ld241015LD2410Component11dump_configEv+0x7c): undefined reference to `esphome::switch_::log_switch(char const*, char const*, char const*, esphome::switch_::Switch*)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/ld2410.o: in function `esphome::ld2410::LD2410Component::handle_periodic_data_(unsigned char*, int)':
/config/esphome/.esphome/build/presencia-comedor/src/esphome/components/ld2410/ld2410.cpp:167: undefined reference to `esphome::switch_::Switch::publish_state(bool)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/ld2410.o: in function `esphome::ld2410::LD2410Component::dump_config()':
/config/esphome/.esphome/build/presencia-comedor/src/esphome/components/ld2410/ld2410.cpp:27: undefined reference to `esphome::switch_::log_switch(char const*, char const*, char const*, esphome::switch_::Switch*)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/ld2410.o: in function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()':
/data/cache/platformio/packages/toolchain-xtensa-esp32/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.h:657: undefined reference to `esphome::switch_::log_switch(char const*, char const*, char const*, esphome::switch_::Switch*)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/components/ld2410/ld2410.o: in function `esphome::ld2410::LD2410Component::handle_ack_data_(unsigned char*, int)':
/config/esphome/.esphome/build/presencia-comedor/src/esphome/components/ld2410/ld2410.cpp:410: undefined reference to `esphome::switch_::Switch::publish_state(bool)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/main.o:(.literal._Z5setupv+0x98): undefined reference to `vtable for esphome::ld2410::EngineeringModeSwitch'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/main.o:(.literal._Z5setupv+0xb4): undefined reference to `vtable for esphome::ld2410::BluetoothSwitch'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/main.o:(.literal._Z5setupv+0x390): undefined reference to `esphome::switch_::Switch::Switch()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/main.o: in function `setup()':
/config/esphome/.esphome/build/presencia-comedor/src/main.cpp:233: undefined reference to `esphome::switch_::Switch::Switch()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /config/esphome/.esphome/build/presencia-comedor/src/main.cpp:257: undefined reference to `esphome::switch_::Switch::Switch()'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/controller.o:(.literal._ZN7esphome10Controller16setup_controllerEb+0x20): undefined reference to `esphome::switch_::Switch::add_on_state_callback(std::function<void (bool)>&&)'
/data/cache/platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /data/presencia-comedor/.pioenvs/presencia-comedor/src/esphome/core/controller.o: in function `esphome::Controller::setup_controller(bool)':
/config/esphome/.esphome/build/presencia-comedor/src/esphome/core/controller.cpp:35: undefined reference to `esphome::switch_::Switch::add_on_state_callback(std::function<void (bool)>&&)'
collect2: error: ld returned 1 exit status
*** [/data/presencia-comedor/.pioenvs/presencia-comedor/firmware.elf] Error 1
========================= [FAILED] Took 164.79 seconds =========================

Additional information

I'm sorry if I'm missing something or this is not the right way to report the problem. This is my first bug report. Thank you for all the hard work.

sebcaps commented 1 year ago

Hello @elminos With

esp32:
  board: esp32dev
  framework:
    type: arduino

compilation is successful. Not skilled enough to get all implications switching from esp-idf to arduino but you may give a try. In the same time, not sure it's related to LD2410 component or switch component.

My 2cent's

SodaWithoutSparkles commented 1 year ago

I found updating the docker container of esphome solved my issue of the ld2410 components not found. I want to document it here cuz this this the first google search github result.

Usually when stuff does not compile I just wipe the cache and starts again. works 90% of the time. I also uses the espidf framework.

also, iirc, switching frameworks cannot be done via ota. you need to physically connect it.

elminos commented 1 year ago

Thank you guys for the feedback. I'm really a rookie here and I'm using Home Assistant OS with the native ESPHome integration.

Following your wipe cache approach I tried the "Clean Build Files" option and now it compiles: image

Not sure if this will happen to more people nor if it's an issue to be addressed or not...

All the best!

SodaWithoutSparkles commented 1 year ago

@elminos if you have solved your issue, mark it as close please.