Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Commit

Permalink
add debug logging for backoff exceptions in coordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
rlippmann committed Feb 1, 2024
1 parent 5e1e6d8 commit 621a790
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion custom_components/adtpulse/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.util.dt import as_local, utc_from_timestamp
from pyadtpulse.exceptions import (
PulseExceptionWithBackoff,
PulseExceptionWithRetry,
Expand Down Expand Up @@ -83,8 +84,21 @@ async def _async_update_data(self) -> None:
if self.config_entry:
self.config_entry.async_start_reauth(self.hass)
return
except (PulseExceptionWithRetry, PulseExceptionWithBackoff) as ex:
except PulseExceptionWithRetry as ex:
if ex.retry_time:
LOG.debug(
"%s: coordinator received retryable exception will retry at %s",
ADTPULSE_DOMAIN,
as_local(utc_from_timestamp(ex.retry_time)),
)
update_exception = ex
except PulseExceptionWithBackoff as ex:
update_exception = ex
LOG.debug(
"%s: coordinator received backoff exception, backing off for %s seconds",
ADTPULSE_DOMAIN,
ex.backoff.get_current_backoff_interval(),
)
except CancelledError:
LOG.debug("%s: coordinator received cancellation", ADTPULSE_DOMAIN)
return
Expand Down

0 comments on commit 621a790

Please sign in to comment.