mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Explicitly pass in the config_entry in mastodon coordinator (#138094)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
f8d4a63644
commit
e3822ed277
@ -47,7 +47,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: MastodonConfigEntry) ->
|
|||||||
|
|
||||||
assert entry.unique_id
|
assert entry.unique_id
|
||||||
|
|
||||||
coordinator = MastodonCoordinator(hass, client)
|
coordinator = MastodonCoordinator(hass, entry, client)
|
||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
|
@ -32,10 +32,18 @@ type MastodonConfigEntry = ConfigEntry[MastodonData]
|
|||||||
class MastodonCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
class MastodonCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
"""Class to manage fetching Mastodon data."""
|
"""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."""
|
"""Initialize coordinator."""
|
||||||
super().__init__(
|
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
|
self.client = client
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from typing import Any
|
|||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from . import MastodonConfigEntry
|
from .coordinator import MastodonConfigEntry
|
||||||
|
|
||||||
|
|
||||||
async def async_get_config_entry_diagnostics(
|
async def async_get_config_entry_diagnostics(
|
||||||
|
@ -4,9 +4,8 @@ from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
|||||||
from homeassistant.helpers.entity import EntityDescription
|
from homeassistant.helpers.entity import EntityDescription
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from . import MastodonConfigEntry
|
|
||||||
from .const import DEFAULT_NAME, DOMAIN, INSTANCE_VERSION
|
from .const import DEFAULT_NAME, DOMAIN, INSTANCE_VERSION
|
||||||
from .coordinator import MastodonCoordinator
|
from .coordinator import MastodonConfigEntry, MastodonCoordinator
|
||||||
from .utils import construct_mastodon_username
|
from .utils import construct_mastodon_username
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import MastodonConfigEntry
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ACCOUNT_FOLLOWERS_COUNT,
|
ACCOUNT_FOLLOWERS_COUNT,
|
||||||
ACCOUNT_FOLLOWING_COUNT,
|
ACCOUNT_FOLLOWING_COUNT,
|
||||||
ACCOUNT_STATUSES_COUNT,
|
ACCOUNT_STATUSES_COUNT,
|
||||||
)
|
)
|
||||||
|
from .coordinator import MastodonConfigEntry
|
||||||
from .entity import MastodonEntity
|
from .entity import MastodonEntity
|
||||||
|
|
||||||
# Coordinator is used to centralize the data updates
|
# Coordinator is used to centralize the data updates
|
||||||
|
@ -12,7 +12,6 @@ from homeassistant.config_entries import ConfigEntryState
|
|||||||
from homeassistant.core import HomeAssistant, ServiceCall, ServiceResponse
|
from homeassistant.core import HomeAssistant, ServiceCall, ServiceResponse
|
||||||
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
|
||||||
|
|
||||||
from . import MastodonConfigEntry
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_CONFIG_ENTRY_ID,
|
ATTR_CONFIG_ENTRY_ID,
|
||||||
ATTR_CONTENT_WARNING,
|
ATTR_CONTENT_WARNING,
|
||||||
@ -22,6 +21,7 @@ from .const import (
|
|||||||
ATTR_VISIBILITY,
|
ATTR_VISIBILITY,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
|
from .coordinator import MastodonConfigEntry
|
||||||
from .utils import get_media_type
|
from .utils import get_media_type
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user