6namespace homeassistant {
8static 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));
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";
53 resp.
data.push_back(entity_id_kv);
void send_homeassistant_service_call(const HomeassistantServiceResponse &call)
void subscribe_home_assistant_state(std::string entity_id, optional< std::string > attribute, std::function< void(std::string)> f)
std::vector< HomeassistantServiceMap > data
void write_state(bool state) override
float get_setup_priority() const override
void dump_config() override
bool state
The current reported state of the binary sensor.
void publish_state(bool state)
Publish a state to the front-end from the back-end.
APIServer * global_api_server
const float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
Providing packet encoding functions for exchanging data with a remote host.
ParseOnOffState parse_on_off(const char *str, const char *on, const char *off)
Parse a string that contains either on, off or toggle.
const nullopt_t nullopt((nullopt_t::init()))