11static const char *
const TAG =
"mqtt.event";
19 JsonArray event_types = root[MQTT_EVENT_TYPES].to<JsonArray>();
21 event_types.add(event_type);
25 if (!device_class.empty()) {
26 root[MQTT_DEVICE_CLASS] = device_class;
39 ESP_LOGCONFIG(TAG,
"Event Types: ");
41 ESP_LOGCONFIG(TAG,
"- %s", event_type);
43 LOG_MQTT_COMPONENT(
true,
true);
49 root[MQTT_EVENT_TYPE] = event_type;
StringRef get_device_class_ref() const
Get the device class as StringRef.
const StringRef & get_name() const
constexpr const char * c_str() const
const FixedVector< const char * > & get_event_types() const
Return the event types supported by this event.
void add_on_event_callback(std::function< void(const std::string &event_type)> &&callback)
bool publish_json(const std::string &topic, const json::json_build_t &f)
Construct and send a JSON MQTT message.
std::string get_state_topic_() const
Get the MQTT topic that new states will be shared to.
bool publish_event_(const std::string &event_type)
void dump_config() override
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
MQTTEventComponent(event::Event *event)
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.