1 """Binary Sensor for SimpleFin."""
3 from collections.abc
import Callable
4 from dataclasses
import dataclass
6 from simplefin4py
import Account
9 BinarySensorDeviceClass,
11 BinarySensorEntityDescription,
17 from .
import SimpleFinConfigEntry
18 from .entity
import SimpleFinEntity
21 @dataclass(frozen=True, kw_only=True)
23 """Describes a sensor entity."""
25 value_fn: Callable[[Account], bool]
28 SIMPLEFIN_BINARY_SENSORS: tuple[SimpleFinBinarySensorEntityDescription, ...] = (
31 translation_key=
"possible_error",
32 device_class=BinarySensorDeviceClass.PROBLEM,
33 entity_category=EntityCategory.DIAGNOSTIC,
34 value_fn=
lambda account: account.possible_error,
41 config_entry: SimpleFinConfigEntry,
42 async_add_entities: AddEntitiesCallback,
44 """Set up SimpleFIN sensors for config entries."""
46 sf_coordinator = config_entry.runtime_data
47 accounts = sf_coordinator.data.accounts
55 for account
in accounts
56 for sensor_description
in SIMPLEFIN_BINARY_SENSORS
61 """Extends IntellifireEntity with Binary Sensor specific logic."""
63 entity_description: SimpleFinBinarySensorEntityDescription
67 """Use this to get the correct value."""
Account account_data(self)
None async_setup_entry(HomeAssistant hass, SimpleFinConfigEntry config_entry, AddEntitiesCallback async_add_entities)