Fix issues after rebasing

This commit is contained in:
Teemu Rytilahti 2024-05-07 17:55:14 +02:00
parent 6dcc2758d7
commit fc122eac6b
4 changed files with 13 additions and 28 deletions

View File

@ -26,6 +26,7 @@ from ..deviceconfig import DeviceConfig
from ..emeterstatus import EmeterStatus from ..emeterstatus import EmeterStatus
from ..exceptions import KasaException from ..exceptions import KasaException
from ..feature import Feature from ..feature import Feature
from ..firmware import Firmware
from ..module import ModuleT from ..module import ModuleT
from ..protocol import BaseProtocol from ..protocol import BaseProtocol
from .iotmodule import IotModule from .iotmodule import IotModule
@ -718,6 +719,6 @@ class IotDevice(Device):
@property @property
@requires_update @requires_update
def firmware(self) -> Cloud: def firmware(self) -> Firmware:
"""Returns object implementing the firmware handling.""" """Returns object implementing the firmware handling."""
return self.modules["cloud"] return cast(Firmware, self.modules["cloud"])

View File

@ -3,12 +3,11 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from pydantic.v1 import BaseModel
from datetime import date from datetime import date
from typing import Optional from typing import Optional
from pydantic.v1 import BaseModel, Field, validator
from ...feature import Feature from ...feature import Feature
from ...firmware import ( from ...firmware import (
Firmware, Firmware,

View File

@ -9,14 +9,13 @@ from typing import TYPE_CHECKING, Any, Optional
# When support for cpython older than 3.11 is dropped # When support for cpython older than 3.11 is dropped
# async_timeout can be replaced with asyncio.timeout # async_timeout can be replaced with asyncio.timeout
from async_timeout import timeout as asyncio_timeout
from pydantic.v1 import BaseModel, Field, validator
# When support for cpython older than 3.11 is dropped # When support for cpython older than 3.11 is dropped
# async_timeout can be replaced with asyncio.timeout # async_timeout can be replaced with asyncio.timeout
from async_timeout import timeout as asyncio_timeout from async_timeout import timeout as asyncio_timeout
from pydantic.v1 import BaseModel, Field, validator
from ...exceptions import SmartErrorCode from ...exceptions import SmartErrorCode
from ...feature import Feature, FeatureType from ...feature import Feature
from ...firmware import Firmware as FirmwareInterface from ...firmware import Firmware as FirmwareInterface
from ...firmware import FirmwareUpdate as FirmwareUpdateInterface from ...firmware import FirmwareUpdate as FirmwareUpdateInterface
from ...firmware import UpdateResult from ...firmware import UpdateResult
@ -105,22 +104,6 @@ class Firmware(SmartModule, FirmwareInterface):
category=Feature.Category.Info, category=Feature.Category.Info,
) )
) )
self._add_feature(
Feature(
device,
"Current firmware version",
container=self,
attribute_getter="current_firmware",
)
)
self._add_feature(
Feature(
device,
"Available firmware version",
container=self,
attribute_getter="latest_firmware",
)
)
def query(self) -> dict: def query(self) -> dict:
"""Query to execute during the update cycle.""" """Query to execute during the update cycle."""

View File

@ -16,6 +16,7 @@ from ..emeterstatus import EmeterStatus
from ..exceptions import AuthenticationError, DeviceError, KasaException, SmartErrorCode from ..exceptions import AuthenticationError, DeviceError, KasaException, SmartErrorCode
from ..fan import Fan from ..fan import Fan
from ..feature import Feature from ..feature import Feature
from ..firmware import Firmware
from ..module import ModuleT from ..module import ModuleT
from ..smartprotocol import SmartProtocol from ..smartprotocol import SmartProtocol
from .modules import ( from .modules import (
@ -26,9 +27,11 @@ from .modules import (
DeviceModule, DeviceModule,
EnergyModule, EnergyModule,
FanModule, FanModule,
Firmware,
TimeModule, TimeModule,
) )
from .modules import (
Firmware as FirmwareModule,
)
from .smartmodule import SmartModule from .smartmodule import SmartModule
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -626,11 +629,10 @@ class SmartDevice(Bulb, Fan, Device):
return self._device_type return self._device_type
@property @property
def firmware(self) -> FirmwareInterface: def firmware(self) -> Firmware:
"""Return firmware module.""" """Return firmware module."""
# TODO: open question: does it make sense to expose common modules? # TODO: open question: does it make sense to expose common modules?
fw = cast(FirmwareInterface, self.modules["Firmware"]) return cast(Firmware, self.get_module(FirmwareModule))
return fw
@staticmethod @staticmethod
def _get_device_type_from_components( def _get_device_type_from_components(