1 """Base class for Mastodon entities."""
7 from .
import MastodonConfigEntry
8 from .const
import DEFAULT_NAME, DOMAIN, INSTANCE_VERSION
9 from .coordinator
import MastodonCoordinator
10 from .utils
import construct_mastodon_username
14 """Defines a base Mastodon entity."""
16 _attr_has_entity_name =
True
20 coordinator: MastodonCoordinator,
21 entity_description: EntityDescription,
22 data: MastodonConfigEntry,
24 """Initialize Mastodon entity."""
26 unique_id = data.unique_id
27 assert unique_id
is not None
32 if data.title != DEFAULT_NAME:
33 name = f
"Mastodon {data.title}"
36 data.runtime_data.instance, data.runtime_data.account
40 identifiers={(DOMAIN, unique_id)},
41 manufacturer=
"Mastodon gGmbH",
42 model=full_account_name,
43 entry_type=DeviceEntryType.SERVICE,
44 sw_version=data.runtime_data.instance[INSTANCE_VERSION],
None __init__(self, MastodonCoordinator coordinator, EntityDescription entity_description, MastodonConfigEntry data)
str construct_mastodon_username(dict[str, str]|None instance, dict[str, str]|None account)