diff --git a/kasa/iot/modules/ambientlight.py b/kasa/iot/modules/ambientlight.py index fd693ed5..d6470d26 100644 --- a/kasa/iot/modules/ambientlight.py +++ b/kasa/iot/modules/ambientlight.py @@ -16,11 +16,11 @@ from ..iotmodule import IotModule, merge class AmbientLight(IotModule): """Implements ambient light controls for the motion sensor.""" - def __init__(self, device, module): - super().__init__(device, module) + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device=device, + device=self._device, container=self, id="ambient_light", name="Ambient Light", diff --git a/kasa/iot/modules/cloud.py b/kasa/iot/modules/cloud.py index 5022a68e..8be393d9 100644 --- a/kasa/iot/modules/cloud.py +++ b/kasa/iot/modules/cloud.py @@ -24,11 +24,11 @@ class CloudInfo(BaseModel): class Cloud(IotModule): """Module implementing support for cloud services.""" - def __init__(self, device, module): - super().__init__(device, module) + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device=device, + device=self._device, container=self, id="cloud_connection", name="Cloud connection", diff --git a/kasa/smart/modules/cloud.py b/kasa/smart/modules/cloud.py index e66f1858..347b9ec8 100644 --- a/kasa/smart/modules/cloud.py +++ b/kasa/smart/modules/cloud.py @@ -2,14 +2,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ...feature import Feature from ..smartmodule import SmartModule -if TYPE_CHECKING: - from ..smartdevice import SmartDevice - class Cloud(SmartModule): """Implementation of cloud module.""" @@ -18,12 +13,11 @@ class Cloud(SmartModule): REQUIRED_COMPONENT = "cloud_connect" MINIMUM_UPDATE_INTERVAL_SECS = 60 - def __init__(self, device: SmartDevice, module: str): - super().__init__(device, module) - + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device, + self._device, id="cloud_connection", name="Cloud connection", container=self, diff --git a/kasa/smart/modules/color.py b/kasa/smart/modules/color.py index bbabbdef..772d9335 100644 --- a/kasa/smart/modules/color.py +++ b/kasa/smart/modules/color.py @@ -2,26 +2,21 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ...feature import Feature from ...interfaces.light import HSV from ..smartmodule import SmartModule -if TYPE_CHECKING: - from ..smartdevice import SmartDevice - class Color(SmartModule): """Implementation of color module.""" REQUIRED_COMPONENT = "color" - def __init__(self, device: SmartDevice, module: str): - super().__init__(device, module) + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device, + self._device, "hsv", "HSV", container=self, diff --git a/kasa/smart/modules/contactsensor.py b/kasa/smart/modules/contactsensor.py index 7932a081..0bfa1bde 100644 --- a/kasa/smart/modules/contactsensor.py +++ b/kasa/smart/modules/contactsensor.py @@ -2,14 +2,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ...feature import Feature from ..smartmodule import SmartModule -if TYPE_CHECKING: - from ..smartdevice import SmartDevice - class ContactSensor(SmartModule): """Implementation of contact sensor module.""" @@ -17,11 +12,11 @@ class ContactSensor(SmartModule): REQUIRED_COMPONENT = None # we depend on availability of key REQUIRED_KEY_ON_PARENT = "open" - def __init__(self, device: SmartDevice, module: str): - super().__init__(device, module) + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device, + self._device, id="is_open", name="Open", container=self, diff --git a/kasa/smart/modules/fan.py b/kasa/smart/modules/fan.py index 245bef2c..9cb1a8df 100644 --- a/kasa/smart/modules/fan.py +++ b/kasa/smart/modules/fan.py @@ -2,27 +2,21 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ...feature import Feature from ...interfaces.fan import Fan as FanInterface from ..smartmodule import SmartModule -if TYPE_CHECKING: - from ..smartdevice import SmartDevice - class Fan(SmartModule, FanInterface): """Implementation of fan_control module.""" REQUIRED_COMPONENT = "fan_control" - def __init__(self, device: SmartDevice, module: str): - super().__init__(device, module) - + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device, + self._device, id="fan_speed_level", name="Fan speed level", container=self, @@ -36,7 +30,7 @@ class Fan(SmartModule, FanInterface): ) self._add_feature( Feature( - device, + self._device, id="fan_sleep_mode", name="Fan sleep mode", container=self, diff --git a/kasa/smart/modules/humiditysensor.py b/kasa/smart/modules/humiditysensor.py index 606b1d54..fab30f05 100644 --- a/kasa/smart/modules/humiditysensor.py +++ b/kasa/smart/modules/humiditysensor.py @@ -2,14 +2,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ...feature import Feature from ..smartmodule import SmartModule -if TYPE_CHECKING: - from ..smartdevice import SmartDevice - class HumiditySensor(SmartModule): """Implementation of humidity module.""" @@ -17,11 +12,11 @@ class HumiditySensor(SmartModule): REQUIRED_COMPONENT = "humidity" QUERY_GETTER_NAME = "get_comfort_humidity_config" - def __init__(self, device: SmartDevice, module: str): - super().__init__(device, module) + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device, + self._device, id="humidity", name="Humidity", container=self, @@ -34,7 +29,7 @@ class HumiditySensor(SmartModule): ) self._add_feature( Feature( - device, + self._device, id="humidity_warning", name="Humidity warning", container=self, diff --git a/kasa/smart/modules/reportmode.py b/kasa/smart/modules/reportmode.py index d2c9d929..34559cab 100644 --- a/kasa/smart/modules/reportmode.py +++ b/kasa/smart/modules/reportmode.py @@ -2,14 +2,9 @@ from __future__ import annotations -from typing import TYPE_CHECKING - from ...feature import Feature from ..smartmodule import SmartModule -if TYPE_CHECKING: - from ..smartdevice import SmartDevice - class ReportMode(SmartModule): """Implementation of report module.""" @@ -17,11 +12,11 @@ class ReportMode(SmartModule): REQUIRED_COMPONENT = "report_mode" QUERY_GETTER_NAME = "get_report_mode" - def __init__(self, device: SmartDevice, module: str): - super().__init__(device, module) + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device, + self._device, id="report_interval", name="Report interval", container=self, diff --git a/kasa/smart/modules/temperaturesensor.py b/kasa/smart/modules/temperaturesensor.py index 1741b26b..8162ce60 100644 --- a/kasa/smart/modules/temperaturesensor.py +++ b/kasa/smart/modules/temperaturesensor.py @@ -2,14 +2,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Literal +from typing import Literal from ...feature import Feature from ..smartmodule import SmartModule -if TYPE_CHECKING: - from ..smartdevice import SmartDevice - class TemperatureSensor(SmartModule): """Implementation of temperature module.""" @@ -17,11 +14,11 @@ class TemperatureSensor(SmartModule): REQUIRED_COMPONENT = "temperature" QUERY_GETTER_NAME = "get_comfort_temp_config" - def __init__(self, device: SmartDevice, module: str): - super().__init__(device, module) + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device, + self._device, id="temperature", name="Temperature", container=self, @@ -32,10 +29,10 @@ class TemperatureSensor(SmartModule): type=Feature.Type.Sensor, ) ) - if "current_temp_exception" in device.sys_info: + if "current_temp_exception" in self._device.sys_info: self._add_feature( Feature( - device, + self._device, id="temperature_warning", name="Temperature warning", container=self, @@ -47,7 +44,7 @@ class TemperatureSensor(SmartModule): ) self._add_feature( Feature( - device, + self._device, id="temperature_unit", name="Temperature unit", container=self, diff --git a/kasa/smart/modules/time.py b/kasa/smart/modules/time.py index 49a1d940..254fd098 100644 --- a/kasa/smart/modules/time.py +++ b/kasa/smart/modules/time.py @@ -4,14 +4,11 @@ from __future__ import annotations from datetime import datetime, timedelta, timezone from time import mktime -from typing import TYPE_CHECKING, cast +from typing import cast from ...feature import Feature from ..smartmodule import SmartModule -if TYPE_CHECKING: - from ..smartdevice import SmartDevice - class Time(SmartModule): """Implementation of device_local_time.""" @@ -19,12 +16,11 @@ class Time(SmartModule): REQUIRED_COMPONENT = "time" QUERY_GETTER_NAME = "get_device_time" - def __init__(self, device: SmartDevice, module: str): - super().__init__(device, module) - + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device=device, + device=self._device, id="device_time", name="Device time", attribute_getter="time", diff --git a/kasa/smart/modules/waterleaksensor.py b/kasa/smart/modules/waterleaksensor.py index 9f75b9b4..bba4f61d 100644 --- a/kasa/smart/modules/waterleaksensor.py +++ b/kasa/smart/modules/waterleaksensor.py @@ -3,14 +3,10 @@ from __future__ import annotations from enum import Enum -from typing import TYPE_CHECKING from ...feature import Feature from ..smartmodule import SmartModule -if TYPE_CHECKING: - from ..smartdevice import SmartDevice - class WaterleakStatus(Enum): """Waterleawk status.""" @@ -25,11 +21,11 @@ class WaterleakSensor(SmartModule): REQUIRED_COMPONENT = "sensor_alarm" - def __init__(self, device: SmartDevice, module: str): - super().__init__(device, module) + def _initialize_features(self): + """Initialize features after the initial update.""" self._add_feature( Feature( - device, + self._device, id="water_leak", name="Water leak", container=self, @@ -41,7 +37,7 @@ class WaterleakSensor(SmartModule): ) self._add_feature( Feature( - device, + self._device, id="water_alert", name="Water alert", container=self,