Skip to content

Commit

Permalink
only add joint savings if joint account was found
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-oswald committed Dec 8, 2023
1 parent 919664b commit f2ac8ec
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions custom_components/up/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for account_id in coordinator.data["accounts"]:
entities.append(Account(coordinator, coordinator.data["accounts"][account_id]))

entities.append(TotalSavings(
coordinator,
'joint',
coordinator.data['totals']['joint']['balance'],
coordinator.data['accounts'][coordinator.data['totals']['joint']['id']]
))

individual_balance = coordinator.data['totals']['individual']['balance']
individual_id = coordinator.data['totals']['individual']['id']
entities.append(TotalSavings(
coordinator,
'individual',
coordinator.data['totals']['individual']['balance'],
coordinator.data['accounts'][coordinator.data['totals']['individual']['id']]
individual_balance,
coordinator.data['accounts'][individual_id]
))

joint_balance = coordinator.data['totals']['joint']['balance']
joint_id = coordinator.data['totals']['joint']['id']
if(joint_id != ''):
entities.append(TotalSavings(
coordinator,
'joint',
joint_balance,
coordinator.data['accounts'][joint_id]
))


async_add_entities(entities)
Expand Down

0 comments on commit f2ac8ec

Please sign in to comment.