Skip to content

Commit 6ad8523

Browse files
committed
Optimize energy_log_update() further
1 parent 9e0a3be commit 6ad8523

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,6 @@ async def energy_log_update(
589589

590590
_LOGGER.debug("EnergyLogs from node %s, address=%s:", self._mac_in_str, address)
591591
await self._available_update_state(True, response.timestamp)
592-
energy_record_update = False
593592

594593
# Forward historical energy log information to energy counters
595594
# Each response message contains 4 log counters (slots) of the
@@ -608,17 +607,16 @@ async def energy_log_update(
608607
self._energy_counters.add_empty_log(response.log_address, _slot)
609608
continue
610609

611-
await self._energy_log_record_update_state(
610+
cache_updated = await self._energy_log_record_update_state(
612611
response.log_address,
613612
_slot,
614613
log_timestamp.replace(tzinfo=UTC),
615614
log_pulses,
616615
import_only=True,
617616
)
618-
energy_record_update = True
619617

620618
self._energy_counters.update()
621-
if energy_record_update and self._cache_enabled and save_cache:
619+
if cache_updated and save_cache:
622620
_LOGGER.debug(
623621
"Saving energy record update to cache for %s", self._mac_in_str
624622
)

0 commit comments

Comments
 (0)