mirror of
https://github.com/esphome/esphome.git
synced 2025-09-06 05:12:21 +01:00
Merge branch 'helpful_custom_api_error' into integration
This commit is contained in:
@@ -61,7 +61,8 @@ class CustomAPIDevice {
|
|||||||
void register_service(void (T::*callback)(Ts...), const std::string &name,
|
void register_service(void (T::*callback)(Ts...), const std::string &name,
|
||||||
const std::array<std::string, sizeof...(Ts)> &arg_names) {
|
const std::array<std::string, sizeof...(Ts)> &arg_names) {
|
||||||
static_assert(
|
static_assert(
|
||||||
false, "register_service() requires 'custom_services: true' in the 'api:' section of your YAML configuration");
|
sizeof(T) == 0,
|
||||||
|
"register_service() requires 'custom_services: true' in the 'api:' section of your YAML configuration");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -91,7 +92,8 @@ class CustomAPIDevice {
|
|||||||
#else
|
#else
|
||||||
template<typename T> void register_service(void (T::*callback)(), const std::string &name) {
|
template<typename T> void register_service(void (T::*callback)(), const std::string &name) {
|
||||||
static_assert(
|
static_assert(
|
||||||
false, "register_service() requires 'custom_services: true' in the 'api:' section of your YAML configuration");
|
sizeof(T) == 0,
|
||||||
|
"register_service() requires 'custom_services: true' in the 'api:' section of your YAML configuration");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -151,15 +153,17 @@ class CustomAPIDevice {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void subscribe_homeassistant_state(void (T::*callback)(std::string), const std::string &entity_id,
|
void subscribe_homeassistant_state(void (T::*callback)(std::string), const std::string &entity_id,
|
||||||
const std::string &attribute = "") {
|
const std::string &attribute = "") {
|
||||||
static_assert(false, "subscribe_homeassistant_state() requires 'homeassistant_states: true' in the 'api:' section "
|
static_assert(sizeof(T) == 0,
|
||||||
"of your YAML configuration");
|
"subscribe_homeassistant_state() requires 'homeassistant_states: true' in the 'api:' section "
|
||||||
|
"of your YAML configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void subscribe_homeassistant_state(void (T::*callback)(std::string, std::string), const std::string &entity_id,
|
void subscribe_homeassistant_state(void (T::*callback)(std::string, std::string), const std::string &entity_id,
|
||||||
const std::string &attribute = "") {
|
const std::string &attribute = "") {
|
||||||
static_assert(false, "subscribe_homeassistant_state() requires 'homeassistant_states: true' in the 'api:' section "
|
static_assert(sizeof(T) == 0,
|
||||||
"of your YAML configuration");
|
"subscribe_homeassistant_state() requires 'homeassistant_states: true' in the 'api:' section "
|
||||||
|
"of your YAML configuration");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -249,24 +253,26 @@ class CustomAPIDevice {
|
|||||||
global_api_server->send_homeassistant_service_call(resp);
|
global_api_server->send_homeassistant_service_call(resp);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void call_homeassistant_service(const std::string &service_name) {
|
template<typename T = void> void call_homeassistant_service(const std::string &service_name) {
|
||||||
static_assert(false, "call_homeassistant_service() requires 'homeassistant_services: true' in the 'api:' section "
|
static_assert(sizeof(T) == 0, "call_homeassistant_service() requires 'homeassistant_services: true' in the 'api:' "
|
||||||
"of your YAML configuration");
|
"section of your YAML configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T = void>
|
||||||
void call_homeassistant_service(const std::string &service_name, const std::map<std::string, std::string> &data) {
|
void call_homeassistant_service(const std::string &service_name, const std::map<std::string, std::string> &data) {
|
||||||
static_assert(false, "call_homeassistant_service() requires 'homeassistant_services: true' in the 'api:' section "
|
static_assert(sizeof(T) == 0, "call_homeassistant_service() requires 'homeassistant_services: true' in the 'api:' "
|
||||||
"of your YAML configuration");
|
"section of your YAML configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fire_homeassistant_event(const std::string &event_name) {
|
template<typename T = void> void fire_homeassistant_event(const std::string &event_name) {
|
||||||
static_assert(false, "fire_homeassistant_event() requires 'homeassistant_services: true' in the 'api:' section of "
|
static_assert(sizeof(T) == 0, "fire_homeassistant_event() requires 'homeassistant_services: true' in the 'api:' "
|
||||||
"your YAML configuration");
|
"section of your YAML configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T = void>
|
||||||
void fire_homeassistant_event(const std::string &service_name, const std::map<std::string, std::string> &data) {
|
void fire_homeassistant_event(const std::string &service_name, const std::map<std::string, std::string> &data) {
|
||||||
static_assert(false, "fire_homeassistant_event() requires 'homeassistant_services: true' in the 'api:' section of "
|
static_assert(sizeof(T) == 0, "fire_homeassistant_event() requires 'homeassistant_services: true' in the 'api:' "
|
||||||
"your YAML configuration");
|
"section of your YAML configuration");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user