home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.88k stars 30.95k forks source link

Monzo integration throwing errors and has no data #129511

Open RealGandy opened 3 weeks ago

RealGandy commented 3 weeks ago

The problem

Since approx 09:00 on 29th October (GMT), the Monzo integration has stopped collecting data and is throwing errors in the log as shown below.

What version of Home Assistant Core has the issue?

Core-2024.10.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Monzo Bank

Link to integration documentation on our website

https://www.home-assistant.io/integrations/monzo/

Diagnostics information

No response

Example YAML snippet

Set up via UI

Anything in the logs that might be useful for us?

2024-10-30 16:10:31.009 ERROR (MainThread) [custom_components.monzo] Unexpected error fetching monzo data
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/monzopy/monzopy.py", line 130, in _get_accounts
    for acc in res["accounts"]:
               ~~~^^^^^^^^^^^^
KeyError: 'accounts'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 271, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/monzo/__init__.py", line 73, in async_get_monzo_api_data
    accounts = await externalapi.user_account.accounts()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/monzopy/monzopy.py", line 90, in accounts
    accounts = await self._get_accounts()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/monzopy/monzopy.py", line 135, in _get_accounts
    raise InvalidMonzoAPIResponseError
monzopy.monzopy.InvalidMonzoAPIResponseError
2024-10-30 16:10:31.011 DEBUG (MainThread) [custom_components.monzo] Finished fetching monzo data in 0.261 seconds (success: False)

Additional information

No response

home-assistant[bot] commented 3 weeks ago

Hey there @jakemartin-icl, mind taking a look at this issue as it has been labeled with an integration (monzo) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `monzo` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign monzo` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


monzo documentation monzo source (message by IssueLinks)

JakeMartin-ICL commented 3 weeks ago

Thanks for reporting, there's a user with a similar issue on the HACS version too. It's hard to say what the issue is, as I can't debug it since mine's working. My current plan is to get monzopy to push the contents of the response to home assistant so we can see exactly how the API is responding in the logs.

In the meantime, have you tried removing and setting up the integration again? It'd rule out a failure to detect auth expiry at least

RealGandy commented 3 weeks ago

Oh... I think I may be using the HACS version as well, but I'll take a look at removing and setting it up again.

Just read the notes, so now know the difference

Thanks

RealGandy commented 3 weeks ago

Steps taken - have done this numerous times with the same outcome:

When I log into Monzo dev portal, it shows my OAuth client configuration for HomeAssistant

JakeMartin-ICL commented 3 weeks ago

Thanks again for the extra info, it's a bit strange your auth flow isn't completing. That'd tend to suggest something is blocking the oauth callback. Is your OAuth redirecting to https://my.home-assistant.io/redirect/oauth and https://my.home-assistant.io set up to point at https?

If you haven't tried to the core version, you could maybe give that a go too. It is missing a couple of features, but I think it's a bit more stable.

Otherwise, I'll try and get the improved logging on the HACS version this weekend (though if your auth flow isn't completing now, this might not help)

RealGandy commented 1 week ago

After removing and attempting to re-add the configuration, the initial setup flow was not completing for over a week, trying multiple times. Yesterday, it eventually completed and data is now being collected as expected.

Whilst my issue is now resolved, the extra logging being proposed would certainly assist in future.