* reset to latest dev branch * Update homeassistant/components/simplefin/sensor.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * formatting tweak * Removed info errors * fix bad billing error message * addressing PR * addressing PR * reauth abort and already_confiugred added to strings.json * adding the reauth message * ruff * update reqs * reset to latest dev branch * Update homeassistant/components/simplefin/sensor.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * formatting tweak * Removed info errors * fix bad billing error message * addressing PR * addressing PR * reauth abort and already_confiugred added to strings.json * adding the reauth message * ruff * update reqs * Update homeassistant/components/simplefin/__init__.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Addressing a few PR comments - removing nix - and adding runtime data * updated comments * rename config flow * pulling reauth :( - inline stuff * inline more * fixed a tab issue * reverting changes * various PR updates and code removal * generator async add * Update homeassistant/components/simplefin/__init__.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/simplefin/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/simplefin/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/simplefin/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/simplefin/sensor.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * always callable * Update homeassistant/components/simplefin/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * no-verify * type * fixing missing domain * it looks like this file is gone now * typing * sorta pass * fix license * Update homeassistant/components/simplefin/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/simplefin/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * addressing PR * Update homeassistant/components/simplefin/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * move property to entity.py * moved stuff out to else block * Initial Snappshot Testing ... still have unadressed changes to make * Addressing PR Comments * pushing back to joost * removing non-needed file * added more asserts * reducing mocks - need to fix patch paths still * Changed patch to be more localized to config_flow * Removed unneeded fixture * Moved coordinator around * Cleaning up the code * Removed a NOQA" * Upping the number of asserts * cleanup * fixed abort call * incremental update - for Josot... changed a function signature and removed an annotatoin * no-verify * Added an abort test * ruff * increased coverage but it might not pass muster for JOOST * increased coverage but it might not pass muster for JOOST * Much nicer test now * tried to simplify * Fix nits --------- Co-authored-by: Erik Montnemery <erik@montnemery.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
"""SimpleFin Base Entity."""
|
|
|
|
from simplefin4py import Account
|
|
|
|
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
|
from homeassistant.helpers.entity import EntityDescription
|
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
|
|
|
from .const import DOMAIN
|
|
from .coordinator import SimpleFinDataUpdateCoordinator
|
|
|
|
|
|
class SimpleFinEntity(CoordinatorEntity[SimpleFinDataUpdateCoordinator]):
|
|
"""Define a generic class for SimpleFIN entities."""
|
|
|
|
_attr_attribution = "Data provided by SimpleFIN API"
|
|
_attr_has_entity_name = True
|
|
|
|
def __init__(
|
|
self,
|
|
coordinator: SimpleFinDataUpdateCoordinator,
|
|
description: EntityDescription,
|
|
account: Account,
|
|
) -> None:
|
|
"""Class initializer."""
|
|
super().__init__(coordinator)
|
|
self.entity_description = description
|
|
self._account_id = account.id
|
|
|
|
self._attr_unique_id = f"account_{account.id}_{description.key}"
|
|
|
|
self._attr_device_info = DeviceInfo(
|
|
identifiers={(DOMAIN, account.id)},
|
|
name=f"{account.org.name} {account.name}",
|
|
entry_type=DeviceEntryType.SERVICE,
|
|
manufacturer=account.org.name,
|
|
model=account.name,
|
|
)
|
|
|
|
@property
|
|
def account_data(self) -> Account:
|
|
"""Return the account data."""
|
|
return self.coordinator.data.get_account_for_id(self._account_id)
|