From e5104fc005f60685e721519f6e5a4b73fca7f8ec Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Tue, 26 May 2026 16:03:25 +0200 Subject: [PATCH] Removed 2 unneeded values from HA reporting, fixed mV reporting value --- esphome/owon-b35t.yaml | 16 ---------------- esphome/owon_b35t.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/esphome/owon-b35t.yaml b/esphome/owon-b35t.yaml index 2f0a8f9..796668c 100644 --- a/esphome/owon-b35t.yaml +++ b/esphome/owon-b35t.yaml @@ -268,22 +268,6 @@ sensor: name: "${friendly_name} WiFi Signal" update_interval: 60s - - platform: template - name: "${friendly_name} Display Value" - id: owon_display_value - accuracy_decimals: 6 - update_interval: 2s - lambda: |- - return owon_meter.has_reading && !owon_meter.overload ? owon_meter.value() : NAN; - - - platform: template - name: "${friendly_name} Base Value" - id: owon_base_value - accuracy_decimals: 9 - update_interval: 2s - lambda: |- - return owon_meter.has_reading && !owon_meter.overload ? owon_meter.value_base() : NAN; - text_sensor: - platform: template name: "${friendly_name} Reading" diff --git a/esphome/owon_b35t.h b/esphome/owon_b35t.h index bba7ca2..d824472 100644 --- a/esphome/owon_b35t.h +++ b/esphome/owon_b35t.h @@ -277,6 +277,19 @@ class Meter { float calc_display_value_() const { if (this->overload) return NAN; + + if (this->is_plus) { + uint16_t pair1 = static_cast(this->raw_[0]) | (static_cast(this->raw_[1]) << 8); + uint8_t decimal = pair1 & 0x07; + if (decimal >= 7) return NAN; + + uint16_t pair3 = static_cast(this->raw_[4]) | (static_cast(this->raw_[5]) << 8); + bool negative = pair3 >= 0x7FFF; + uint16_t digits = negative ? (pair3 & 0x7FFF) : pair3; + float v = static_cast(digits) / std::pow(10.0f, decimal); + return negative ? -v : v; + } + uint8_t decimal = 0; switch (this->value_[REGPOINT] & 0x07) { case 0b001: decimal = 1; break;