diff --git a/homeassistant/components/mastodon/__init__.py b/homeassistant/components/mastodon/__init__.py index 2f713a97dfe..ab8514c8321 100644 --- a/homeassistant/components/mastodon/__init__.py +++ b/homeassistant/components/mastodon/__init__.py @@ -47,7 +47,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: MastodonConfigEntry) -> assert entry.unique_id - coordinator = MastodonCoordinator(hass, client) + coordinator = MastodonCoordinator(hass, entry, client) await coordinator.async_config_entry_first_refresh() diff --git a/homeassistant/components/mastodon/coordinator.py b/homeassistant/components/mastodon/coordinator.py index 4c6fe6b1c88..5d2b193b4a8 100644 --- a/homeassistant/components/mastodon/coordinator.py +++ b/homeassistant/components/mastodon/coordinator.py @@ -32,10 +32,18 @@ type MastodonConfigEntry = ConfigEntry[MastodonData] class MastodonCoordinator(DataUpdateCoordinator[dict[str, Any]]): """Class to manage fetching Mastodon data.""" - def __init__(self, hass: HomeAssistant, client: Mastodon) -> None: + config_entry: MastodonConfigEntry + + def __init__( + self, hass: HomeAssistant, config_entry: MastodonConfigEntry, client: Mastodon + ) -> None: """Initialize coordinator.""" super().__init__( - hass, logger=LOGGER, name="Mastodon", update_interval=timedelta(hours=1) + hass, + logger=LOGGER, + config_entry=config_entry, + name="Mastodon", + update_interval=timedelta(hours=1), ) self.client = client diff --git a/homeassistant/components/mastodon/diagnostics.py b/homeassistant/components/mastodon/diagnostics.py index 7246ae9cf63..dc7c1b785ab 100644 --- a/homeassistant/components/mastodon/diagnostics.py +++ b/homeassistant/components/mastodon/diagnostics.py @@ -6,7 +6,7 @@ from typing import Any from homeassistant.core import HomeAssistant -from . import MastodonConfigEntry +from .coordinator import MastodonConfigEntry async def async_get_config_entry_diagnostics( diff --git a/homeassistant/components/mastodon/entity.py b/homeassistant/components/mastodon/entity.py index 93d630627d7..2ae8c0d852e 100644 --- a/homeassistant/components/mastodon/entity.py +++ b/homeassistant/components/mastodon/entity.py @@ -4,9 +4,8 @@ from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo from homeassistant.helpers.entity import EntityDescription from homeassistant.helpers.update_coordinator import CoordinatorEntity -from . import MastodonConfigEntry from .const import DEFAULT_NAME, DOMAIN, INSTANCE_VERSION -from .coordinator import MastodonCoordinator +from .coordinator import MastodonConfigEntry, MastodonCoordinator from .utils import construct_mastodon_username diff --git a/homeassistant/components/mastodon/sensor.py b/homeassistant/components/mastodon/sensor.py index 1bb59ad7c05..93ec77032ce 100644 --- a/homeassistant/components/mastodon/sensor.py +++ b/homeassistant/components/mastodon/sensor.py @@ -15,12 +15,12 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType -from . import MastodonConfigEntry from .const import ( ACCOUNT_FOLLOWERS_COUNT, ACCOUNT_FOLLOWING_COUNT, ACCOUNT_STATUSES_COUNT, ) +from .coordinator import MastodonConfigEntry from .entity import MastodonEntity # Coordinator is used to centralize the data updates diff --git a/homeassistant/components/mastodon/services.py b/homeassistant/components/mastodon/services.py index ab3a89c0c4b..2a919e5fa5f 100644 --- a/homeassistant/components/mastodon/services.py +++ b/homeassistant/components/mastodon/services.py @@ -12,7 +12,6 @@ from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant, ServiceCall, ServiceResponse from homeassistant.exceptions import HomeAssistantError, ServiceValidationError -from . import MastodonConfigEntry from .const import ( ATTR_CONFIG_ENTRY_ID, ATTR_CONTENT_WARNING, @@ -22,6 +21,7 @@ from .const import ( ATTR_VISIBILITY, DOMAIN, ) +from .coordinator import MastodonConfigEntry from .utils import get_media_type