mirror of
https://github.com/esphome/esphome.git
synced 2026-10-21 13:34:12 +00:00
[mqtt] Print the dump_config header in LOG_MQTT_COMPONENT (#21226)
This commit is contained in:
@@ -77,7 +77,6 @@ void MQTTAlarmControlPanelComponent::setup() {
|
||||
}
|
||||
|
||||
void MQTTAlarmControlPanelComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT alarm_control_panel '%s':", this->alarm_control_panel_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
ESP_LOGCONFIG(TAG,
|
||||
" Supported Features: %" PRIu32 "\n"
|
||||
|
||||
@@ -17,10 +17,7 @@ void MQTTBinarySensorComponent::setup() {
|
||||
this->binary_sensor_->add_on_state_callback([this](bool state) { this->publish_state(state); });
|
||||
}
|
||||
|
||||
void MQTTBinarySensorComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Binary Sensor '%s':", this->binary_sensor_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, false);
|
||||
}
|
||||
void MQTTBinarySensorComponent::dump_config() { LOG_MQTT_COMPONENT(true, false); }
|
||||
MQTTBinarySensorComponent::MQTTBinarySensorComponent(binary_sensor::BinarySensor *binary_sensor)
|
||||
: binary_sensor_(binary_sensor) {
|
||||
if (this->binary_sensor_->is_status_binary_sensor()) {
|
||||
|
||||
@@ -24,10 +24,7 @@ void MQTTButtonComponent::setup() {
|
||||
}
|
||||
});
|
||||
}
|
||||
void MQTTButtonComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Button '%s': ", this->button_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(false, true);
|
||||
}
|
||||
void MQTTButtonComponent::dump_config() { LOG_MQTT_COMPONENT(false, true); }
|
||||
|
||||
void MQTTButtonComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) {
|
||||
config.state_topic = false;
|
||||
|
||||
@@ -38,6 +38,7 @@ inline char *append_char(char *p, char c) {
|
||||
|
||||
// Function implementation of LOG_MQTT_COMPONENT macro to reduce code size
|
||||
void log_mqtt_component(const char *tag, MQTTComponent *obj, bool state_topic, bool command_topic) {
|
||||
ESP_LOGCONFIG(tag, "MQTT %s '%s':", obj->component_type(), obj->friendly_name_().c_str());
|
||||
char buf[MQTT_DEFAULT_TOPIC_MAX_LEN];
|
||||
if (state_topic) {
|
||||
ESP_LOGCONFIG(tag, " State Topic: '%s'", obj->get_state_topic_to_(buf).c_str());
|
||||
|
||||
@@ -63,7 +63,6 @@ void MQTTCoverComponent::setup() {
|
||||
}
|
||||
|
||||
void MQTTCoverComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT cover '%s':", this->cover_->get_name().c_str());
|
||||
auto traits = this->cover_->get_traits();
|
||||
bool has_command_topic = traits.get_supports_position() || !traits.get_supports_tilt();
|
||||
LOG_MQTT_COMPONENT(true, has_command_topic);
|
||||
|
||||
@@ -34,10 +34,7 @@ void MQTTDateComponent::setup() {
|
||||
[this]() { this->publish_state(this->date_->year, this->date_->month, this->date_->day); });
|
||||
}
|
||||
|
||||
void MQTTDateComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Date '%s':", this->date_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
}
|
||||
void MQTTDateComponent::dump_config() { LOG_MQTT_COMPONENT(true, true); }
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTDateComponent, "date")
|
||||
const EntityBase *MQTTDateComponent::get_entity() const { return this->date_; }
|
||||
|
||||
@@ -45,10 +45,7 @@ void MQTTDateTimeComponent::setup() {
|
||||
});
|
||||
}
|
||||
|
||||
void MQTTDateTimeComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT DateTime '%s':", this->datetime_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
}
|
||||
void MQTTDateTimeComponent::dump_config() { LOG_MQTT_COMPONENT(true, true); }
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTDateTimeComponent, "datetime")
|
||||
const EntityBase *MQTTDateTimeComponent::get_entity() const { return this->datetime_; }
|
||||
|
||||
@@ -28,12 +28,11 @@ void MQTTEventComponent::setup() {
|
||||
}
|
||||
|
||||
void MQTTEventComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Event '%s': ", this->event_->get_name().c_str());
|
||||
ESP_LOGCONFIG(TAG, "Event Types: ");
|
||||
for (const char *event_type : this->event_->get_event_types()) {
|
||||
ESP_LOGCONFIG(TAG, "- %s", event_type);
|
||||
}
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
ESP_LOGCONFIG(TAG, " Event Types:");
|
||||
for (const char *event_type : this->event_->get_event_types()) {
|
||||
ESP_LOGCONFIG(TAG, " - %s", event_type);
|
||||
}
|
||||
}
|
||||
|
||||
bool MQTTEventComponent::publish_event_(const std::string &event_type) {
|
||||
|
||||
@@ -125,7 +125,6 @@ void MQTTFanComponent::setup() {
|
||||
}
|
||||
|
||||
void MQTTFanComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Fan '%s': ", this->state_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
if (this->state_->get_traits().supports_direction()) {
|
||||
ESP_LOGCONFIG(TAG,
|
||||
|
||||
@@ -87,10 +87,7 @@ void MQTTJSONLightComponent::send_discovery(JsonObject root, mqtt::SendDiscovery
|
||||
}
|
||||
}
|
||||
bool MQTTJSONLightComponent::send_initial_state() { return this->publish_state_(); }
|
||||
void MQTTJSONLightComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Light '%s':", this->state_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
}
|
||||
void MQTTJSONLightComponent::dump_config() { LOG_MQTT_COMPONENT(true, true); }
|
||||
|
||||
} // namespace esphome::mqtt
|
||||
|
||||
|
||||
@@ -31,10 +31,7 @@ void MQTTLockComponent::setup() {
|
||||
this->lock_->add_on_state_callback(
|
||||
[this](LockState /*state*/) { this->defer(SEND_DEFER_ID, [this]() { this->publish_state(); }); });
|
||||
}
|
||||
void MQTTLockComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Lock '%s': ", this->lock_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
}
|
||||
void MQTTLockComponent::dump_config() { LOG_MQTT_COMPONENT(true, true); }
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTLockComponent, "lock")
|
||||
const EntityBase *MQTTLockComponent::get_entity() const { return this->lock_; }
|
||||
|
||||
@@ -32,10 +32,7 @@ void MQTTNumberComponent::setup() {
|
||||
this->number_->add_on_state_callback([this](float state) { this->publish_state(state); });
|
||||
}
|
||||
|
||||
void MQTTNumberComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Number '%s':", this->number_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, false);
|
||||
}
|
||||
void MQTTNumberComponent::dump_config() { LOG_MQTT_COMPONENT(true, false); }
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTNumberComponent, "number")
|
||||
const EntityBase *MQTTNumberComponent::get_entity() const { return this->number_; }
|
||||
|
||||
@@ -23,10 +23,7 @@ void MQTTSelectComponent::setup() {
|
||||
this->select_->add_on_state_callback([this](size_t index) { this->publish_state(this->select_->option_at(index)); });
|
||||
}
|
||||
|
||||
void MQTTSelectComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Select '%s':", this->select_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, false);
|
||||
}
|
||||
void MQTTSelectComponent::dump_config() { LOG_MQTT_COMPONENT(true, false); }
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTSelectComponent, "select")
|
||||
const EntityBase *MQTTSelectComponent::get_entity() const { return this->select_; }
|
||||
|
||||
@@ -25,11 +25,10 @@ void MQTTSensorComponent::setup() {
|
||||
}
|
||||
|
||||
void MQTTSensorComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Sensor '%s':", this->sensor_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, false);
|
||||
if (this->get_expire_after() > 0) {
|
||||
ESP_LOGCONFIG(TAG, " Expire After: %" PRIu32 "s", this->get_expire_after() / 1000);
|
||||
}
|
||||
LOG_MQTT_COMPONENT(true, false);
|
||||
}
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTSensorComponent, "sensor")
|
||||
|
||||
@@ -36,10 +36,7 @@ void MQTTSwitchComponent::setup() {
|
||||
this->switch_->add_on_state_callback(
|
||||
[this](bool enabled) { this->defer(SEND_DEFER_ID, [this, enabled]() { this->publish_state(enabled); }); });
|
||||
}
|
||||
void MQTTSwitchComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Switch '%s': ", this->switch_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
}
|
||||
void MQTTSwitchComponent::dump_config() { LOG_MQTT_COMPONENT(true, true); }
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTSwitchComponent, "switch")
|
||||
const EntityBase *MQTTSwitchComponent::get_entity() const { return this->switch_; }
|
||||
|
||||
@@ -28,10 +28,7 @@ void MQTTTextComponent::setup() {
|
||||
this->text_->add_on_state_callback([this](const std::string &state) { this->publish_state(state); });
|
||||
}
|
||||
|
||||
void MQTTTextComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT text '%s':", this->text_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
}
|
||||
void MQTTTextComponent::dump_config() { LOG_MQTT_COMPONENT(true, true); }
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTTextComponent, "text")
|
||||
const EntityBase *MQTTTextComponent::get_entity() const { return this->text_; }
|
||||
|
||||
@@ -20,10 +20,7 @@ void MQTTTextSensor::setup() {
|
||||
this->sensor_->add_on_state_callback([this](const std::string &state) { this->publish_state(state); });
|
||||
}
|
||||
|
||||
void MQTTTextSensor::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Text Sensor '%s':", this->sensor_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, false);
|
||||
}
|
||||
void MQTTTextSensor::dump_config() { LOG_MQTT_COMPONENT(true, false); }
|
||||
|
||||
bool MQTTTextSensor::publish_state(const std::string &value) {
|
||||
char topic_buf[MQTT_DEFAULT_TOPIC_MAX_LEN];
|
||||
|
||||
@@ -34,10 +34,7 @@ void MQTTTimeComponent::setup() {
|
||||
[this]() { this->publish_state(this->time_->hour, this->time_->minute, this->time_->second); });
|
||||
}
|
||||
|
||||
void MQTTTimeComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Time '%s':", this->time_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
}
|
||||
void MQTTTimeComponent::dump_config() { LOG_MQTT_COMPONENT(true, true); }
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTTimeComponent, "time")
|
||||
const EntityBase *MQTTTimeComponent::get_entity() const { return this->time_; }
|
||||
|
||||
@@ -48,10 +48,7 @@ void MQTTUpdateComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryCon
|
||||
|
||||
bool MQTTUpdateComponent::send_initial_state() { return this->publish_state(); }
|
||||
|
||||
void MQTTUpdateComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT Update '%s': ", this->update_->get_name().c_str());
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
}
|
||||
void MQTTUpdateComponent::dump_config() { LOG_MQTT_COMPONENT(true, true); }
|
||||
|
||||
MQTT_COMPONENT_TYPE(MQTTUpdateComponent, "update")
|
||||
const EntityBase *MQTTUpdateComponent::get_entity() const { return this->update_; }
|
||||
|
||||
@@ -51,7 +51,6 @@ void MQTTValveComponent::setup() {
|
||||
}
|
||||
|
||||
void MQTTValveComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "MQTT valve '%s':", this->valve_->get_name().c_str());
|
||||
auto traits = this->valve_->get_traits();
|
||||
bool has_command_topic = traits.get_supports_position();
|
||||
LOG_MQTT_COMPONENT(true, has_command_topic);
|
||||
|
||||
Reference in New Issue
Block a user