Fix fints integration (#69041)

This commit is contained in:
Waldemar Tomme
2022-06-23 01:08:51 +02:00
committed by GitHub
parent fe54db6eb9
commit e855529f73
3 changed files with 18 additions and 18 deletions

View File

@ -2,8 +2,8 @@
"domain": "fints",
"name": "FinTS",
"documentation": "https://www.home-assistant.io/integrations/fints",
"requirements": ["fints==1.0.1"],
"requirements": ["fints==3.1.0"],
"codeowners": [],
"iot_class": "local_push",
"iot_class": "cloud_polling",
"loggers": ["fints", "mt_940", "sepaxml"]
}

View File

@ -7,7 +7,6 @@ import logging
from typing import Any
from fints.client import FinTS3PinTanClient
from fints.dialog import FinTSDialogError
import voluptuous as vol
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
@ -128,6 +127,9 @@ class FinTsClient:
As the fints library is stateless, there is not benefit in caching
the client objects. If that ever changes, consider caching the client
object and also think about potential concurrency problems.
Note: As of version 2, the fints library is not stateless anymore.
This should be considered when reworking this integration.
"""
return FinTS3PinTanClient(
@ -140,24 +142,22 @@ class FinTsClient:
def detect_accounts(self):
"""Identify the accounts of the bank."""
bank = self.client
accounts = bank.get_sepa_accounts()
account_types = {
x["iban"]: x["type"]
for x in bank.get_information()["accounts"]
if x["iban"] is not None
}
balance_accounts = []
holdings_accounts = []
for account in self.client.get_sepa_accounts():
try:
self.client.get_balance(account)
for account in accounts:
account_type = account_types[account.iban]
if 1 <= account_type <= 9: # 1-9 is balance account
balance_accounts.append(account)
except IndexError:
# account is not a balance account.
pass
except FinTSDialogError:
# account is not a balance account.
pass
try:
self.client.get_holdings(account)
elif 30 <= account_type <= 39: # 30-39 is holdings account
holdings_accounts.append(account)
except FinTSDialogError:
# account is not a holdings account.
pass
return balance_accounts, holdings_accounts

View File

@ -638,7 +638,7 @@ feedparser==6.0.2
fiblary3==0.1.8
# homeassistant.components.fints
fints==1.0.1
fints==3.1.0
# homeassistant.components.fitbit
fitbit==0.3.1