Skip to content

Commit

Permalink
ensure price state exists before doing calcs
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnodgrass committed Jan 19, 2022
1 parent a9e9792 commit 8393639
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/helium/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ async def async_update(self):
self._attrs[attr] = json[attr]

# update USD price attribute for the current HNT value based on current Oracle HNT/USD price
self._attrs[CURRENCY_USD] = round(self._price_sensor.state * self._state, 2)

if self._state and self._price_sensor.state:
self._attrs[CURRENCY_USD] = round(self._price_sensor.state * self._state, 2)
else
self._attrs.pop(CURRENCY_USD)

@property
def extra_state_attributes(self):
Expand Down

0 comments on commit 8393639

Please sign in to comment.