Coder Social home page Coder Social logo

ben8p / home-assistant-bunq-balance-sensors Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 6.0 60 KB

Home assistant custom component to provide monetary account balance sensors for Bunq

Python 100.00%
home-assistant home-assistant-sensor hacs hassio home-assistant-custom bunq bunq-api

home-assistant-bunq-balance-sensors's Introduction

hacs_badge

Bunq Integration

This integration provides access to Bunq:

  • monetary account balance sensors including transactions
  • debit- and creditcard sensors with a reference to the linked account
  • a service to transfer funds to own accounts
  • a service to link an account to a card.

⚠️⚠️⚠️⚠️⚠️ Backward incompatibility ⚠️⚠️⚠️⚠️⚠️

Version 1.0.0 of the integration was using configuration.yaml and bunq api key. This is now fully deprecated. It won't work anymore. It was replaced by oauth.

If you are upgrading, before installing version 2.0.0 you should:

  • uninstall the previous integration
  • and clean up the configuration.yaml

Minimum version for HA

2023.6.1+

Integration configuration

Simply follow the config flow. The integration uses oauth. In order to get the "client id" and the "client secret" follow these steps:

  • Open the bunq app
  • Go to "Profile"
  • Go to "Developers"
  • Click OAuth
  • Click "Add redirect URL"
  • Enter "https://my.home-assistant.io/redirect/oauth"
  • Click "Done"
  • Click "SHOW CLIENT DETAILS"
  • use the values when configuring the integration

Note: During the configuration process you will be redirected to https://my.home-assistant.io. There, you need to enter the address on which your home assistant can be reached (it can be local ip/dns or external one) Then click on "Link Account"

Why oauth instead of API Key ?

oauth is much safer. API keys gives all writes to your accounts (including money transfert). However, oauth only allow reading.

Displaying transaction details

Each account sensor can show the balance as well as a list of transactions.
You can use the custom card html-template-card to display them.

Example of configuration:

type: "custom:html-template-card"
title: Transactions
ignore_line_breaks: true
content: >
    <style>.bunq_table { width:100% } .bunq_table tr:nth-child(even) {background:
    var(--material-secondary-background-color)}</style>
    <table class="bunq_table">
        <tr>
            <th>Amount</th> <th>Description</th> <th>Time</th>
        </tr>

        {% for transaction in state_attr('sensor.bunq_groceries', 'transactions') %}
        <tr>
            <td style="width: 20%;text-align:right">
            {{ transaction.amount }}&nbsp;{{ transaction.currency }}
            </td>

            <td style="padding:0 0.5em">
            {{ transaction.description }}
            </td>

            <td style="width: 20%;">
            {{ strptime(transaction.created, '%Y-%m-%d %H:%M:%S.%f') | relative_time }}
            </td>
        </tr>
        {% endfor %}
    </table>

CHANGELOG

V2.1.0

  • Add card sensor and service
  • Add transfer service

V2.0.0

  • Replace api_key by oauth
  • Modernize all the code

V1.0.0

  • Initial version

home-assistant-bunq-balance-sensors's People

Contributors

arner avatar basnijholt avatar ben8p avatar rhopman avatar tbrasser avatar wrt54g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

home-assistant-bunq-balance-sensors's Issues

Getting data but no sensors / entities created.

Logs show:

File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 360, in _async_setup_platform

await asyncio.shield(task)

File "/config/custom_components/bunq/sensor.py", line 18, in async_setup_entry

sensors.append(BunqBalanceSensor(coordinator, account))

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/config/custom_components/bunq/bunq_balance_sensor.py", line 23, in __init__

self._async_update_attrs()

File "/config/custom_components/bunq/bunq_balance_sensor.py", line 47, in _async_update_attrs

self.entity_description.name = "bunq_" + account["description"].lower().replace(" ", "_")

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "<string>", line 4, in __setattr__

dataclasses.FrozenInstanceError: cannot assign to field 'name'


Transaction Card is empty

This is what the cards look like in my Lovelace view.
The sensor with the amount of money does work, but however, the transaction card is empty, although I do have made several payments.

Overview - Home

Connection not found

Trying to integrate Bunq to my Home Assistant instance. But every single time since the update (I followed all the steps for a clean setup) it fails by telling me "Connection not found" on the Bunq website..

Any ideas?

CleanShot 2023-06-17 at 00 05 22@2x

