ESPHome  2024.12.2
user_services.cpp
Go to the documentation of this file.
1 #include "user_services.h"
2 #include "esphome/core/log.h"
3 
4 namespace esphome {
5 namespace api {
6 
7 template<> bool get_execute_arg_value<bool>(const ExecuteServiceArgument &arg) { return arg.bool_; }
8 template<> int32_t get_execute_arg_value<int32_t>(const ExecuteServiceArgument &arg) {
9  if (arg.legacy_int != 0)
10  return arg.legacy_int;
11  return arg.int_;
12 }
13 template<> float get_execute_arg_value<float>(const ExecuteServiceArgument &arg) { return arg.float_; }
14 template<> std::string get_execute_arg_value<std::string>(const ExecuteServiceArgument &arg) { return arg.string_; }
15 template<> std::vector<bool> get_execute_arg_value<std::vector<bool>>(const ExecuteServiceArgument &arg) {
16  return arg.bool_array;
17 }
18 template<> std::vector<int32_t> get_execute_arg_value<std::vector<int32_t>>(const ExecuteServiceArgument &arg) {
19  return arg.int_array;
20 }
21 template<> std::vector<float> get_execute_arg_value<std::vector<float>>(const ExecuteServiceArgument &arg) {
22  return arg.float_array;
23 }
24 template<> std::vector<std::string> get_execute_arg_value<std::vector<std::string>>(const ExecuteServiceArgument &arg) {
25  return arg.string_array;
26 }
27 
31 template<> enums::ServiceArgType to_service_arg_type<std::string>() { return enums::SERVICE_ARG_TYPE_STRING; }
32 template<> enums::ServiceArgType to_service_arg_type<std::vector<bool>>() { return enums::SERVICE_ARG_TYPE_BOOL_ARRAY; }
33 template<> enums::ServiceArgType to_service_arg_type<std::vector<int32_t>>() {
35 }
36 template<> enums::ServiceArgType to_service_arg_type<std::vector<float>>() {
38 }
39 template<> enums::ServiceArgType to_service_arg_type<std::vector<std::string>>() {
41 }
42 
43 } // namespace api
44 } // namespace esphome
enums::ServiceArgType to_service_arg_type< bool >()
bool get_execute_arg_value< bool >(const ExecuteServiceArgument &arg)
enums::ServiceArgType to_service_arg_type< float >()
enums::ServiceArgType to_service_arg_type< int32_t >()
float get_execute_arg_value< float >(const ExecuteServiceArgument &arg)
int32_t get_execute_arg_value< int32_t >(const ExecuteServiceArgument &arg)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7