Skip to content

Commit

Permalink
feat: Add current month's budgeted amount for monitored categories
Browse files Browse the repository at this point in the history
Signed-off-by: wxt9861 <34514130+wxt9861@users.noreply.github.com>
  • Loading branch information
wxt9861 committed Mar 28, 2023
1 parent 50752fc commit 11a972b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ This component will retreieve the following data from your YNAB budget
1. To be budgeted amount
2. Current month's budgeted amount
3. Current month's remaining balance of any specified category
4. Current balance of any specified account
5. Number of transactions needing approval
6. Number of uncleared transactions
7. Number of overspent categories
4. Current month's budgeted amount of any specific category
5. Current balance of any specified account
6. Number of transactions needing approval
7. Number of uncleared transactions
8. Number of overspent categories

To keep api usage low, the sensor updates every 5 minutes.

Expand Down
5 changes: 4 additions & 1 deletion custom_components/ynab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,12 @@ async def update_data(self):
self.hass.data[DOMAIN_DATA].update(
[(category.name, category.balance / 1000)]
)
self.hass.data[DOMAIN_DATA].update(
[(category.name + "_budgeted", category.budgeted / 1000)]
)
_LOGGER.debug(
"Received data for categories: %s",
[category.name, category.balance / 1000],
[category.name, category.balance / 1000, category.budgeted / 1000],
)


Expand Down
3 changes: 3 additions & 0 deletions custom_components/ynab/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ async def async_update(self):
self.attr[category.replace(" ", "_").lower()] = self.hass.data[
DOMAIN_DATA
].get(category)
self.attr[
(category + "_budgeted").replace(" ", "_").lower()
] = self.hass.data[DOMAIN_DATA].get(category + "_budgeted")
else:
category_error = CATEGORY_ERROR.format(category=category)
_LOGGER.error(category_error)
Expand Down

0 comments on commit 11a972b

Please sign in to comment.