10static const char *
const TAG =
"homeassistant.number";
14 if (!number_value.has_value()) {
15 ESP_LOGW(TAG,
"'%s': Can't convert '%s' to number!", this->
entity_id_, state.
c_str());
19 if (this->state == number_value.value()) {
28 if (!min_value.has_value()) {
29 ESP_LOGE(TAG,
"'%s': Can't convert 'min' value '%s' to number!", this->
entity_id_, min.
c_str());
32 ESP_LOGD(TAG,
"'%s': Min retrieved: %s",
get_name().c_str(), min.
c_str());
38 if (!max_value.has_value()) {
39 ESP_LOGE(TAG,
"'%s': Can't convert 'max' value '%s' to number!", this->
entity_id_, max.
c_str());
42 ESP_LOGD(TAG,
"'%s': Max retrieved: %s",
get_name().c_str(), max.
c_str());
48 if (!step_value.has_value()) {
49 ESP_LOGE(TAG,
"'%s': Can't convert 'step' value '%s' to number!", this->
entity_id_, step.
c_str());
52 ESP_LOGD(TAG,
"'%s': Step Retrieved %s",
get_name().c_str(), step.
c_str());
69 LOG_NUMBER(
"",
"Homeassistant Number",
this);
70 ESP_LOGCONFIG(TAG,
" Entity ID: '%s'", this->
entity_id_);
77 ESP_LOGE(TAG,
"No clients connected to API server");
91 auto &entity_id = resp.
data.emplace_back();
92 entity_id.key = ENTITY_ID_KEY;
95 auto &entity_value = resp.
data.emplace_back();
96 entity_value.key = VALUE_KEY;
99 buf_append_printf(value_buf,
sizeof(value_buf), 0,
"%g", value);
100 entity_value.value =
StringRef(value_buf);
const StringRef & get_name() const
StringRef is a reference to a string owned by something else.
constexpr const char * c_str() const
static constexpr StringRef from_lit(const CharT(&s)[N])
void get_home_assistant_state(const char *entity_id, const char *attribute, std::function< void(StringRef)> &&f)
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 control(float value) override
void max_retrieved_(StringRef max)
void dump_config() override
void step_retrieved_(StringRef step)
float get_setup_priority() const override
void min_retrieved_(StringRef min)
void state_changed_(StringRef state)
void publish_state(float state)
void set_min_value(float min_value)
void set_step(float step)
void set_max_value(float max_value)
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.