Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: message protocol version default #316

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion midealocal/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(
self._device_protocol_version = device_protocol
self._model = model
self._subtype = subtype
self._message_protocol_version: ProtocolVersion = ProtocolVersion.V1
self._message_protocol_version: int = 0
self._updates: list[Callable[[dict[str, Any]], None]] = []
self._unsupported_protocol: list[str] = []
self._is_run = False
Expand Down
6 changes: 3 additions & 3 deletions midealocal/devices/a1/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MessageA1Base(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand Down Expand Up @@ -62,7 +62,7 @@ def body(self) -> bytearray:
class MessageQuery(MessageA1Base):
"""Message A1 query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize message A1 query."""
super().__init__(
protocol_version=protocol_version,
Expand Down Expand Up @@ -120,7 +120,7 @@ def _body(self) -> bytearray:
class MessageSet(MessageA1Base):
"""Message A1 set."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize message A1 set."""
super().__init__(
protocol_version=protocol_version,
Expand Down
24 changes: 12 additions & 12 deletions midealocal/devices/ac/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from enum import IntEnum

from midealocal.const import MAX_BYTE_VALUE, DeviceType, ProtocolVersion
from midealocal.const import MAX_BYTE_VALUE, DeviceType
from midealocal.crc8 import calculate
from midealocal.message import (
BodyType,
Expand Down Expand Up @@ -106,7 +106,7 @@ class MessageACBase(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand Down Expand Up @@ -137,7 +137,7 @@ def body(self) -> bytearray:
class MessageQuery(MessageACBase):
"""AC message query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize AC message query."""
super().__init__(
protocol_version=protocol_version,
Expand Down Expand Up @@ -177,7 +177,7 @@ class MessageCapabilitiesQuery(MessageACBase):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
additional_capabilities: bool,
) -> None:
"""Initialize AC message capabilities query."""
Expand All @@ -198,7 +198,7 @@ def _body(self) -> bytearray:
class MessagePowerQuery(MessageACBase):
"""AC message power query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize AC message power query."""
super().__init__(
protocol_version=protocol_version,
Expand All @@ -221,7 +221,7 @@ def body(self) -> bytearray:
class MessageToggleDisplay(MessageACBase):
"""AC message toggle display."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize AC message toggle display."""
super().__init__(
protocol_version=protocol_version,
Expand Down Expand Up @@ -261,7 +261,7 @@ def _body(self) -> bytearray:
class MessageNewProtocolQuery(MessageACBase):
"""AC message new protocol query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize AC message new protocol query."""
super().__init__(
protocol_version=protocol_version,
Expand Down Expand Up @@ -291,7 +291,7 @@ class MessageSubProtocol(MessageACBase):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
subprotocol_query_type: int,
) -> None:
Expand Down Expand Up @@ -339,7 +339,7 @@ class MessageSubProtocolQuery(MessageSubProtocol):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
subprotocol_query_type: int,
) -> None:
"""Initialize AC message sub protocol query."""
Expand All @@ -353,7 +353,7 @@ def __init__(
class MessageSubProtocolSet(MessageSubProtocol):
"""AC message sub protocol set."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize AC message sub protocol set."""
super().__init__(
protocol_version=protocol_version,
Expand Down Expand Up @@ -437,7 +437,7 @@ def _subprotocol_body(self) -> bytes:
class MessageGeneralSet(MessageACBase):
"""AC message general set."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize AC message general set."""
super().__init__(
protocol_version=protocol_version,
Expand Down Expand Up @@ -529,7 +529,7 @@ def _body(self) -> bytearray:
class MessageNewProtocolSet(MessageACBase):
"""AC message new protocol set."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize AC message new protocol set."""
super().__init__(
protocol_version=protocol_version,
Expand Down
4 changes: 2 additions & 2 deletions midealocal/devices/b0/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MessageB0Base(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand Down Expand Up @@ -53,7 +53,7 @@ def _body(self) -> bytearray:
class MessageQuery01(MessageB0Base):
"""B0 message query 01."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize B0 message query 01."""
super().__init__(
protocol_version=protocol_version,
Expand Down
6 changes: 3 additions & 3 deletions midealocal/devices/b1/message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Midea local B1 message."""

from midealocal.const import MAX_BYTE_VALUE, DeviceType, ProtocolVersion
from midealocal.const import MAX_BYTE_VALUE, DeviceType
from midealocal.message import (
BodyType,
MessageBody,
Expand All @@ -15,7 +15,7 @@ class MessageB1Base(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand All @@ -35,7 +35,7 @@ def _body(self) -> bytearray:
class MessageQuery(MessageB1Base):
"""B1 message query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize B1 message query."""
super().__init__(
protocol_version=protocol_version,
Expand Down
6 changes: 3 additions & 3 deletions midealocal/devices/b3/message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Midea local B3 message."""

from midealocal.const import MAX_BYTE_VALUE, DeviceType, ProtocolVersion
from midealocal.const import MAX_BYTE_VALUE, DeviceType
from midealocal.message import (
BodyType,
MessageBody,
Expand All @@ -22,7 +22,7 @@ class MessageB3Base(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand All @@ -42,7 +42,7 @@ def _body(self) -> bytearray:
class MessageQuery(MessageB3Base):
"""B3 message query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize B3 message query."""
super().__init__(
protocol_version=protocol_version,
Expand Down
6 changes: 3 additions & 3 deletions midealocal/devices/b4/message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Midea local B4 message."""

from midealocal.const import MAX_BYTE_VALUE, DeviceType, ProtocolVersion
from midealocal.const import MAX_BYTE_VALUE, DeviceType
from midealocal.message import (
BodyType,
MessageBody,
Expand All @@ -15,7 +15,7 @@ class MessageB4Base(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand All @@ -35,7 +35,7 @@ def _body(self) -> bytearray:
class MessageQuery(MessageB4Base):
"""B4 message query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize B4 message query."""
super().__init__(
protocol_version=protocol_version,
Expand Down
10 changes: 4 additions & 6 deletions midealocal/devices/b6/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MessageB6Base(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand All @@ -41,14 +41,12 @@ def _body(self) -> bytearray:
class MessageQuery(MessageB6Base):
"""B6 message query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize B6 message query."""
super().__init__(
protocol_version=protocol_version,
message_type=MessageType.query,
body_type=BodyType.X11
if protocol_version == ProtocolVersion.V2
else BodyType.X31,
body_type=BodyType.X11 if protocol_version == 2 else BodyType.X31,
)

@property
Expand All @@ -75,7 +73,7 @@ def _body(self) -> bytearray:
class MessageSet(MessageB6Base):
"""B6 message set."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize B6 message set."""
super().__init__(
protocol_version=protocol_version,
Expand Down
10 changes: 5 additions & 5 deletions midealocal/devices/b8/message.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Midea local B8 message."""

from midealocal.const import DeviceType, ProtocolVersion
from midealocal.const import DeviceType
from midealocal.message import (
BodyType,
BoolParser,
Expand Down Expand Up @@ -37,7 +37,7 @@ class MessageB8Base(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand All @@ -57,7 +57,7 @@ def _body(self) -> bytearray:
class MessageQuery(MessageB8Base):
"""B8 message query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize B8 message query."""
super().__init__(
protocol_version=protocol_version,
Expand All @@ -73,7 +73,7 @@ def _body(self) -> bytearray:
class MessageSet(MessageB8Base):
"""B8 message set."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize B8 message set."""
super().__init__(
protocol_version=protocol_version,
Expand Down Expand Up @@ -107,7 +107,7 @@ class MessageSetCommand(MessageB8Base):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
work_mode: B8WorkMode,
) -> None:
"""Initialize B8 message set command."""
Expand Down
4 changes: 2 additions & 2 deletions midealocal/devices/bf/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MessageBFBase(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand All @@ -35,7 +35,7 @@ def _body(self) -> bytearray:
class MessageQuery(MessageBFBase):
"""BF message query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize BF message query."""
super().__init__(
protocol_version=protocol_version,
Expand Down
8 changes: 4 additions & 4 deletions midealocal/devices/c2/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MessageC2Base(MessageRequest):

def __init__(
self,
protocol_version: ProtocolVersion,
protocol_version: int,
message_type: MessageType,
body_type: BodyType,
) -> None:
Expand All @@ -74,7 +74,7 @@ def _body(self) -> bytearray:
class MessageQuery(MessageC2Base):
"""C2 message query."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize C2 message query."""
super().__init__(
protocol_version=protocol_version,
Expand All @@ -90,7 +90,7 @@ def _body(self) -> bytearray:
class MessagePower(MessageC2Base):
"""C2 message power."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize C2 message power."""
super().__init__(
protocol_version=protocol_version,
Expand Down Expand Up @@ -127,7 +127,7 @@ def _body(self) -> bytearray:
class MessageSet(MessageC2Base):
"""C2 message set."""

def __init__(self, protocol_version: ProtocolVersion) -> None:
def __init__(self, protocol_version: int) -> None:
"""Initialize C2 message set."""
super().__init__(
protocol_version=protocol_version,
Expand Down
Loading
Loading