Explicitly pass in the config_entry in starlink coordinator (#137932)
explicitly pass in the config_entry in coordinatorpull/138061/head
parent
6d776469d2
commit
906beb48a4
|
@ -3,7 +3,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_IP_ADDRESS, Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -21,11 +21,7 @@ PLATFORMS = [
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up Starlink from a config entry."""
|
"""Set up Starlink from a config entry."""
|
||||||
coordinator = StarlinkUpdateCoordinator(
|
coordinator = StarlinkUpdateCoordinator(hass, entry)
|
||||||
hass=hass,
|
|
||||||
url=entry.data[CONF_IP_ADDRESS],
|
|
||||||
name=entry.title,
|
|
||||||
)
|
|
||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ from starlink_grpc import (
|
||||||
status_data,
|
status_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import CONF_IP_ADDRESS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
@ -49,15 +51,17 @@ class StarlinkData:
|
||||||
class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]):
|
class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]):
|
||||||
"""Coordinates updates between all Starlink sensors defined in this file."""
|
"""Coordinates updates between all Starlink sensors defined in this file."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, name: str, url: str) -> None:
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
|
def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None:
|
||||||
"""Initialize an UpdateCoordinator for a group of sensors."""
|
"""Initialize an UpdateCoordinator for a group of sensors."""
|
||||||
self.channel_context = ChannelContext(target=url)
|
self.channel_context = ChannelContext(target=config_entry.data[CONF_IP_ADDRESS])
|
||||||
self.history_stats_start = None
|
self.history_stats_start = None
|
||||||
self.timezone = ZoneInfo(hass.config.time_zone)
|
self.timezone = ZoneInfo(hass.config.time_zone)
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
name=name,
|
name=config_entry.title,
|
||||||
update_interval=timedelta(seconds=5),
|
update_interval=timedelta(seconds=5),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue