Skip to content

Commit

Permalink
🔧 Fix population of accounts in each category
Browse files Browse the repository at this point in the history
  • Loading branch information
iantrich committed Jan 11, 2019
1 parent 6edc2d4 commit e0123ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Version](https://img.shields.io/badge/version-0.0.5-green.svg?style=for-the-badge)](#) [![mantained](https://img.shields.io/maintenance/yes/2019.svg?style=for-the-badge)](#)
[![Version](https://img.shields.io/badge/version-0.0.6-green.svg?style=for-the-badge)](#) [![mantained](https://img.shields.io/maintenance/yes/2019.svg?style=for-the-badge)](#)

[![maintainer](https://img.shields.io/badge/maintainer-Ian%20Richardson%20%40iantrich-blue.svg?style=for-the-badge)](#)

Expand Down
11 changes: 5 additions & 6 deletions custom_components/sensor/personalcapital.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from homeassistant.components.sensor import (PLATFORM_SCHEMA)
from homeassistant.util import Throttle

__version__ = '0.0.5'
__version__ = '0.0.6'

REQUIREMENTS = ['personalcapital==1.0.1']

Expand Down Expand Up @@ -177,6 +177,7 @@ def update(self):
"""Get the latest state of the sensor."""
self._rest.update()
data = self._rest.data.json()['spData']
_LOGGER.error(data)
self._state = data.get('networth', 0.0)
self._networth = data.get('networth', 0.0)
self._assets = data.get('assets', 0.0)
Expand All @@ -192,7 +193,7 @@ def update(self):
@property
def name(self):
"""Return the name of the sensor."""
return 'Personal Capital Networth'
return 'PC Networth'

@property
def state(self):
Expand Down Expand Up @@ -241,7 +242,7 @@ def __init__(self, hass, rest, unit_of_measurement, sensor_type):
"""Initialize the sensor."""
self.hass = hass
self._rest = rest
self._name = f'Personal Capital {SENSOR_TYPES[sensor_type][3]}'
self._name = f'PC {SENSOR_TYPES[sensor_type][3]}'
self._productType = SENSOR_TYPES[sensor_type][0]
self._accountType = SENSOR_TYPES[sensor_type][1]
self._balanceName = SENSOR_TYPES[sensor_type][2]
Expand All @@ -257,9 +258,7 @@ def update(self):
accounts = data.get('accounts')

for account in accounts:
if self._productType == account.get('productType') and \
(self._accountType == '' or self._accountType == account.get('accountType', '')) and \
account.get('closeDate', '') == '':
if self._productType == account.get('productType') and account.get('closeDate', '') == '':
self.hass.data[self._productType][account.get('name', '')] = {
"name": account.get('name', ''),
"firm_name": account.get('firmName', ''),
Expand Down

0 comments on commit e0123ad

Please sign in to comment.