Skip to content

Commit 9c59cbd

Browse files
committed
Add guarding for production _energy_statistics
1 parent 9dcba83 commit 9c59cbd

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

plugwise_usb/nodes/helpers/counter.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,22 @@ def update(self) -> None:
173173
self._energy_statistics.week_consumption_reset,
174174
) = self._counters[EnergyType.CONSUMPTION_WEEK].update(self._pulse_collection)
175175

176-
(
177-
self._energy_statistics.hour_production,
178-
self._energy_statistics.hour_production_reset,
179-
) = self._counters[EnergyType.PRODUCTION_HOUR].update(self._pulse_collection)
180-
(
181-
self._energy_statistics.day_production,
182-
self._energy_statistics.day_production_reset,
183-
) = self._counters[EnergyType.PRODUCTION_DAY].update(self._pulse_collection)
184-
(
185-
self._energy_statistics.week_production,
186-
self._energy_statistics.week_production_reset,
187-
) = self._counters[EnergyType.PRODUCTION_WEEK].update(self._pulse_collection)
176+
if self._pulse_collection.production_logging:
177+
self._energy_statistics.log_interval_production = (
178+
self._pulse_collection.log_interval_production
179+
)
180+
(
181+
self._energy_statistics.hour_production,
182+
self._energy_statistics.hour_production_reset,
183+
) = self._counters[EnergyType.PRODUCTION_HOUR].update(self._pulse_collection)
184+
(
185+
self._energy_statistics.day_production,
186+
self._energy_statistics.day_production_reset,
187+
) = self._counters[EnergyType.PRODUCTION_DAY].update(self._pulse_collection)
188+
(
189+
self._energy_statistics.week_production,
190+
self._energy_statistics.week_production_reset,
191+
) = self._counters[EnergyType.PRODUCTION_WEEK].update(self._pulse_collection)
188192

189193
@property
190194
def timestamp(self) -> datetime | None:

0 commit comments

Comments
 (0)