Skip to content

Commit bdd0313

Browse files
committed
Don't save calibration data back to cache when loaded before
1 parent 2cdf2d9 commit bdd0313

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ async def _calibration_load_from_cache(self) -> bool:
236236
cal_gain_b,
237237
cal_noise,
238238
cal_tot,
239+
load_from_cache=True,
239240
)
240241
if result:
241242
_LOGGER.debug(
@@ -254,6 +255,7 @@ async def _calibration_update_state(
254255
gain_b: float | None,
255256
off_noise: float | None,
256257
off_tot: float | None,
258+
load_from_cache=False,
257259
) -> bool:
258260
"""Process new energy calibration settings. Returns True if successful."""
259261
if gain_a is None or gain_b is None or off_noise is None or off_tot is None:
@@ -263,13 +265,11 @@ async def _calibration_update_state(
263265
)
264266
# Forward calibration config to energy collection
265267
self._energy_counters.calibration = self._calibration
266-
267-
if self._cache_enabled:
268+
if self._cache_enabled and not load_from_cache:
268269
self._set_cache(CACHE_CALIBRATION_GAIN_A, gain_a)
269270
self._set_cache(CACHE_CALIBRATION_GAIN_B, gain_b)
270271
self._set_cache(CACHE_CALIBRATION_NOISE, off_noise)
271272
self._set_cache(CACHE_CALIBRATION_TOT, off_tot)
272-
_LOGGER.debug("Saving calibration update to cache for %s", self._mac_in_str)
273273
await self.save_cache()
274274
return True
275275

0 commit comments

Comments
 (0)