11static const char *
const TAG =
"mqtt.button";
19 if (payload ==
"PRESS") {
22 ESP_LOGW(TAG,
"'%s': Received unknown status payload: %s", this->
friendly_name_().c_str(), payload.c_str());
29 LOG_MQTT_COMPONENT(
false,
true);
36 if (!device_class.empty()) {
37 root[MQTT_DEVICE_CLASS] = device_class;
void status_momentary_warning(const char *name, uint32_t length=5000)
Set warning status flag and automatically clear it after a timeout.
StringRef get_device_class_ref() const
Get the device class as StringRef.
const StringRef & get_name() const
constexpr const char * c_str() const
const StringRef & friendly_name_() const
Get the friendly name of this MQTT component.
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.
MQTT_COMPONENT_TYPE(MQTTAlarmControlPanelComponent, "alarm_control_panel") const EntityBase *MQTTAlarmControlPanelComponent
Simple Helper struct used for Home Assistant MQTT send_discovery().
bool state_topic
If the state topic should be included. Defaults to true.