13 void (T::*callback)(Ts...))
49 template<
typename T,
typename... Ts>
51 const std::array<std::string,
sizeof...(Ts)> &arg_names) {
74 template<
typename T>
void register_service(
void (T::*callback)(),
const std::string &name) {
100 const std::string &attribute =
"") {
101 auto f = std::bind(callback, (T *)
this, std::placeholders::_1);
126 const std::string &attribute =
"") {
127 auto f = std::bind(callback, (T *)
this, entity_id, std::placeholders::_1);
164 for (
auto &it : data) {
167 kv.
value = it.second;
168 resp.
data.push_back(kv);
207 for (
auto &it : data) {
210 kv.
value = it.second;
211 resp.
data.push_back(kv);
bool is_connected() const
Return if a client (such as Home Assistant) is connected to the native API.
bool is_connected() const
CustomAPIDeviceService(const std::string &name, const std::array< std::string, sizeof...(Ts)> &arg_names, T *obj, void(T::*callback)(Ts...))
void execute(Ts... x) override
void send_homeassistant_service_call(const HomeassistantServiceResponse &call)
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, 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 call_homeassistant_service(const std::string &service_name)
Call a Home Assistant service from ESPHome.
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.
void register_user_service(UserServiceDescriptor *descriptor)
void fire_homeassistant_event(const std::string &service_name, const std::map< std::string, std::string > &data)
Fire an ESPHome event in Home Assistant.
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.
Implementation of SPI Controller mode.
void(T::* callback_)(Ts...)
void subscribe_home_assistant_state(std::string entity_id, optional< std::string > attribute, std::function< void(std::string)> f)
std::vector< HomeassistantServiceMap > data
void register_service(void(T::*callback)(), const std::string &name)
Register a custom native API service that will show up in Home Assistant.
APIServer * global_api_server