diff --git a/custom_components/hon/__init__.py b/custom_components/hon/__init__.py index 1e38a2d5..ea1647e6 100644 --- a/custom_components/hon/__init__.py +++ b/custom_components/hon/__init__.py @@ -6,7 +6,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_EMAIL, CONF_PASSWORD from homeassistant.helpers import config_validation as cv, aiohttp_client -from homeassistant.helpers.typing import HomeAssistantType +from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from pyhon import Hon @@ -27,7 +27,7 @@ ) -async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # Updated type session = aiohttp_client.async_get_clientsession(hass) if (config_dir := hass.config.config_dir) is None: raise ValueError("Missing Config Dir") @@ -53,21 +53,20 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN][entry.unique_id] = {"hon": hon, "coordinator": coordinator} - for platform in PLATFORMS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, platform) - ) + await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) + return True -async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: +async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: refresh_token = hass.data[DOMAIN][entry.unique_id]["hon"].api.auth.refresh_token hass.config_entries.async_update_entry( entry, data={**entry.data, CONF_REFRESH_TOKEN: refresh_token} ) - unload = await hass.config_entries.async_unload_platforms(entry, PLATFORMS) + unload = await hass.config_entries.async_unload_entry_platforms(entry, PLATFORMS) if unload: + hass.data[DOMAIN].pop(entry.unique_id) if not hass.data[DOMAIN]: hass.data.pop(DOMAIN, None) return unload diff --git a/custom_components/hon/climate.py b/custom_components/hon/climate.py index f3ce937c..f7c1933a 100644 --- a/custom_components/hon/climate.py +++ b/custom_components/hon/climate.py @@ -199,7 +199,7 @@ async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: self._attr_hvac_mode = hvac_mode if hvac_mode == HVACMode.OFF: await self._device.commands["stopProgram"].send() - self._device.sync_command("stopProgram", "settings") + self._device.settings["settings.onOffStatus"].value = "0" else: self._device.settings["settings.onOffStatus"].value = "1" setting = self._device.settings["settings.machMode"]