From 0e04ac2836bd582fbd6b953b9733fa6f6bfa7e3a Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Tue, 22 Oct 2024 21:13:30 -0700 Subject: [PATCH] Fix some minor things. --- .../emporia_vue_utility/emporia_vue_utility.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/esphome/components/emporia_vue_utility/emporia_vue_utility.h b/esphome/components/emporia_vue_utility/emporia_vue_utility.h index e3b6834..907a51a 100644 --- a/esphome/components/emporia_vue_utility/emporia_vue_utility.h +++ b/esphome/components/emporia_vue_utility/emporia_vue_utility.h @@ -405,7 +405,7 @@ class EmporiaVueUtility : public PollingComponent, public uart::UARTDevice { } uint8_t parse_meter_div(uint8_t new_meter_div) { - uint8_t div; + uint8_t div = new_meter_div; if ((new_meter_div > 10) || (new_meter_div < 1)) { ESP_LOGW(TAG, "Unreasonable MeterDiv value %d, ignoring", new_meter_div); last_reading_has_error = 1; @@ -415,8 +415,6 @@ class EmporiaVueUtility : public PollingComponent, public uart::UARTDevice { new_meter_div); last_reading_has_error = 1; div = new_meter_div; - } else { - div = new_meter_div; } return div; } @@ -539,8 +537,9 @@ class EmporiaVueUtility : public PollingComponent, public uart::UARTDevice { // 1) Some sort of outage causes a long gap between the previous reading // (or is 0 after a reboot) and the current reading. In this case, the // difference from the previous reading can be "too" large, but actually - // be expected. 2) I have seen erroneous blips of a single sample with a - // value that is way too big. + // be expected. + // 2) I have seen erroneous blips of a single sample with a value that is + // way too big. // // The code handles scenario #1 by ignoring the current reading but then // continuing on as normal after. The code handles scenario #2 by ignoring @@ -645,7 +644,7 @@ class EmporiaVueUtility : public PollingComponent, public uart::UARTDevice { float watts = apply_watt_adjustment(watts_raw, meter_div, cost_unit); if ((watts >= WATTS_MAX) || (watts < WATTS_MIN)) { - ESP_LOGE(TAG, "Unreasonable watts value %d", watts); + ESP_LOGE(TAG, "Unreasonable watts value %f", watts); last_reading_has_error = 1; } else { if (power_sensor_ != nullptr) {