-
Notifications
You must be signed in to change notification settings - Fork 234
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
增加 #419
Open
tufeikafei
wants to merge
8
commits into
georgezhao2010:master
Choose a base branch
from
tufeikafei:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
增加 #419
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fe4e4bb
Update device.py
tufeikafei 2c68265
Update message.py
tufeikafei 7df3b97
Update device.py
tufeikafei 6a5d596
Update message.py
tufeikafei 09cdcdb
Update midea_devices.py
tufeikafei 5e6efd6
新增破壁机
tufeikafei 1e46089
Delete custom_components/midea_ac_lan/midea/devices/f1/__pycache__ di…
tufeikafei 8522999
调试破壁机
tufeikafei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,28 @@ def _body(self): | |
bytearray([0xff] * 6) + bytearray([0x00] * 27) | ||
|
||
|
||
class MessageStrongStart(MessageE1Base): | ||
def __init__(self, device_protocol_version): | ||
super().__init__( | ||
device_protocol_version=device_protocol_version, | ||
message_type=MessageType.set, | ||
body_type=0x08) | ||
self.strong = False | ||
|
||
@property | ||
def _body(self): | ||
strong = 0x03 if self.strong else 0x01 | ||
# return bytearray([0x00, 0x00, 0x00, strong]) + \ | ||
# bytearray([0xff] * 6) + bytearray([0x00] * 27) | ||
|
||
# return bytearray([ | ||
# 0x03,0x02,0x00,0x00 | ||
# ]) | ||
|
||
return bytearray([ | ||
strong,0x02,0x00,0x00 | ||
]) | ||
|
||
class MessageQuery(MessageE1Base): | ||
def __init__(self, device_protocol_version): | ||
super().__init__( | ||
|
@@ -82,6 +104,9 @@ class E1GeneralMessageBody(MessageBody): | |
def __init__(self, body): | ||
super().__init__(body) | ||
self.power = body[1] > 0 | ||
|
||
self.strong= body[1] > 2 | ||
|
||
self.status = body[1] | ||
self.mode = body[2] | ||
self.additional = body[3] | ||
|
@@ -91,8 +116,11 @@ def __init__(self, body): | |
start_pause = (body[5] & 0x08) > 0 | ||
if start_pause: | ||
self.start = True | ||
|
||
elif self.status in [2, 3]: | ||
self.start = False | ||
|
||
|
||
self.child_lock = (body[5] & 0x10) > 0 | ||
self.uv = (body[4] & 0x2) > 0 | ||
self.dry = (body[4] & 0x10) > 0 | ||
|
@@ -110,6 +138,7 @@ class MessageE1Response(MessageResponse): | |
def __init__(self, message): | ||
super().__init__(message) | ||
body = message[10: -1] | ||
print(body) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here as well |
||
if (self._message_type == MessageType.set and 0 <= self._body_type <= 7) or \ | ||
(self._message_type in [MessageType.query, MessageType.notify1] and self._body_type == 0): | ||
self._body = E1GeneralMessageBody(body) | ||
|
157 changes: 157 additions & 0 deletions
157
custom_components/midea_ac_lan/midea/devices/f1/device.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import logging | ||
from .message import ( | ||
MessageQuery, | ||
MessageF1Response, | ||
MessageSet | ||
) | ||
from ...core.device import MiedaDevice | ||
from ...backports.enum import StrEnum | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class DeviceAttributes(StrEnum): | ||
mode="mode" | ||
error_code="error_code" | ||
response_type="response_type" | ||
work_status="work_status" | ||
step_status="step_status" | ||
work_step="work_step" | ||
cup_capstatus="cup_capstatus" | ||
cup_bodystatus="cup_bodystatus" | ||
curworktime="curworktime" | ||
curtemperature="curtemperature" | ||
curwork_speed="curwork_speed" | ||
temperature_reservehot="temperature_reservehot" | ||
temperature_reservewarm="temperature_reservewarm" | ||
time_reservefinish="time_reservefinish" | ||
time_reservework="time_reservework" | ||
time_reservewarm="time_reservewarm" | ||
code_id="code_id" | ||
|
||
|
||
class MideaF1Device(MiedaDevice): | ||
|
||
def __init__( | ||
self, | ||
name: str, | ||
device_id: int, | ||
ip_address: str, | ||
port: int, | ||
token: str, | ||
key: str, | ||
protocol: int, | ||
model: str, | ||
customize: str | ||
): | ||
super().__init__( | ||
name=name, | ||
device_id=device_id, | ||
device_type=0xF1, | ||
ip_address=ip_address, | ||
port=port, | ||
token=token, | ||
key=key, | ||
protocol=protocol, | ||
model=model | ||
) | ||
self._attributes = { | ||
DeviceAttributes.mode: None, | ||
DeviceAttributes.error_code: None, | ||
DeviceAttributes.response_type: None, | ||
DeviceAttributes.work_status: None, | ||
DeviceAttributes.step_status: None, | ||
DeviceAttributes.work_step: None, | ||
DeviceAttributes.cup_capstatus: None, | ||
DeviceAttributes.cup_bodystatus: None, | ||
DeviceAttributes.curworktime: None, | ||
DeviceAttributes.curtemperature: None, | ||
DeviceAttributes.curwork_speed: None, | ||
DeviceAttributes.temperature_reservehot: None, | ||
DeviceAttributes.temperature_reservewarm: None, | ||
DeviceAttributes.time_reservefinish: None, | ||
DeviceAttributes.time_reservework: None, | ||
DeviceAttributes.time_reservewarm: None, | ||
DeviceAttributes.code_id: None | ||
} | ||
|
||
# @property | ||
# def modes(self): | ||
# return MideaF1Device._modes | ||
|
||
# @property | ||
# def fan_speeds(self): | ||
# return list(MideaF1Device._speeds.values()) | ||
|
||
# @property | ||
# def water_level_sets(self): | ||
# return MideaF1Device._water_level_sets | ||
|
||
def build_query(self): | ||
return [ | ||
MessageQuery(self._device_protocol_version) | ||
] | ||
|
||
def process_message(self, msg): | ||
message = MessageF1Response(msg) | ||
_LOGGER.debug(f"[{self.device_id}] Received: {message}") | ||
new_status = {} | ||
for status in self._attributes.keys(): | ||
if hasattr(message, status.value): | ||
self._attributes[status] = getattr(message, status.value) | ||
new_status[status.value] = getattr(message, status.value) | ||
return new_status | ||
|
||
def make_message_set(self): | ||
message = MessageSet(self._device_protocol_version) | ||
message.mode = self._attributes[DeviceAttributes.mode] | ||
message.error_code = self._attributes[DeviceAttributes.error_code] | ||
message.response_type = self._attributes[DeviceAttributes.response_type] | ||
message.work_status = self._attributes[DeviceAttributes.work_status] | ||
message.step_status = self._attributes[DeviceAttributes.step_status] | ||
message.work_step = self._attributes[DeviceAttributes.work_step] | ||
message.cup_capstatus = self._attributes[DeviceAttributes.cup_capstatus] | ||
message.cup_bodystatus = self._attributes[DeviceAttributes.cup_bodystatus] | ||
message.curworktime = self._attributes[DeviceAttributes.curworktime] | ||
message.curtemperature = self._attributes[DeviceAttributes.curtemperature] | ||
message.curwork_speed = self._attributes[DeviceAttributes.curwork_speed] | ||
message.temperature_reservehot = self._attributes[DeviceAttributes.temperature_reservehot] | ||
message.temperature_reservewarm = self._attributes[DeviceAttributes.temperature_reservewarm] | ||
message.time_reservefinish = self._attributes[DeviceAttributes.time_reservefinish] | ||
message.time_reservework = self._attributes[DeviceAttributes.time_reservework] | ||
message.time_reservewarm = self._attributes[DeviceAttributes.time_reservewarm] | ||
message.code_id = self._attributes[DeviceAttributes.code_id] | ||
|
||
return message | ||
|
||
|
||
def set_attribute(self, attr, value): | ||
# if attr == DeviceAttributes.prompt_tone: | ||
# self._attributes[DeviceAttributes.prompt_tone] = value | ||
# self.update_all({DeviceAttributes.prompt_tone.value: value}) | ||
# else: | ||
# message = self.make_message_set() | ||
# if attr == DeviceAttributes.mode: | ||
# if value in MideaF1Device._modes: | ||
# message.mode = MideaF1Device._modes.index(value) + 1 | ||
# elif attr == DeviceAttributes.fan_speed: | ||
# if value in MideaF1Device._speeds.values(): | ||
# message.fan_speed = list(MideaF1Device._speeds.keys())[ | ||
# list(MideaF1Device._speeds.values()).index(value) | ||
# ] | ||
# elif attr == DeviceAttributes.water_level_set: | ||
# if value in MideaF1Device._water_level_sets: | ||
# message.water_level_set = int(value) | ||
# else: | ||
message = self.make_message_set() | ||
|
||
setattr(message, str(attr), value) | ||
self.build_send(message) | ||
|
||
@property | ||
def attributes(self): | ||
return super().attributes | ||
|
||
|
||
class MideaAppliance(MideaF1Device): | ||
pass |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use _LOGGER.debug instead of print.