validating some other fields sometimes not present
This commit is contained in:
@@ -41,7 +41,7 @@ class FplApi(object):
|
|||||||
self._loop = loop
|
self._loop = loop
|
||||||
self._session = None
|
self._session = None
|
||||||
|
|
||||||
async def get_data(self):
|
async def get_data(self) -> dict:
|
||||||
self._session = aiohttp.ClientSession()
|
self._session = aiohttp.ClientSession()
|
||||||
data = {}
|
data = {}
|
||||||
data["accounts"] = []
|
data["accounts"] = []
|
||||||
@@ -115,7 +115,7 @@ class FplApi(object):
|
|||||||
# self._premise_number = js["data"]["selectedAccount"]["data"]["acctSecSettings"]["premiseNumber"]
|
# self._premise_number = js["data"]["selectedAccount"]["data"]["acctSecSettings"]["premiseNumber"]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def __async_get_data(self, account):
|
async def __async_get_data(self, account) -> dict:
|
||||||
_LOGGER.info(f"Getting Data")
|
_LOGGER.info(f"Getting Data")
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ class FplApi(object):
|
|||||||
data.update(await self.__getDataFromApplianceUsage(account, currentBillDate))
|
data.update(await self.__getDataFromApplianceUsage(account, currentBillDate))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def __getFromProjectedBill(self, account, premise, currentBillDate):
|
async def __getFromProjectedBill(self, account, premise, currentBillDate) -> dict:
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -209,7 +209,7 @@ class FplApi(object):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def __getBBL_async(self, account, projectedBillData):
|
async def __getBBL_async(self, account, projectedBillData) -> dict:
|
||||||
_LOGGER.info(f"Getting budget billing data")
|
_LOGGER.info(f"Getting budget billing data")
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
@@ -295,7 +295,12 @@ class FplApi(object):
|
|||||||
totalPowerUsage = 0
|
totalPowerUsage = 0
|
||||||
if "data" in r["DailyUsage"]:
|
if "data" in r["DailyUsage"]:
|
||||||
for daily in r["DailyUsage"]["data"]:
|
for daily in r["DailyUsage"]["data"]:
|
||||||
if "kwhUsed" in daily.keys():
|
if (
|
||||||
|
"kwhUsed" in daily.keys()
|
||||||
|
and "billingCharge" in daily.keys()
|
||||||
|
and "date" in daily.keys()
|
||||||
|
and "averageHighTemperature" in daily.keys()
|
||||||
|
):
|
||||||
dailyUsage.append(
|
dailyUsage.append(
|
||||||
{
|
{
|
||||||
"usage": daily["kwhUsed"],
|
"usage": daily["kwhUsed"],
|
||||||
@@ -311,7 +316,7 @@ class FplApi(object):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def __getDataFromApplianceUsage(self, account, lastBilledDate):
|
async def __getDataFromApplianceUsage(self, account, lastBilledDate) -> dict:
|
||||||
_LOGGER.info(f"Getting data from applicance usage")
|
_LOGGER.info(f"Getting data from applicance usage")
|
||||||
URL = "https://www.fpl.com/dashboard-api/resources/account/{account}/applianceUsage/{account}"
|
URL = "https://www.fpl.com/dashboard-api/resources/account/{account}/applianceUsage/{account}"
|
||||||
JSON = {"startDate": str(lastBilledDate.strftime("%m%d%Y"))}
|
JSON = {"startDate": str(lastBilledDate.strftime("%m%d%Y"))}
|
||||||
|
|||||||
Reference in New Issue
Block a user