17 if (!number_value.has_value()) {
18 ESP_LOGW(TAG,
"'%s': Can't convert '%s' to number!", this->
entity_id_, state.
c_str());
22 if (this->state == number_value.value()) {
31 if (!min_value.has_value()) {
32 ESP_LOGE(TAG,
"'%s': Can't convert 'min' value '%s' to number!", this->
entity_id_, min.
c_str());
35 ESP_LOGD(TAG,
"'%s': Min retrieved: %s", LOG_STR_ARG(this->
get_log_name()), min.
c_str());
41 if (!max_value.has_value()) {
42 ESP_LOGE(TAG,
"'%s': Can't convert 'max' value '%s' to number!", this->
entity_id_, max.
c_str());
45 ESP_LOGD(TAG,
"'%s': Max retrieved: %s", LOG_STR_ARG(this->
get_log_name()), max.
c_str());
51 if (!step_value.has_value()) {
52 ESP_LOGE(TAG,
"'%s': Can't convert 'step' value '%s' to number!", this->
entity_id_, step.
c_str());
55 ESP_LOGD(TAG,
"'%s': Step Retrieved %s", LOG_STR_ARG(this->
get_log_name()), step.
c_str());
72 LOG_NUMBER(
"",
"Homeassistant Number",
this);
73 ESP_LOGCONFIG(TAG,
" Entity ID: '%s'", this->
entity_id_);
80 ESP_LOGE(TAG,
"No clients connected to API server");
84#ifdef USE_API_WIZARD_LINKED_INPUTS
86 ESP_LOGW(TAG,
"'%s': No entity ID set yet", LOG_STR_ARG(this->
get_log_name()));
94 static const char NUMBER_SERVICE_NAME[]
PROGMEM =
"number.set_value";
95 static const char INPUT_NUMBER_SERVICE_NAME[]
PROGMEM =
"input_number.set_value";
96 static const char ENTITY_ID_KEY[]
PROGMEM =
"entity_id";
97 static const char VALUE_KEY[]
PROGMEM =
"value";
101 const bool input_helper = ESPHOME_strncmp_P(this->
entity_id_, INPUT_NUMBER_SERVICE_NAME,
sizeof(
"input_") - 1) == 0;
106 auto &entity_id = resp.
data.emplace_back();
110 auto &entity_value = resp.
data.emplace_back();
114 buf_append_printf(value_buf,
sizeof(value_buf), 0,
"%g", value);
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.
constexpr const char * c_str() const
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
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.
optional< T > parse_number(const char *str)
Parse an unsigned decimal number from a null-terminated string.