mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-10-12 10:28:01 +00:00
Move feature initialization from __init__ to _initialize_features (#1140)
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user