Skip to content

Commit 4e1bc54

Browse files
committed
Improve _energy_log_record_update_state()
1 parent 058b0d2 commit 4e1bc54

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,10 +734,9 @@ async def _energy_log_record_update_state(
734734
if not self._cache_enabled:
735735
return False
736736

737-
log_cache_record = f"{address}:{slot}:{timestamp.year}"
738-
log_cache_record += f"-{timestamp.month}-{timestamp.day}"
739-
log_cache_record += f"-{timestamp.hour}-{timestamp.minute}"
740-
log_cache_record += f"-{timestamp.second}:{pulses}"
737+
log_cache_record = (
738+
f"{address}:{slot}:{timestamp.strftime('%Y-%m-%d-%H-%M-%S')}:{pulses}"
739+
)
741740
if (cached_logs := self._get_cache(CACHE_ENERGY_COLLECTION)) is not None:
742741
entries = cached_logs.split("|") if cached_logs else []
743742
if log_cache_record not in entries:
@@ -753,6 +752,7 @@ async def _energy_log_record_update_state(
753752
else log_cache_record
754753
)
755754
self._set_cache(CACHE_ENERGY_COLLECTION, new_cache)
755+
await self.save_cache(trigger_only=True)
756756
return True
757757

758758
_LOGGER.debug(

0 commit comments

Comments
 (0)