Removed 2 unneeded values from HA reporting, fixed mV reporting value

This commit is contained in:
2026-05-26 16:03:25 +02:00
parent 91f3f69bd9
commit e5104fc005
2 changed files with 13 additions and 16 deletions
-16
View File
@@ -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"
+13
View File
@@ -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<uint16_t>(this->raw_[0]) | (static_cast<uint16_t>(this->raw_[1]) << 8);
uint8_t decimal = pair1 & 0x07;
if (decimal >= 7) return NAN;
uint16_t pair3 = static_cast<uint16_t>(this->raw_[4]) | (static_cast<uint16_t>(this->raw_[5]) << 8);
bool negative = pair3 >= 0x7FFF;
uint16_t digits = negative ? (pair3 & 0x7FFF) : pair3;
float v = static_cast<float>(digits) / std::pow(10.0f, decimal);
return negative ? -v : v;
}
uint8_t decimal = 0;
switch (this->value_[REGPOINT] & 0x07) {
case 0b001: decimal = 1; break;