13static const char *
const TAG =
"homeassistant.text";
16 if (
state == this->state) {
25 if (!min_value.has_value()) {
26 ESP_LOGE(TAG,
"'%s': Can't convert 'min' value '%s' to number!", this->
entity_id_, min.
c_str());
29 ESP_LOGD(TAG,
"'%s': Min retrieved: %s", this->
entity_id_, min.
c_str());
35 if (!max_value.has_value()) {
36 ESP_LOGE(TAG,
"'%s': Can't convert 'max' value '%s' to number!", this->
entity_id_, max.
c_str());
39 ESP_LOGD(TAG,
"'%s': Max retrieved: %s", this->
entity_id_, max.
c_str());
46 }
else if (mode ==
"password") {
49 ESP_LOGW(TAG,
"'%s': Unknown 'mode' value '%s'", this->
entity_id_, mode.
c_str());
52 ESP_LOGD(TAG,
"'%s': Mode retrieved: %s", this->
entity_id_, mode.
c_str());
70 LOG_TEXT(
"",
"Homeassistant Text",
this);
71 ESP_LOGCONFIG(TAG,
" Entity ID: '%s'", this->
entity_id_);
78 ESP_LOGE(TAG,
"No clients connected to API server");
82#ifdef USE_API_WIZARD_LINKED_INPUTS
84 ESP_LOGW(TAG,
"'%s': No entity ID set yet", this->
get_name().c_str());
93 static constexpr char INPUT_PREFIX[] =
"input_";
96 if (strncmp(this->
entity_id_, INPUT_PREFIX,
sizeof(INPUT_PREFIX) - 1) == 0) {
97 resp.
service = SERVICE_INPUT_TEXT;
103 auto &entity_id_kv = resp.
data.emplace_back();
104 entity_id_kv.key = ENTITY_ID_KEY;
107 auto &value_kv = resp.
data.emplace_back();
108 value_kv.key = VALUE_KEY;
109 value_kv.value =
StringRef(value.data(), value.size());
BedjetMode mode
BedJet operating mode.
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 state_changed_(StringRef state)
void mode_retrieved_(StringRef mode)
void dump_config() override
float get_setup_priority() const override
void max_retrieved_(StringRef max)
void control(const std::string &value) override
void min_retrieved_(StringRef min)
void publish_state(const std::string &state)
void set_mode(TextMode mode)
void set_max_length(int max_length)
void set_min_length(int min_length)
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.