Skip to content

Commit

Permalink
Improve forecast fetch error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
autoSteve committed Aug 16, 2024
1 parent fd72e5d commit 0f77f12
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/solcast_solar/solcastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1196,12 +1196,16 @@ async def fetch_data(self, usageCacheFileName, path="error", hours=168, site="",
if rs is not None:
if rs.get('error_code') == 'TooManyRequests':
status = 998
_LOGGER.debug(f"Exceeded daily free limit, setting API Counter to {self._api_used[apikey]}")
_LOGGER.debug(f"Exceeded daily free limit, setting API Counter to {self._api_limit[apikey]}")
self._api_used[apikey] = self._api_limit[apikey]
await self.write_api_usage_cache_file(usageCacheFileName,
{"daily_limit": self._api_limit[apikey], "daily_limit_consumed": self._api_used[apikey]},
apikey)
break
else:
_LOGGER.warning("An unexpected error occurred: %s", rs.get('message'))
status = 1000 # Intentionally not handled below
break
except:
pass
if counter >= tries:
Expand Down

0 comments on commit 0f77f12

Please sign in to comment.