Open elstevega opened 10 months ago
I've got the same issue.
I made a quick script to test monarch money portion of the code (not sure how you properly test a home assistant sensor in isolation) and it returns all the expect data. Still trying to narrow it down but looks right now it seems like a sensor write issue.
from monarchmoney import MonarchMoney
mm = MonarchMoney()
ATTR_ASSETS = "ASSETS"
ATTR_LIABILITIES = "LIABILITIES"
ATTR_BROKERAGE = "Investments"
ATTR_CREDIT = "Credit Cards"
ATTR_DEPOSITORY = "Cash"
ATTR_LOAN = "Loans"
ATTR_OTHER = "Other"
ATTR_REAL_ESTATE = "Real Estate"
ATTR_VALUABLE = "Valuables"
ATTR_VEHICLE = "Vehicles"
ATTR_OTHER_ASSET = "Other Assets"
ATTR_OTHER_LIABILITY = "Other Liabilities"
SENSOR_TYPES_GROUP = {
ATTR_BROKERAGE: {
"type": "brokerage",
"group": ATTR_ASSETS,
"icon": "mdi:chart-line",
},
ATTR_CREDIT: {
"type": "credit",
"group": ATTR_LIABILITIES,
"icon": "mdi:credit-card",
},
ATTR_DEPOSITORY: {"type": "depository", "group": ATTR_ASSETS, "icon": "mdi:cash"},
ATTR_LOAN: {"type": "loan", "group": ATTR_LIABILITIES, "icon": "mdi:bank"},
ATTR_OTHER: {"type": "other", "group": "OTHER", "icon": "mdi:information-outline"},
ATTR_REAL_ESTATE: {"type": "real_estate", "group": ATTR_ASSETS, "icon": "mdi:home"},
ATTR_VALUABLE: {
"type": "valuables",
"group": ATTR_ASSETS,
"icon": "mdi:treasure-chest",
},
ATTR_VEHICLE: {"type": "vehicle", "group": ATTR_ASSETS, "icon": "mdi:car"},
ATTR_OTHER_ASSET: {
"type": "other_asset",
"group": ATTR_ASSETS,
"icon": "mdi:file-document-outline",
},
ATTR_OTHER_LIABILITY: {
"type": "other_liability",
"group": ATTR_LIABILITIES,
"icon": "mdi:account-alert-outline",
},
}
def balances(accounts, category):
account_type = SENSOR_TYPES_GROUP[category]["type"]
account_data = {}
sensor_type_accounts = [
account
for account in accounts
if account.get("type").get("name") == account_type
]
for account in sensor_type_accounts:
institution = None
try:
institution = account.get("credential").get("institution").get("name", "")
except AttributeError:
pass
account_data[account.get("id", "")] = {
"id": account.get("id", ""),
"name": account.get("displayName", ""),
"balance": account.get("displayBalance", ""),
"account_type": account.get("type").get("name", ""),
"institution": institution,
}
sensor_type_accounts_sum = round(
sum(
sensor_type_account["displayBalance"]
for sensor_type_account in sensor_type_accounts
)
)
print(category)
print(sensor_type_accounts_sum)
#print(account_data)
def net_worth(accounts):
print("=======================")
print("Net worth")
print("=======================")
active_accounts = [
account for account in accounts if account["includeInNetWorth"] is True
]
asset_accounts = [
account
for account in active_accounts
if account["isAsset"] is True
# and account["type"]["name"] in ASSET_ACCOUNT_TYPES
]
liability_accounts = [
account
for account in accounts
if account["isAsset"] is False
# and account["type"]["name"] in LIABILITY_ACCOUNT_TYPES
]
asset_accounts_sum = round(
sum(asset_account["displayBalance"] for asset_account in asset_accounts)
)
liability_accounts_sum = round(
sum(
liability_account["displayBalance"]
for liability_account in liability_accounts
)
)
active_accounts_sum = asset_accounts_sum - liability_accounts_sum
print(active_accounts_sum)
print(asset_accounts_sum)
print(liability_accounts_sum)
async def login_to_monarch(email, password):
await mm.login(email, password)
data = await mm.get_accounts()
accounts = data["accounts"]
net_worth(accounts)
categories = SENSOR_TYPES_GROUP.keys()
print("=======================")
print("Balances")
print("=======================")
for category in categories:
balances(accounts, category)
import asyncio
EMAIL=""
PASSWORD=""
asyncio.run(login_to_monarch(EMAIL, PASSWORD))
Thanks for looking into this - curious to see what you find.
The default update interval is 1 hour. Can you check if it updates in 1 hour or not?
I've changed it between 30mins and 1hr doesn't seem to change the sensor. The state doesn't seem to persist either when I alter the settings but i suspect that might be an artifact of HACs or HA.
It's strange be because the net worth sensor is accurate and updates but all other sensors are 0.
Running: | |
---|---|
Core | 2024.1.5 |
Supervisor | 2023.12.1 |
Operating System | 11.4 |
Also having the same issue.
Just installed and having the same issue. All 0's except Net Worth.
I'm wondering if there is a problem with the repo? Downloading through HACs does not bring back the most recent code changes made two weeks ago. If I download the whole repo and drop it in HA I get a 'failed to initialize' error.
If I just selectively use the latest sensor.py, config_flow.py & update_coordinator.py the integration initializes but then again, all sensor except net_worth are 0.
HACS expects we publish a new release in github, I just did that. See if you can pull latest release and if it fixes the issue
Completely deleted the integration & started over in HACs. Looks like it grabbed the 0.0.2 release, which is good, however now it's caught in loop of "Failed setup, will retry" & "Initializing". Nothing in the log.
Same issue as @elstevega
Same issue as @elstevega
Ok - some updates: In sensor.py starting at line 313, comment these lines out & then add: '# c = cashflow.get("summary")[0]
'# self._state = c.get("summary").get("savings") '# self._income = c.get("summary").get("sumIncome") '# self._expenses = c.get("summary").get("sumExpense") '# self._savings = c.get("summary").get("savings") '# self._savings_rate = c.get("summary").get("savingsRate") * 100
self._income = 0
self._expenses = 0
self._savings = 0
self._savings_rate = 0
and in update_coordinator.py comment out lines 109-110 '# cashflow = await self._api.get_cashflow() '# data["cashflow"] = cashflow
Seems Monarch doesn't like the get_cashflow() API call
Now I'm getting data for Cash, Credit, Net Worth & Vehicles. Expense, Income & Cash Flow are unknown
Monarch Loans, Monarch Other, Monarch Other Assets, Monarch Other Liabilities, Monarch Real Estate, Monarch Valuables are all still $0.00 - but that may be correct as I don't have any data that fits those categories. (edit: not true as I have a ton of investment accounts - not sure which bucket they should be in...)
Can you please update to the latest release (0.0.3) and report if it's still an issue?
It works! Thank you!
I can't get past authentication. Anyone having that issue?
On Sun, Jun 30, 2024, 9:43 AM defkon @.***> wrote:
It works! Thank you!
— Reply to this email directly, view it on GitHub https://github.com/sanghviharshit/ha-monarchmoney/issues/3#issuecomment-2198585370, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJXIGPVNWJY2BZP3JMREHCLZKAKPJAVCNFSM6AAAAABCLA37IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYGU4DKMZXGA . You are receiving this because you commented.Message ID: @.***>
Just installed, same thing, most sensors do not update.
I have installed 0.0.3, but:
"version": "0.0.1",
Is still listed in the manifest.json. I notice even in the source code, that this is set to 0.0.1, for the 0.0.3 tag.
Also I think I figured out why part of it was not updating.
In Monarch one of my accounts had a question mark. I deleted it from Monarch and many more sensors are populated.
however the "investments" is still "Unknown", but in Monarch there is money in ithere, and no zero or question mark accounts.
The only sensor that is retrieving data from Monarch Money is 'Net Worth'. All the others are coming back as 0.