Added exception handling to try to prevent sensor crashing

This commit is contained in:
dotKrad
2020-05-15 00:29:42 -04:00
parent 66f37d228c
commit 33a7977513

View File

@@ -145,6 +145,8 @@ class FplApi(object):
dailyAvg = float(projectedBillData["dailyAvg"])
avgHighTemp = int(projectedBillData["avgHighTemp"])
try:
url = (
"https://app.fpl.com/wps/PA_ESFPortalWeb/getDailyConsumption"
f"?premiseNumber={premise}"
@@ -225,6 +227,10 @@ class FplApi(object):
details.append(day_detail)
data["details"] = details
except:
data["details"] = []
remaining_days = serviceDays - asOfDays
avg_kw = round(total_kw / days, 0)
@@ -239,6 +245,6 @@ class FplApi(object):
data["remaining_days"] = remaining_days
data["mtd_kwh"] = total_kw
data["average_kwh"] = avg_kw
data["details"] = details
return data