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");
54 resp.
data.emplace_back();
55 auto &entity_id_kv = resp.
data.back();
56 entity_id_kv.set_key(ENTITY_ID_KEY);
static constexpr StringRef from_lit(const CharT(&s)[N])
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)
void set_service(const StringRef &ref)
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()))