Explicitly pass in the config_entry in steamist coordinator (#137930)

explicitly pass in the config_entry in coordinator
pull/137961/head
Michael 2025-02-08 20:24:38 +01:00 committed by GitHub
parent ed8ee34a28
commit 32d13f3356
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 7 deletions

View File

@ -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):

View File

@ -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,
)