[mqtt] clang-tidy fixes for #7822 (#7877)

This commit is contained in:
Keith Burzinski 2024-11-27 16:19:41 -06:00 committed by GitHub
parent 8439232b11
commit f2e8e655ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View file

@ -80,8 +80,7 @@ const EntityBase *MQTTAlarmControlPanelComponent::get_entity() const { return th
bool MQTTAlarmControlPanelComponent::send_initial_state() { return this->publish_state(); }
bool MQTTAlarmControlPanelComponent::publish_state() {
bool success = true;
const char *state_s = "";
const char *state_s;
switch (this->alarm_control_panel_->get_state()) {
case ACP_STATE_DISARMED:
state_s = "disarmed";
@ -116,9 +115,7 @@ bool MQTTAlarmControlPanelComponent::publish_state() {
default:
state_s = "unknown";
}
if (!this->publish(this->get_state_topic_(), state_s))
success = false;
return success;
return this->publish(this->get_state_topic_(), state_s);
}
} // namespace mqtt

View file

@ -257,7 +257,7 @@ const EntityBase *MQTTClimateComponent::get_entity() const { return this->device
bool MQTTClimateComponent::publish_state_() {
auto traits = this->device_->get_traits();
// mode
const char *mode_s = "";
const char *mode_s;
switch (this->device_->mode) {
case CLIMATE_MODE_OFF:
mode_s = "off";
@ -280,6 +280,8 @@ bool MQTTClimateComponent::publish_state_() {
case CLIMATE_MODE_HEAT_COOL:
mode_s = "heat_cool";
break;
default:
mode_s = "unknown";
}
bool success = true;
if (!this->publish(this->get_mode_state_topic(), mode_s))
@ -343,6 +345,8 @@ bool MQTTClimateComponent::publish_state_() {
case CLIMATE_PRESET_ACTIVITY:
payload = "activity";
break;
default:
payload = "unknown";
}
}
if (this->device_->custom_preset.has_value())
@ -352,7 +356,7 @@ bool MQTTClimateComponent::publish_state_() {
}
if (traits.get_supports_action()) {
const char *payload = "unknown";
const char *payload;
switch (this->device_->action) {
case CLIMATE_ACTION_OFF:
payload = "off";
@ -372,6 +376,8 @@ bool MQTTClimateComponent::publish_state_() {
case CLIMATE_ACTION_FAN:
payload = "fan";
break;
default:
payload = "unknown";
}
if (!this->publish(this->get_action_state_topic(), payload))
success = false;
@ -411,6 +417,8 @@ bool MQTTClimateComponent::publish_state_() {
case CLIMATE_FAN_QUIET:
payload = "quiet";
break;
default:
payload = "unknown";
}
}
if (this->device_->custom_fan_mode.has_value())
@ -420,7 +428,7 @@ bool MQTTClimateComponent::publish_state_() {
}
if (traits.get_supports_swing_modes()) {
const char *payload = "";
const char *payload;
switch (this->device_->swing_mode) {
case CLIMATE_SWING_OFF:
payload = "off";
@ -434,6 +442,8 @@ bool MQTTClimateComponent::publish_state_() {
case CLIMATE_SWING_HORIZONTAL:
payload = "horizontal";
break;
default:
payload = "unknown";
}
if (!this->publish(this->get_swing_mode_state_topic(), payload))
success = false;