Skip to content

Commit

Permalink
Merge pull request #7 from zacs/dev
Browse files Browse the repository at this point in the history
Fix playoff status
  • Loading branch information
zacs authored Jan 12, 2022
2 parents 4fae73a + e06a0fd commit 5745934
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions custom_components/nfl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,30 @@ async def async_get_state(config) -> dict:
_LOGGER.debug("Did not find a game with for the configured team. Checking if it's a bye week.")
found_bye = False
values = await async_clear_states(config)
for bye_team in data["week"]["teamsOnBye"]:
if team_id.lower() == bye_team["abbreviation"].lower():
_LOGGER.debug("Bye week confirmed.")
found_bye = True
values["team_abbr"] = bye_team["abbreviation"]
values["team_name"] = bye_team["shortDisplayName"]
values["team_logo"] = bye_team["logo"]
values["state"] = 'BYE'
values["last_update"] = arrow.now().format(arrow.FORMAT_W3C)
if found_bye == False:
_LOGGER.debug("Team not found in active games or bye week list. Have you missed the playoffs?")
values["team_abbr"] = None
values["team_name"] = None
values["team_logo"] = None
values["state"] = 'NOT_FOUND'
values["last_update"] = arrow.now().format(arrow.FORMAT_W3C)
try: # look for byes in regular season
for bye_team in data["week"]["teamsOnBye"]:
if team_id.lower() == bye_team["abbreviation"].lower():
_LOGGER.debug("Bye week confirmed.")
found_bye = True
values["team_abbr"] = bye_team["abbreviation"]
values["team_name"] = bye_team["shortDisplayName"]
values["team_logo"] = bye_team["logo"]
values["state"] = 'BYE'
values["last_update"] = arrow.now().format(arrow.FORMAT_W3C)
if found_bye == False:
_LOGGER.debug("Team not found in active games or bye week list. Have you missed the playoffs?")
values["team_abbr"] = None
values["team_name"] = None
values["team_logo"] = None
values["state"] = 'NOT_FOUND'
values["last_update"] = arrow.now().format(arrow.FORMAT_W3C)
except:
_LOGGER.debug("Team not found in active games or bye week list. Have you missed the playoffs?")
values["team_abbr"] = None
values["team_name"] = None
values["team_logo"] = None
values["state"] = 'NOT_FOUND'
values["last_update"] = arrow.now().format(arrow.FORMAT_W3C)

if values["state"] == 'PRE' and ((arrow.get(values["date"])-arrow.now()).total_seconds() < 1200):
_LOGGER.debug("Event is within 20 minutes, setting refresh rate to 5 seconds.")
Expand Down

0 comments on commit 5745934

Please sign in to comment.