mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
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:
parent
16390d56b6
commit
711dd7f05b
@ -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
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
||||
|
@ -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__)
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user