Skip to content

Commit

Permalink
added 2 new switch for C3
Browse files Browse the repository at this point in the history
  • Loading branch information
georgezhao2010 committed Oct 6, 2023
1 parent dad4d0f commit 448410e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
14 changes: 14 additions & 0 deletions custom_components/midea_ac_lan/midea/devices/c3/device.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging
from .message import (
MessageQuery,
MessageSetSilent,
MessageSetECO,
MessageC3Response,
MessageSet
)
Expand Down Expand Up @@ -50,6 +52,8 @@ class DeviceAttributes(StrEnum):
total_energy_consumption = "total_energy_consumption"
total_produced_energy = "total_produced_energy"
outdoor_temperature = "outdoor_temperature"
silent_mode = "silent_mode"
eco_mode = "eco_mode"


class MideaC3Device(MiedaDevice):
Expand Down Expand Up @@ -90,6 +94,8 @@ def __init__(
DeviceAttributes.zone2_room_temp_mode: False,
DeviceAttributes.zone1_water_temp_mode: False,
DeviceAttributes.zone2_water_temp_mode: False,
DeviceAttributes.silent_mode: False,
DeviceAttributes.eco_mode: False,
DeviceAttributes.mode: 1,
DeviceAttributes.mode_auto: 1,
DeviceAttributes.zone_target_temp: [25, 25],
Expand Down Expand Up @@ -196,6 +202,7 @@ def make_message_set(self):
return message

def set_attribute(self, attr, value):
message= None
if attr in [
DeviceAttributes.zone1_power,
DeviceAttributes.zone2_power,
Expand All @@ -208,6 +215,13 @@ def set_attribute(self, attr, value):
]:
message = self.make_message_set()
setattr(message, str(attr), value)
elif attr == DeviceAttributes.eco_mode:
message = MessageSetECO(self._protocol_version)
setattr(message, str(attr), value)
elif attr == DeviceAttributes.silent_mode:
message = MessageSetSilent(self._protocol_version)
setattr(message, str(attr), value)
if message is not None:
self.build_send(message)

def set_mode(self, zone, mode):
Expand Down
42 changes: 42 additions & 0 deletions custom_components/midea_ac_lan/midea/devices/c3/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,46 @@ def _body(self):
])


class MessageSetSilent(MessageC3Base):
def __init__(self, protocol_version):
super().__init__(
protocol_version=protocol_version,
message_type=MessageType.set,
body_type=0x05)
self.silent_mode = False
self.super_silent = False

@property
def _body(self):
silent_mode = 0x01 if self.silent_mode else 0
super_silent = 0x02 if self.super_silent else 0

return bytearray([
silent_mode | super_silent,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
])


class MessageSetECO(MessageC3Base):
def __init__(self, protocol_version):
super().__init__(
protocol_version=protocol_version,
message_type=MessageType.set,
body_type=0x07)
self.eco_mode = False

@property
def _body(self):
eco_mode = 0x01 if self.eco_mode else 0

return bytearray([
eco_mode,
0x00, 0x00, 0x00, 0x00,
0x00
])


class C3MessageBody(MessageBody):
def __init__(self, body, data_offset=0):
super().__init__(body)
Expand All @@ -87,6 +127,8 @@ def __init__(self, body, data_offset=0):
body[data_offset + 1] & 0x10 > 0,
body[data_offset + 1] & 0x20 > 0
]
self.silent_mode = body[data_offset + 2] & 0x02 > 0
self.eco_mode = body[data_offset + 2] & 0x08 > 0
self.mode = body[data_offset + 3]
self.mode_auto = body[data_offset + 4]
self.zone_target_temp = [
Expand Down
10 changes: 10 additions & 0 deletions custom_components/midea_ac_lan/midea_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,11 +921,21 @@
"name": "DHW Power",
"icon": "mdi:power"
},
C3Attributes.eco_mode: {
"type": Platform.SWITCH,
"name": "ECO Mode",
"icon": "mdi:leaf-circle"
},
C3Attributes.fast_dhw: {
"type": Platform.SWITCH,
"name": "Fast DHW",
"icon": "mdi:rotate-orbit"
},
C3Attributes.silent_mode:{
"type": Platform.SWITCH,
"name": "Silent Mode",
"icon": "mdi:fan-remove"
},
C3Attributes.zone1_curve: {
"type": Platform.SWITCH,
"name": "Zone1 Curve",
Expand Down

0 comments on commit 448410e

Please sign in to comment.