diff --git a/README.md b/README.md index 11deffa..cc6279b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/README_hans.md b/README_hans.md index b1b835e..74adc02 100644 --- a/README_hans.md +++ b/README_hans.md @@ -22,6 +22,7 @@ - T0x15 养生壶 - T0x17 智能晾衣架 - T0x21 中央空调网关 +- T0x24 电压力锅 - T0x26 浴霸 - T0x3D 电热水瓶 - T0x9B 蒸烤箱 diff --git a/custom_components/midea_auto_cloud/core/device.py b/custom_components/midea_auto_cloud/core/device.py index 9e10c81..c8239aa 100644 --- a/custom_components/midea_auto_cloud/core/device.py +++ b/custom_components/midea_auto_cloud/core/device.py @@ -297,8 +297,8 @@ class MiedaDevice(threading.Thread): await self._build_send(set_cmd) return except Exception as e: - MideaLogger.debug(f"LuaRuntimeError in set_attributes {nested_status}: {repr(e)}") - traceback.print_exc() + MideaLogger.debug(f"LuaRuntimeError in set_attributes {nested_status}: {repr(e)}") + traceback.print_exc() cloud = self._cloud if cloud and hasattr(cloud, "send_device_control"): @@ -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 ) - self._update_all(new_status) + 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,14 +508,15 @@ class MiedaDevice(threading.Thread): MideaLogger.warning( f"Calculation Error: {lvalue} = {rvalue}", self._device_id ) - self._update_all(new_status) + if update: + self._update_all(new_status) return ParseMessageResult.SUCCESS async def _send_message(self, data): 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: diff --git a/custom_components/midea_auto_cloud/device_mapping/T0x24.py b/custom_components/midea_auto_cloud/device_mapping/T0x24.py new file mode 100644 index 0000000..c3b1b1b --- /dev/null +++ b/custom_components/midea_auto_cloud/device_mapping/T0x24.py @@ -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, + }, + } + } + } +} diff --git a/custom_components/midea_auto_cloud/translations/en.json b/custom_components/midea_auto_cloud/translations/en.json index e37a2c1..be971f4 100644 --- a/custom_components/midea_auto_cloud/translations/en.json +++ b/custom_components/midea_auto_cloud/translations/en.json @@ -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" }, diff --git a/custom_components/midea_auto_cloud/translations/zh-Hans.json b/custom_components/midea_auto_cloud/translations/zh-Hans.json index 962440d..497fb67 100644 --- a/custom_components/midea_auto_cloud/translations/zh-Hans.json +++ b/custom_components/midea_auto_cloud/translations/zh-Hans.json @@ -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": "照明亮度" },