12static const char *
const TAG =
"mqtt.text";
30 LOG_MQTT_COMPONENT(
true,
true)
const StringRef & get_name() const
constexpr const char * c_str() const
bool publish(const std::string &topic, const std::string &payload)
Send a MQTT message.
std::string get_state_topic_() const
Get the MQTT topic that new states will be shared to.
std::string get_command_topic_() const
Get the MQTT topic for listening to commands.
void subscribe(const std::string &topic, mqtt_callback_t callback, uint8_t qos=0)
Subscribe to a MQTT topic.
std::string component_type() const override
Override for MQTTComponent, returns "text".
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
void dump_config() override
void setup() override
Override setup.
bool send_initial_state() override
MQTTTextComponent(text::Text *text)
Construct this MQTTTextComponent instance with the provided friendly_name and text.
const EntityBase * get_entity() const override
bool publish_state(const std::string &value)
TextCall & set_value(const std::string &value)
Base-class for all text inputs.
TextCall make_call()
Instantiate a TextCall object to modify this text component's state.
void add_on_state_callback(std::function< void(std::string)> &&callback)
bool has_state() const
Return whether this text input has gotten a full state yet.
TextMode get_mode() const
constexpr const char *const MQTT_MODE
Providing packet encoding functions for exchanging data with a remote host.
Simple Helper struct used for Home Assistant MQTT send_discovery().
bool command_topic
If the command topic should be included. Default to true.