feat: update device mapping for T0x24. Fix #82

This commit is contained in:
sususweet
2026-01-07 20:53:05 +08:00
parent 06ee534873
commit 77b3af3168
6 changed files with 110 additions and 8 deletions

View File

@@ -22,6 +22,7 @@ Get devices from MSmartHome/Midea Meiju homes through the network and control th
- T0x15 Water Heater
- T0x17 Laundry Machine
- T0x21 Central Air Conditioning Gateway
- T0x24 Electric Oven
- T0x26 Bath Heater
- T0x3D Water Heater
- T0x9B Steam oven

View File

@@ -22,6 +22,7 @@
- T0x15 养生壶
- T0x17 智能晾衣架
- T0x21 中央空调网关
- T0x24 电压力锅
- T0x26 浴霸
- T0x3D 电热水瓶
- T0x9B 蒸烤箱

View File

@@ -414,13 +414,13 @@ class MiedaDevice(threading.Thread):
await self._build_send(query_cmd)
def _parse_cloud_message(self, status):
def _parse_cloud_message(self, status, update=True):
# MideaLogger.debug(f"Received: {decrypted}")
new_status = {}
for single in status.keys():
value = status.get(single)
if single not in self._attributes or self._attributes[single] != value:
self._attributes[single] = value
# self._attributes[single] = value
new_status[single] = value
if len(new_status) > 0:
for c in self._calculate_get:
@@ -450,10 +450,11 @@ class MiedaDevice(threading.Thread):
f"Calculation Error: {lvalue} = {rvalue}, calculate_str1: {calculate_str1}, calculate_str2: {calculate_str2}",
self._device_id
)
if update:
self._update_all(new_status)
return ParseMessageResult.SUCCESS
def _parse_message(self, msg):
def _parse_message(self, msg, update=True):
if self._protocol == 3:
messages, self._buffer = self._security.decode_8370(self._buffer + msg)
else:
@@ -507,6 +508,7 @@ class MiedaDevice(threading.Thread):
MideaLogger.warning(
f"Calculation Error: {lvalue} = {rvalue}", self._device_id
)
if update:
self._update_all(new_status)
return ParseMessageResult.SUCCESS
@@ -514,7 +516,7 @@ class MiedaDevice(threading.Thread):
if reply := await self._cloud.send_cloud(self._device_id, data):
if reply_dec := self._lua_runtime.decode_status(dec_string_to_bytes(reply).hex()):
MideaLogger.debug(f"Decoded: {reply_dec}")
result = self._parse_cloud_message(reply_dec)
result = self._parse_cloud_message(reply_dec, update=False)
if result == ParseMessageResult.ERROR:
MideaLogger.debug(f"Message 'ERROR' received")
elif result == ParseMessageResult.SUCCESS:

View File

@@ -0,0 +1,62 @@
from homeassistant.const import Platform, UnitOfTemperature, PRECISION_HALVES
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": ["temperature", "fire_level", "set_work_time_sec", "sub_type", "childLock_flag", "control_mode"],
"entities": {
Platform.NUMBER: {
"temperature": {
"min": 25,
"max": 100,
"step": 1,
},
"fire_level": {
"min": 0,
"max": 100,
"step": 1,
},
"set_work_time_sec": {
"min": 60,
"max": 3600 * 3,
"step": 60,
},
},
Platform.SELECT: {
"work_switch": {
"options": {
"cancel": {"work_switch": "cancel"},
"schedule": {"work_switch": "schedule"},
"work": {"work_switch": "work"},
"pause": {"work_switch": "pause"},
"power_off": {"work_switch": "power_off"},
"power_on": {"work_switch": "power_on"}
}
},
},
Platform.SENSOR: {
"work_status": {
"device_class": SensorDeviceClass.ENUM,
},
"cur_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT,
"precision": PRECISION_HALVES
},
"cur_fire_level": {
"device_class": SensorDeviceClass.ENUM,
},
"cur_step": {
"device_class": SensorDeviceClass.ENUM,
},
"total_step": {
"device_class": SensorDeviceClass.ENUM,
},
}
}
}
}

View File

@@ -420,6 +420,9 @@
}
},
"select": {
"work_switch": {
"name": "Work Switch"
},
"heat_start": {
"name": "Boil Water",
"state": {
@@ -1052,6 +1055,15 @@
}
},
"sensor": {
"cur_fire_level": {
"name": "Current Fire Level"
},
"cur_step": {
"name": "Current Step"
},
"total_step": {
"name": "Total Step"
},
"deep_filter_percent": {
"name": "Filter Life Remaining"
},
@@ -2076,6 +2088,12 @@
}
},
"number": {
"fire_level": {
"name": "Fire Level"
},
"set_work_time_sec": {
"name": "Set Work Time(sec)"
},
"custom_timing": {
"name": "Light Off Timer"
},

View File

@@ -420,6 +420,9 @@
}
},
"select": {
"work_switch": {
"name": "工作开关"
},
"heat_start": {
"name": "烧水",
"state": {
@@ -1229,6 +1232,15 @@
}
},
"sensor": {
"cur_fire_level": {
"name": "当前火力等级"
},
"cur_step": {
"name": "当前步骤"
},
"total_step": {
"name": "总步骤"
},
"deep_filter_percent": {
"name": "滤芯寿命"
},
@@ -2311,6 +2323,12 @@
}
},
"number": {
"fire_level": {
"name": "火焰等级"
},
"set_work_time_sec": {
"name": "设置工作时间(秒)"
},
"lightness": {
"name": "照明亮度"
},