From e85e83a68127fe59f5b2c03f888d376d348118af Mon Sep 17 00:00:00 2001 From: sususweet Date: Thu, 8 Jan 2026 16:46:47 +0800 Subject: [PATCH] feat: update device mapping for T0xE7. Fix #89 --- .../midea_auto_cloud/device_mapping/T0xE7.py | 50 +++++++++++++++---- .../midea_auto_cloud/translations/en.json | 16 +++++- .../translations/zh-Hans.json | 18 +++++-- 3 files changed, 69 insertions(+), 15 deletions(-) diff --git a/custom_components/midea_auto_cloud/device_mapping/T0xE7.py b/custom_components/midea_auto_cloud/device_mapping/T0xE7.py index f31d793..2e5199c 100644 --- a/custom_components/midea_auto_cloud/device_mapping/T0xE7.py +++ b/custom_components/midea_auto_cloud/device_mapping/T0xE7.py @@ -1,4 +1,4 @@ -from homeassistant.const import Platform, UnitOfTemperature, PRECISION_HALVES +from homeassistant.const import Platform, UnitOfTemperature, PRECISION_HALVES, UnitOfTime from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass DEVICE_MAPPING = { @@ -6,6 +6,19 @@ DEVICE_MAPPING = { "rationale": ["off", "on"], "queries": [{}], "centralized": [], + "calculate": { + "get": [ + { + "lvalue": "[time_running]", + "rvalue": "[time_running_hr] * 60 + [time_running_min]" + }, + { + "lvalue": "[time_surplus]", + "rvalue": "[time_surplus_hr] * 60 + [time_surplus_min]" + }, + ], + "set": [] + }, "entities": { Platform.NUMBER: { "temperature": { @@ -13,18 +26,31 @@ DEVICE_MAPPING = { "max": 100, "step": 1, }, - "fire_level": { - "min": 120, - "max": 2200, + "definite_time_hr": { + "min": 0, + "max": 3, "step": 1, }, - "set_work_time": { + "definite_time_min": { "min": 1, - "max": 180, + "max": 59, "step": 1, }, }, Platform.SELECT: { + "fire_level": { + "options": { + "120W": {"fire_level": "1"}, + "300W": {"fire_level": "2"}, + "500W": {"fire_level": "3"}, + "800W": {"fire_level": "4"}, + "1200W": {"fire_level": "5"}, + "1400W": {"fire_level": "6"}, + "1600W": {"fire_level": "7"}, + "1800W": {"fire_level": "8"}, + "2200W": {"fire_level": "9"}, + } + }, "work_status": { "options": { "standby": {"work_status": "0"}, @@ -38,11 +64,15 @@ DEVICE_MAPPING = { }, }, Platform.SENSOR: { - "work_mode": { - "device_class": SensorDeviceClass.ENUM, + "time_surplus": { + "device_class": SensorDeviceClass.DURATION, + "unit_of_measurement": UnitOfTime.MINUTES, + "state_class": SensorStateClass.MEASUREMENT }, - "work_stage": { - "device_class": SensorDeviceClass.ENUM, + "time_running": { + "device_class": SensorDeviceClass.DURATION, + "unit_of_measurement": UnitOfTime.MINUTES, + "state_class": SensorStateClass.MEASUREMENT }, } } diff --git a/custom_components/midea_auto_cloud/translations/en.json b/custom_components/midea_auto_cloud/translations/en.json index be971f4..0e9c6c4 100644 --- a/custom_components/midea_auto_cloud/translations/en.json +++ b/custom_components/midea_auto_cloud/translations/en.json @@ -420,6 +420,9 @@ } }, "select": { + "fire_level": { + "name": "Fire Level" + }, "work_switch": { "name": "Work Switch" }, @@ -1055,6 +1058,12 @@ } }, "sensor": { + "time_surplus": { + "name": "Surplus Time" + }, + "time_running": { + "name": "Running Time" + }, "cur_fire_level": { "name": "Current Fire Level" }, @@ -2088,8 +2097,11 @@ } }, "number": { - "fire_level": { - "name": "Fire Level" + "definite_time_hr": { + "name": "Definite Time(hr)" + }, + "definite_time_min": { + "name": "Definite Time(min)" }, "set_work_time_sec": { "name": "Set Work Time(sec)" diff --git a/custom_components/midea_auto_cloud/translations/zh-Hans.json b/custom_components/midea_auto_cloud/translations/zh-Hans.json index 497fb67..74e6958 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": { + "fire_level": { + "name": "火焰等级" + }, "work_switch": { "name": "工作开关" }, @@ -1012,7 +1015,7 @@ "auto_clean_pause": "清扫暂停", "auto_clean_continue": "继续清扫", "stop": "停止", - "work": "清扫" + "work": "工作" } }, "fan_level": { @@ -1232,6 +1235,12 @@ } }, "sensor": { + "time_surplus": { + "name": "剩余时间" + }, + "time_running": { + "name": "运行时间" + }, "cur_fire_level": { "name": "当前火力等级" }, @@ -2323,8 +2332,11 @@ } }, "number": { - "fire_level": { - "name": "火焰等级" + "definite_time_hr": { + "name": "设定时间(小时)" + }, + "definite_time_min": { + "name": "设定时间(分钟)" }, "set_work_time_sec": { "name": "设置工作时间(秒)"