Disclaimer: I tried to get help from chatgpt.
We had issues with getting external components to work, so we cut it down to the most basic: hello_world.
It seems like the external component isn’t being used
We are probably missing something obvious.
The output from compiling is this:
Processing helloworldtest (board: esp32-c3-devkitm-1; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
- toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
Dependency Graph
|-- WiFi @ 2.0.0
|-- ESPmDNS @ 2.0.0
Compiling .pioenvs/helloworldtest/src/main.cpp.o
Compiling .pioenvs/helloworldtest/lib18f/WiFi/WiFiAP.cpp.o
/config/hello_world_test.yaml: In lambda function:
/config/hello_world_test.yaml:14:24: error: expected type-specifier before 'HelloWorld'
auto hello = new HelloWorld();
^~~~~~~~~~
/config/hello_world_test.yaml:16:20: error: could not convert '{hello}' from '<brace-enclosed initializer list>' to 'std::vector<esphome::Component*>'
return {hello};
^
Compiling .pioenvs/helloworldtest/lib18f/WiFi/WiFiClient.cpp.o
*** [.pioenvs/helloworldtest/src/main.cpp.o] Error 1
========================== [FAILED] Took 3.75 seconds ==========================
hello_world_test.yaml
external_components:
- source:
type: local
path: my_components
components: [hello_world]
esphome:
name: helloworldtest
platform: ESP32
board: esp32-c3-devkitm-1
custom_component:
- lambda: |-
auto hello = new HelloWorld();
App.register_component(hello);
return {hello};
logger:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
tree config/my_components/hello_world
config/my_components/hello_world/
├── esphome.yaml
├── hello_world.cpp
├── hello_world.h
└── __init__.py
esphome.yaml
name: "Hello World Component"
files:
- hello_world.h
- hello_world.cpp
hello_world.cpp
#include "hello_world.h"
hello_world.h
#error "hello_world.h included" <-- test, this does not trigger
#pragma once
#include "esphome.h"
class HelloWorld : public Component {
public:
void setup() override {
ESP_LOGI("hello_world", "Hello, World!");
}
};
init.py
# Empty file to register the component