Skip to content

Commit

Permalink
Discard supply points without power
Browse files Browse the repository at this point in the history
  • Loading branch information
yinyang17 committed Feb 17, 2024
1 parent 75f7f10 commit 28250d8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions custom_components/pvpc_energy/ufd.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,13 @@ async def supplypoints():
if resp.status == 200:
response = await resp.json()
_LOGGER.debug(f"response={response}")
UFD.cups = response['supplyPoints']['items'][0]['cups']
UFD.power_high = float(response['supplyPoints']['items'][0]['power1'])
UFD.power_low = float(response['supplyPoints']['items'][0]['power2'])
UFD.zip_code = response['supplyPoints']['items'][0]['address']['zipCode']
_LOGGER.debug(f"cups={UFD.cups}, power_high={UFD.power_high}, power_low={UFD.power_low}")
for supplyPoint in response['supplyPoints']['items']:
if supplyPoint['power1'] != '' and supplyPoint['power1'] != '':
UFD.cups = supplyPoint['cups']
UFD.power_high = float(supplyPoint['power1'])
UFD.power_low = float(supplyPoint['power2'])
UFD.zip_code = supplyPoint['address']['zipCode']
_LOGGER.debug(f"cups={UFD.cups}, power_high={UFD.power_high}, power_low={UFD.power_low}")
break
_LOGGER.debug(f"END - UFD.supplypoints()")

0 comments on commit 28250d8

Please sign in to comment.