Skip to content

Commit ddd1953

Browse files
authored
Merge pull request #40 from cabberley/multi
Multi period calculation bug fix
2 parents f604b25 + 6fa17ff commit ddd1953

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

custom_components/utility_meter_next_gen/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"issue_tracker": "https://github.com/cabberley/utility_meter_evolved/issues",
1212
"requirements": ["cronsim==2.6"],
1313
"ssdp": [],
14-
"version": "2025.7.9",
14+
"version": "2025.7.10",
1515
"zeroconf": []
1616
}

custom_components/utility_meter_next_gen/sensor.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -773,19 +773,15 @@ def async_reading(self, event: Event[EventStateChangedData]) -> None:
773773
and source_calc_state.state not in [STATE_UNAVAILABLE, STATE_UNKNOWN]
774774
):
775775
try:
776-
if str(self._tariff).lower() in [SINGLE_TARIFF, TOTAL_TARIFF]:
777-
# If the tariff is a single tariff or total, we use the calibration value
778-
calibrate_value = Decimal(self._calibrate_calc_value)
779-
else:
780-
# If the tariff is not a single tariff or total, we use 0 as the calibration value
781-
calibrate_value = Decimal(0)
782-
self._attr_calculated_current_value = round(
776+
self._attr_calculated_current_value += round(
783777
(
784778
Decimal(source_calc_state.state)
785-
* Decimal(self._attr_native_value)
779+
# Bug fix with Multi Meters we need to use
780+
# the adjustment and add not just recalc
781+
# Decimal(self._attr_native_value)
782+
* Decimal(adjustment)
786783
* Decimal(self._attr_multiplier)
787-
)
788-
+ calibrate_value,
784+
),
789785
PRECISION,
790786
)
791787
except (DecimalException, InvalidOperation) as err:

0 commit comments

Comments
 (0)