Skip to content

Commit

Permalink
Merge pull request #51 from apetrycki/electric
Browse files Browse the repository at this point in the history
Fix electric
  • Loading branch information
dotKrad authored Apr 27, 2024
2 parents ce36020 + c4105c0 commit 93a58ef
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions custom_components/fpl/FplMainRegionApiClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,16 +468,20 @@ async def __getDataFromApplianceUsage(self, account, lastBilledDate) -> dict:
URL_APPLIANCE_USAGE.format(account=account), json=JSON
)
if response.status == 200:
electric = (await response.json())["data"]["electric"]

full = 100
for e in electric:
rr = round(float(e["percentageDollar"]))
if rr < full:
full = full - rr
else:
rr = full
data[e["category"].replace(" ", "_")] = rr
data = (await response.json())["data"]
if "electric" in data:
electric = data["electric"]

full = 100
for e in electric:
rr = round(float(e["percentageDollar"]))
if rr < full:
full = full - rr
else:
rr = full
data[e["category"].replace(" ", "_")] = rr
else:
_LOGGER.info("appliance usage data does not exist")
except Exception as e:
_LOGGER.error(e)

Expand Down

0 comments on commit 93a58ef

Please sign in to comment.