35 JsonArray
options = root[MQTT_OPTIONS].to<JsonArray>();
36 for (
const auto &option : traits.get_options())
44 return this->
publish_state(std::string(option.c_str(), option.size()));
50 char topic_buf[MQTT_DEFAULT_TOPIC_MAX_LEN];
void subscribe(T &&topic, F &&callback, uint8_t qos=0)
Subscribe to a MQTT topic.
MQTTTopicSource command_topic_source_() const
The command topic as a subscription source. A lambda topic is read once and copied,...
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).
void setup() override
Override setup.
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
void dump_config() override
bool publish_state(const std::string &value)
bool send_initial_state() override
MQTTSelectComponent(select::Select *select)
Construct this MQTTSelectComponent instance with the provided friendly_name and select.
SelectCall & set_option(const char *option, size_t len)
Base-class for all selects.
void add_on_state_callback(F &&callback)
const char * option_at(size_t index) const
Return the option value at the provided index offset (as const char* from flash).
SelectCall make_call()
Instantiate a SelectCall object to modify this select component's state.
StringRef current_option() const
Return the currently selected option, or empty StringRef if no state.
ESPHOME_LOG_TAG(TAG, "alarm_control_panel")
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.