Open THorst92 opened 1 year ago
Found something: If I use the following configuration
- service: set_textid
variables:
new_textid: int
then:
- sensor.template.publish:
id: textid
state: !lambda return (float)new_textid;
it is transferred in the main.c into
api_userservicetrigger = new api::UserServiceTrigger<int32_t>("set_textid", {"new_textid"});
api_apiserver->register_user_service(api_userservicetrigger);
automation = new Automation<int32_t>(api_userservicetrigger);
but there seems no template function for int32_t
in the user_services.cpp
.
Example for the function to_service_arg_type
:
template<> enums::ServiceArgType to_service_arg_type<bool>() { return enums::SERVICE_ARG_TYPE_BOOL; }
template<> enums::ServiceArgType to_service_arg_type<int>() { return enums::SERVICE_ARG_TYPE_INT; }
template<> enums::ServiceArgType to_service_arg_type<float>() { return enums::SERVICE_ARG_TYPE_FLOAT; }
template<> enums::ServiceArgType to_service_arg_type<std::string>() { return enums::SERVICE_ARG_TYPE_STRING; }
template<> enums::ServiceArgType to_service_arg_type<std::vector<bool>>() { return enums::SERVICE_ARG_TYPE_BOOL_ARRAY; }
template<> enums::ServiceArgType to_service_arg_type<std::vector<int>>() { return enums::SERVICE_ARG_TYPE_INT_ARRAY; }
template<> enums::ServiceArgType to_service_arg_type<std::vector<float>>() {
return enums::SERVICE_ARG_TYPE_FLOAT_ARRAY;
}
template<> enums::ServiceArgType to_service_arg_type<std::vector<std::string>>() {
return enums::SERVICE_ARG_TYPE_STRING_ARRAY;
}
When I change it to
- service: set_textid
variables:
new_textid: float
then:
- sensor.template.publish:
id: textid
state: !lambda return new_textid;
it works fine.
I think that it is dependent on the board if an int
has a size of 2 bytes or 4 bytes.
Maybe it would be better to exchange all int
with int32_t
in the user_services.cpp
.
The problem
The build of the RPi Pico W firmware fails as soon as I add the
service
section in theapi
section. Without theservice
section I have no problems. Theservice
section was already successfully tested on an esp8266 and esp32.Which version of ESPHome has the issue?
2022.12.8
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
2023.2.0
What platform are you using?
RP2040
Board
Raspberry Pi Pico W
Component causing the issue
api
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response