Skip to content

Commit

Permalink
🚧 Decrease verbosity of errors upon 429 answers from RTE API
Browse files Browse the repository at this point in the history
Goal is to avoid raising verbose errors when this is a "normal" error.
In practice it should not change the current behavior since refresh
period is calibrated to avoid this. 429 should happen only at startup
(or when removing/re-adding the integration)
  • Loading branch information
kamaradclimber committed Nov 18, 2023
1 parent 990d4bf commit c932c8e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions custom_components/rte_ecowatt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ async def update_method(self):
if api_result.status == 429:
# a code 429 is expected when requesting more often than every 15minutes and not using the sandbox url
# FIXME(kamaradclimber): avoid this error when home assistant is restarting by storing state and last update
if self.data is not None:
_LOGGER.warn(
"Error communicating with RTE API: requests too frequent. Using old data"
)
return self.data
raise UpdateFailed(
f"Error communicating with RTE API: requests too frequent to RTE API"
)
Expand Down

0 comments on commit c932c8e

Please sign in to comment.