mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Explicitly pass in the config_entry in steamist coordinator (#137930)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
ed8ee34a28
commit
32d13f3356
@ -8,7 +8,7 @@ from typing import Any
|
|||||||
from aiosteamist import Steamist
|
from aiosteamist import Steamist
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
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.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
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]
|
host = entry.data[CONF_HOST]
|
||||||
coordinator = SteamistDataUpdateCoordinator(
|
coordinator = SteamistDataUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
|
entry,
|
||||||
Steamist(host, async_get_clientsession(hass)),
|
Steamist(host, async_get_clientsession(hass)),
|
||||||
host,
|
|
||||||
entry.data.get(CONF_NAME), # Only found from discovery
|
|
||||||
)
|
)
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
if not async_get_discovery(hass, host):
|
if not async_get_discovery(hass, host):
|
||||||
|
@ -7,6 +7,8 @@ import logging
|
|||||||
|
|
||||||
from aiosteamist import Steamist, SteamistStatus
|
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.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
@ -16,20 +18,22 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
class SteamistDataUpdateCoordinator(DataUpdateCoordinator[SteamistStatus]):
|
class SteamistDataUpdateCoordinator(DataUpdateCoordinator[SteamistStatus]):
|
||||||
"""DataUpdateCoordinator to gather data from a steamist steam shower."""
|
"""DataUpdateCoordinator to gather data from a steamist steam shower."""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
client: Steamist,
|
client: Steamist,
|
||||||
host: str,
|
|
||||||
device_name: str | None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize DataUpdateCoordinator to gather data for specific steamist."""
|
"""Initialize DataUpdateCoordinator to gather data for specific steamist."""
|
||||||
self.client = client
|
self.client = client
|
||||||
self.device_name = device_name
|
self.device_name = config_entry.data.get(CONF_NAME) # Only found from discovery
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
name=f"Steamist {host}",
|
config_entry=config_entry,
|
||||||
|
name=f"Steamist {config_entry.data[CONF_HOST]}",
|
||||||
update_interval=timedelta(seconds=5),
|
update_interval=timedelta(seconds=5),
|
||||||
always_update=False,
|
always_update=False,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user