Skip to content

Commit 0fdf172

Browse files
committed
Implement CRAI suggestions
1 parent 78516e8 commit 0fdf172

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -544,33 +544,33 @@ async def energy_log_update(self, address: int | None) -> bool:
544544
if (
545545
log_timestamp is None
546546
or log_pulses is None
547-
# Don't store an old log-record, store am empty record instead
547+
# Don't store an old log-record; store am empty record instead
548548
or not self._check_timestamp_is_recent(address, _slot, log_timestamp)
549549
):
550550
self._energy_counters.add_empty_log(response.log_address, _slot)
551551
continue
552552

553-
if await self._energy_log_record_update_state(
553+
await self._energy_log_record_update_state(
554554
response.log_address,
555555
_slot,
556556
log_timestamp.replace(tzinfo=UTC),
557557
log_pulses,
558558
import_only=True,
559-
):
560-
any_record_stored = True
561-
if not last_energy_timestamp_collected:
562-
# Collect the timestamp of the most recent response
563-
self._last_collected_energy_timestamp = log_timestamp.replace(
564-
tzinfo=UTC
565-
)
566-
_LOGGER.debug(
567-
"Setting last_collected_energy_timestamp to %s",
568-
self._last_collected_energy_timestamp,
569-
)
570-
last_energy_timestamp_collected = True
559+
)
560+
any_record_stored = True
561+
if not last_energy_timestamp_collected:
562+
# Collect the timestamp of the most recent response
563+
self._last_collected_energy_timestamp = log_timestamp.replace(
564+
tzinfo=UTC
565+
)
566+
_LOGGER.debug(
567+
"Setting last_collected_energy_timestamp to %s",
568+
self._last_collected_energy_timestamp,
569+
)
570+
last_energy_timestamp_collected = True
571571

572572
self._energy_counters.update()
573-
if any_record_stored:
573+
if any_record_stored and self._cache_enabled:
574574
_LOGGER.debug(
575575
"Saving energy record update to cache for %s", self._mac_in_str
576576
)

0 commit comments

Comments
 (0)