mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Fix fints integration (#69041)
This commit is contained in:
parent
fe54db6eb9
commit
e855529f73
@ -2,8 +2,8 @@
|
|||||||
"domain": "fints",
|
"domain": "fints",
|
||||||
"name": "FinTS",
|
"name": "FinTS",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/fints",
|
"documentation": "https://www.home-assistant.io/integrations/fints",
|
||||||
"requirements": ["fints==1.0.1"],
|
"requirements": ["fints==3.1.0"],
|
||||||
"codeowners": [],
|
"codeowners": [],
|
||||||
"iot_class": "local_push",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["fints", "mt_940", "sepaxml"]
|
"loggers": ["fints", "mt_940", "sepaxml"]
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from fints.client import FinTS3PinTanClient
|
from fints.client import FinTS3PinTanClient
|
||||||
from fints.dialog import FinTSDialogError
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
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
|
As the fints library is stateless, there is not benefit in caching
|
||||||
the client objects. If that ever changes, consider caching the client
|
the client objects. If that ever changes, consider caching the client
|
||||||
object and also think about potential concurrency problems.
|
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(
|
return FinTS3PinTanClient(
|
||||||
@ -140,24 +142,22 @@ class FinTsClient:
|
|||||||
def detect_accounts(self):
|
def detect_accounts(self):
|
||||||
"""Identify the accounts of the bank."""
|
"""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 = []
|
balance_accounts = []
|
||||||
holdings_accounts = []
|
holdings_accounts = []
|
||||||
for account in self.client.get_sepa_accounts():
|
for account in accounts:
|
||||||
try:
|
account_type = account_types[account.iban]
|
||||||
self.client.get_balance(account)
|
if 1 <= account_type <= 9: # 1-9 is balance account
|
||||||
balance_accounts.append(account)
|
balance_accounts.append(account)
|
||||||
except IndexError:
|
elif 30 <= account_type <= 39: # 30-39 is holdings account
|
||||||
# account is not a balance account.
|
|
||||||
pass
|
|
||||||
except FinTSDialogError:
|
|
||||||
# account is not a balance account.
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
self.client.get_holdings(account)
|
|
||||||
holdings_accounts.append(account)
|
holdings_accounts.append(account)
|
||||||
except FinTSDialogError:
|
|
||||||
# account is not a holdings account.
|
|
||||||
pass
|
|
||||||
|
|
||||||
return balance_accounts, holdings_accounts
|
return balance_accounts, holdings_accounts
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ feedparser==6.0.2
|
|||||||
fiblary3==0.1.8
|
fiblary3==0.1.8
|
||||||
|
|
||||||
# homeassistant.components.fints
|
# homeassistant.components.fints
|
||||||
fints==1.0.1
|
fints==3.1.0
|
||||||
|
|
||||||
# homeassistant.components.fitbit
|
# homeassistant.components.fitbit
|
||||||
fitbit==0.3.1
|
fitbit==0.3.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user