Skip to content

Commit ecd8889

Browse files
committed
Fix setting cache_updated state
1 parent 2d25c76 commit ecd8889

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,9 @@ async def energy_update(self) -> EnergyStatistics | None: # noqa: PLR0911 PLR09
432432
# Retry with previous log address as Circle node pointer to self._current_log_address
433433
# could be rolled over while the last log is at previous address/slot
434434
prev_log_address, _ = calc_log_address(self._current_log_address, 1, -4)
435-
result = await self.energy_log_update(prev_log_address, save_cache=False)
435+
result = await self.energy_log_update(
436+
prev_log_address, save_cache=False
437+
)
436438
if not result:
437439
_LOGGER.debug(
438440
"async_energy_update | %s | Log rollover | energy_log_update from address %s failed",
@@ -612,13 +614,15 @@ async def energy_log_update(
612614
self._energy_counters.add_empty_log(response.log_address, _slot)
613615
continue
614616

615-
cache_updated = await self._energy_log_record_update_state(
617+
updated = await self._energy_log_record_update_state(
616618
response.log_address,
617619
_slot,
618620
log_timestamp.replace(tzinfo=UTC),
619621
log_pulses,
620622
import_only=True,
621623
)
624+
if updated:
625+
cache_updated = True
622626

623627
self._energy_counters.update()
624628
if cache_updated and save_cache:

0 commit comments

Comments
 (0)