11"""Provides the DataUpdateCoordinator."""
2+
23from __future__ import annotations
34
45from datetime import timedelta
@@ -72,8 +73,15 @@ async def send_command(
7273 while retry_count < RETRY_COUNT :
7374 try :
7475 return await getattr (self .device , function )(** payload )
75- except (InvalidByteValueError , TimeoutError ): # noqa: PERF203
76+ except (InvalidByteValueError , TimeoutError ) as ex : # noqa: PERF203
7677 retry_count += 1
78+ LOGGER .info (
79+ "Retrying command '%s' to '%s' after %s (%s)" ,
80+ payload ,
81+ caller_entity_id ,
82+ type (ex ).__name__ ,
83+ ex ,
84+ )
7785 except ValueError as err :
7886 raise ServiceValidationError (
7987 f"Invalid payload '{ payload } ' for '{ caller_entity_id } ': { err } "
@@ -100,8 +108,7 @@ async def _async_update_data(self) -> dict[str, bytes]:
100108 # If one value was not retrieved correctly, keep the old value
101109 ** {
102110 k : retrieved_temperatures .get (k ) or self .data .get (k )
103- for k
104- in CONF_ALL_TEMPERATURES
111+ for k in CONF_ALL_TEMPERATURES
105112 },
106113 }
107114 # Reset failed update count if all values were retrieved correctly
@@ -110,6 +117,12 @@ async def _async_update_data(self) -> dict[str, bytes]:
110117 # allow invalid bytes until RETRY_COUNT is reached
111118 if self .failed_update_count < RETRY_COUNT and self .data :
112119 self .failed_update_count += 1
120+ LOGGER .info (
121+ "Returning old data for '%s' after %s (%s)" ,
122+ self .device .device .address ,
123+ type (ex ).__name__ ,
124+ ex ,
125+ )
113126 return self .data
114127 raise UpdateFailed (f"Error in device response: { ex } " ) from ex
115128 except Exception as ex :
0 commit comments