6 namespace homeassistant {
8 static const char *
const TAG =
"homeassistant.sensor";
13 auto val = parse_number<float>(
state);
14 if (!
val.has_value()) {
15 ESP_LOGW(TAG,
"'%s': Can't convert '%s' to number!", this->
entity_id_.c_str(), state.c_str());
21 ESP_LOGD(TAG,
"'%s::%s': Got attribute state %.2f", this->
entity_id_.c_str(),
24 ESP_LOGD(TAG,
"'%s': Got state %.2f", this->
entity_id_.c_str(), *
val);
30 LOG_SENSOR(
"",
"Homeassistant Sensor",
this);
31 ESP_LOGCONFIG(TAG,
" Entity ID: '%s'", this->
entity_id_.c_str());
33 ESP_LOGCONFIG(TAG,
" Attribute: '%s'", this->
attribute_.
value().c_str());
value_type const & value() const
void dump_config() override
const float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
float state
This member variable stores the last state that has passed through all filters.
void publish_state(float state)
Publish a new state to the front-end.
float get_setup_priority() const override
optional< std::string > attribute_
Implementation of SPI Controller mode.
void subscribe_home_assistant_state(std::string entity_id, optional< std::string > attribute, std::function< void(std::string)> f)
APIServer * global_api_server