A standalone HACS-ready version of my Monzo Home Assistant integration for preview and testing
This is an integration for Monzo, the UK bank. It provides balance and total balance sensors for each account and balance sensors for each pot. It also registers a webhook for transaction creation events which can be used as a device trigger, plus a simple service to transfer money between your own accounts and pots.
If you'd like to check out the integration on HACS, it can be found at: https://github.com/JakeMartin-ICL/ha-monzo/tree/main The repo with the API wrapper is: https://github.com/JakeMartin-ICL/monzopy
Update 06/06/24: As of today, the Monzo integration is now part of Home Assistant core, however the core version currently lacks some features (pot transfer and device triggers) that didn't make it in time for the release. If you're using these features, stick with this version for now. This version will still continue to be updated, typically getting new fixes and features before the core integration.
Each account is shown in HA as a device
Each device has a balance sensor, plus a total balance if the account has pots
An example of an automation I use to keep my current account at a target I set, moving any excess to savings or pulling back into my current account if needed
In HACS, you'll need to add this repo as a custom repo, then restart:
You'll then be able to add the integration via the UI. For more details on how to setup, see below.
The Monzo integration allows you to connect your Monzo bank accounts to Home Assistant
Before adding the Monzo integration, you'll need to create a Monzo developer account. From here, you need to create a new OAuth client for Home Assistant to use by going to Clients > New OAuth Client, then fill in the form as follows (make sure to copy the URL as shown, don't replace it with your own):
- Name: Home Assistant
- Logo URL: This can be left blank
- Redirect URLs: https://my.home-assistant.io/redirect/oauth
- Description: Eg: Used by the Monzo Home Assistant Integration
- Confidentiality: Confidential
Once submitted, you can proceed with adding the integration, filling in the OAuth details for the client you've created in the Monzo developer portal.
Important - After authorizing Home Assistant access via email, for security you'll also need to verify again from within the Monzo app. A reminder to do this will be displayed in Home Assistant before completing the installation - don't proceed until you've done this from the popup in the mobile app.
If you've forgotten to do this, the integration will fail to load, but you can simply accept the popup and reload the integration without entering your details again.
To add a second Monzo account in Home Assistant, you'll need to repeat the above process for creating an OAuth client. Then in Home Assistant, you need to add the new credentials before trying to add the new entry. Open Application Credentials (three dots menu, top right of Devices & Services page) and click add application credentials - I'd recommend including the person's name in the Name field so you can distinguish it later. Once added you can return to Devices & Services -> Monzo -> Add Entry to proceed with authentication.
The integration will create a device for each of your accounts and pots. For an account or a pot, you'll have:
- Balance: The current balance of the account.
Additionally, an account will also have:
- Total Balance: The current balance of that account plus all of its pots.
Each account will setup a webhook that will fire an event in Home Assistant for each transaction created. The event contains lots of data about the transaction provided exactly reported by the Monzo API. For the structure of this data, see Monzo's transaction created documentation.
These events are also registered as device triggers, so you can, for example, trigger an automation when a transaction is created on your current account and access the data from that event for use in your automation.
For this to work, your Home Assistant instance must be accessible remotely.
pot_transfer
Transfer money between one of your accounts (default: current account) and one of your pots.
register_webhook
and unregister_webhook
Service to manually register and unregister the webhook. This is done automatically as part of (un)installation, but can also be triggered manually with this service.