Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extra_state_attributes fix & ynab-sdk bump #19

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.9

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ynab

YNAB component for Home Assistant
YNAB component for Home Assistant
This component will retreieve the following data from your YNAB budget

1. To be budgeted amount
Expand Down Expand Up @@ -42,7 +42,7 @@ To keep api usage low, the sensor updates every 5 minutes.
| `budget` | `string` | False | last-used | Budget ID to use if you have multiple budgets. If none specified, your last used budget will be used |
| `currency` | `string` | False | \$ | Currency to use as unit of measurement |
| `categories` | `list` | False | None | List of YNAB categories to include in the sensor. These are **CASE SENSITIVE** |
| `accounts` | `list` | False | None | List of YNAB categories to include in the sensor. These are **CASE SENSITIVE** |
| `accounts` | `list` | False | None | List of YNAB accounts to include in the sensor. These are **CASE SENSITIVE** |

### Example default configuration.yaml

Expand Down Expand Up @@ -84,6 +84,6 @@ API:
4. Enter your password and click Generate
5. Copy the token that appears at the top of the page

Budget ID:
Budget ID:
The budget ID is the combination between the slashes after the URL <https://app.youneedabudget.com>
If you only have one budget, you can omit the the budget option, if you have multiple budgets pick a budget you want the sensor to report on. At this time only 1 budget is retrieved.
4 changes: 3 additions & 1 deletion custom_components/ynab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ async def update_data(self):
if account.name not in self.accounts:
continue
else:
self.hass.data[DOMAIN_DATA].update([(account.name, account.balance / 1000)])
self.hass.data[DOMAIN_DATA].update(
[(account.name, account.balance / 1000)]
)
_LOGGER.debug(
"Received data for account: %s",
[account.name, account.balance / 1000],
Expand Down
4 changes: 2 additions & 2 deletions custom_components/ynab/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"issue_tracker": "https://github.com/wxt9861/ynab/issues",
"dependencies": [],
"codeowners": ["@wxt9861"],
"requirements": ["ynab-sdk==0.2.4"],
"version": "0.1.10"
"requirements": ["ynab-sdk==0.2.5"],
"version": "0.1.11"
}
10 changes: 3 additions & 7 deletions custom_components/ynab/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ async def async_update(self):
self.attr["activity_this_month"] = self.hass.data[DOMAIN_DATA].get(
"activity_this_month"
)
self.attr["age_of_money"] = self.hass.data[DOMAIN_DATA].get(
"age_of_money"
)
self.attr["age_of_money"] = self.hass.data[DOMAIN_DATA].get("age_of_money")

self.attr["total_balance"] = self.hass.data[DOMAIN_DATA].get(
"total_balance"
)
self.attr["total_balance"] = self.hass.data[DOMAIN_DATA].get("total_balance")

self.attr["need_approval"] = self.hass.data[DOMAIN_DATA].get("need_approval")

Expand Down Expand Up @@ -109,6 +105,6 @@ def icon(self):
return ICON

@property
def device_state_attributes(self):
def extra_state_attributes(self):
"""Return the state attributes."""
return self.attr