diff --git a/homeassistant/components/airtouch5/__init__.py b/homeassistant/components/airtouch5/__init__.py index b8b9a3f765a..4ae6c1f1fee 100644 --- a/homeassistant/components/airtouch5/__init__.py +++ b/homeassistant/components/airtouch5/__init__.py @@ -13,8 +13,10 @@ from .const import DOMAIN PLATFORMS: list[Platform] = [Platform.CLIMATE] +Airtouch5ConfigEntry = ConfigEntry[Airtouch5SimpleClient] -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: + +async def async_setup_entry(hass: HomeAssistant, entry: Airtouch5ConfigEntry) -> bool: """Set up Airtouch 5 from a config entry.""" hass.data.setdefault(DOMAIN, {}) @@ -30,22 +32,21 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: raise ConfigEntryNotReady from t # Store an API object for your platforms to access - hass.data[DOMAIN][entry.entry_id] = client + entry.runtime_data = client await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) return True -async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: +async def async_unload_entry(hass: HomeAssistant, entry: Airtouch5ConfigEntry) -> bool: """Unload a config entry.""" if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS): - client: Airtouch5SimpleClient = hass.data[DOMAIN][entry.entry_id] + client = entry.runtime_data await client.disconnect() client.ac_status_callbacks.clear() client.connection_state_callbacks.clear() client.data_packet_callbacks.clear() client.zone_status_callbacks.clear() - hass.data[DOMAIN].pop(entry.entry_id) return unload_ok diff --git a/homeassistant/components/airtouch5/climate.py b/homeassistant/components/airtouch5/climate.py index 157e3b7d643..1f97c254efe 100644 --- a/homeassistant/components/airtouch5/climate.py +++ b/homeassistant/components/airtouch5/climate.py @@ -34,12 +34,12 @@ from homeassistant.components.climate import ( ClimateEntityFeature, HVACMode, ) -from homeassistant.config_entries import ConfigEntry from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback +from . import Airtouch5ConfigEntry from .const import DOMAIN, FAN_INTELLIGENT_AUTO, FAN_TURBO from .entity import Airtouch5Entity @@ -92,11 +92,11 @@ FAN_MODE_TO_SET_AC_FAN_SPEED = { async def async_setup_entry( hass: HomeAssistant, - config_entry: ConfigEntry, + config_entry: Airtouch5ConfigEntry, async_add_entities: AddEntitiesCallback, ) -> None: """Set up the Airtouch 5 Climate entities.""" - client: Airtouch5SimpleClient = hass.data[DOMAIN][config_entry.entry_id] + client = config_entry.runtime_data entities: list[ClimateEntity] = []