Skip to content

Commit

Permalink
chore(nexa): energy call fallback value
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Apr 12, 2024
1 parent e0d30b3 commit 2f02f2c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions custom_components/nexa_bridge_x/nexa.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ async def fetch_energy_nodes(self) -> NexaEnergyNodeData | None:
if self.legacy:
return None

return await self.request("get", "energy/nodes")
try:
# Not all non-legacy firmware has this apparently
return await self.request("get", "energy/nodes")
except Exception:
return None

async def node_call(
self,
Expand Down Expand Up @@ -421,10 +425,13 @@ def __init__(
self.yesterday_kilowatt_hours = None
self.month_kilowatt_hours = None

if not legacy and data and node_data:
self.populate(data, node_data)
elif legacy and data:
self.populate_legacy(data)
try:
if not legacy and data and node_data:
self.populate(data, node_data)
elif legacy and data:
self.populate_legacy(data)
except Exception:
pass

def populate_legacy(
self,
Expand Down

0 comments on commit 2f02f2c

Please sign in to comment.