Skip to content

Commit

Permalink
Explicitly pass in the config_entry in jvc_projector coordinator (#13…
Browse files Browse the repository at this point in the history
…8127)

explicitly pass in the config_entry in coordinator
  • Loading branch information
mib1185 authored Feb 9, 2025
1 parent b9828c5 commit ca77b94
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
7 changes: 2 additions & 5 deletions homeassistant/components/jvc_projector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from jvcprojector import JvcProjector, JvcProjectorAuthError, JvcProjectorConnectError

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
Expand All @@ -15,9 +14,7 @@
from homeassistant.core import Event, HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady

from .coordinator import JvcProjectorDataUpdateCoordinator

type JVCConfigEntry = ConfigEntry[JvcProjectorDataUpdateCoordinator]
from .coordinator import JVCConfigEntry, JvcProjectorDataUpdateCoordinator

PLATFORMS = [Platform.BINARY_SENSOR, Platform.REMOTE, Platform.SELECT, Platform.SENSOR]

Expand All @@ -41,7 +38,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: JVCConfigEntry) -> bool:
await device.disconnect()
raise ConfigEntryAuthFailed("Password authentication failed") from err

coordinator = JvcProjectorDataUpdateCoordinator(hass, device)
coordinator = JvcProjectorDataUpdateCoordinator(hass, entry, device)
await coordinator.async_config_entry_first_refresh()

entry.runtime_data = coordinator
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/jvc_projector/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import JVCConfigEntry, JvcProjectorDataUpdateCoordinator
from .coordinator import JVCConfigEntry, JvcProjectorDataUpdateCoordinator
from .entity import JvcProjectorEntity

ON_STATUS = (const.ON, const.WARMING)
Expand Down
10 changes: 9 additions & 1 deletion homeassistant/components/jvc_projector/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
const,
)

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
from homeassistant.helpers.device_registry import format_mac
Expand All @@ -25,15 +26,22 @@
INTERVAL_SLOW = timedelta(seconds=10)
INTERVAL_FAST = timedelta(seconds=5)

type JVCConfigEntry = ConfigEntry[JvcProjectorDataUpdateCoordinator]


class JvcProjectorDataUpdateCoordinator(DataUpdateCoordinator[dict[str, str]]):
"""Data update coordinator for the JVC Projector integration."""

def __init__(self, hass: HomeAssistant, device: JvcProjector) -> None:
config_entry: JVCConfigEntry

def __init__(
self, hass: HomeAssistant, config_entry: JVCConfigEntry, device: JvcProjector
) -> None:
"""Initialize the coordinator."""
super().__init__(
hass=hass,
logger=_LOGGER,
config_entry=config_entry,
name=NAME,
update_interval=INTERVAL_SLOW,
)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/jvc_projector/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import JVCConfigEntry
from .coordinator import JVCConfigEntry
from .entity import JvcProjectorEntity

COMMANDS = {
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/jvc_projector/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import JVCConfigEntry, JvcProjectorDataUpdateCoordinator
from .coordinator import JVCConfigEntry, JvcProjectorDataUpdateCoordinator
from .entity import JvcProjectorEntity


Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/jvc_projector/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import JVCConfigEntry, JvcProjectorDataUpdateCoordinator
from .coordinator import JVCConfigEntry, JvcProjectorDataUpdateCoordinator
from .entity import JvcProjectorEntity

JVC_SENSORS = (
Expand Down

0 comments on commit ca77b94

Please sign in to comment.