Skip to content

Commit

Permalink
Address #499: remove deprecated HomeAssistantType type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
albertogeniola committed May 4, 2024
1 parent 91f09bc commit 27785a1
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
13 changes: 6 additions & 7 deletions custom_components/meross_cloud/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions custom_components/meross_cloud/climate.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions custom_components/meross_cloud/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions custom_components/meross_cloud/humidifier.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions custom_components/meross_cloud/light.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions custom_components/meross_cloud/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
5 changes: 3 additions & 2 deletions custom_components/meross_cloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions custom_components/meross_cloud/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 27785a1

Please sign in to comment.