JayBlackedOut / hass-nhlapi

NHL Stats API Integration Into Home Assistant
64 stars 18 forks source link

Too many api requests to statsapi.web.nhl.com #52

Closed rspierz closed 1 year ago

rspierz commented 2 years ago

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 515, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 710, in async_device_update raise exc File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/nhl_api/sensor.py", line 210, in update self.set_state() File "/config/custom_components/nhl_api/sensor.py", line 166, in set_state next_date_time = self.get_game_data()[1] File "/config/custom_components/nhl_api/sensor.py", line 107, in get_game_data dates = Schedule(self._team_id).datetime_info() File "/usr/local/lib/python3.10/site-packages/pynhl/classes.py", line 34, in __init__ self.response = requests.get(url) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in get return request("get", url, params=params, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 565, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='statsapi.web.nhl.com', port=443): Max retries exceeded with url: /api/v1/teams/10?expand=team.schedule.next (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x5ad002f8>: Failed to establish a new connection: [Errno -3] Try again'))

Not sure what happened here, been using this for a year plus not too many issues. It is pre-season games.. hope maybe its just some things to iron out on the remote end and not new throttle limits.

JayBlackedOut commented 2 years ago

What's your polling interval set to in your configuration?

rspierz commented 2 years ago

The defaut 1 sec

JayBlackedOut commented 2 years ago

Did this happen while a game was live? The sensor only updates every 10 seconds in pre-game and less frequently before that.

rspierz commented 2 years ago

Yes, currently watching Leafs preseason game. Also none of the goals have fired (this was working fine in the playoffs this year)

blockdrops commented 2 years ago

I did not see a goal fired for Leafs preseason games as well

JayBlackedOut commented 2 years ago

Sounds like there have been some changes to the API. Unfortunately, the NHL doesn't provide any documentation so the community has to figure things out on our own. I'll look into this in the coming weeks.

waltlillyman commented 2 years ago

FYI, goals scored by the Blues are triggering my HA automation successfully, tonight. Let’s Go Blues!

rspierz commented 2 years ago

I think this may be resolved. Also noticed it firing again.. although not very consistent on the timings perhaps some preseason API jitters the NHL devs are working out :)

JayBlackedOut commented 1 year ago

Yes, I think you're right. I tested over a few different games and the logs are clean and the events are firing as expected. Will close the issue.