From 9e50cb842479cf2ac8e9db30d1c6ee6d1edbcb3d Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Fri, 4 Oct 2024 15:58:23 +0200 Subject: [PATCH] chore: rename var to clarify meaning (#315) --- library_test.py | 2 +- midealocal/cli.py | 4 ++-- midealocal/device.py | 18 +++++++------- midealocal/devices/__init__.py | 6 ++--- midealocal/devices/a1/__init__.py | 10 ++++---- midealocal/devices/ac/__init__.py | 36 ++++++++++++++-------------- midealocal/devices/b0/__init__.py | 6 ++--- midealocal/devices/b1/__init__.py | 6 ++--- midealocal/devices/b3/__init__.py | 6 ++--- midealocal/devices/b4/__init__.py | 6 ++--- midealocal/devices/b6/__init__.py | 20 ++++++++-------- midealocal/devices/b8/__init__.py | 10 ++++---- midealocal/devices/bf/__init__.py | 6 ++--- midealocal/devices/c2/__init__.py | 10 ++++---- midealocal/devices/c3/__init__.py | 14 +++++------ midealocal/devices/ca/__init__.py | 6 ++--- midealocal/devices/cc/__init__.py | 8 +++---- midealocal/devices/cd/__init__.py | 8 +++---- midealocal/devices/ce/__init__.py | 8 +++---- midealocal/devices/cf/__init__.py | 10 ++++---- midealocal/devices/da/__init__.py | 10 ++++---- midealocal/devices/db/__init__.py | 10 ++++---- midealocal/devices/dc/__init__.py | 10 ++++---- midealocal/devices/e1/__init__.py | 12 +++++----- midealocal/devices/e2/__init__.py | 12 +++++----- midealocal/devices/e3/__init__.py | 12 +++++----- midealocal/devices/e6/__init__.py | 8 +++---- midealocal/devices/e8/__init__.py | 6 ++--- midealocal/devices/ea/__init__.py | 6 ++--- midealocal/devices/ec/__init__.py | 6 ++--- midealocal/devices/ed/__init__.py | 10 ++++---- midealocal/devices/fa/__init__.py | 22 ++++++++--------- midealocal/devices/fb/__init__.py | 12 +++++----- midealocal/devices/fc/__init__.py | 8 +++---- midealocal/devices/fd/__init__.py | 8 +++---- midealocal/devices/x13/__init__.py | 8 +++---- midealocal/devices/x26/__init__.py | 8 +++---- midealocal/devices/x34/__init__.py | 12 +++++----- midealocal/devices/x40/__init__.py | 8 +++---- midealocal/message.py | 6 ++--- tests/cli_test.py | 2 +- tests/device_test.py | 6 ++--- tests/devices/a1/device_a1_test.py | 2 +- tests/devices/ac/device_ac_test.py | 2 +- tests/devices/b8/device_b8_test.py | 2 +- tests/devices/c3/device_c3_test.py | 2 +- tests/devices/da/device_da_test.py | 2 +- tests/devices/ed/device_ed_test.py | 2 +- tests/devices/x40/device_x40_test.py | 2 +- 49 files changed, 208 insertions(+), 208 deletions(-) diff --git a/library_test.py b/library_test.py index 0bdc13ad..875b96ef 100644 --- a/library_test.py +++ b/library_test.py @@ -106,7 +106,7 @@ async def main() -> None: port=first_device["port"], token=token, key=key, - protocol=first_device["protocol"], + device_protocol=first_device["protocol"], model=first_device["model"], subtype=0, customize="", diff --git a/midealocal/cli.py b/midealocal/cli.py index a78883eb..cdaed028 100644 --- a/midealocal/cli.py +++ b/midealocal/cli.py @@ -109,7 +109,7 @@ async def discover(self) -> list[MideaDevice]: port=device["port"], token=key["token"], key=key["key"], - protocol=device["protocol"], + device_protocol=device["protocol"], model=device["model"], subtype=0, customize="", @@ -143,7 +143,7 @@ def message(self) -> None: device_type=device_type, ip_address="192.168.192.168", port=6664, - protocol=ProtocolVersion.V2, + device_protocol=ProtocolVersion.V2, model="0000", token="", key="", diff --git a/midealocal/device.py b/midealocal/device.py index 924f73a3..6bce4e0c 100644 --- a/midealocal/device.py +++ b/midealocal/device.py @@ -76,7 +76,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, attributes: dict, @@ -94,10 +94,10 @@ def __init__( self._device_name = name self._device_id = device_id self._device_type = device_type - self._protocol = protocol + self._device_protocol_version = device_protocol self._model = model self._subtype = subtype - self._protocol_version: ProtocolVersion = ProtocolVersion.V1 + self._message_protocol_version: ProtocolVersion = ProtocolVersion.V1 self._updates: list[Callable[[dict[str, Any]], None]] = [] self._unsupported_protocol: list[str] = [] self._is_run = False @@ -165,7 +165,7 @@ def connect(self, check_protocol: bool = False) -> bool: ) self._socket.connect((self._ip_address, self._port)) _LOGGER.debug("[%s] Connected", self._device_id) - if self._protocol == ProtocolVersion.V3: + if self._device_protocol_version == ProtocolVersion.V3: self.authenticate() # 1. midea_ac_lan add device verify token with connect and auth # 2. init connection, check_protocol @@ -231,7 +231,7 @@ def authenticate(self) -> None: def send_message(self, data: bytes, query: bool = False) -> None: """Send message.""" - if self._protocol == ProtocolVersion.V3: + if self._device_protocol_version == ProtocolVersion.V3: self.send_message_v3(data, msg_type=MSGTYPE_ENCRYPTED_REQUEST, query=query) else: self.send_message_v2(data, query=query) @@ -389,18 +389,18 @@ def pre_process_message(self, msg: bytearray) -> bool: message = MessageApplianceResponse(msg) self._appliance_query = False _LOGGER.debug("[%s] Appliance query Received: %s", self._device_id, message) - self._protocol_version = message.protocol_version + self._message_protocol_version = message.protocol_version _LOGGER.debug( "[%s] Device protocol version: %s", self._device_id, - self._protocol_version, + self._message_protocol_version, ) return False return True def parse_message(self, msg: bytes) -> MessageResult: """Parse message.""" - if self._protocol == ProtocolVersion.V3: + if self._device_protocol_version == ProtocolVersion.V3: messages, self._buffer = self._security.decode_8370(self._buffer + msg) else: messages, self._buffer = self.fetch_v2_message(self._buffer + msg) @@ -482,7 +482,7 @@ def send_command(self, cmd_type: MessageType, cmd_body: bytearray) -> None: """Send command.""" cmd = MessageQuestCustom( self._device_type, - self._protocol_version, + self._message_protocol_version, cmd_type, cmd_body, ) diff --git a/midealocal/devices/__init__.py b/midealocal/devices/__init__.py index dd429de6..e2b09b2a 100644 --- a/midealocal/devices/__init__.py +++ b/midealocal/devices/__init__.py @@ -3,7 +3,7 @@ from importlib import import_module from typing import cast -from midealocal.const import DeviceType +from midealocal.const import DeviceType, ProtocolVersion from midealocal.device import MideaDevice @@ -15,7 +15,7 @@ def device_selector( port: int, token: str, key: str, - protocol: int, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -34,7 +34,7 @@ def device_selector( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, customize=customize, diff --git a/midealocal/devices/a1/__init__.py b/midealocal/devices/a1/__init__.py index 30faed63..eca8eb75 100644 --- a/midealocal/devices/a1/__init__.py +++ b/midealocal/devices/a1/__init__.py @@ -58,7 +58,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -72,7 +72,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -109,12 +109,12 @@ def water_level_sets(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea A1 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea A1 device process message.""" message = MessageA1Response(bytearray(msg)) - self._protocol_version = message.protocol_version + self._message_protocol_version = message.protocol_version _LOGGER.debug("[%s] Received: %s", self.device_id, message) new_status = {} for status in self._attributes: @@ -159,7 +159,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def make_message_set(self) -> MessageSet: """Midea A1 device make message set.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = self._attributes[DeviceAttributes.power] message.prompt_tone = self._attributes[DeviceAttributes.prompt_tone] message.child_lock = self._attributes[DeviceAttributes.child_lock] diff --git a/midealocal/devices/ac/__init__.py b/midealocal/devices/ac/__init__.py index 974f8fd9..6effd0e4 100644 --- a/midealocal/devices/ac/__init__.py +++ b/midealocal/devices/ac/__init__.py @@ -83,7 +83,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -97,7 +97,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -168,21 +168,21 @@ def build_query( """Midea AC device build query.""" if self._used_subprotocol: return [ - MessageSubProtocolQuery(self._protocol_version, 0x10), - MessageSubProtocolQuery(self._protocol_version, 0x11), - MessageSubProtocolQuery(self._protocol_version, 0x30), + MessageSubProtocolQuery(self._message_protocol_version, 0x10), + MessageSubProtocolQuery(self._message_protocol_version, 0x11), + MessageSubProtocolQuery(self._message_protocol_version, 0x30), ] return [ - MessageQuery(self._protocol_version), - MessageNewProtocolQuery(self._protocol_version), - MessagePowerQuery(self._protocol_version), + MessageQuery(self._message_protocol_version), + MessageNewProtocolQuery(self._message_protocol_version), + MessagePowerQuery(self._message_protocol_version), ] def capabilities_query(self) -> list: """Capabilities query message.""" return [ - MessageCapabilitiesQuery(self._protocol_version, False), - MessageCapabilitiesQuery(self._protocol_version, True), + MessageCapabilitiesQuery(self._message_protocol_version, False), + MessageCapabilitiesQuery(self._message_protocol_version, True), ] def process_message(self, msg: bytes) -> dict[str, Any]: @@ -232,7 +232,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def make_message_set(self) -> MessageGeneralSet: """Midea AC device make message set.""" - message = MessageGeneralSet(self._protocol_version) + message = MessageGeneralSet(self._message_protocol_version) message.power = self._attributes[DeviceAttributes.power] message.prompt_tone = self._attributes[DeviceAttributes.prompt_tone] message.mode = self._attributes[DeviceAttributes.mode] @@ -256,7 +256,7 @@ def make_message_set(self) -> MessageGeneralSet: def make_subptotocol_message_set(self) -> MessageSubProtocolSet: """Midea AC device make subprotocol message set.""" - message = MessageSubProtocolSet(self._protocol_version) + message = MessageSubProtocolSet(self._message_protocol_version) message.power = self._attributes[DeviceAttributes.power] message.prompt_tone = self._attributes[DeviceAttributes.prompt_tone] message.aux_heating = self._attributes[DeviceAttributes.aux_heating] @@ -305,19 +305,19 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: self._attributes[DeviceAttributes.prompt_tone] = value self.update_all({DeviceAttributes.prompt_tone.value: value}) elif attr == DeviceAttributes.screen_display: - message = MessageToggleDisplay(self._protocol_version) + message = MessageToggleDisplay(self._message_protocol_version) message.prompt_tone = self._attributes[DeviceAttributes.prompt_tone] elif attr in [ DeviceAttributes.indirect_wind, DeviceAttributes.breezeless, DeviceAttributes.screen_display_alternate, ]: - message = MessageNewProtocolSet(self._protocol_version) + message = MessageNewProtocolSet(self._message_protocol_version) setattr(message, str(attr), value) message.prompt_tone = self._attributes[DeviceAttributes.prompt_tone] elif attr == DeviceAttributes.fresh_air_power: if self._fresh_air_version is not None: - message = MessageNewProtocolSet(self._protocol_version) + message = MessageNewProtocolSet(self._message_protocol_version) setattr( message, str(self._fresh_air_version), @@ -338,10 +338,10 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: self._attributes[DeviceAttributes.fresh_air_fan_speed], ] ) - message = MessageNewProtocolSet(self._protocol_version) + message = MessageNewProtocolSet(self._message_protocol_version) setattr(message, str(self._fresh_air_version), fresh_air) elif not value: - message = MessageNewProtocolSet(self._protocol_version) + message = MessageNewProtocolSet(self._message_protocol_version) setattr( message, str(self._fresh_air_version), @@ -349,7 +349,7 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: ) elif attr == DeviceAttributes.fresh_air_fan_speed: if self._fresh_air_version is not None: - message = MessageNewProtocolSet(self._protocol_version) + message = MessageNewProtocolSet(self._message_protocol_version) fresh_air = ( [True, int(value)] if int(value) > 0 diff --git a/midealocal/devices/b0/__init__.py b/midealocal/devices/b0/__init__.py index dae0f77f..8e92ca06 100644 --- a/midealocal/devices/b0/__init__.py +++ b/midealocal/devices/b0/__init__.py @@ -44,7 +44,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -58,7 +58,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -74,7 +74,7 @@ def __init__( def build_query(self) -> list[MessageQuery01]: """B0 Midea device build query.""" - return [MessageQuery01(self._protocol_version)] + return [MessageQuery01(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict: """B0 Midea device process message.""" diff --git a/midealocal/devices/b1/__init__.py b/midealocal/devices/b1/__init__.py index 34063524..44c5b70a 100644 --- a/midealocal/devices/b1/__init__.py +++ b/midealocal/devices/b1/__init__.py @@ -44,7 +44,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -58,7 +58,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -74,7 +74,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea B1 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea B1 device process message.""" diff --git a/midealocal/devices/b3/__init__.py b/midealocal/devices/b3/__init__.py index 4a19807d..06dc5251 100644 --- a/midealocal/devices/b3/__init__.py +++ b/midealocal/devices/b3/__init__.py @@ -58,7 +58,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -72,7 +72,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -103,7 +103,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea local B3 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea local B3 process message.""" diff --git a/midealocal/devices/b4/__init__.py b/midealocal/devices/b4/__init__.py index 01b26e1e..7a609cfd 100644 --- a/midealocal/devices/b4/__init__.py +++ b/midealocal/devices/b4/__init__.py @@ -44,7 +44,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -58,7 +58,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -74,7 +74,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea B4 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea B4 device process message.""" diff --git a/midealocal/devices/b6/__init__.py b/midealocal/devices/b6/__init__.py index ec80ac8c..2b05eca7 100644 --- a/midealocal/devices/b6/__init__.py +++ b/midealocal/devices/b6/__init__.py @@ -36,7 +36,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -50,7 +50,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -81,12 +81,12 @@ def preset_modes(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea B6 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea B6 device process message.""" message = MessageB6Response(msg) - self._protocol_version = message.protocol_version + self._message_protocol_version = message.protocol_version _LOGGER.debug("[%s] Received: %s", self.device_id, message) new_status = {} for status in self._attributes: @@ -118,30 +118,30 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: message = None if attr == DeviceAttributes.fan_speed: if int(value) < len(self._speeds): - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.fan_level = list(self._speeds.keys())[int(value)] elif attr == DeviceAttributes.mode: if value in self._speeds.values(): - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.fan_level = list(self._speeds.keys())[ list(self._speeds.values()).index(str(value)) ] elif not value: - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = False elif attr == DeviceAttributes.power: - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = bool(value) message.fan_level = self._power_speed elif attr == DeviceAttributes.light: - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.light = int(value) if message is not None: self.build_send(message) def turn_on(self, fan_speed: int | None = None, mode: str | None = None) -> None: """Midea B6 device turn on.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = True if fan_speed is not None and fan_speed < len(self._speeds): message.fan_level = list(self._speeds.keys())[fan_speed] diff --git a/midealocal/devices/b8/__init__.py b/midealocal/devices/b8/__init__.py index 223ecdb0..e07cc21a 100644 --- a/midealocal/devices/b8/__init__.py +++ b/midealocal/devices/b8/__init__.py @@ -43,7 +43,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -57,7 +57,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -91,7 +91,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea B8 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea B8 device process message.""" @@ -108,7 +108,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: return new_status def _gen_set_msg_default_values(self) -> MessageSet: - msg = MessageSet(self._protocol_version) + msg = MessageSet(self._message_protocol_version) msg.clean_mode = B8CleanMode[ self.attributes[B8DeviceAttributes.CLEAN_MODE].upper() ] @@ -130,7 +130,7 @@ def set_work_mode(self, work_mode: B8WorkMode) -> None: ) return - msg = MessageSetCommand(self._protocol_version, work_mode=work_mode) + msg = MessageSetCommand(self._message_protocol_version, work_mode=work_mode) self.build_send(msg) def set_attribute(self, attr: str, value: bool | int | str) -> None: diff --git a/midealocal/devices/bf/__init__.py b/midealocal/devices/bf/__init__.py index 7ac85a7a..faeba06a 100644 --- a/midealocal/devices/bf/__init__.py +++ b/midealocal/devices/bf/__init__.py @@ -44,7 +44,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -58,7 +58,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -74,7 +74,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea BF device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea BF device process message.""" diff --git a/midealocal/devices/c2/__init__.py b/midealocal/devices/c2/__init__.py index 909d7319..011828b4 100644 --- a/midealocal/devices/c2/__init__.py +++ b/midealocal/devices/c2/__init__.py @@ -42,7 +42,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -56,7 +56,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -100,7 +100,7 @@ def max_seat_temp_level(self) -> int | None: def build_query(self) -> list[MessageQuery]: """Midea C2 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea C2 device process message.""" @@ -117,7 +117,7 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: """Midea C2 device set attribute.""" message: MessagePower | MessageSet | None = None if attr == DeviceAttributes.power: - message = MessagePower(self._protocol_version) + message = MessagePower(self._message_protocol_version) message.power = bool(value) elif attr in [ DeviceAttributes.child_lock, @@ -127,7 +127,7 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: DeviceAttributes.seat_temp_level, DeviceAttributes.dry_level, ]: - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) setattr(message, attr, value) if message: self.build_send(message) diff --git a/midealocal/devices/c3/__init__.py b/midealocal/devices/c3/__init__.py index 7d4d50c8..960247eb 100644 --- a/midealocal/devices/c3/__init__.py +++ b/midealocal/devices/c3/__init__.py @@ -38,7 +38,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -52,7 +52,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -116,8 +116,8 @@ def silent_modes(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea C3 device build query.""" return [ - MessageQueryBasic(self._protocol_version), - MessageQuerySilence(self._protocol_version), + MessageQueryBasic(self._message_protocol_version), + MessageQuerySilence(self._message_protocol_version), ] def process_message(self, msg: bytes) -> dict[str, Any]: @@ -211,7 +211,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def make_message_set(self) -> MessageSet: """Midea C3 device make message set.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.zone1_power = self._attributes[DeviceAttributes.zone1_power] message.zone2_power = self._attributes[DeviceAttributes.zone2_power] message.dhw_power = self._attributes[DeviceAttributes.dhw_power] @@ -243,13 +243,13 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: message = self.make_message_set() setattr(message, str(attr), value) elif attr == DeviceAttributes.eco_mode: - message = MessageSetECO(self._protocol_version) + message = MessageSetECO(self._message_protocol_version) setattr(message, str(attr), value) elif attr in [ DeviceAttributes.silent_mode.value, DeviceAttributes.SILENT_LEVEL.value, ]: - message = MessageSetSilent(self._protocol_version) + message = MessageSetSilent(self._message_protocol_version) if attr == DeviceAttributes.silent_mode.value and isinstance(value, bool): message.silent_mode = bool(value) message.silent_level = ( diff --git a/midealocal/devices/ca/__init__.py b/midealocal/devices/ca/__init__.py index 12f6c633..031e3fb8 100644 --- a/midealocal/devices/ca/__init__.py +++ b/midealocal/devices/ca/__init__.py @@ -46,7 +46,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -60,7 +60,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -87,7 +87,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea CA device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea CA device process message.""" diff --git a/midealocal/devices/cc/__init__.py b/midealocal/devices/cc/__init__.py index 1bc97c9e..cbde4e3a 100644 --- a/midealocal/devices/cc/__init__.py +++ b/midealocal/devices/cc/__init__.py @@ -61,7 +61,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -75,7 +75,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -106,7 +106,7 @@ def fan_modes(self) -> list[str] | None: def build_query(self) -> list[MessageQuery]: """Midea CC device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea CC device process message.""" @@ -153,7 +153,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def make_message_set(self) -> MessageSet: """Midea CC device make message set.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = self._attributes[DeviceAttributes.power] message.mode = self._attributes[DeviceAttributes.mode] message.target_temperature = self._attributes[ diff --git a/midealocal/devices/cd/__init__.py b/midealocal/devices/cd/__init__.py index b6212d99..2729d794 100644 --- a/midealocal/devices/cd/__init__.py +++ b/midealocal/devices/cd/__init__.py @@ -41,7 +41,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -55,7 +55,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -88,7 +88,7 @@ def preset_modes(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea CD device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea CD device process message.""" @@ -114,7 +114,7 @@ def set_attribute(self, attr: str, value: str | int | bool) -> None: DeviceAttributes.power, DeviceAttributes.target_temperature, ]: - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.fields = self._fields message.mode = MideaCDDevice._modes.index( self._attributes[DeviceAttributes.mode], diff --git a/midealocal/devices/ce/__init__.py b/midealocal/devices/ce/__init__.py index 7fa43ad7..11ac71c3 100644 --- a/midealocal/devices/ce/__init__.py +++ b/midealocal/devices/ce/__init__.py @@ -49,7 +49,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -63,7 +63,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -103,7 +103,7 @@ def preset_modes(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea CE device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea CE device process message.""" @@ -128,7 +128,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def make_message_set(self) -> MessageSet: """Midea CE device make message set.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = self._attributes[DeviceAttributes.power] message.fan_speed = self._attributes[DeviceAttributes.fan_speed] message.link_to_ac = self._attributes[DeviceAttributes.link_to_ac] diff --git a/midealocal/devices/cf/__init__.py b/midealocal/devices/cf/__init__.py index 0a52c84d..cab091f8 100644 --- a/midealocal/devices/cf/__init__.py +++ b/midealocal/devices/cf/__init__.py @@ -36,7 +36,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -50,7 +50,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -66,7 +66,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea CF device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea CF device process message.""" @@ -86,7 +86,7 @@ def set_target_temperature( zone: int | None = None, # noqa: ARG002 ) -> None: """Midea CF device set target temperature.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = True message.mode = self._attributes[DeviceAttributes.mode] message.target_temperature = target_temperature @@ -98,7 +98,7 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: """Midea CF device set attribute.""" if not isinstance(value, bool): raise ValueWrongType("[cf] Expected bool") - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = True message.mode = self._attributes[DeviceAttributes.mode] if attr == DeviceAttributes.power: diff --git a/midealocal/devices/da/__init__.py b/midealocal/devices/da/__init__.py index e0a81e49..29e654af 100644 --- a/midealocal/devices/da/__init__.py +++ b/midealocal/devices/da/__init__.py @@ -48,7 +48,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -62,7 +62,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -88,7 +88,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea DA device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea DA device process message.""" @@ -176,11 +176,11 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: raise ValueWrongType("[da] Expected bool") message: MessagePower | MessageStart | None = None if attr == DeviceAttributes.power: - message = MessagePower(self._protocol_version) + message = MessagePower(self._message_protocol_version) message.power = value self.build_send(message) elif attr == DeviceAttributes.start: - message = MessageStart(self._protocol_version) + message = MessageStart(self._message_protocol_version) message.start = value message.washing_data = self._attributes[DeviceAttributes.washing_data] self.build_send(message) diff --git a/midealocal/devices/db/__init__.py b/midealocal/devices/db/__init__.py index ba47e82c..376f0e78 100644 --- a/midealocal/devices/db/__init__.py +++ b/midealocal/devices/db/__init__.py @@ -34,7 +34,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -48,7 +48,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -62,7 +62,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea DB device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea DB device process message.""" @@ -95,11 +95,11 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: raise ValueWrongType("[db] Expected bool") message: MessagePower | MessageStart | None = None if attr == DeviceAttributes.power: - message = MessagePower(self._protocol_version) + message = MessagePower(self._message_protocol_version) message.power = value self.build_send(message) elif attr == DeviceAttributes.start: - message = MessageStart(self._protocol_version) + message = MessageStart(self._message_protocol_version) message.start = value message.washing_data = self._attributes[DeviceAttributes.washing_data] self.build_send(message) diff --git a/midealocal/devices/dc/__init__.py b/midealocal/devices/dc/__init__.py index 4f29702f..928b0fcb 100644 --- a/midealocal/devices/dc/__init__.py +++ b/midealocal/devices/dc/__init__.py @@ -34,7 +34,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -48,7 +48,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -62,7 +62,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea DC device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea DC device process message.""" @@ -94,11 +94,11 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: raise ValueWrongType("[dc] Expected bool") message: MessagePower | MessageStart | None = None if attr == DeviceAttributes.power: - message = MessagePower(self._protocol_version) + message = MessagePower(self._message_protocol_version) message.power = value self.build_send(message) elif attr == DeviceAttributes.start: - message = MessageStart(self._protocol_version) + message = MessageStart(self._message_protocol_version) message.start = value message.washing_data = self._attributes[DeviceAttributes.washing_data] self.build_send(message) diff --git a/midealocal/devices/e1/__init__.py b/midealocal/devices/e1/__init__.py index 348fa48b..a366b5d6 100644 --- a/midealocal/devices/e1/__init__.py +++ b/midealocal/devices/e1/__init__.py @@ -59,7 +59,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -73,7 +73,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -132,7 +132,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea E1 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea E1 device process message.""" @@ -167,15 +167,15 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: raise ValueWrongType("[e1] Expected bool") message: MessagePower | MessageLock | MessageStorage | None = None if attr == DeviceAttributes.power: - message = MessagePower(self._protocol_version) + message = MessagePower(self._message_protocol_version) message.power = value self.build_send(message) elif attr == DeviceAttributes.child_lock: - message = MessageLock(self._protocol_version) + message = MessageLock(self._message_protocol_version) message.lock = value self.build_send(message) elif attr == DeviceAttributes.storage: - message = MessageStorage(self._protocol_version) + message = MessageStorage(self._message_protocol_version) message.storage = value self.build_send(message) diff --git a/midealocal/devices/e2/__init__.py b/midealocal/devices/e2/__init__.py index da594095..8f3255d0 100644 --- a/midealocal/devices/e2/__init__.py +++ b/midealocal/devices/e2/__init__.py @@ -63,7 +63,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -77,7 +77,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -113,7 +113,7 @@ def _normalize_old_protocol(self, value: str | bool | int) -> OldProtocol: def build_query(self) -> list[MessageQuery]: """Midea E2 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea E2 device process message.""" @@ -128,7 +128,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def make_message_set(self) -> MessageSet: """Midea E2 device make message set.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.protection = self._attributes[DeviceAttributes.protection] message.whole_tank_heating = self._attributes[ DeviceAttributes.whole_tank_heating @@ -149,13 +149,13 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: ]: old_protocol = self._normalize_old_protocol(self._old_protocol) if attr == DeviceAttributes.power: - message = MessagePower(self._protocol_version) + message = MessagePower(self._message_protocol_version) message.power = bool(value) elif old_protocol == OldProtocol.true: message = self.make_message_set() setattr(message, str(attr), value) else: - message = MessageNewProtocolSet(self._protocol_version) + message = MessageNewProtocolSet(self._message_protocol_version) setattr(message, str(attr), value) self.build_send(message) diff --git a/midealocal/devices/e3/__init__.py b/midealocal/devices/e3/__init__.py index fd3c93a8..a880bb76 100644 --- a/midealocal/devices/e3/__init__.py +++ b/midealocal/devices/e3/__init__.py @@ -43,7 +43,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -57,7 +57,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -83,7 +83,7 @@ def precision_halves(self) -> bool | None: def build_query(self) -> list[MessageQuery]: """Midea E3 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea E3 device process message.""" @@ -105,7 +105,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def make_message_set(self) -> MessageSet: """Midea E3 device make message set.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.zero_cold_water = self._attributes[DeviceAttributes.zero_cold_water] message.protection = self._attributes[DeviceAttributes.protection] message.zero_cold_pulse = self._attributes[DeviceAttributes.zero_cold_pulse] @@ -126,13 +126,13 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: if self._precision_halves and attr == DeviceAttributes.target_temperature: value = int(value * 2) if attr == DeviceAttributes.power: - message = MessagePower(self._protocol_version) + message = MessagePower(self._message_protocol_version) message.power = bool(value) elif self.subtype in self._old_subtypes: message = self.make_message_set() setattr(message, str(attr), value) else: - message = MessageNewProtocolSet(self._protocol_version) + message = MessageNewProtocolSet(self._message_protocol_version) message.key = str(attr) message.value = value self.build_send(message) diff --git a/midealocal/devices/e6/__init__.py b/midealocal/devices/e6/__init__.py index 3a257977..39bd1cbc 100644 --- a/midealocal/devices/e6/__init__.py +++ b/midealocal/devices/e6/__init__.py @@ -38,7 +38,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -52,7 +52,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -71,7 +71,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea E6 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea E6 device process message.""" @@ -92,7 +92,7 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: DeviceAttributes.heating_temperature, DeviceAttributes.bathing_temperature, ]: - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) setattr(message, str(attr), value) self.build_send(message) diff --git a/midealocal/devices/e8/__init__.py b/midealocal/devices/e8/__init__.py index 67a71b13..e206d340 100644 --- a/midealocal/devices/e8/__init__.py +++ b/midealocal/devices/e8/__init__.py @@ -45,7 +45,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -59,7 +59,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -76,7 +76,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea E8 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea E8 device process message.""" diff --git a/midealocal/devices/ea/__init__.py b/midealocal/devices/ea/__init__.py index df21e152..c3608516 100644 --- a/midealocal/devices/ea/__init__.py +++ b/midealocal/devices/ea/__init__.py @@ -140,7 +140,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -154,7 +154,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -171,7 +171,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea EA device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea EA device process message.""" diff --git a/midealocal/devices/ec/__init__.py b/midealocal/devices/ec/__init__.py index 59b22247..beb56057 100644 --- a/midealocal/devices/ec/__init__.py +++ b/midealocal/devices/ec/__init__.py @@ -152,7 +152,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -166,7 +166,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -183,7 +183,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea EC device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea EC device process merge.""" diff --git a/midealocal/devices/ed/__init__.py b/midealocal/devices/ed/__init__.py index 3678efde..f8472611 100644 --- a/midealocal/devices/ed/__init__.py +++ b/midealocal/devices/ed/__init__.py @@ -40,7 +40,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -54,7 +54,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -79,7 +79,7 @@ def _use_new_set(self) -> bool: def build_query(self) -> list[MessageQuery]: """Midea ED device build query.""" - return [MessageQuery(self._protocol_version, self._device_class)] + return [MessageQuery(self._message_protocol_version, self._device_class)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea ED device process message.""" @@ -99,9 +99,9 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: message: MessageNewSet | MessageOldSet | None = None if self._use_new_set(): if attr in [DeviceAttributes.power, DeviceAttributes.child_lock]: - message = MessageNewSet(self._protocol_version) + message = MessageNewSet(self._message_protocol_version) elif attr in []: - message = MessageOldSet(self._protocol_version) + message = MessageOldSet(self._message_protocol_version) if message is not None: setattr(message, str(attr), value) self.build_send(message) diff --git a/midealocal/devices/fa/__init__.py b/midealocal/devices/fa/__init__.py index 5eaebb51..c4078eb5 100644 --- a/midealocal/devices/fa/__init__.py +++ b/midealocal/devices/fa/__init__.py @@ -83,7 +83,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -97,7 +97,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -142,7 +142,7 @@ def preset_modes(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea FA device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea FA device process message.""" @@ -275,7 +275,7 @@ def set_oscillation(self, attr: str, value: int | str | bool) -> MessageSet | No message: MessageSet | None = None if self._attributes[attr] != value: if attr == DeviceAttributes.oscillate: - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) message.oscillate = bool(value) if value: message.oscillation_angle = 3 # 90 @@ -283,17 +283,17 @@ def set_oscillation(self, attr: str, value: int | str | bool) -> MessageSet | No elif attr == DeviceAttributes.oscillation_mode and ( value in MideaFADevice._oscillation_modes or not value ): - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) self._set_oscillation_mode(message, str(value)) elif attr == DeviceAttributes.oscillation_angle and ( value in MideaFADevice._oscillation_angles or not value ): - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) self._set_oscillation_angle(message, str(value)) elif attr == DeviceAttributes.tilting_angle and ( value in MideaFADevice._tilting_angles or not value ): - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) self._set_tilting_angle(message, str(value)) return message @@ -312,22 +312,22 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: and int(value) > 0 and not self._attributes[DeviceAttributes.power] ): - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) message.fan_speed = int(value) message.power = True elif attr == DeviceAttributes.mode: if value in MideaFADevice._modes: - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) message.mode = MideaFADevice._modes.index(str(value)) elif not (attr == DeviceAttributes.fan_speed and value == 0): - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) setattr(message, str(attr), value) if message is not None: self.build_send(message) def turn_on(self, fan_speed: int | None = None, mode: str | None = None) -> None: """Turn on the device.""" - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) message.power = True if fan_speed is not None: message.fan_speed = fan_speed diff --git a/midealocal/devices/fb/__init__.py b/midealocal/devices/fb/__init__.py index 6e7fa6e9..8f9525c1 100644 --- a/midealocal/devices/fb/__init__.py +++ b/midealocal/devices/fb/__init__.py @@ -46,7 +46,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -60,7 +60,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -80,7 +80,7 @@ def modes(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea FB device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea FB device process message.""" @@ -103,13 +103,13 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def set_attribute(self, attr: str, value: str | int | bool) -> None: """Midea FB device set attribute.""" if attr == DeviceAttributes.mode: - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) if value in MideaFBDevice._modes.values(): message.mode = list(MideaFBDevice._modes.keys())[ list(MideaFBDevice._modes.values()).index(str(value)) ] else: - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) setattr(message, str(attr), value) self.build_send(message) @@ -120,7 +120,7 @@ def set_target_temperature( zone: int | None = None, # noqa: ARG002 ) -> None: """Midea FB device set target temperature.""" - message = MessageSet(self._protocol_version, self.subtype) + message = MessageSet(self._message_protocol_version, self.subtype) setattr(message, DeviceAttributes.target_temperature, target_temperature) self.build_send(message) diff --git a/midealocal/devices/fc/__init__.py b/midealocal/devices/fc/__init__.py index 061261aa..6f5ae0d7 100644 --- a/midealocal/devices/fc/__init__.py +++ b/midealocal/devices/fc/__init__.py @@ -63,7 +63,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -77,7 +77,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -124,7 +124,7 @@ def detect_modes(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea FC device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea FC device process message.""" @@ -163,7 +163,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def make_message_set(self) -> MessageSet: """Midea FC device make message set.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = self._attributes[DeviceAttributes.power] message.child_lock = self._attributes[DeviceAttributes.child_lock] message.prompt_tone = self._attributes[DeviceAttributes.prompt_tone] diff --git a/midealocal/devices/fd/__init__.py b/midealocal/devices/fd/__init__.py index c3ab9eab..c2bb9b54 100644 --- a/midealocal/devices/fd/__init__.py +++ b/midealocal/devices/fd/__init__.py @@ -68,7 +68,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -82,7 +82,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -125,7 +125,7 @@ def detect_modes(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea FD device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea FD device process message.""" @@ -159,7 +159,7 @@ def process_message(self, msg: bytes) -> dict[str, Any]: def make_message_set(self) -> MessageSet: """Midea FD device make message set.""" - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.power = self._attributes[DeviceAttributes.power] message.prompt_tone = self._attributes[DeviceAttributes.prompt_tone] message.screen_display = self._attributes[DeviceAttributes.screen_display] diff --git a/midealocal/devices/x13/__init__.py b/midealocal/devices/x13/__init__.py index ac4b8a43..ce56c086 100644 --- a/midealocal/devices/x13/__init__.py +++ b/midealocal/devices/x13/__init__.py @@ -43,7 +43,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -57,7 +57,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -99,7 +99,7 @@ def midea_to_kelvin(self, midea: int) -> float: def build_query(self) -> list[MessageQuery]: """Midea x13 Device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea x13 Device process message.""" @@ -131,7 +131,7 @@ def set_attribute(self, attr: str, value: str | int | bool) -> None: DeviceAttributes.effect, DeviceAttributes.power, ]: - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) if attr == DeviceAttributes.effect and value in self._effects: setattr(message, str(attr), Midea13Device._effects.index(str(value))) elif attr == DeviceAttributes.color_temperature: diff --git a/midealocal/devices/x26/__init__.py b/midealocal/devices/x26/__init__.py index d730d61a..e649b6d7 100644 --- a/midealocal/devices/x26/__init__.py +++ b/midealocal/devices/x26/__init__.py @@ -59,7 +59,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -73,7 +73,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -120,7 +120,7 @@ def directions(self) -> list[str]: def build_query(self) -> list[MessageQuery]: """Midea x26 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea x26 device process message.""" @@ -150,7 +150,7 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: DeviceAttributes.mode, DeviceAttributes.direction, ]: - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.fields = self._fields message.main_light = self._attributes[DeviceAttributes.main_light] message.night_light = self._attributes[DeviceAttributes.night_light] diff --git a/midealocal/devices/x34/__init__.py b/midealocal/devices/x34/__init__.py index fa246322..edbd2bba 100644 --- a/midealocal/devices/x34/__init__.py +++ b/midealocal/devices/x34/__init__.py @@ -59,7 +59,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, # noqa: ARG002 @@ -73,7 +73,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -132,7 +132,7 @@ def __init__( def build_query(self) -> list[MessageQuery]: """Midea x34 device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea x34 device process message.""" @@ -167,15 +167,15 @@ def set_attribute(self, attr: str, value: bool | int | str) -> None: raise ValueWrongType("[x34] Expected bool") message: MessagePower | MessageLock | MessageStorage | None = None if attr == DeviceAttributes.power: - message = MessagePower(self._protocol_version) + message = MessagePower(self._message_protocol_version) message.power = value self.build_send(message) elif attr == DeviceAttributes.child_lock: - message = MessageLock(self._protocol_version) + message = MessageLock(self._message_protocol_version) message.lock = value self.build_send(message) elif attr == DeviceAttributes.storage: - message = MessageStorage(self._protocol_version) + message = MessageStorage(self._message_protocol_version) message.storage = value self.build_send(message) diff --git a/midealocal/devices/x40/__init__.py b/midealocal/devices/x40/__init__.py index 018732e0..d8880b42 100644 --- a/midealocal/devices/x40/__init__.py +++ b/midealocal/devices/x40/__init__.py @@ -42,7 +42,7 @@ def __init__( port: int, token: str, key: str, - protocol: ProtocolVersion, + device_protocol: ProtocolVersion, model: str, subtype: int, customize: str, @@ -56,7 +56,7 @@ def __init__( port=port, token=token, key=key, - protocol=protocol, + device_protocol=device_protocol, model=model, subtype=subtype, attributes={ @@ -99,7 +99,7 @@ def _convert_from_midea_direction(direction: int) -> int: def build_query(self) -> list[MessageQuery]: """Midea x40 Device build query.""" - return [MessageQuery(self._protocol_version)] + return [MessageQuery(self._message_protocol_version)] def process_message(self, msg: bytes) -> dict[str, Any]: """Midea x40 Device process message.""" @@ -133,7 +133,7 @@ def set_attribute(self, attr: str, value: int | str | bool) -> None: DeviceAttributes.ventilation, DeviceAttributes.smelly_sensor, ]: - message = MessageSet(self._protocol_version) + message = MessageSet(self._message_protocol_version) message.fields = self._fields message.light = self._attributes[DeviceAttributes.light] message.ventilation = self._attributes[DeviceAttributes.ventilation] diff --git a/midealocal/message.py b/midealocal/message.py index 445bdafb..75e61f69 100644 --- a/midealocal/message.py +++ b/midealocal/message.py @@ -135,7 +135,7 @@ def __init__(self) -> None: self._device_type: DeviceType = DeviceType.X00 self._message_type: MessageType = MessageType.default self._body_type: BodyType = BodyType.X00 - self._protocol_version: ProtocolVersion = ProtocolVersion.V1 + self._message_protocol_version: ProtocolVersion = ProtocolVersion.V1 @staticmethod def checksum(data: bytes) -> SupportsIndex: @@ -182,11 +182,11 @@ def body_type(self, value: BodyType) -> None: @property def protocol_version(self) -> ProtocolVersion: """Message protocol version.""" - return self._protocol_version + return self._message_protocol_version @protocol_version.setter def protocol_version(self, protocol_version: ProtocolVersion) -> None: - self._protocol_version = protocol_version + self._message_protocol_version = protocol_version def _format_attribute( self, diff --git a/tests/cli_test.py b/tests/cli_test.py index 22af1104..c2462b7b 100644 --- a/tests/cli_test.py +++ b/tests/cli_test.py @@ -186,7 +186,7 @@ def test_message(self) -> None: device_type=int(self.namespace.message[2]), ip_address="192.168.192.168", port=6664, - protocol=ProtocolVersion.V2, + device_protocol=ProtocolVersion.V2, model="0000", token="", key="", diff --git a/tests/device_test.py b/tests/device_test.py index ba31018a..1ec25e4f 100644 --- a/tests/device_test.py +++ b/tests/device_test.py @@ -43,7 +43,7 @@ def _setup_device(self) -> None: port=6444, token=DEFAULT_KEYS[99]["token"], key=DEFAULT_KEYS[99]["key"], - protocol=ProtocolVersion.V3, + device_protocol=ProtocolVersion.V3, model="test_model", subtype=1, attributes={}, @@ -189,7 +189,7 @@ def test_send_message(self) -> None: self.device.authenticate() self.device.send_message(bytearray([0x0] * 20)) self.device._socket = None - self.device._protocol = ProtocolVersion.V2 + self.device._device_protocol_version = ProtocolVersion.V2 self.device.send_message(bytearray([0x0] * 20)) def test_get_capabilities(self) -> None: @@ -282,7 +282,7 @@ def test_parse_message(self) -> None: ), ): assert self.device.parse_message(bytearray([])) == MessageResult.PADDING - self.device._protocol = ProtocolVersion.V2 + self.device._device_protocol_version = ProtocolVersion.V2 assert self.device.parse_message(bytearray([])) == MessageResult.ERROR with patch.object( self.device, diff --git a/tests/devices/a1/device_a1_test.py b/tests/devices/a1/device_a1_test.py index ba8cbd62..397a3663 100644 --- a/tests/devices/a1/device_a1_test.py +++ b/tests/devices/a1/device_a1_test.py @@ -22,7 +22,7 @@ def _setup_device(self) -> None: port=6444, token="AA", key="BB", - protocol=ProtocolVersion.V3, + device_protocol=ProtocolVersion.V3, model="test_model", subtype=1, customize="test_customize", diff --git a/tests/devices/ac/device_ac_test.py b/tests/devices/ac/device_ac_test.py index 56ffdf3c..62a83781 100644 --- a/tests/devices/ac/device_ac_test.py +++ b/tests/devices/ac/device_ac_test.py @@ -30,7 +30,7 @@ def _setup_device(self) -> None: port=12345, token="AA", key="BB", - protocol=ProtocolVersion.V1, + device_protocol=ProtocolVersion.V1, model="test_model", subtype=1, customize='{"temperature_step": 1, "power_analysis_method": 2}', diff --git a/tests/devices/b8/device_b8_test.py b/tests/devices/b8/device_b8_test.py index b6ebe2ea..6e38a265 100644 --- a/tests/devices/b8/device_b8_test.py +++ b/tests/devices/b8/device_b8_test.py @@ -44,7 +44,7 @@ def _setup_device(self) -> None: port=12345, token="AA", key="BB", - protocol=ProtocolVersion.V1, + device_protocol=ProtocolVersion.V1, model="test_model", subtype=1, customize="", diff --git a/tests/devices/c3/device_c3_test.py b/tests/devices/c3/device_c3_test.py index b3723ab6..e51c79cd 100644 --- a/tests/devices/c3/device_c3_test.py +++ b/tests/devices/c3/device_c3_test.py @@ -30,7 +30,7 @@ def _setup_device(self) -> None: port=12345, token="AA", key="BB", - protocol=ProtocolVersion.V1, + device_protocol=ProtocolVersion.V1, model="test_model", subtype=1, customize='{"temperature_step": 1}', diff --git a/tests/devices/da/device_da_test.py b/tests/devices/da/device_da_test.py index 4338ef34..1f6fb835 100644 --- a/tests/devices/da/device_da_test.py +++ b/tests/devices/da/device_da_test.py @@ -25,7 +25,7 @@ def _setup_device(self) -> None: port=6444, token="AA", key="BB", - protocol=ProtocolVersion.V3, + device_protocol=ProtocolVersion.V3, model="test_model", subtype=1, customize="test_customize", diff --git a/tests/devices/ed/device_ed_test.py b/tests/devices/ed/device_ed_test.py index b83ebe9c..d29d7129 100644 --- a/tests/devices/ed/device_ed_test.py +++ b/tests/devices/ed/device_ed_test.py @@ -24,7 +24,7 @@ def _setup_device(self) -> None: port=6444, token="AA", key="BB", - protocol=ProtocolVersion.V3, + device_protocol=ProtocolVersion.V3, model="test_model", subtype=1, customize="test_customize", diff --git a/tests/devices/x40/device_x40_test.py b/tests/devices/x40/device_x40_test.py index 7643500c..d66682d1 100644 --- a/tests/devices/x40/device_x40_test.py +++ b/tests/devices/x40/device_x40_test.py @@ -23,7 +23,7 @@ def _setup_device(self) -> None: port=6444, token="AA", key="BB", - protocol=ProtocolVersion.V3, + device_protocol=ProtocolVersion.V3, model="test_model", subtype=1, customize="",