Removed 2 unneeded values from HA reporting, fixed mV reporting value
This commit is contained in:
@@ -268,22 +268,6 @@ sensor:
|
|||||||
name: "${friendly_name} WiFi Signal"
|
name: "${friendly_name} WiFi Signal"
|
||||||
update_interval: 60s
|
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:
|
text_sensor:
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "${friendly_name} Reading"
|
name: "${friendly_name} Reading"
|
||||||
|
|||||||
@@ -277,6 +277,19 @@ class Meter {
|
|||||||
|
|
||||||
float calc_display_value_() const {
|
float calc_display_value_() const {
|
||||||
if (this->overload) return NAN;
|
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;
|
uint8_t decimal = 0;
|
||||||
switch (this->value_[REGPOINT] & 0x07) {
|
switch (this->value_[REGPOINT] & 0x07) {
|
||||||
case 0b001: decimal = 1; break;
|
case 0b001: decimal = 1; break;
|
||||||
|
|||||||
Reference in New Issue
Block a user