esphome / issues

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

Template Number error #5298

Closed lordzid closed 8 months ago

lordzid commented 8 months ago

The problem

component template number in the latest update compilation error

Which version of ESPHome has the issue?

2023.12.5

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.12.3

What platform are you using?

ESP32

Board

Nodemcu

Component causing the issue

Template Number

Example YAML snippet

esphome:
  name: test
  friendly_name: test

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

api:

ota:

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

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

captive_portal:

number:                              #выбор мелодии
  - platform: template
    name: "MP3 select"
    id: select
    optimistic: true
    min_value: 0
    max_value: 100
    step: 1

Anything in the logs that might be useful for us?

INFO ESPHome 2023.12.5
INFO Reading configuration /config/esphome/test.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing test (board: esp32dev; framework: arduino; platform: platformio/espressif32@5.4.0)
--------------------------------------------------------------------------------
Library Manager: Installing esphome/AsyncTCP-esphome @ 2.0.1
INFO Installing esphome/AsyncTCP-esphome @ 2.0.1
Unpacking  [####################################]  100%
Library Manager: AsyncTCP-esphome@2.0.1 has been installed!
INFO AsyncTCP-esphome@2.0.1 has been installed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
Unpacking  [####################################]  100%
Library Manager: ESPAsyncWebServer-esphome@3.1.0 has been installed!
INFO ESPAsyncWebServer-esphome@3.1.0 has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.0.1
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
Compiling .pioenvs/test/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/test/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/test/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/test/src/esphome/components/api/api_pb2_service.cpp.o
Compiling .pioenvs/test/src/esphome/components/api/api_server.cpp.o
Compiling .pioenvs/test/src/esphome/components/api/list_entities.cpp.o
Compiling .pioenvs/test/src/esphome/components/api/proto.cpp.o
Compiling .pioenvs/test/src/esphome/components/api/subscribe_state.cpp.o
Compiling .pioenvs/test/src/esphome/components/api/user_services.cpp.o
Compiling .pioenvs/test/src/esphome/components/captive_portal/captive_portal.cpp.o
Compiling .pioenvs/test/src/esphome/components/esp32/core.cpp.o
Compiling .pioenvs/test/src/esphome/components/esp32/gpio.cpp.o
Compiling .pioenvs/test/src/esphome/components/esp32/preferences.cpp.o
Compiling .pioenvs/test/src/esphome/components/logger/logger.cpp.o
Compiling .pioenvs/test/src/esphome/components/md5/md5.cpp.o
Compiling .pioenvs/test/src/esphome/components/mdns/mdns_component.cpp.o
Compiling .pioenvs/test/src/esphome/components/mdns/mdns_esp32.cpp.o
Compiling .pioenvs/test/src/esphome/components/mdns/mdns_esp8266.cpp.o
Compiling .pioenvs/test/src/esphome/components/mdns/mdns_host.cpp.o
Compiling .pioenvs/test/src/esphome/components/mdns/mdns_libretiny.cpp.o
Compiling .pioenvs/test/src/esphome/components/mdns/mdns_rp2040.cpp.o
Compiling .pioenvs/test/src/esphome/components/network/util.cpp.o
Compiling .pioenvs/test/src/esphome/components/number/automation.cpp.o
Compiling .pioenvs/test/src/esphome/components/number/number.cpp.o
Compiling .pioenvs/test/src/esphome/components/number/number_call.cpp.o
Compiling .pioenvs/test/src/esphome/components/number/number_traits.cpp.o
Compiling .pioenvs/test/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
Compiling .pioenvs/test/src/esphome/components/ota/ota_backend_arduino_esp8266.cpp.o
Compiling .pioenvs/test/src/esphome/components/ota/ota_backend_arduino_libretiny.cpp.o
Compiling .pioenvs/test/src/esphome/components/ota/ota_backend_arduino_rp2040.cpp.o
Compiling .pioenvs/test/src/esphome/components/ota/ota_backend_esp_idf.cpp.o
Compiling .pioenvs/test/src/esphome/components/ota/ota_component.cpp.o
Compiling .pioenvs/test/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling .pioenvs/test/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling .pioenvs/test/src/esphome/components/socket/lwip_sockets_impl.cpp.o
Compiling .pioenvs/test/src/esphome/components/socket/socket.cpp.o
Compiling .pioenvs/test/src/esphome/components/template/number/template_number.cpp.o
Compiling .pioenvs/test/src/esphome/components/web_server_base/web_server_base.cpp.o
Compiling .pioenvs/test/src/esphome/components/wifi/wifi_component.cpp.o
Compiling .pioenvs/test/src/esphome/components/wifi/wifi_component_esp32_arduino.cpp.o
Compiling .pioenvs/test/src/esphome/components/wifi/wifi_component_esp8266.cpp.o
Compiling .pioenvs/test/src/esphome/components/wifi/wifi_component_esp_idf.cpp.o
Compiling .pioenvs/test/src/esphome/components/wifi/wifi_component_libretiny.cpp.o
Compiling .pioenvs/test/src/esphome/components/wifi/wifi_component_pico_w.cpp.o
Compiling .pioenvs/test/src/esphome/core/application.cpp.o
Compiling .pioenvs/test/src/esphome/core/color.cpp.o
Compiling .pioenvs/test/src/esphome/core/component.cpp.o
Compiling .pioenvs/test/src/esphome/core/component_iterator.cpp.o
Compiling .pioenvs/test/src/esphome/core/controller.cpp.o
Compiling .pioenvs/test/src/esphome/core/entity_base.cpp.o
Compiling .pioenvs/test/src/esphome/core/helpers.cpp.o
Compiling .pioenvs/test/src/esphome/core/log.cpp.o
Compiling .pioenvs/test/src/esphome/core/scheduler.cpp.o
Compiling .pioenvs/test/src/esphome/core/string_ref.cpp.o
Compiling .pioenvs/test/src/esphome/core/time.cpp.o
Compiling .pioenvs/test/src/esphome/core/util.cpp.o
Compiling .pioenvs/test/src/main.cpp.o
Building .pioenvs/test/bootloader.bin
Creating esp32 image...
Successfully created esp32 image.
Generating partitions .pioenvs/test/partitions.bin
Compiling .pioenvs/test/lib293/AsyncTCP-esphome/AsyncTCP.cpp.o
Compiling .pioenvs/test/lib64d/WiFi/WiFi.cpp.o
Compiling .pioenvs/test/lib64d/WiFi/WiFiAP.cpp.o
src/main.cpp:18:28: error: 'esphome::template_::TemplateNumber* select' redeclared as different kind of symbol
 template_::TemplateNumber *select;
                            ^~~~~~
In file included from /data/cache/platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/newlib/platform_include/sys/select.h:21,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/sys-include/sys/types.h:50,
                 from /data/cache/platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/newlib/platform_include/pthread.h:17,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/include/c++/8.4.0/xtensa-esp32-elf/no-rtti/bits/gthr-default.h:48,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/include/c++/8.4.0/xtensa-esp32-elf/no-rtti/bits/gthr.h:151,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/include/c++/8.4.0/ext/atomicity.h:35,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/include/c++/8.4.0/bits/basic_string.h:39,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/include/c++/8.4.0/string:52,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/include/c++/8.4.0/stdexcept:39,
                 from /data/cache/platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/include/c++/8.4.0/array:39,
                 from src/esphome/components/api/api_noise_context.h:3,
                 from src/esphome/components/api/api_frame_helper.h:13,
                 from src/esphome/components/api/api_connection.h:3,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
/data/cache/platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch5/xtensa-esp32-elf/sys-include/sys/select.h:62:5: note: previous declaration 'int select(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
 int select __P ((int __n, fd_set *__readfds, fd_set *__writefds,
     ^~~~~~
src/main.cpp: In function 'void setup()':
src/main.cpp:165:42: error: assignment of function 'int select(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select = new template_::TemplateNumber();
                                          ^
src/main.cpp:166:11: error: request for member 'set_update_interval' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->set_update_interval(60000);
           ^~~~~~~~~~~~~~~~~~~
src/main.cpp:167:11: error: request for member 'set_component_source' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->set_component_source("template.number");
           ^~~~~~~~~~~~~~~~~~~~
src/main.cpp:169:29: error: no matching function for call to 'esphome::Application::register_number(int (&)(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*))'
   App.register_number(select);
                             ^
In file included from src/esphome/components/api/api_connection.h:7,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
src/esphome/core/application.h:121:8: note: candidate: 'void esphome::Application::register_number(esphome::number::Number*)'
   void register_number(number::Number *number) { this->numbers_.push_back(number); }
        ^~~~~~~~~~~~~~~
src/esphome/core/application.h:121:8: note:   no known conversion for argument 1 from 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)' to 'esphome::number::Number*'
src/main.cpp:170:11: error: request for member 'set_name' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->set_name("MP3 select");
           ^~~~~~~~
src/main.cpp:171:11: error: request for member 'set_object_id' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->set_object_id("mp3_select");
           ^~~~~~~~~~~~~
src/main.cpp:172:11: error: request for member 'set_disabled_by_default' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->set_disabled_by_default(false);
           ^~~~~~~~~~~~~~~~~~~~~~~
src/main.cpp:173:11: error: request for member 'traits' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->traits.set_min_value(0.0f);
           ^~~~~~
src/main.cpp:174:11: error: request for member 'traits' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->traits.set_max_value(100.0f);
           ^~~~~~
src/main.cpp:175:11: error: request for member 'traits' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->traits.set_step(1.0f);
           ^~~~~~
src/main.cpp:176:11: error: request for member 'traits' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->traits.set_mode(number::NUMBER_MODE_AUTO);
           ^~~~~~
src/main.cpp:177:11: error: request for member 'set_optimistic' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->set_optimistic(true);
           ^~~~~~~~~~~~~~
src/main.cpp:178:11: error: request for member 'set_initial_value' in '* select', which is of non-class type 'int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)'
   select->set_initial_value(0.0f);
           ^~~~~~~~~~~~~~~~~
Compiling .pioenvs/test/lib64d/WiFi/WiFiClient.cpp.o
In file included from src/esphome/components/api/api_connection.h:7,
                 from src/esphome.h:3,
                 from src/main.cpp:3:
src/esphome/core/application.h: In instantiation of 'C* esphome::Application::register_component(C*) [with C = int(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, timeval*)]':
src/main.cpp:168:32:   required from here
src/esphome/core/application.h:148:19: error: static assertion failed: Only Component subclasses can be registered
     static_assert(std::is_base_of<Component, C>::value, "Only Component subclasses can be registered");
                   ^~~
Archiving .pioenvs/test/lib293/libAsyncTCP-esphome.a
Compiling .pioenvs/test/lib64d/WiFi/WiFiGeneric.cpp.o
Compiling .pioenvs/test/lib64d/WiFi/WiFiMulti.cpp.o
*** [.pioenvs/test/src/main.cpp.o] Error 1
========================= [FAILED] Took 87.87 seconds =========================

Additional information

` INFO ESPHome 2023.12.5 INFO Reading configuration /config/esphome/test.yaml... INFO Generating C++ source... INFO Compiling app... Processing test (board: esp32dev; framework: arduino; platform: platformio/espressif32@5.4.0)

Library Manager: Installing esphome/AsyncTCP-esphome @ 2.0.1 INFO Installing esphome/AsyncTCP-esphome @ 2.0.1 Unpacking [####################################] 100% Library Manager: AsyncTCP-esphome@2.0.1 has been installed! INFO AsyncTCP-esphome@2.0.1 has been installed! Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0 INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0 Unpacking [####################################] 100% Library Manager: ESPAsyncWebServer-esphome@3.1.0 has been installed! INFO ESPAsyncWebServer-esphome@3.1.0 has been installed! Library Manager: Resolving dependencies... INFO Resolving dependencies... HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

ssieb commented 8 months ago

Use a different id: than select.

lordzid commented 8 months ago

thank you, it helped

Используйте другой, id:чем select.