Add SimpleFin binary sensor for errors (#122554)

* Binary Sensor Support

* updated requirements

* ng ambr

* update strings.json

* update snapshot
This commit is contained in:
Jeef 2024-08-25 21:57:57 -06:00 committed by GitHub
parent d915fee833
commit 0dfe12840d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 873 additions and 1 deletions

View File

@ -11,7 +11,10 @@ from homeassistant.core import HomeAssistant
from .const import CONF_ACCESS_URL
from .coordinator import SimpleFinDataUpdateCoordinator
PLATFORMS: list[str] = [Platform.SENSOR]
PLATFORMS: list[str] = [
Platform.BINARY_SENSOR,
Platform.SENSOR,
]
type SimpleFinConfigEntry = ConfigEntry[SimpleFinDataUpdateCoordinator]

View File

@ -0,0 +1,68 @@
"""Binary Sensor for SimpleFin."""
from collections.abc import Callable
from dataclasses import dataclass
from simplefin4py import Account
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
BinarySensorEntityDescription,
)
from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import SimpleFinConfigEntry
from .entity import SimpleFinEntity
@dataclass(frozen=True, kw_only=True)
class SimpleFinBinarySensorEntityDescription(BinarySensorEntityDescription):
"""Describes a sensor entity."""
value_fn: Callable[[Account], bool]
SIMPLEFIN_BINARY_SENSORS: tuple[SimpleFinBinarySensorEntityDescription, ...] = (
SimpleFinBinarySensorEntityDescription(
key="possible_error",
translation_key="possible_error",
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda account: account.possible_error,
),
)
async def async_setup_entry(
hass: HomeAssistant,
config_entry: SimpleFinConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up SimpleFIN sensors for config entries."""
sf_coordinator = config_entry.runtime_data
accounts = sf_coordinator.data.accounts
async_add_entities(
SimpleFinBinarySensor(
sf_coordinator,
sensor_description,
account,
)
for account in accounts
for sensor_description in SIMPLEFIN_BINARY_SENSORS
)
class SimpleFinBinarySensor(SimpleFinEntity, BinarySensorEntity):
"""Extends IntellifireEntity with Binary Sensor specific logic."""
entity_description: SimpleFinBinarySensorEntityDescription
@property
def is_on(self) -> bool:
"""Use this to get the correct value."""
return self.entity_description.value_fn(self.account_data)

View File

@ -21,6 +21,9 @@
}
},
"entity": {
"binary_sensor": {
"possible_error": { "name": "Possible error" }
},
"sensor": {
"balance": {
"name": "Balance"

View File

@ -0,0 +1,769 @@
# serializer version: 1
# name: test_all_entities[binary_sensor.investments_dr_evil_possible_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.investments_dr_evil_possible_error',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Possible error',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-4k5l6m7n-8o9p-1q2r-3s4t_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.investments_dr_evil_possible_error-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Investments Dr Evil Possible error',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.investments_dr_evil_possible_error',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[binary_sensor.investments_dr_evil_problem-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.investments_dr_evil_problem',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Problem',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-4k5l6m7n-8o9p-1q2r-3s4t_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.investments_dr_evil_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Investments Dr Evil Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.investments_dr_evil_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[binary_sensor.investments_my_checking_possible_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.investments_my_checking_possible_error',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Possible error',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-1k2l3m4n-5o6p-7q8r-9s0t_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.investments_my_checking_possible_error-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Investments My Checking Possible error',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.investments_my_checking_possible_error',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[binary_sensor.investments_my_checking_problem-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.investments_my_checking_problem',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Problem',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-1k2l3m4n-5o6p-7q8r-9s0t_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.investments_my_checking_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Investments My Checking Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.investments_my_checking_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[binary_sensor.investments_nerdcorp_series_b_possible_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.investments_nerdcorp_series_b_possible_error',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Possible error',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-5k6l7m8n-9o0p-1q2r-3s4t_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.investments_nerdcorp_series_b_possible_error-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Investments NerdCorp Series B Possible error',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.investments_nerdcorp_series_b_possible_error',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[binary_sensor.investments_nerdcorp_series_b_problem-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.investments_nerdcorp_series_b_problem',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Problem',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-5k6l7m8n-9o0p-1q2r-3s4t_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.investments_nerdcorp_series_b_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Investments NerdCorp Series B Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.investments_nerdcorp_series_b_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[binary_sensor.mythical_randomsavings_castle_mortgage_possible_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.mythical_randomsavings_castle_mortgage_possible_error',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Possible error',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-7a8b9c0d-1e2f-3g4h-5i6j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.mythical_randomsavings_castle_mortgage_possible_error-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Mythical RandomSavings Castle Mortgage Possible error',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.mythical_randomsavings_castle_mortgage_possible_error',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_entities[binary_sensor.mythical_randomsavings_castle_mortgage_problem-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.mythical_randomsavings_castle_mortgage_problem',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Problem',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-7a8b9c0d-1e2f-3g4h-5i6j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.mythical_randomsavings_castle_mortgage_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Mythical RandomSavings Castle Mortgage Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.mythical_randomsavings_castle_mortgage_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_entities[binary_sensor.mythical_randomsavings_unicorn_pot_possible_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.mythical_randomsavings_unicorn_pot_possible_error',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Possible error',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-6a7b8c9d-0e1f-2g3h-4i5j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.mythical_randomsavings_unicorn_pot_possible_error-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Mythical RandomSavings Unicorn Pot Possible error',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.mythical_randomsavings_unicorn_pot_possible_error',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_entities[binary_sensor.mythical_randomsavings_unicorn_pot_problem-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.mythical_randomsavings_unicorn_pot_problem',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Problem',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-6a7b8c9d-0e1f-2g3h-4i5j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.mythical_randomsavings_unicorn_pot_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Mythical RandomSavings Unicorn Pot Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.mythical_randomsavings_unicorn_pot_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_entities[binary_sensor.random_bank_costco_anywhere_visa_r_card_possible_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.random_bank_costco_anywhere_visa_r_card_possible_error',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Possible error',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-3a4b5c6d-7e8f-9g0h-1i2j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.random_bank_costco_anywhere_visa_r_card_possible_error-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Random Bank Costco Anywhere Visa® Card Possible error',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.random_bank_costco_anywhere_visa_r_card_possible_error',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_entities[binary_sensor.random_bank_costco_anywhere_visa_r_card_problem-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.random_bank_costco_anywhere_visa_r_card_problem',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Problem',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-3a4b5c6d-7e8f-9g0h-1i2j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.random_bank_costco_anywhere_visa_r_card_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'Random Bank Costco Anywhere Visa® Card Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.random_bank_costco_anywhere_visa_r_card_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_all_entities[binary_sensor.the_bank_of_go_prime_savings_possible_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.the_bank_of_go_prime_savings_possible_error',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Possible error',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-2a3b4c5d-6e7f-8g9h-0i1j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.the_bank_of_go_prime_savings_possible_error-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'The Bank of Go PRIME SAVINGS Possible error',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.the_bank_of_go_prime_savings_possible_error',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[binary_sensor.the_bank_of_go_prime_savings_problem-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.the_bank_of_go_prime_savings_problem',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Problem',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-2a3b4c5d-6e7f-8g9h-0i1j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.the_bank_of_go_prime_savings_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'The Bank of Go PRIME SAVINGS Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.the_bank_of_go_prime_savings_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[binary_sensor.the_bank_of_go_the_bank_possible_error-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.the_bank_of_go_the_bank_possible_error',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Possible error',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-1a2b3c4d-5e6f-7g8h-9i0j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.the_bank_of_go_the_bank_possible_error-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'The Bank of Go The Bank Possible error',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.the_bank_of_go_the_bank_possible_error',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_all_entities[binary_sensor.the_bank_of_go_the_bank_problem-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.the_bank_of_go_the_bank_problem',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Problem',
'platform': 'simplefin',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'possible_error',
'unique_id': 'account_ACT-1a2b3c4d-5e6f-7g8h-9i0j_possible_error',
'unit_of_measurement': None,
})
# ---
# name: test_all_entities[binary_sensor.the_bank_of_go_the_bank_problem-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'attribution': 'Data provided by SimpleFIN API',
'device_class': 'problem',
'friendly_name': 'The Bank of Go The Bank Problem',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.the_bank_of_go_the_bank_problem',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---

View File

@ -0,0 +1,29 @@
"""Test SimpleFin Sensor with Snapshot data."""
from unittest.mock import AsyncMock, patch
from syrupy import SnapshotAssertion
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import setup_integration
from tests.common import MockConfigEntry, snapshot_platform
async def test_all_entities(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
mock_config_entry: MockConfigEntry,
entity_registry: er.EntityRegistry,
mock_simplefin_client: AsyncMock,
) -> None:
"""Test all entities."""
with patch(
"homeassistant.components.simplefin.PLATFORMS", [Platform.BINARY_SENSOR]
):
await setup_integration(hass, mock_config_entry)
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)