@@ -627,6 +627,7 @@ async def _energy_log_records_save_to_cache(self) -> None:
627627 """Save currently collected energy logs to cached file."""
628628 if not self ._cache_enabled :
629629 return
630+
630631 logs : dict [int , dict [int , PulseLogRecord ]] = (
631632 self ._energy_counters .get_pulse_logs ()
632633 )
@@ -640,6 +641,8 @@ async def _energy_log_records_save_to_cache(self) -> None:
640641 cached_logs += f"-{ log .timestamp .month } -{ log .timestamp .day } "
641642 cached_logs += f"-{ log .timestamp .hour } -{ log .timestamp .minute } "
642643 cached_logs += f"-{ log .timestamp .second } :{ log .pulses } "
644+
645+ _LOGGER .debu ("Saving energy logrecords to cache for %s" , self ._mac_in_str )
643646 self ._set_cache (CACHE_ENERGY_COLLECTION , cached_logs )
644647
645648 async def _energy_log_record_update_state (
@@ -664,7 +667,7 @@ async def _energy_log_record_update_state(
664667 if (cached_logs := self ._get_cache (CACHE_ENERGY_COLLECTION )) is not None :
665668 if log_cache_record not in cached_logs :
666669 _LOGGER .debug (
667- "Add logrecord (%s, %s) to log cache of %s" ,
670+ "Adding logrecord (%s, %s) to cache of %s" ,
668671 str (address ),
669672 str (slot ),
670673 self ._mac_in_str ,
@@ -674,10 +677,16 @@ async def _energy_log_record_update_state(
674677 )
675678 return True
676679
680+ _LOGGER .debug (
681+ "Energy logrecord already present for %s, ignoring" , self ._mac_in_str
682+ )
677683 return False
678684
679685 _LOGGER .debug (
680- "No existing energy collection log cached for %s" , self ._mac_in_str
686+ "Cache is empty, adding new logrecord (%s, %s) for %s" ,
687+ str (address ),
688+ str (slot ),
689+ self ._mac_in_str
681690 )
682691 self ._set_cache (CACHE_ENERGY_COLLECTION , log_cache_record )
683692 return True
0 commit comments