diff --git a/homeassistant/components/brother/__init__.py b/homeassistant/components/brother/__init__.py index e828d35f9c7..464e6629224 100644 --- a/homeassistant/components/brother/__init__.py +++ b/homeassistant/components/brother/__init__.py @@ -5,17 +5,14 @@ from __future__ import annotations from brother import Brother, SnmpError from homeassistant.components.snmp import async_get_snmp_engine -from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_TYPE, Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady -from .coordinator import BrotherDataUpdateCoordinator +from .coordinator import BrotherConfigEntry, BrotherDataUpdateCoordinator PLATFORMS = [Platform.SENSOR] -type BrotherConfigEntry = ConfigEntry[BrotherDataUpdateCoordinator] - async def async_setup_entry(hass: HomeAssistant, entry: BrotherConfigEntry) -> bool: """Set up Brother from a config entry.""" @@ -30,7 +27,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: BrotherConfigEntry) -> b except (ConnectionError, SnmpError, TimeoutError) as error: raise ConfigEntryNotReady from error - coordinator = BrotherDataUpdateCoordinator(hass, brother) + coordinator = BrotherDataUpdateCoordinator(hass, entry, brother) await coordinator.async_config_entry_first_refresh() entry.runtime_data = coordinator diff --git a/homeassistant/components/brother/coordinator.py b/homeassistant/components/brother/coordinator.py index 69463d107e4..4f518ba8a25 100644 --- a/homeassistant/components/brother/coordinator.py +++ b/homeassistant/components/brother/coordinator.py @@ -5,6 +5,7 @@ import logging from brother import Brother, BrotherSensors, SnmpError, UnsupportedModelError +from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed @@ -12,17 +13,24 @@ from .const import DOMAIN, UPDATE_INTERVAL _LOGGER = logging.getLogger(__name__) +type BrotherConfigEntry = ConfigEntry[BrotherDataUpdateCoordinator] + class BrotherDataUpdateCoordinator(DataUpdateCoordinator[BrotherSensors]): """Class to manage fetching Brother data from the printer.""" - def __init__(self, hass: HomeAssistant, brother: Brother) -> None: + config_entry: BrotherConfigEntry + + def __init__( + self, hass: HomeAssistant, config_entry: BrotherConfigEntry, brother: Brother + ) -> None: """Initialize.""" self.brother = brother super().__init__( hass, _LOGGER, + config_entry=config_entry, name=DOMAIN, update_interval=UPDATE_INTERVAL, ) diff --git a/homeassistant/components/brother/diagnostics.py b/homeassistant/components/brother/diagnostics.py index d4a6c6c5400..33b2e8297e4 100644 --- a/homeassistant/components/brother/diagnostics.py +++ b/homeassistant/components/brother/diagnostics.py @@ -7,7 +7,7 @@ from typing import Any from homeassistant.core import HomeAssistant -from . import BrotherConfigEntry +from .coordinator import BrotherConfigEntry async def async_get_config_entry_diagnostics( diff --git a/homeassistant/components/brother/sensor.py b/homeassistant/components/brother/sensor.py index d49ebdf07ca..087a971f928 100644 --- a/homeassistant/components/brother/sensor.py +++ b/homeassistant/components/brother/sensor.py @@ -24,8 +24,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import CoordinatorEntity -from . import BrotherConfigEntry, BrotherDataUpdateCoordinator from .const import DOMAIN +from .coordinator import BrotherConfigEntry, BrotherDataUpdateCoordinator ATTR_COUNTER = "counter" ATTR_REMAINING_PAGES = "remaining_pages"