19 ESP_LOGW(TAG,
"Can't convert '%s' to binary state!",
state.c_str());
24 ESP_LOGD(TAG,
"'%s': Got state %s", this->
entity_id_, ONOFF(new_state));
32 LOG_SWITCH(
"",
"Homeassistant Switch",
this);
33 ESP_LOGCONFIG(TAG,
" Entity ID: '%s'", this->
entity_id_);
40 ESP_LOGE(TAG,
"No clients connected to API server");
44#ifdef USE_API_WIZARD_LINKED_INPUTS
46 ESP_LOGW(TAG,
"'%s': No entity ID set yet", LOG_STR_ARG(this->
get_log_name()));
52 static const char SERVICE_ON[]
PROGMEM =
"homeassistant.turn_on";
53 static const char SERVICE_OFF[]
PROGMEM =
"homeassistant.turn_off";
54 static const char ENTITY_ID_KEY[]
PROGMEM =
"entity_id";
60 auto &entity_id_kv = resp.
data.emplace_back();
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
A string that may live in flash (on ESP8266): pointer and length, with no byte-reading operations.
static constexpr ProgmemStringRef from_lit(const char(&s)[N])
A PROGMEM char array, with its length known at compile time.
StringRef is a reference to a string owned by something else.
void send_homeassistant_action(const HomeassistantActionRequest &call)
void subscribe_home_assistant_state(const char *entity_id, const char *attribute, std::function< void(StringRef)> &&f)
FixedVector< 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
ESPHOME_LOG_TAG(TAG, "homeassistant.binary_sensor")
constexpr ColorMode COLOR_MODE_LOOKUP[] PROGMEM
constexpr float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
ParseOnOffState parse_on_off(const char *str, const char *on, const char *off)
Parse a string that contains either on, off or toggle.