12static const char *
const TAG =
"mqtt.text";
33 LOG_MQTT_COMPONENT(
true,
true);
41 root[MQTT_MODE] = TextMqttModeStrings::get_progmem_str(
static_cast<uint8_t
>(this->
text_->
traits.
get_mode()),
54 char topic_buf[MQTT_DEFAULT_TOPIC_MAX_LEN];
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.
StringRef get_state_topic_to_(std::span< char, MQTT_DEFAULT_TOPIC_MAX_LEN > buf) const
Get the MQTT state topic into a buffer (no heap allocation for non-lambda custom topics).
std::string get_command_topic_() const
Get the MQTT topic for listening to commands (allocates std::string).
void subscribe(const std::string &topic, mqtt_callback_t callback, uint8_t qos=0)
Subscribe to a MQTT topic.
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.
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(const std::string &)> &&callback)
TextMode get_mode() const
PROGMEM_STRING_TABLE(AlarmControlPanelStateStrings, "DISARMED", "ARMED_HOME", "ARMED_AWAY", "ARMED_NIGHT", "ARMED_VACATION", "ARMED_CUSTOM_BYPASS", "PENDING", "ARMING", "DISARMING", "TRIGGERED", "UNKNOWN")
MQTT_COMPONENT_TYPE(MQTTAlarmControlPanelComponent, "alarm_control_panel") const EntityBase *MQTTAlarmControlPanelComponent
Simple Helper struct used for Home Assistant MQTT send_discovery().
bool command_topic
If the command topic should be included. Default to true.