#include <custom_api_device.h>
|
bool | is_connected () const |
| Return if a client (such as Home Assistant) is connected to the native API.
|
|
template<typename T , typename... Ts> |
void | register_service (void(T::*callback)(Ts...), const std::string &name, const std::array< std::string, sizeof...(Ts)> &arg_names) |
| Register a custom native API service that will show up in Home Assistant.
|
|
template<typename T > |
void | register_service (void(T::*callback)(), const std::string &name) |
| Register a custom native API service that will show up in Home Assistant.
|
|
template<typename T > |
void | subscribe_homeassistant_state (void(T::*callback)(std::string), const std::string &entity_id, const std::string &attribute="") |
| Subscribe to the state (or attribute state) of an entity from Home Assistant.
|
|
template<typename T > |
void | subscribe_homeassistant_state (void(T::*callback)(std::string, std::string), const std::string &entity_id, const std::string &attribute="") |
| Subscribe to the state (or attribute state) of an entity from Home Assistant.
|
|
void | call_homeassistant_service (const std::string &service_name) |
| Call a Home Assistant service from ESPHome.
|
|
void | call_homeassistant_service (const std::string &service_name, const std::map< std::string, std::string > &data) |
| Call a Home Assistant service from ESPHome.
|
|
void | fire_homeassistant_event (const std::string &event_name) |
| Fire an ESPHome event in Home Assistant.
|
|
void | fire_homeassistant_event (const std::string &service_name, const std::map< std::string, std::string > &data) |
| Fire an ESPHome event in Home Assistant.
|
|
Definition at line 23 of file custom_api_device.h.
◆ call_homeassistant_service() [1/2]
void esphome::api::CustomAPIDevice::call_homeassistant_service |
( |
const std::string & | service_name | ) |
|
|
inline |
Call a Home Assistant service from ESPHome.
Usage:
void call_homeassistant_service(const std::string &service_name)
Call a Home Assistant service from ESPHome.
- Parameters
-
service_name | The service to call. |
Definition at line 141 of file custom_api_device.h.
◆ call_homeassistant_service() [2/2]
void esphome::api::CustomAPIDevice::call_homeassistant_service |
( |
const std::string & | service_name, |
|
|
const std::map< std::string, std::string > & | data ) |
|
inline |
Call a Home Assistant service from ESPHome.
Usage:
{"entity_id", "light.my_light"},
{"brightness", "127"},
});
- Parameters
-
service_name | The service to call. |
data | The data for the service call, mapping from string to string. |
Definition at line 161 of file custom_api_device.h.
◆ fire_homeassistant_event() [1/2]
void esphome::api::CustomAPIDevice::fire_homeassistant_event |
( |
const std::string & | event_name | ) |
|
|
inline |
Fire an ESPHome event in Home Assistant.
Usage:
void fire_homeassistant_event(const std::string &event_name)
Fire an ESPHome event in Home Assistant.
- Parameters
-
event_name | The event to fire. |
Definition at line 183 of file custom_api_device.h.
◆ fire_homeassistant_event() [2/2]
void esphome::api::CustomAPIDevice::fire_homeassistant_event |
( |
const std::string & | service_name, |
|
|
const std::map< std::string, std::string > & | data ) |
|
inline |
Fire an ESPHome event in Home Assistant.
Usage:
- Parameters
-
event_name | The event to fire. |
data | The data for the event, mapping from string to string. |
Definition at line 203 of file custom_api_device.h.
◆ is_connected()
bool esphome::api::CustomAPIDevice::is_connected |
( |
| ) |
const |
|
inline |
Return if a client (such as Home Assistant) is connected to the native API.
Definition at line 26 of file custom_api_device.h.
◆ register_service() [1/2]
template<typename T >
void esphome::api::CustomAPIDevice::register_service |
( |
void(T::* | callback )(), |
|
|
const std::string & | name ) |
|
inline |
Register a custom native API service that will show up in Home Assistant.
Usage:
}
void on_hello_world() {
}
void register_service(void(T::*callback)(Ts...), const std::string &name, const std::array< std::string, sizeof...(Ts)> &arg_names)
Register a custom native API service that will show up in Home Assistant.
- Template Parameters
-
T | The class type creating the service, automatically deduced from the function pointer. |
- Parameters
-
callback | The member function to call when the service is triggered. |
name | The name of the arguments for the service, must match the arguments of the function. |
Definition at line 74 of file custom_api_device.h.
◆ register_service() [2/2]
template<typename T , typename... Ts>
void esphome::api::CustomAPIDevice::register_service |
( |
void(T::* | callback )(Ts...), |
|
|
const std::string & | name, |
|
|
const std::array< std::string, sizeof...(Ts)> & | arg_names ) |
|
inline |
Register a custom native API service that will show up in Home Assistant.
Usage:
{"cycle_length"});
}
void on_start_washer_cycle(int cycle_length) {
}
- Template Parameters
-
T | The class type creating the service, automatically deduced from the function pointer. |
Ts | The argument types for the service, automatically deduced from the function arguments. |
- Parameters
-
callback | The member function to call when the service is triggered. |
name | The name of the service to register. |
arg_names | The name of the arguments for the service, must match the arguments of the function. |
Definition at line 50 of file custom_api_device.h.
◆ subscribe_homeassistant_state() [1/2]
template<typename T >
void esphome::api::CustomAPIDevice::subscribe_homeassistant_state |
( |
void(T::* | callback )(std::string), |
|
|
const std::string & | entity_id, |
|
|
const std::string & | attribute = "" ) |
|
inline |
Subscribe to the state (or attribute state) of an entity from Home Assistant.
Usage:
}
void on_state_changed(std::string
state) {
}
void subscribe_homeassistant_state(void(T::*callback)(std::string), const std::string &entity_id, const std::string &attribute="")
Subscribe to the state (or attribute state) of an entity from Home Assistant.
- Template Parameters
-
T | The class type creating the service, automatically deduced from the function pointer. |
- Parameters
-
callback | The member function to call when the entity state changes. |
entity_id | The entity_id to track. |
attribute | The entity state attribute to track. |
Definition at line 99 of file custom_api_device.h.
◆ subscribe_homeassistant_state() [2/2]
template<typename T >
void esphome::api::CustomAPIDevice::subscribe_homeassistant_state |
( |
void(T::* | callback )(std::string, std::string), |
|
|
const std::string & | entity_id, |
|
|
const std::string & | attribute = "" ) |
|
inline |
Subscribe to the state (or attribute state) of an entity from Home Assistant.
Usage:
}
void on_state_changed(std::string entity_id, std::string
state) {
}
- Template Parameters
-
T | The class type creating the service, automatically deduced from the function pointer. |
- Parameters
-
callback | The member function to call when the entity state changes. |
entity_id | The entity_id to track. |
attribute | The entity state attribute to track. |
Definition at line 125 of file custom_api_device.h.
The documentation for this class was generated from the following file: