From 21b29f1a51872439032d83a634a5d50350fdaf87 Mon Sep 17 00:00:00 2001 From: Cyborg2017 Date: Thu, 5 Feb 2026 10:50:52 +0800 Subject: [PATCH 1/2] feat: Add wind swing angle controls and prevent super cool switch for AC devices --- .../midea_auto_cloud/device_mapping/T0xAC.py | 66 ++++++++++++++++++- .../midea_auto_cloud/translations/en.json | 14 +++- .../translations/zh-Hans.json | 14 +++- 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/custom_components/midea_auto_cloud/device_mapping/T0xAC.py b/custom_components/midea_auto_cloud/device_mapping/T0xAC.py index e7e67a0..8e6780e 100644 --- a/custom_components/midea_auto_cloud/device_mapping/T0xAC.py +++ b/custom_components/midea_auto_cloud/device_mapping/T0xAC.py @@ -1128,7 +1128,8 @@ DEVICE_MAPPING = { }, ("22012369", "22040023", "22270043"): { "rationale": ["off", "on"], - "queries": [{}, {"query_type": "prevent_straight_wind"}], + "queries": [{}, {"query_type": "prevent_straight_wind"}, {"query_type": "prevent_super_cool"}, + {"query_type": "wind_swing_ud_angle"}, {"query_type": "wind_swing_lr_angle"}], "centralized": ["buzzer"], "calculate":{ "get": [ @@ -1183,10 +1184,33 @@ DEVICE_MAPPING = { "precision": PRECISION_HALVES, } }, + Platform.SELECT: { + "wind_swing_ud_angle": { + "options": { + "关闭": {"wind_swing_ud_angle": 0}, + "最上": {"wind_swing_ud_angle": 1}, + "偏上": {"wind_swing_ud_angle": 25}, + "中间": {"wind_swing_ud_angle": 50}, + "偏下": {"wind_swing_ud_angle": 75}, + "最下": {"wind_swing_ud_angle": 100} + } + }, + "wind_swing_lr_angle": { + "options": { + "关闭": {"wind_swing_lr_angle": 0}, + "最左": {"wind_swing_lr_angle": 1}, + "偏左": {"wind_swing_lr_angle": 25}, + "中间": {"wind_swing_lr_angle": 50}, + "偏右": {"wind_swing_lr_angle": 75}, + "最右": {"wind_swing_lr_angle": 100} + } + } + }, Platform.SWITCH: { "buzzer": { "device_class": SwitchDeviceClass.SWITCH, "default_value": "on", + "translation_key": "voice" }, "screen_display": { "device_class": SwitchDeviceClass.SWITCH, @@ -1196,6 +1220,9 @@ DEVICE_MAPPING = { "device_class": SwitchDeviceClass.SWITCH, "rationale": [1, 2] }, + "prevent_super_cool": { + "device_class": SwitchDeviceClass.SWITCH, + }, "dry": { "device_class": SwitchDeviceClass.SWITCH, }, @@ -1223,7 +1250,8 @@ DEVICE_MAPPING = { }, "22251077": { "rationale": ["off", "on"], - "queries": [{}, {"query_type": "prevent_straight_wind"}], + "queries": [{}, {"query_type": "no_wind_sense"}, {"query_type": "prevent_super_cool"}, + {"query_type": "wind_swing_ud_angle"}, {"query_type": "wind_swing_lr_angle"}], "centralized": ["buzzer"], "calculate":{ "get": [ @@ -1278,15 +1306,49 @@ DEVICE_MAPPING = { "precision": PRECISION_HALVES, } }, + Platform.SELECT: { + "wind_swing_ud_angle": { + "options": { + "关闭": {"wind_swing_ud_angle": 0}, + "最上": {"wind_swing_ud_angle": 1}, + "偏上": {"wind_swing_ud_angle": 25}, + "中间": {"wind_swing_ud_angle": 50}, + "偏下": {"wind_swing_ud_angle": 75}, + "最下": {"wind_swing_ud_angle": 100} + } + }, + "wind_swing_lr_angle": { + "options": { + "关闭": {"wind_swing_lr_angle": 0}, + "最左": {"wind_swing_lr_angle": 1}, + "偏左": {"wind_swing_lr_angle": 25}, + "中间": {"wind_swing_lr_angle": 50}, + "偏右": {"wind_swing_lr_angle": 75}, + "最右": {"wind_swing_lr_angle": 100} + } + }, + "no_wind_sense": { + "options": { + "关闭": {"no_wind_sense": 0}, + "上+下无风感": {"no_wind_sense": 1}, + "上无风感": {"no_wind_sense": 2}, + "下无风感": {"no_wind_sense": 3}, + } + } + }, Platform.SWITCH: { "buzzer": { "device_class": SwitchDeviceClass.SWITCH, "default_value": "on", + "translation_key": "voice" }, "screen_display": { "device_class": SwitchDeviceClass.SWITCH, "translation_key": "screen_close", }, + "prevent_super_cool": { + "device_class": SwitchDeviceClass.SWITCH, + }, "dry": { "device_class": SwitchDeviceClass.SWITCH, }, diff --git a/custom_components/midea_auto_cloud/translations/en.json b/custom_components/midea_auto_cloud/translations/en.json index f282e38..d576d91 100644 --- a/custom_components/midea_auto_cloud/translations/en.json +++ b/custom_components/midea_auto_cloud/translations/en.json @@ -442,6 +442,15 @@ } }, "select": { + "no_wind_sense": { + "name": "No Wind Sense" + }, + "wind_swing_ud_angle": { + "name": "Vertical Wind Direction" + }, + "wind_swing_lr_angle": { + "name": "Horizontal Wind Direction" + }, "custom_temperature": { "name": "Custom Temperature" }, @@ -2358,7 +2367,10 @@ "name": "Fan" } }, - "switch": { + "switch": { + "prevent_super_cool": { + "name": "Prevent Super Cool" + }, "new_wind_machine": { "name": "Fresh air switch" }, diff --git a/custom_components/midea_auto_cloud/translations/zh-Hans.json b/custom_components/midea_auto_cloud/translations/zh-Hans.json index 11c5701..625f2c6 100644 --- a/custom_components/midea_auto_cloud/translations/zh-Hans.json +++ b/custom_components/midea_auto_cloud/translations/zh-Hans.json @@ -462,6 +462,15 @@ } }, "select": { + "no_wind_sense": { + "name": "无风感" + }, + "wind_swing_ud_angle": { + "name": "上下摆动风向" + }, + "wind_swing_lr_angle": { + "name": "左右摆动风向" + }, "custom_temperature": { "name": "自定义烧水温度" }, @@ -2689,7 +2698,10 @@ } } }, - "switch": { + "switch": { + "prevent_super_cool": { + "name": "智控温" + }, "new_wind_machine": { "name": "新风开关" }, From cfabc390f318445ba829c7672405500d0b53b321 Mon Sep 17 00:00:00 2001 From: "yangsiyuan.rengar" Date: Fri, 6 Feb 2026 14:51:49 +0800 Subject: [PATCH 2/2] fix: write lua files with utf-8 encoding,the env as below:haos 17.0,core 2026.1.3 --- custom_components/midea_auto_cloud/__init__.py | 4 ++-- custom_components/midea_auto_cloud/core/cloud.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/midea_auto_cloud/__init__.py b/custom_components/midea_auto_cloud/__init__.py index 26b7ac2..3f671c3 100644 --- a/custom_components/midea_auto_cloud/__init__.py +++ b/custom_components/midea_auto_cloud/__init__.py @@ -172,7 +172,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType): from .const import BIT_LUA bit_lua = base64.b64decode(BIT_LUA.encode("utf-8")).decode("utf-8") try: - with open(bit, "wt") as fp: + with open(bit, "wt", encoding="utf-8") as fp: fp.write(bit_lua) except PermissionError as e: MideaLogger.error(f"Failed to create bit.lua at {bit}: {e}") @@ -180,7 +180,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType): import tempfile temp_dir = tempfile.gettempdir() bit = os.path.join(temp_dir, "bit.lua") - with open(bit, "wt") as fp: + with open(bit, "wt", encoding="utf-8") as fp: fp.write(bit_lua) MideaLogger.warning(f"Using temporary file for bit.lua: {bit}") diff --git a/custom_components/midea_auto_cloud/core/cloud.py b/custom_components/midea_auto_cloud/core/cloud.py index ef1f9cf..6d7c10f 100644 --- a/custom_components/midea_auto_cloud/core/cloud.py +++ b/custom_components/midea_auto_cloud/core/cloud.py @@ -492,7 +492,7 @@ class MeijuCloud(MideaCloud): self._security.aes_decrypt_with_fixed_key(lua)) stream = stream.replace("\r\n", "\n") fnm = f"{path}/{response['fileName']}" - async with aiofiles.open(fnm, "w") as fp: + async with aiofiles.open(fnm, "w", encoding="utf-8") as fp: await fp.write(stream) return fnm @@ -744,7 +744,7 @@ class MSmartHomeCloud(MideaCloud): self._security.aes_decrypt_with_fixed_key(lua)) stream = stream.replace("\r\n", "\n") fnm = f"{path}/{response['fileName']}" - async with aiofiles.open(fnm, "w") as fp: + async with aiofiles.open(fnm, "w", encoding="utf-8") as fp: await fp.write(stream) return fnm