diff --git a/midealocal/devices/b4/__init__.py b/midealocal/devices/b4/__init__.py index 35e79d78..dfc4b470 100644 --- a/midealocal/devices/b4/__init__.py +++ b/midealocal/devices/b4/__init__.py @@ -1,5 +1,6 @@ import logging import sys +from typing import Any from .message import MessageB4Response, MessageQuery @@ -24,7 +25,7 @@ class DeviceAttributes(StrEnum): class MideaB4Device(MideaDevice): - _status = { + _status: dict[int, str] = { 0x01: "Standby", 0x02: "Idle", 0x03: "Working", @@ -45,7 +46,7 @@ def __init__( model: str, subtype: int, customize: str, - ): + ) -> None: super().__init__( name=name, device_id=device_id, @@ -68,10 +69,10 @@ def __init__( }, ) - def build_query(self): + def build_query(self) -> list[MessageQuery]: return [MessageQuery(self._protocol_version)] - def process_message(self, msg): + def process_message(self, msg: bytes) -> dict[str, Any]: message = MessageB4Response(msg) _LOGGER.debug(f"[{self.device_id}] Received: {message}") new_status = {} @@ -90,7 +91,7 @@ def process_message(self, msg): new_status[str(status)] = self._attributes[status] return new_status - def set_attribute(self, attr, value): + def set_attribute(self, attr: str, value: Any) -> None: pass diff --git a/midealocal/devices/b4/message.py b/midealocal/devices/b4/message.py index 28ec95a7..4d9acc12 100644 --- a/midealocal/devices/b4/message.py +++ b/midealocal/devices/b4/message.py @@ -2,7 +2,9 @@ class MessageB4Base(MessageRequest): - def __init__(self, protocol_version, message_type, body_type): + def __init__( + self, protocol_version: int, message_type: int, body_type: int + ) -> None: super().__init__( device_type=0xB4, protocol_version=protocol_version, @@ -11,12 +13,12 @@ def __init__(self, protocol_version, message_type, body_type): ) @property - def _body(self): + def _body(self) -> bytearray: raise NotImplementedError class MessageQuery(MessageB4Base): - def __init__(self, protocol_version): + def __init__(self, protocol_version: int) -> None: super().__init__( protocol_version=protocol_version, message_type=MessageType.query, @@ -24,12 +26,12 @@ def __init__(self, protocol_version): ) @property - def _body(self): + def _body(self) -> bytearray: return bytearray([]) class B4MessageBody(MessageBody): - def __init__(self, body): + def __init__(self, body: bytearray) -> None: super().__init__(body) self.time_remaining = ( (0 if body[22] == 0xFF else body[22]) * 3600 @@ -47,8 +49,8 @@ def __init__(self, body): class MessageB4Response(MessageResponse): - def __init__(self, message): - super().__init__(message) + def __init__(self, message: bytes) -> None: + super().__init__(bytearray(message)) if self.message_type in [ MessageType.notify1, MessageType.query,