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 homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_IP_ADDRESS, Platform
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -21,11 +21,7 @@ PLATFORMS = [
|
|||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up Starlink from a config entry."""
|
||||
coordinator = StarlinkUpdateCoordinator(
|
||||
hass=hass,
|
||||
url=entry.data[CONF_IP_ADDRESS],
|
||||
name=entry.title,
|
||||
)
|
||||
coordinator = StarlinkUpdateCoordinator(hass, entry)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ from starlink_grpc import (
|
|||
status_data,
|
||||
)
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_IP_ADDRESS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
@ -49,15 +51,17 @@ class StarlinkData:
|
|||
class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]):
|
||||
"""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."""
|
||||
self.channel_context = ChannelContext(target=url)
|
||||
self.channel_context = ChannelContext(target=config_entry.data[CONF_IP_ADDRESS])
|
||||
self.history_stats_start = None
|
||||
self.timezone = ZoneInfo(hass.config.time_zone)
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
name=name,
|
||||
name=config_entry.title,
|
||||
update_interval=timedelta(seconds=5),
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue