Explicitly pass in the config_entry in steamist coordinator (#137930)
explicitly pass in the config_entry in coordinatorpull/137961/head
parent
ed8ee34a28
commit
32d13f3356
|
@ -8,7 +8,7 @@ from typing import Any
|
|||
from aiosteamist import Steamist
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, Platform
|
||||
from homeassistant.const import CONF_HOST, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -52,9 +52,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
host = entry.data[CONF_HOST]
|
||||
coordinator = SteamistDataUpdateCoordinator(
|
||||
hass,
|
||||
entry,
|
||||
Steamist(host, async_get_clientsession(hass)),
|
||||
host,
|
||||
entry.data.get(CONF_NAME), # Only found from discovery
|
||||
)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
if not async_get_discovery(hass, host):
|
||||
|
|
|
@ -7,6 +7,8 @@ import logging
|
|||
|
||||
from aiosteamist import Steamist, SteamistStatus
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
|
@ -16,20 +18,22 @@ _LOGGER = logging.getLogger(__name__)
|
|||
class SteamistDataUpdateCoordinator(DataUpdateCoordinator[SteamistStatus]):
|
||||
"""DataUpdateCoordinator to gather data from a steamist steam shower."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
client: Steamist,
|
||||
host: str,
|
||||
device_name: str | None,
|
||||
) -> None:
|
||||
"""Initialize DataUpdateCoordinator to gather data for specific steamist."""
|
||||
self.client = client
|
||||
self.device_name = device_name
|
||||
self.device_name = config_entry.data.get(CONF_NAME) # Only found from discovery
|
||||
super().__init__(
|
||||
hass,
|
||||
_LOGGER,
|
||||
name=f"Steamist {host}",
|
||||
config_entry=config_entry,
|
||||
name=f"Steamist {config_entry.data[CONF_HOST]}",
|
||||
update_interval=timedelta(seconds=5),
|
||||
always_update=False,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue