diff --git a/custom_components/meross_cloud/__init__.py b/custom_components/meross_cloud/__init__.py index 50102cb4a7..7b59b72c2e 100644 --- a/custom_components/meross_cloud/__init__.py +++ b/custom_components/meross_cloud/__init__.py @@ -1,25 +1,24 @@ """Meross devices platform loader""" +import asyncio import logging from datetime import datetime, timedelta -from typing import List, Tuple, Mapping, Any, Dict, Optional, Collection +from typing import List, Tuple, Dict, Optional, Collection -import asyncio import homeassistant.helpers.config_validation as cv import voluptuous as vol from homeassistant import config_entries from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_PASSWORD, CONF_USERNAME +from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady, ConfigEntryAuthFailed from homeassistant.helpers.entity import Entity -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed +from meross_iot.controller.device import BaseDevice from meross_iot.http_api import MerossHttpClient, ErrorCodes from meross_iot.manager import MerossManager from meross_iot.model.credentials import MerossCloudCreds from meross_iot.model.enums import OnlineStatus, Namespace from meross_iot.model.exception import CommandTimeoutError from meross_iot.model.http.device import HttpDeviceInfo -from meross_iot.controller.device import BaseDevice from meross_iot.model.http.exception import ( TokenExpiredException, TooManyTokensException, @@ -96,7 +95,7 @@ def print_startup_message(http_devices: List[HttpDeviceInfo]): class MerossCoordinator(DataUpdateCoordinator): def __init__(self, - hass: HomeAssistantType, + hass: HomeAssistant, config_entry: ConfigEntry, http_api_endpoint: str, creds: MerossCloudCreds, @@ -350,7 +349,7 @@ def _http_info_changed(known: Collection[HttpDeviceInfo], discovered: Collection return len(unknown) > 0 -async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry): +async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry): """ This class is called by the HomeAssistant framework when a configuration entry is provided. For us, the configuration entry is the username-password credentials that the user diff --git a/custom_components/meross_cloud/climate.py b/custom_components/meross_cloud/climate.py index 78b2928575..4782e51eff 100644 --- a/custom_components/meross_cloud/climate.py +++ b/custom_components/meross_cloud/climate.py @@ -1,6 +1,7 @@ import logging from typing import Optional, List, Dict +from homeassistant.core import HomeAssistant from meross_iot.controller.device import BaseDevice from meross_iot.controller.mixins.thermostat import ThermostatModeMixin from meross_iot.controller.subdevice import Mts100v3Valve @@ -12,7 +13,6 @@ from homeassistant.const import UnitOfTemperature from homeassistant.components.climate import ClimateEntity from homeassistant.components.climate import ClimateEntityFeature, HVACMode, HVACAction -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import MerossDevice from .common import (DOMAIN, MANAGER, HA_CLIMATE, DEVICE_LIST_COORDINATOR) @@ -259,7 +259,7 @@ async def async_turn_on(self) -> None: await self.async_set_hvac_mode(HVACMode.HEATING) -async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities): +async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities): def entity_adder_callback(): """Discover and adds new Meross entities""" manager: MerossManager = hass.data[DOMAIN][MANAGER] # type diff --git a/custom_components/meross_cloud/cover.py b/custom_components/meross_cloud/cover.py index 7222cc0475..ac86162470 100644 --- a/custom_components/meross_cloud/cover.py +++ b/custom_components/meross_cloud/cover.py @@ -2,6 +2,7 @@ from enum import Enum from typing import Any, Dict, Union +from homeassistant.core import HomeAssistant from meross_iot.controller.device import BaseDevice from meross_iot.model.enums import RollerShutterState, Namespace from meross_iot.controller.mixins.garage import GarageOpenerMixin @@ -17,7 +18,6 @@ ATTR_POSITION, ) -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import MerossDevice from .common import (DOMAIN, MANAGER, HA_COVER, DEVICE_LIST_COORDINATOR) @@ -176,7 +176,7 @@ def set_cover_position(self, **kwargs): self.hass.async_add_executor_job(self.async_set_cover_position, int(position)) -async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities): +async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities): def entity_adder_callback(): """Discover and adds new Meross entities""" manager: MerossManager = hass.data[DOMAIN][MANAGER] diff --git a/custom_components/meross_cloud/humidifier.py b/custom_components/meross_cloud/humidifier.py index 17337c642d..0710b7de81 100644 --- a/custom_components/meross_cloud/humidifier.py +++ b/custom_components/meross_cloud/humidifier.py @@ -1,6 +1,7 @@ import logging from typing import Any, Optional, List, Dict +from homeassistant.core import HomeAssistant from meross_iot.controller.device import BaseDevice from meross_iot.controller.mixins.spray import SprayMixin from meross_iot.controller.mixins.diffuser_spray import DiffuserSprayMixin @@ -9,7 +10,6 @@ from meross_iot.model.http.device import HttpDeviceInfo from homeassistant.components.humidifier import HumidifierEntity, HumidifierEntityFeature, HumidifierDeviceClass -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import MerossDevice from .common import (DOMAIN, MANAGER, HA_HUMIDIFIER, DEVICE_LIST_COORDINATOR) @@ -143,7 +143,7 @@ def is_on(self) -> Optional[bool]: return mode != DiffuserSprayMode.OFF -async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities): +async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities): def entity_adder_callback(): """Discover and adds new Meross entities""" manager: MerossManager = hass.data[DOMAIN][MANAGER] # type diff --git a/custom_components/meross_cloud/light.py b/custom_components/meross_cloud/light.py index 777589c310..890c610762 100644 --- a/custom_components/meross_cloud/light.py +++ b/custom_components/meross_cloud/light.py @@ -1,6 +1,7 @@ import logging from typing import Optional, Dict +from homeassistant.core import HomeAssistant from meross_iot.controller.device import BaseDevice from meross_iot.controller.mixins.light import LightMixin from meross_iot.controller.mixins.diffuser_light import DiffuserLightMixin @@ -11,7 +12,6 @@ from homeassistant.components.light import LightEntity from homeassistant.components.light import ColorMode, \ ATTR_HS_COLOR, ATTR_COLOR_TEMP, ATTR_BRIGHTNESS, ATTR_RGB_COLOR -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import MerossDevice from .common import (DOMAIN, MANAGER, HA_LIGHT, DEVICE_LIST_COORDINATOR) @@ -196,7 +196,7 @@ def color_temp(self): return None -async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities): +async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities): def entity_adder_callback(): """Discover and adds new Meross entities""" manager: MerossManager = hass.data[DOMAIN][MANAGER] # type diff --git a/custom_components/meross_cloud/manifest.json b/custom_components/meross_cloud/manifest.json index 701a3b2873..29cfa982a4 100644 --- a/custom_components/meross_cloud/manifest.json +++ b/custom_components/meross_cloud/manifest.json @@ -5,9 +5,9 @@ "issue_tracker": "https://github.com/albertogeniola/meross-homeassistant", "dependencies": ["persistent_notification"], "codeowners": ["@albertogeniola"], - "requirements": ["meross_iot==0.4.7.1"], + "requirements": ["meross_iot==0.4.7.2b3"], "config_flow": true, "quality_scale": "platinum", "iot_class": "cloud_push", - "version": "1.3.1" + "version": "1.3.2" } diff --git a/custom_components/meross_cloud/sensor.py b/custom_components/meross_cloud/sensor.py index f15fd8ec94..6474a836d7 100644 --- a/custom_components/meross_cloud/sensor.py +++ b/custom_components/meross_cloud/sensor.py @@ -3,6 +3,7 @@ from datetime import timedelta from typing import Optional, Dict +from homeassistant.core import HomeAssistant from meross_iot.controller.device import BaseDevice, GenericSubDevice, HubDevice from meross_iot.controller.mixins.consumption import ConsumptionXMixin from meross_iot.controller.mixins.electricity import ElectricityMixin @@ -14,7 +15,7 @@ from homeassistant.components.sensor import SensorStateClass, SensorEntity, SensorDeviceClass from homeassistant.const import PERCENTAGE, UnitOfTemperature, UnitOfPower -from homeassistant.helpers.typing import StateType, HomeAssistantType +from homeassistant.helpers.typing import StateType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import MerossDevice from .common import (DOMAIN, MANAGER, log_exception, HA_SENSOR, @@ -327,7 +328,7 @@ def should_poll(self) -> bool: # ---------------------------------------------- # PLATFORM METHODS # ---------------------------------------------- -async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities): +async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities): def entity_adder_callback(): """Discover and adds new Meross entities""" manager: MerossManager = hass.data[DOMAIN][MANAGER] # type diff --git a/custom_components/meross_cloud/switch.py b/custom_components/meross_cloud/switch.py index 9e725aab1e..962a52f6a8 100644 --- a/custom_components/meross_cloud/switch.py +++ b/custom_components/meross_cloud/switch.py @@ -2,6 +2,7 @@ from datetime import datetime from typing import Optional, Dict +from homeassistant.core import HomeAssistant from meross_iot.controller.device import BaseDevice from meross_iot.controller.mixins.consumption import ConsumptionXMixin from meross_iot.controller.mixins.electricity import ElectricityMixin @@ -15,7 +16,6 @@ # Conditional import for switch device from homeassistant.components.switch import SwitchEntity -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import MerossDevice from .common import (DOMAIN, MANAGER, DEVICE_LIST_COORDINATOR, HA_SWITCH) @@ -136,7 +136,7 @@ async def async_turn_on(self, **kwargs) -> None: self._dnd_mode = DNDMode.DND_DISABLED -async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities): +async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entities): def entity_adder_callback(): """Discover and adds new Meross entities""" manager: MerossManager = hass.data[DOMAIN][MANAGER] # type