Skip to content

Commit 4a2155d

Browse files
committed
Graceful response to 420 status: Enhance your calm
1 parent 3bc7732 commit 4a2155d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎custom_components/solcast_solar/solcastapi.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
403: "Forbidden",
9999
404: "Not found",
100100
418: "I'm a teapot",
101+
420: "Enhance your calm (rate limited)",
101102
429: "Try again later",
102103
500: "Internal web server error",
103104
501: "Not implemented",
@@ -630,7 +631,7 @@ def check_rekey(response_json: dict[str, Any], api_key: str) -> bool:
630631
if status in (401, 403):
631632
self.sites_status = SitesStatus.BAD_KEY
632633
break
633-
if status == 429:
634+
if status in (429, 420):
634635
self.sites_status = SitesStatus.API_BUSY
635636
break
636637
self.sites_status = SitesStatus.ERROR
@@ -2435,7 +2436,7 @@ async def get_pv_generation(self) -> None:
24352436
await self.serialise_data(self._data_generation, self._filename_generation)
24362437
_LOGGER.debug("Task get_pv_generation took %.3f seconds", time.time() - start_time)
24372438

2438-
async def model_automated_dampening(self, force: bool = False) -> None: # noqa: C901
2439+
async def model_automated_dampening(self, force: bool = False) -> None:
24392440
"""Model the automated dampening of the forecast data.
24402441
24412442
Look for outliers in PV generation versus estimated actuals.

0 commit comments

Comments
 (0)