Dynamic transaction view in lovelace

Hi,

I have the transaction card and a mini graph card which works perfect but i was also curious if it is possible to make something Dyme does? (https://dyme.app/)
So when i tap that view in my lovelace i will have logos and the money they are send or received. Thanks!

New features for cards and transfers

Thanks for the helpful integration.

I made some updates in a fork that you might be interested in. The code is here: https://github.com/ben8p/home-assistant-bunq-balance-sensors/compare/master...arner:home-assistant-bunq-balance-sensors:cards_payments?expand=1 . Feedback would be appreciated! If you like the concept I can create a PR and we can discuss what's needed to make it ready to merge.

Cards

  • You can see your credit- and debitcards as sensors. The state is the name of the currently connected account (if this account exists in home assistant). Attributes include the limit and atm limit.
  • The service bunq.link_account takes a card sensor and an account sensor as input. It changes the primary connected account of that card to the selected account.

Transfer to own account

The bunq.transfer service lets you transfer a specified amount of the base currency of the account to any of your own accounts that you imported to home assistant, with an optional message.

Why?

You can:

  • see your balances and connected cards on your dashboard at a glance
  • organize your monthly budgets when your salary comes in
  • select the right account for your debitcard based on being at work, in your car, or on specific times or whatever other data you have in home assistant
  • reward yourself by automatically transferring some money from your savings to your fun account whenever you went for a run
  • ...!

bunq sensors unavailable regularly

Hi,

Multiple times a day, the bunq sensors in Home Assistent are unavailable to me. The error message:

Logger: custom_components.bunq
Source: helpers/update_coordinator.py:229
Integration: bunq (documentation)
First occurred: 00:30:26 (1 occurrences)
Last logged: 00:30:26

Error fetching bunq data: Invalid response from API: (401, {'Error': [{'error_description': 'Insufficient authorisation.', 'error_description_translated': 'Insufficient authorisation.'}]})

Usually a restart fixes the issue. Is this a known issue?

Doesnt work

I couldnt get this to work when following the steps? Everything is fine config but does not add any sensors. Is this still working?

Rate limit reached

I noticed that the integration hit the rate-limit this weekend. I saw the following in the logging:

This error originated from a custom integration.

Logger: custom_components.bunq
Source: helpers/update_coordinator.py:350
integration: bunq (documentation)
First occurred: March 15, 2024 at 16:25:14 (20 occurrences)
Last logged: 08:48:06

Error fetching bunq data: Invalid response from API: Rate limit error has occurred with the Bunq API
Error fetching bunq data: Invalid response from API: Timeout occurred while connecting to the Bunq API
Error fetching bunq data: Invalid response from API: (502, {'message': '<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n</body>\r\n</html>\r\n'})

I have allowed access to 4 monetary accounts and 3 cards.

Link account service erroring out

Hi there - thanks for this integration, look forward to using it! Specifically, I am very interested in the link account service but it's constantly erroring out. Could you take a look please?

request - I masked the debit card number:

service: bunq.link_account
data:
card_entity: sensor.mastercard_debit_nnnnnnn
account_entity: sensor.bank_fees

error:
Failed to call service bunq.link_account. Invalid type for field "monetary_account_id" (expected INTEGER).

I've tried multiple accounts without success and all sensors are reporting values.

account_id: "nnnnnnn"
transactions:
-
device_class: monetary
icon: mdi:cash-multiple
friendly_name: Bank Fees

HASS logs reports Direct I/O error

Logger: homeassistant.util.async_
Source: util/async_.py:120
First occurred: 8:49:32 PM (1456 occurrences)
Last logged: 9:38:36 PM

Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for bunq doing I/O at custom_components/bunq/api.py, line 104: "X-Bunq-Client-Request-Id": _request_id,
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for bunq doing I/O at custom_components/bunq/api.py, line 141: "X-Bunq-Client-Authentication": installation_token,
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for bunq doing I/O at custom_components/bunq/api.py, line 159: "X-Bunq-Client-Authentication": installation_token,
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for bunq doing I/O at custom_components/bunq/api.py, line 183: "X-Bunq-Client-Authentication": _session_token,
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for bunq doing I/O at custom_components/bunq/api.py, line 216: "X-Bunq-Client-Authentication": _session_token,

Using this plugin indeed makes my instance rather slow.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.