mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 23:27:37 +00:00
Explicitly pass in the config_entry in renson coordinator (#137974)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
7b42dc5c35
commit
8afc3568fb
@ -37,7 +37,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Set up Renson from a config entry."""
|
"""Set up Renson from a config entry."""
|
||||||
|
|
||||||
api = RensonVentilation(entry.data[CONF_HOST])
|
api = RensonVentilation(entry.data[CONF_HOST])
|
||||||
coordinator = RensonCoordinator("Renson", hass, api)
|
coordinator = RensonCoordinator(hass, entry, api)
|
||||||
|
|
||||||
if not await hass.async_add_executor_job(api.connect):
|
if not await hass.async_add_executor_job(api.connect):
|
||||||
raise ConfigEntryNotReady("Cannot connect to Renson device")
|
raise ConfigEntryNotReady("Cannot connect to Renson device")
|
||||||
|
@ -9,30 +9,35 @@ from typing import Any
|
|||||||
|
|
||||||
from renson_endura_delta.renson import RensonVentilation
|
from renson_endura_delta.renson import RensonVentilation
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
|
from .const import DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class RensonCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
class RensonCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||||
"""Data update coordinator for Renson."""
|
"""Data update coordinator for Renson."""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
api: RensonVentilation,
|
api: RensonVentilation,
|
||||||
update_interval=timedelta(seconds=30),
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize my coordinator."""
|
"""Initialize my coordinator."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
# Name of the data. For logging purposes.
|
# Name of the data. For logging purposes.
|
||||||
name=name,
|
name=DOMAIN,
|
||||||
# Polling interval. Will only be polled if there are subscribers.
|
# Polling interval. Will only be polled if there are subscribers.
|
||||||
update_interval=update_interval,
|
update_interval=timedelta(seconds=30),
|
||||||
)
|
)
|
||||||
self.api = api
|
self.api = api
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user