ESPHome  2022.9.1
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_; }
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<int>>() { return enums::SERVICE_ARG_TYPE_INT_ARRAY; }
34 template<> enums::ServiceArgType to_service_arg_type<std::vector<float>>() {
36 }
37 template<> enums::ServiceArgType to_service_arg_type<std::vector<std::string>>() {
39 }
40 
41 } // namespace api
42 } // 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 >()
int get_execute_arg_value< int >(const ExecuteServiceArgument &arg)
float get_execute_arg_value< float >(const ExecuteServiceArgument &arg)
Definition: a4988.cpp:4
enums::ServiceArgType to_service_arg_type< int >()