8static const char *
const TAG =
"homeassistant.sensor";
13 if (!
val.has_value()) {
14 ESP_LOGW(TAG,
"'%s': Can't convert '%s' to number!", this->
entity_id_, state.
c_str());
22 ESP_LOGV(TAG,
"'%s': Got state %.2f", this->
entity_id_, *
val);
28 LOG_SENSOR(
"",
"Homeassistant Sensor",
this);
29 ESP_LOGCONFIG(TAG,
" Entity ID: '%s'", this->
entity_id_);
31 ESP_LOGCONFIG(TAG,
" Attribute: '%s'", this->
attribute_);
StringRef is a reference to a string owned by something else.
constexpr const char * c_str() const
void subscribe_home_assistant_state(const char *entity_id, const char *attribute, std::function< void(StringRef)> &&f)
void dump_config() override
float get_setup_priority() const override
void publish_state(float state)
Publish a new state to the front-end.
float state
This member variable stores the last state that has passed through all filters.
APIServer * global_api_server
constexpr float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
optional< T > parse_number(const char *str)
Parse an unsigned decimal number from a null-terminated string.