Force braces around multi-line statements (#3094)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Oxan van Leeuwen
2022-01-24 20:56:36 +01:00
committed by GitHub
parent 6b27f2d2cf
commit 80d03a631e
125 changed files with 770 additions and 504 deletions
+9 -6
View File
@@ -71,31 +71,34 @@ void TuyaLight::dump_config() {
ESP_LOGCONFIG(TAG, " Dimmer has datapoint ID %u", *this->dimmer_id_);
if (this->switch_id_.has_value())
ESP_LOGCONFIG(TAG, " Switch has datapoint ID %u", *this->switch_id_);
if (this->rgb_id_.has_value())
if (this->rgb_id_.has_value()) {
ESP_LOGCONFIG(TAG, " RGB has datapoint ID %u", *this->rgb_id_);
else if (this->hsv_id_.has_value())
} else if (this->hsv_id_.has_value()) {
ESP_LOGCONFIG(TAG, " HSV has datapoint ID %u", *this->hsv_id_);
}
}
light::LightTraits TuyaLight::get_traits() {
auto traits = light::LightTraits();
if (this->color_temperature_id_.has_value() && this->dimmer_id_.has_value()) {
if (this->rgb_id_.has_value() || this->hsv_id_.has_value()) {
if (this->color_interlock_)
if (this->color_interlock_) {
traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::COLOR_TEMPERATURE});
else
} else {
traits.set_supported_color_modes(
{light::ColorMode::RGB_COLOR_TEMPERATURE, light::ColorMode::COLOR_TEMPERATURE});
}
} else
traits.set_supported_color_modes({light::ColorMode::COLOR_TEMPERATURE});
traits.set_min_mireds(this->cold_white_temperature_);
traits.set_max_mireds(this->warm_white_temperature_);
} else if (this->rgb_id_.has_value() || this->hsv_id_.has_value()) {
if (this->dimmer_id_.has_value()) {
if (this->color_interlock_)
if (this->color_interlock_) {
traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::WHITE});
else
} else {
traits.set_supported_color_modes({light::ColorMode::RGB_WHITE});
}
} else
traits.set_supported_color_modes({light::ColorMode::RGB});
} else if (this->dimmer_id_.has_value()) {
+16 -11
View File
@@ -33,20 +33,21 @@ void Tuya::dump_config() {
return;
}
for (auto &info : this->datapoints_) {
if (info.type == TuyaDatapointType::RAW)
if (info.type == TuyaDatapointType::RAW) {
ESP_LOGCONFIG(TAG, " Datapoint %u: raw (value: %s)", info.id, format_hex_pretty(info.value_raw).c_str());
else if (info.type == TuyaDatapointType::BOOLEAN)
} else if (info.type == TuyaDatapointType::BOOLEAN) {
ESP_LOGCONFIG(TAG, " Datapoint %u: switch (value: %s)", info.id, ONOFF(info.value_bool));
else if (info.type == TuyaDatapointType::INTEGER)
} else if (info.type == TuyaDatapointType::INTEGER) {
ESP_LOGCONFIG(TAG, " Datapoint %u: int value (value: %d)", info.id, info.value_int);
else if (info.type == TuyaDatapointType::STRING)
} else if (info.type == TuyaDatapointType::STRING) {
ESP_LOGCONFIG(TAG, " Datapoint %u: string value (value: %s)", info.id, info.value_string.c_str());
else if (info.type == TuyaDatapointType::ENUM)
} else if (info.type == TuyaDatapointType::ENUM) {
ESP_LOGCONFIG(TAG, " Datapoint %u: enum (value: %d)", info.id, info.value_enum);
else if (info.type == TuyaDatapointType::BITMASK)
} else if (info.type == TuyaDatapointType::BITMASK) {
ESP_LOGCONFIG(TAG, " Datapoint %u: bitmask (value: %x)", info.id, info.value_bitmask);
else
} else {
ESP_LOGCONFIG(TAG, " Datapoint %u: unknown", info.id);
}
}
if ((this->gpio_status_ != -1) || (this->gpio_reset_ != -1)) {
ESP_LOGCONFIG(TAG, " GPIO Configuration: status: pin %d, reset: pin %d (not supported)", this->gpio_status_,
@@ -80,9 +81,10 @@ bool Tuya::validate_message_() {
// Byte 4: LENGTH1
// Byte 5: LENGTH2
if (at <= 5)
if (at <= 5) {
// no validation for these fields
return true;
}
uint16_t length = (uint16_t(data[4]) << 8) | (uint16_t(data[5]));
@@ -318,9 +320,10 @@ void Tuya::handle_datapoint_(const uint8_t *buffer, size_t len) {
}
// Run through listeners
for (auto &listener : this->listeners_)
for (auto &listener : this->listeners_) {
if (listener.datapoint_id == datapoint.id)
listener.on_datapoint(datapoint);
}
}
void Tuya::send_raw_command_(TuyaCommand command) {
@@ -488,9 +491,10 @@ void Tuya::force_set_bitmask_datapoint_value(uint8_t datapoint_id, uint32_t valu
}
optional<TuyaDatapoint> Tuya::get_datapoint_(uint8_t datapoint_id) {
for (auto &datapoint : this->datapoints_)
for (auto &datapoint : this->datapoints_) {
if (datapoint.id == datapoint_id)
return datapoint;
}
return {};
}
@@ -578,9 +582,10 @@ void Tuya::register_listener(uint8_t datapoint_id, const std::function<void(Tuya
this->listeners_.push_back(listener);
// Run through existing datapoints
for (auto &datapoint : this->datapoints_)
for (auto &datapoint : this->datapoints_) {
if (datapoint.id == datapoint_id)
func(datapoint);
}
}
TuyaInitState Tuya::get_init_state() { return this->init_state_; }