Skip to content

Commit 5e5986e

Browse files
authored
fix: Fix estimated consumption cases when no FutureConsumption succeeds (#180)
1 parent 1b93373 commit 5e5986e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

custom_components/iec/coordinator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,12 @@ def _calculate_estimated_bill(meter_id, future_consumptions: dict[str, FutureCon
690690
future_consumption = 0
691691

692692
if last_meter_read:
693-
future_consumption = future_consumption_info.total_import - last_meter_read
693+
if future_consumption_info.total_import:
694+
future_consumption = future_consumption_info.total_import - last_meter_read
695+
else:
696+
_LOGGER.warn(f"Failed to calculate Future Consumption, Assuming last meter read \
697+
({last_meter_read}) as full consumption")
698+
future_consumption = last_meter_read
694699

695700
kva_price = power_size * kva_tariff / 365
696701

custom_components/iec/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
"issue_tracker": "https://github.com/guykh/iec-custom-component/issues",
1212
"loggers": ["iec_api"],
1313
"requirements": ["iec-api==0.4.3"],
14-
"version": "0.0.35"
14+
"version": "0.0.36-beta"
1515
}

0 commit comments

Comments
 (0)