zacs / ha-nfl

NFL game scores custom component for Home Assistant
42 stars 32 forks source link

Update __init__.py to guard against empty broadcasts fields #15

Closed gonzotek closed 2 years ago

gonzotek commented 2 years ago

Found a number of my followed teams were coming up unavailable today, but not all of them (BUF was the only working one out of BUF, BAL, PHI, & JAX). Stepping through the json, the broadcasts (event["competitions"][0]["broadcasts"][0]["names"][0]) were empty in each of the non-functioning teams.

A simple try/except block to assign None to the tv_network value if the broadcasts is found to be empty seems to work and the sensors then get populated. @D34DC3N73R 's ha-nfl-card still looks ok without the tv network displayed.

zacs commented 2 years ago

Nice, thanks for the pr!