JayBlackedOut / hass-nhlapi

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

cannot access local variable 'output' where it is not associated with a value #70

Closed Frazou1 closed 4 months ago

Frazou1 commented 5 months ago

Describe the bug Many error entry in the log

To Reproduce Steps to reproduce the behavior:

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Home Assistant Information

Configuration Add the relevent configuration.yaml entry.

Log Logger: homeassistant.helpers.entity Source: helpers/entity.py:950 First occurred: 3:03:53 PM (1283 occurrences) Last logged: 3:25:20 PM

Update for sensor.canadiens_goal fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 950, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1295, in async_device_update await hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/nhl_api/sensor.py", line 204, in update self.set_state() File "/config/custom_components/nhl_api/sensor.py", line 164, in set_state all_attr = self.get_game_data()[0] ^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/nhl_api/sensor.py", line 102, in get_game_data games = Schedule(self._team_abbrev).game_info() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pynhl/classes.py", line 186, in game_info games = data["gamesByDate"][self.game_index()]["games"][0] ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pynhl/classes.py", line 178, in game_index return output ^^^^^^ UnboundLocalError: cannot access local variable 'output' where it is not associated with a value

Additional context Add any other context about the problem here.

JayBlackedOut commented 5 months ago

Found the issue. I wasn't accounting for season end when there is no game_index found for the next scheduled ga,e. Will update pynhl to address.

JayBlackedOut commented 5 months ago

@Frazou1 Please update the integration to version 0.11.7 and report back. Thanks,

Frazou1 commented 4 months ago

Work fine ! Thank