mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Explicitly pass in the config_entry in venstar coordinator (#137880)
* explicitly pass in the config_entry in coordinator * use common name config_entry
This commit is contained in:
parent
4031f85acc
commit
4646d35054
@ -21,14 +21,14 @@ from .coordinator import VenstarDataUpdateCoordinator
|
|||||||
PLATFORMS = [Platform.BINARY_SENSOR, Platform.CLIMATE, Platform.SENSOR]
|
PLATFORMS = [Platform.BINARY_SENSOR, Platform.CLIMATE, Platform.SENSOR]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, config: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||||
"""Set up the Venstar thermostat."""
|
"""Set up the Venstar thermostat."""
|
||||||
username = config.data.get(CONF_USERNAME)
|
username = config_entry.data.get(CONF_USERNAME)
|
||||||
password = config.data.get(CONF_PASSWORD)
|
password = config_entry.data.get(CONF_PASSWORD)
|
||||||
pin = config.data.get(CONF_PIN)
|
pin = config_entry.data.get(CONF_PIN)
|
||||||
host = config.data[CONF_HOST]
|
host = config_entry.data[CONF_HOST]
|
||||||
timeout = VENSTAR_TIMEOUT
|
timeout = VENSTAR_TIMEOUT
|
||||||
protocol = "https" if config.data[CONF_SSL] else "http"
|
protocol = "https" if config_entry.data[CONF_SSL] else "http"
|
||||||
|
|
||||||
client = VenstarColorTouch(
|
client = VenstarColorTouch(
|
||||||
addr=host,
|
addr=host,
|
||||||
@ -41,19 +41,22 @@ async def async_setup_entry(hass: HomeAssistant, config: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
venstar_data_coordinator = VenstarDataUpdateCoordinator(
|
venstar_data_coordinator = VenstarDataUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
|
config_entry,
|
||||||
venstar_connection=client,
|
venstar_connection=client,
|
||||||
)
|
)
|
||||||
await venstar_data_coordinator.async_config_entry_first_refresh()
|
await venstar_data_coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
hass.data.setdefault(DOMAIN, {})[config.entry_id] = venstar_data_coordinator
|
hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = venstar_data_coordinator
|
||||||
await hass.config_entries.async_forward_entry_setups(config, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, config: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||||
"""Unload the config and platforms."""
|
"""Unload the config and platforms."""
|
||||||
unload_ok = await hass.config_entries.async_unload_platforms(config, PLATFORMS)
|
unload_ok = await hass.config_entries.async_unload_platforms(
|
||||||
|
config_entry, PLATFORMS
|
||||||
|
)
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN].pop(config.entry_id)
|
hass.data[DOMAIN].pop(config_entry.entry_id)
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
@ -8,6 +8,7 @@ from datetime import timedelta
|
|||||||
from requests import RequestException
|
from requests import RequestException
|
||||||
from venstarcolortouch import VenstarColorTouch
|
from venstarcolortouch import VenstarColorTouch
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import update_coordinator
|
from homeassistant.helpers import update_coordinator
|
||||||
|
|
||||||
@ -17,16 +18,19 @@ from .const import _LOGGER, DOMAIN, VENSTAR_SLEEP
|
|||||||
class VenstarDataUpdateCoordinator(update_coordinator.DataUpdateCoordinator[None]):
|
class VenstarDataUpdateCoordinator(update_coordinator.DataUpdateCoordinator[None]):
|
||||||
"""Class to manage fetching Venstar data."""
|
"""Class to manage fetching Venstar data."""
|
||||||
|
|
||||||
|
config_entry: ConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
*,
|
config_entry: ConfigEntry,
|
||||||
venstar_connection: VenstarColorTouch,
|
venstar_connection: VenstarColorTouch,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize global Venstar data updater."""
|
"""Initialize global Venstar data updater."""
|
||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name=DOMAIN,
|
name=DOMAIN,
|
||||||
update_interval=timedelta(seconds=60),
|
update_interval=timedelta(seconds=60),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user