Hi Homies !
I have a custom code that used to work fine (months ago) but does not compile any more as there are unresolved externals.
external_components:
- source:
type: git
url: https://github.com/robertklep/esphome-custom-component
components: [ custom, custom_component ]
...
custom_component:
- id: cuart
lambda: |-
auto modBus = new esphome::customUARTComponent( id(mod_bus) );
modBus->setrtspin( id(modbus_xmit) );
App.register_component( modBus );
auto vfd1 = new esphome::ModbusRTUDeviceVFD( 0x11, "vfd1" );
vfd1->set_parent( modBus );
App.register_component( vfd1 );
auto vfd2 = new esphome::ModbusRTUDeviceVFD( 0x12, "vfd2" );
vfd2->set_parent( modBus );
App.register_component( vfd2 );
vfd1->setup();
vfd2->setup();
return { vfd1, vfd2 };
...
the custom code invokes:
register_service(&ModbusRTUDeviceVFD::on_run, fullName( “run_motor” ), { “power” }) ;
the custom class is derived from CustomAPIDevice (already changed) and PollingComponent (used to be Component but loop was no longer envoked) as described here:
https://community.home-assistant.io/t/compile-problem-with-custom-component-and-register-service/494273
class ModbusRTUDevice : public PollingComponent, public CustomAPIDevice { …}
platformio_options:
build_flags: -DUSE_API_HOMEASSISTANT_STATES -DUSE_API_SERVICES
have been set but were already set correctly in defines.h user_services.h
The linker returns:
Linking .pioenvs/poolcontrol/firmware.elf
/data/cache/platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: .pioenvs/poolcontrol/src/customuart/modbusDeviceVFD.cpp.o:(.literal._ZN7esphome3api18UserServiceDynamicIJiEE15execute_serviceERKNS0_21ExecuteServiceRequestE[_ZN7esphome3api18UserServiceDynamicIJiEE15execute_serviceERKNS0_21ExecuteServiceRequestE]+0x0): undefined reference to `_ZN7esphome3api21get_execute_arg_valueIiEET_RKNS0_22ExecuteServiceArgumentE'
/data/cache/platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: .pioenvs/poolcontrol/src/customuart/modbusDeviceVFD.cpp.o:(.literal._ZN7esphome3api18UserServiceDynamicIJiEE28encode_list_service_responseEv[_ZN7esphome3api18UserServiceDynamicIJiEE28encode_list_service_responseEv]+0x0): undefined reference to `_ZN7esphome3api19to_service_arg_typeIiEENS0_5enums14ServiceArgTypeEv'
/data/cache/platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: .pioenvs/poolcontrol/src/customuart/modbusDeviceVFD.cpp.o: in function `_ZN7esphome3api18UserServiceDynamicIJiEE8execute_INS_11FixedVectorINS0_22ExecuteServiceArgumentEEEJLi0EEEEvRKT_NS_3seqIJXspT0_EEEE':
/config/esphome/.esphome/build/poolcontrol/src/esphome/components/api/user_services.h:105:(.text._ZN7esphome3api18UserServiceDynamicIJiEE15execute_serviceERKNS0_21ExecuteServiceRequestE[_ZN7esphome3api18UserServiceDynamicIJiEE15execute_serviceERKNS0_21ExecuteServiceRequestE]+0x1b): undefined reference to `_ZN7esphome3api21get_execute_arg_valueIiEET_RKNS0_22ExecuteServiceArgumentE'
/data/cache/platformio/packages/toolchain-xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/bin/ld: .pioenvs/poolcontrol/src/customuart/modbusDeviceVFD.cpp.o: in function `_ZN7esphome3api18UserServiceDynamicIJiEE28encode_list_service_responseEv':
/config/esphome/.esphome/build/poolcontrol/src/esphome/components/api/user_services.h:83:(.text._ZN7esphome3api18UserServiceDynamicIJiEE28encode_list_service_responseEv[_ZN7esphome3api18UserServiceDynamicIJiEE28encode_list_service_responseEv]+0x2a): undefined reference to `_ZN7esphome3api19to_service_arg_typeIiEENS0_5enums14ServiceArgTypeEv'
collect2: error: ld returned 1 exit status
**** [.pioenvs/poolcontrol/firmware.elf] Error 1*
The reason I implemented it as custom were that
- My Modbus RTU uses echoing which was not supported then
- many devices of different types share this Modbus connection (which might not be supported)
I also used to dynamically register sensors - which does not result in an error but the sensors do no longer appear. I have a workaround for that but don’t know why something that is supposed to work and has worked for years …
ESPHOME framework is actualized every month (or even more often) and every time it is a surprise what will fail next… I doubt switching to the “new concept” of external components will have any other benefit than causing even more work for user implementations not offered and new releases will be flooding with all there new features and new flaws ![]()
Any help or do i have to drop the code and rewrite code outside of esphome ?