I’m quite desperate to port following Arduino library to ESPHome.
I spent about 6 - 8 hours on it without any luck.
It should not be that hard to create a custom component and call the functions, and I managed to compile the exaple custom component.
Unfortunately I don’t get there with built errors.
I need to change the .h file with the esphome.h to add the public component I suppose:
#include "esphome.h"
class TR064 : public Component {
yaml file should be straightforward also:
I placed the .c and .h in a subfolder “./custom_components/tr064” and seems to picked up by the compiler.
custom_component:
- lambda: |-
auto tr064 = new TR064();
return {tr064};
components:
- id: tr064
Built errors like:
error: redefinition of ‘struct MD5Context’
Seems to make sense, since this is used in ESPHome somewhere, removing the “#include <MD5Builder.h>” in the .h file does not seems to work because it’s needed there.
“using namespace esphome;” seems to be to be the solution for this right?
Still the error is there, and a new one appears:
“error: call of overloaded ‘delay(int)’ is ambiguous”
Found a similar topic, also tried the example in it to understand the custom component:
But the answers are like “you can’t read, read the docs you stupid … it’s more than that!”.
Please help me to convert this library, I need this so hard for my project!
Okay,
The code below compiles.
When referring to github I think missing “: public Component” will cause failures with the custom component.
Moving the library local and add this will not solve the custom component.
custom_component:
- lambda: |-
auto my_custom = new TR064();
return {my_custom};
components:
- id: my_custom_id
error: expected type-specifier before 'TR064'
error: could not convert '{my_custom}' from '<brace-enclosed initializer list>' to 'std::vector<esphome::Component*>'
Yes… makes sense, is used somewhere in MQTT part and in the header of the library.
How to prevent his, can’t delete te include in the header because it’s needed for other functions.