Explicitly pass in the config_entry in madvr coordinator init (#137468)

explicitly pass in the config_entry in coordinator init
This commit is contained in:
Michael 2025-02-06 18:42:22 +01:00 committed by GitHub
parent 16390d56b6
commit 711dd7f05b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 11 additions and 17 deletions

View File

@ -6,17 +6,13 @@ import logging
from madvr.madvr import Madvr
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP, Platform
from homeassistant.core import Event, HomeAssistant
from .coordinator import MadVRCoordinator
from .coordinator import MadVRConfigEntry, MadVRCoordinator
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.REMOTE, Platform.SENSOR]
type MadVRConfigEntry = ConfigEntry[MadVRCoordinator]
_LOGGER = logging.getLogger(__name__)
@ -41,7 +37,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: MadVRConfigEntry) -> boo
connect_timeout=10,
loop=hass.loop,
)
coordinator = MadVRCoordinator(hass, madVRClient)
coordinator = MadVRCoordinator(hass, entry, madVRClient)
entry.runtime_data = coordinator

View File

@ -12,8 +12,7 @@ from homeassistant.components.binary_sensor import (
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import MadVRConfigEntry
from .coordinator import MadVRCoordinator
from .coordinator import MadVRConfigEntry, MadVRCoordinator
from .entity import MadVREntity
_HDR_FLAG = "hdr_flag"

View File

@ -3,10 +3,11 @@
from __future__ import annotations
import logging
from typing import TYPE_CHECKING, Any
from typing import Any
from madvr.madvr import Madvr
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -14,8 +15,7 @@ from .const import DOMAIN
_LOGGER = logging.getLogger(__name__)
if TYPE_CHECKING:
from . import MadVRConfigEntry
type MadVRConfigEntry = ConfigEntry[MadVRCoordinator]
class MadVRCoordinator(DataUpdateCoordinator[dict[str, Any]]):
@ -26,10 +26,11 @@ class MadVRCoordinator(DataUpdateCoordinator[dict[str, Any]]):
def __init__(
self,
hass: HomeAssistant,
config_entry: MadVRConfigEntry,
client: Madvr,
) -> None:
"""Initialize madvr coordinator."""
super().__init__(hass, _LOGGER, name=DOMAIN)
super().__init__(hass, _LOGGER, config_entry=config_entry, name=DOMAIN)
assert self.config_entry.unique_id
self.mac = self.config_entry.unique_id
self.client = client

View File

@ -8,7 +8,7 @@ from homeassistant.components.diagnostics import async_redact_data
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from . import MadVRConfigEntry
from .coordinator import MadVRConfigEntry
TO_REDACT = [CONF_HOST]

View File

@ -10,8 +10,7 @@ from homeassistant.components.remote import RemoteEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import MadVRConfigEntry
from .coordinator import MadVRCoordinator
from .coordinator import MadVRConfigEntry, MadVRCoordinator
from .entity import MadVREntity
_LOGGER = logging.getLogger(__name__)

View File

@ -16,7 +16,6 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from . import MadVRConfigEntry
from .const import (
ASPECT_DEC,
ASPECT_INT,
@ -45,7 +44,7 @@ from .const import (
TEMP_HDMI,
TEMP_MAINBOARD,
)
from .coordinator import MadVRCoordinator
from .coordinator import MadVRConfigEntry, MadVRCoordinator
from .entity import MadVREntity