@@ -550,27 +550,27 @@ async def energy_log_update(self, address: int | None) -> bool:
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