From db3424b092b9d87c071617e7e5dfbe6908b0233d Mon Sep 17 00:00:00 2001 From: Ryan Hunter Date: Wed, 4 Aug 2021 00:41:09 -0400 Subject: [PATCH] add age of money to sensor attributes --- custom_components/ynab/__init__.py | 7 +++++++ custom_components/ynab/sensor.py | 3 +++ 2 files changed, 10 insertions(+) diff --git a/custom_components/ynab/__init__.py b/custom_components/ynab/__init__.py index e436a28..fff3619 100644 --- a/custom_components/ynab/__init__.py +++ b/custom_components/ynab/__init__.py @@ -183,6 +183,13 @@ async def update_data(self): self.hass.data[DOMAIN_DATA]["activity_this_month"], ) + # get age of money + self.hass.data[DOMAIN_DATA]["age_of_money"] = m.age_of_money + _LOGGER.debug( + "Received data for: age of money: %s", + self.hass.data[DOMAIN_DATA]["age_of_money"], + ) + # get number of overspend categories overspent_categories = len( [c.balance for c in m.categories if c.balance < 0] diff --git a/custom_components/ynab/sensor.py b/custom_components/ynab/sensor.py index f0266a0..18d550f 100644 --- a/custom_components/ynab/sensor.py +++ b/custom_components/ynab/sensor.py @@ -43,6 +43,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["total_balance"] = self.hass.data[DOMAIN_DATA].get( "total_balance"