move comments

This commit is contained in:
J. Nick Koston
2025-11-05 11:16:43 -06:00
parent 4c097616ae
commit 4c5533b2ea
6 changed files with 14 additions and 7 deletions
@@ -31,9 +31,10 @@ MQTTBinarySensorComponent::MQTTBinarySensorComponent(binary_sensor::BinarySensor
void MQTTBinarySensorComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) {
const auto device_class = this->binary_sensor_->get_device_class_ref();
if (!device_class.empty())
if (!device_class.empty()) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson
root[MQTT_DEVICE_CLASS] = device_class;
}
if (this->binary_sensor_->is_status_binary_sensor())
root[MQTT_PAYLOAD_ON] = mqtt::global_mqtt_client->get_availability().payload_available;
if (this->binary_sensor_->is_status_binary_sensor())
+2 -1
View File
@@ -90,9 +90,10 @@ bool MQTTComponent::send_discovery_() {
if (this->is_disabled_by_default_())
root[MQTT_ENABLED_BY_DEFAULT] = false;
const auto icon_ref = this->get_icon_ref_();
if (!icon_ref.empty())
if (!icon_ref.empty()) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson
root[MQTT_ICON] = icon_ref;
}
const auto entity_category = this->get_entity()->get_entity_category();
switch (entity_category) {
+2 -1
View File
@@ -68,9 +68,10 @@ void MQTTCoverComponent::dump_config() {
}
void MQTTCoverComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) {
const auto device_class = this->cover_->get_device_class_ref();
if (!device_class.empty())
if (!device_class.empty()) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson
root[MQTT_DEVICE_CLASS] = device_class;
}
auto traits = this->cover_->get_traits();
if (traits.get_is_assumed_state()) {
+2 -1
View File
@@ -22,9 +22,10 @@ void MQTTEventComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryConf
event_types.add(event_type);
const auto device_class = this->event_->get_device_class_ref();
if (!device_class.empty())
if (!device_class.empty()) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson
root[MQTT_DEVICE_CLASS] = device_class;
}
config.command_topic = false;
}
+4 -2
View File
@@ -45,9 +45,10 @@ void MQTTNumberComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryCon
root[MQTT_MAX] = traits.get_max_value();
root[MQTT_STEP] = traits.get_step();
const auto unit_of_measurement = this->number_->traits.get_unit_of_measurement_ref();
if (!unit_of_measurement.empty())
if (!unit_of_measurement.empty()) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson
root[MQTT_UNIT_OF_MEASUREMENT] = unit_of_measurement;
}
switch (this->number_->traits.get_mode()) {
case NUMBER_MODE_AUTO:
break;
@@ -59,9 +60,10 @@ void MQTTNumberComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryCon
break;
}
const auto device_class = this->number_->traits.get_device_class_ref();
if (!device_class.empty())
if (!device_class.empty()) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson
root[MQTT_DEVICE_CLASS] = device_class;
}
config.command_topic = true;
}
+2 -1
View File
@@ -51,9 +51,10 @@ void MQTTSensorComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryCon
}
const auto unit_of_measurement = this->sensor_->get_unit_of_measurement_ref();
if (!unit_of_measurement.empty())
if (!unit_of_measurement.empty()) {
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) false positive with ArduinoJson
root[MQTT_UNIT_OF_MEASUREMENT] = unit_of_measurement;
}
if (this->get_expire_after() > 0)
root[MQTT_EXPIRE_AFTER] = this->get_expire_after() / 1000;