6 namespace homeassistant {
8 static const char *
const TAG =
"homeassistant.switch";
18 ESP_LOGW(TAG,
"Can't convert '%s' to binary state!", state.c_str());
23 ESP_LOGD(TAG,
"'%s': Got state %s", this->entity_id_.c_str(), ONOFF(new_state));
24 this->publish_state(new_state);
31 LOG_SWITCH(
"",
"Homeassistant Switch",
this);
32 ESP_LOGCONFIG(TAG,
" Entity ID: '%s'", this->entity_id_.c_str());
39 ESP_LOGE(TAG,
"No clients connected to API server");
45 resp.
service =
"homeassistant.turn_on";
47 resp.
service =
"homeassistant.turn_off";
51 entity_id_kv.
key =
"entity_id";
52 entity_id_kv.
value = this->entity_id_;
53 resp.
data.push_back(entity_id_kv);
const float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
void send_homeassistant_service_call(const HomeassistantServiceResponse &call)
bool is_connected()
Return whether the node is connected to the network (through wifi, eth, ...)
ParseOnOffState parse_on_off(const char *str, const char *on, const char *off)
Parse a string that contains either on, off or toggle.
void write_state(bool state) override
float get_setup_priority() const override
const nullopt_t nullopt((nullopt_t::init()))
void dump_config() override
Implementation of SPI Controller mode.
void subscribe_home_assistant_state(std::string entity_id, optional< std::string > attribute, std::function< void(std::string)> f)
std::vector< HomeassistantServiceMap > data
APIServer * global_api_server