5 Commits

Author SHA1 Message Date
sususweet
087c5db497 feat: add device support for T0xFB. 2025-10-22 16:01:20 +08:00
sususweet
7327ee3433 feat: update readme. 2025-10-21 16:01:48 +08:00
sususweet
47df52654a Merge pull request #32 from asakiasako/feature/add-colmo-turing-central-AC
feat: Add COLMO Turing Central AC
2025-10-20 09:57:30 +08:00
Setsuna
b2bf61f85c readability optimization 2025-10-18 23:30:26 +08:00
Setsuna
80e646637a feat: Add COLMO Turing Central AC
1. Add device mapping of multiple Turing ACs in T0xAC.py
2. Necessary changes in load_device_config() to support tuple or re pattern as the device map key
3. Update in climate.py to support target humidity feature
4. Add missing translations and icons
2025-10-16 00:27:04 +08:00
9 changed files with 410 additions and 54 deletions

View File

@@ -1,60 +1,64 @@
# Midea Auto Cloud
[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/hacs/integration)
[![Stable](https://img.shields.io/github/v/release/sususweet/midea-meiju-codec)](https://github.com/sususweet/midea-meiju-codec/releases/latest)
通过网络获取你美居家庭中的设备,并且通过美的云端进行控制。
English | [简体中文](README_zh_CN.md)
- 自动查找和发现设备
- 自动下载设备的协议文件
- 将设备状态更新为设备可见的属性
Get devices from MSmartHome/Midea Meiju homes through the network and control them via Midea's cloud API.
## 版本说明
- Automatically discover and find devices
- Automatically download device protocol files
- Update device status to visible device attributes
- 所有设备默认可生成一个名为Status的二进制传感器其属性中列出了设备可访问的所有属性当然有些值不可设置
- Status实体前几项列出了该设备的分类信息供参考
## Version Notes
## 目前支持的设备类型
- All devices can generate a binary sensor named "Status" by default, which lists all accessible device attributes in its properties (some values are not settable)
- The first few items of the Status entity list the device classification information for reference
- T0x13 电灯
- T0x21 中央空调网关
- T0x26 浴霸
- T0xA1 除湿机
- T0xAC 空调
- T0xB2 电蒸箱
- T0xB3 消毒碗柜
- T0xB6 抽油烟机
- T0xB7 燃气灶
- T0xB8 智能扫地机器人
- T0xCA 对开门冰箱
- T0xCC 中央空调(风管机)Wi-Fi线控器
- T0xCE 新风机
- T0xCF 中央空调暖家
- T0xD9 复式洗衣机
- T0xDB 滚筒洗衣机
- T0xDC 干衣机
- T0xE1 洗碗机
- T0xE2 电热水器
- T0xE3 恒温式燃气热水器
- T0xEA 电饭锅
- T0xED 软水机
- T0xFA 电风扇
- T0xFD 加湿器
## Currently Supported Device Types
欢迎合作开发添加更多设备支持。
- T0x13 Electric Light
- T0x21 Central Air Conditioning Gateway
- T0x26 Bath Heater
- T0xA1 Dehumidifier
- T0xAC Air Conditioner
- T0xB2 Electric Steamer
- T0xB3 Disinfection Cabinet
- T0xB6 Range Hood
- T0xB7 Gas Stove
- T0xB8 Smart Robot Vacuum
- T0xCA French Door Refrigerator
- T0xCC Central Air Conditioning (Ducted) Wi-Fi Controller
- T0xCE Fresh Air System
- T0xCF Central Air Conditioning Heating
- T0xD9 Twin Tub Washing Machine
- T0xDB Front Load Washing Machine
- T0xDC Clothes Dryer
- T0xE1 Dishwasher
- T0xE2 Electric Water Heater
- T0xE3 Constant Temperature Gas Water Heater
- T0xEA Rice Cooker
- T0xED Water Softener
- T0xFA Electric Fan
- T0xFB Electric Heater
- T0xFD Humidifier
合作开发方法:添加本插件后,找到未能正确识别的设备,点击对应设备`传感器`分类下的`连通性`
Welcome to collaborate on adding support for more devices.
Collaboration method: After adding this plugin, find devices that are not correctly identified, click on `Connectivity` under the `Sensor` category of the corresponding device:
![img.png](./img/img.png)
展开下面的`属性`卡片把里面这些字段随issue提交。 着重关注Device type、Subtype这两个字段这是后续获得设备控制对应lua文件的基础。
Expand the `Attributes` card below and submit these fields with the issue. Pay special attention to the `Device type` and `Subtype` fields, as these are the basis for obtaining the corresponding lua files for device control.
再进入Homeassistant的安装目录, 在`.storage/midea_auto_cloud/lua/`目录下找到设备对应的T_0000_`Device type`_`Subtype`_***.lua文件等待适配就可以了。
Then go to the Home Assistant installation directory, find the device's corresponding T_0000_`Device type`_`Subtype`_***.lua file in the `.storage/midea_auto_cloud/lua/` directory, and wait for adaptation.
![img_1.png](./img/img_1.png)
## 实体映射
## Entity Mapping
映射文件位于`device_mapping`, 每个大的品类一个映射文件,目前支持映射的实体类型如下:
Mapping files are located under `device_mapping`, with one mapping file for each major category. Currently supported entity types for mapping are:
- sensor
- binary_sensor
- switch
@@ -63,8 +67,8 @@
- fan
- water_heater
示例配置`22012227`演示了如何将设备属性映射成以上各种HomeAssistant中的实体。
The example configuration `22012227` demonstrates how to map device attributes to various Home Assistant entities above.
## 致谢
## Acknowledgments
感谢[midea-meiju-codec](https://github.com/MattedBroadSky/midea-meiju-codec)项目提供的先验知识。
Thanks to the [midea-meiju-codec](https://github.com/MattedBroadSky/midea-meiju-codec) project for providing prior knowledge.

74
README_zh_CN.md Normal file
View File

@@ -0,0 +1,74 @@
# Midea Auto Cloud
[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/hacs/integration)
[![Stable](https://img.shields.io/github/v/release/sususweet/midea-meiju-codec)](https://github.com/sususweet/midea-meiju-codec/releases/latest)
[English](README.md) | 简体中文
通过网络获取 MSmartHome/美的美居 家庭中的设备并且通过美的云端API进行控制。
- 自动查找和发现设备
- 自动下载设备的协议文件
- 将设备状态更新为设备可见的属性
## 版本说明
- 所有设备默认可生成一个名为Status的二进制传感器其属性中列出了设备可访问的所有属性当然有些值不可设置
- Status实体前几项列出了该设备的分类信息供参考
## 目前支持的设备类型
- T0x13 电灯
- T0x21 中央空调网关
- T0x26 浴霸
- T0xA1 除湿机
- T0xAC 空调
- T0xB2 电蒸箱
- T0xB3 消毒碗柜
- T0xB6 抽油烟机
- T0xB7 燃气灶
- T0xB8 智能扫地机器人
- T0xCA 对开门冰箱
- T0xCC 中央空调(风管机)Wi-Fi线控器
- T0xCE 新风机
- T0xCF 中央空调暖家
- T0xD9 复式洗衣机
- T0xDB 滚筒洗衣机
- T0xDC 干衣机
- T0xE1 洗碗机
- T0xE2 电热水器
- T0xE3 恒温式燃气热水器
- T0xEA 电饭锅
- T0xED 软水机
- T0xFA 电风扇
- T0xFB 电暖器
- T0xFD 加湿器
欢迎合作开发添加更多设备支持。
合作开发方法:添加本插件后,找到未能正确识别的设备,点击对应设备`传感器`分类下的`连通性`
![img.png](./img/img.png)
展开下面的`属性`卡片把里面这些字段随issue提交。 着重关注Device type、Subtype这两个字段这是后续获得设备控制对应lua文件的基础。
再进入Homeassistant的安装目录`.storage/midea_auto_cloud/lua/`目录下找到设备对应的T_0000_`Device type`_`Subtype`_***.lua文件等待适配就可以了。
![img_1.png](./img/img_1.png)
## 实体映射
映射文件位于`device_mapping`下, 每个大的品类一个映射文件,目前支持映射的实体类型如下:
- sensor
- binary_sensor
- switch
- select
- climate
- fan
- water_heater
示例配置`22012227`演示了如何将设备属性映射成以上各种HomeAssistant中的实体。
## 致谢
感谢[midea-meiju-codec](https://github.com/MattedBroadSky/midea-meiju-codec)项目提供的先验知识。

View File

@@ -1,6 +1,7 @@
import os
import base64
from importlib import import_module
import re
from homeassistant.config_entries import ConfigEntry
from homeassistant.util.json import load_json
@@ -96,14 +97,20 @@ async def load_device_config(hass: HomeAssistant, device_type, sn8):
# # 如果像映射体(包含 entities/centralized 等关键字段),直接使用
# if any(k in raw for k in ["entities", "centralized", "queries", "manufacturer"]):
# json_data = raw
if not json_data:
# if not json_data:
device_path = f".device_mapping.{'T0x%02X' % device_type}"
try:
mapping_module = import_module(device_path, __package__)
if sn8 in mapping_module.DEVICE_MAPPING.keys():
json_data = mapping_module.DEVICE_MAPPING[sn8]
elif "default" in mapping_module.DEVICE_MAPPING:
for key, config in mapping_module.DEVICE_MAPPING.items():
# support tuple & regular expression pattern to support multiple sn8 sharing one mapping
if (key == sn8) or (isinstance(key, tuple) and sn8 in key) or (isinstance(key, str) and re.match(key, sn8)):
json_data = config
break
if not json_data:
if "default" in mapping_module.DEVICE_MAPPING:
json_data = mapping_module.DEVICE_MAPPING["default"]
else:
MideaLogger.warning(f"No mapping found for sn8 {sn8} in type {'T0x%02X' % device_type}")
except ModuleNotFoundError:
MideaLogger.warning(f"Can't load mapping file for type {'T0x%02X' % device_type}")

View File

@@ -79,6 +79,10 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
self._key_max_temp = self._config.get("max_temp")
self._key_current_temperature = self._config.get("current_temperature")
self._key_target_temperature = self._config.get("target_temperature")
self._key_min_humidity = self._config.get("min_humidity")
self._key_max_humidity = self._config.get("max_humidity")
self._key_current_humidity = self._config.get("current_humidity")
self._key_target_humidity = self._config.get("target_humidity")
self._attr_temperature_unit = self._config.get("temperature_unit")
self._attr_precision = self._config.get("precision")
@@ -89,6 +93,8 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
features |= ClimateEntityFeature.TURN_OFF
if self._key_target_temperature is not None:
features |= ClimateEntityFeature.TARGET_TEMPERATURE
if self._key_target_humidity is not None:
features |= ClimateEntityFeature.TARGET_HUMIDITY
if self._key_preset_modes is not None:
features |= ClimateEntityFeature.PRESET_MODE
# if self._key_aux_heat is not None:
@@ -137,6 +143,28 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
return None
return None
@property
def current_humidity(self) -> float | None:
"""Return the current humidity."""
humidity = self._get_nested_value(self._key_current_humidity)
if humidity is not None:
try:
return float(humidity)
except (ValueError, TypeError):
return None
return None
@property
def target_humidity(self) -> float | None:
"""Return the humidity we try to reach."""
humidity = self._get_nested_value(self._key_target_humidity)
if humidity is not None:
try:
return float(humidity)
except (ValueError, TypeError):
return None
return None
@property
def min_temp(self):
if isinstance(self._key_min_temp, str):
@@ -151,6 +179,20 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
else:
return float(self._key_max_temp)
@property
def min_humidity(self):
if isinstance(self._key_min_humidity, str):
return float(self.device_attributes.get(self._key_min_humidity, 45))
else:
return float(self._key_min_humidity)
@property
def max_humidity(self):
if isinstance(self._key_max_humidity, str):
return float(self.device_attributes.get(self._key_max_humidity, 65))
else:
return float(self._key_max_humidity)
@property
def target_temperature_low(self):
return self.min_temp
@@ -159,6 +201,14 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
def target_temperature_high(self):
return self.max_temp
@property
def target_humidity_low(self):
return self.min_humidity
@property
def target_humidity_high(self):
return self.max_humidity
@property
def preset_modes(self):
return list(self._key_preset_modes.keys())
@@ -253,6 +303,13 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
new_status[self._key_target_temperature] = temperature
await self.async_set_attributes(new_status)
async def async_set_humidity(self, humidity: int):
if self._key_target_humidity is None:
return
new_status = {}
new_status[self._key_target_humidity] = int(humidity)
await self.async_set_attributes(new_status)
async def async_set_fan_mode(self, fan_mode: str):
if self._is_central_ac:
fan_speed = self._key_fan_modes.get(fan_mode)

View File

@@ -267,5 +267,86 @@ DEVICE_MAPPING = {
},
}
}
},
# Colmo Turing Central AC indoor units, different cooling capacity models share the same config.
("22396961", "22396963", "22396965", "22396969", "22396973"): {
"rationale": ["off", "on"],
"queries": [{}, {"query_type":"run_status"}],
"centralized": [],
"entities": {
Platform.CLIMATE: {
"thermostat": {
"translation_key": "colmo_turing_central_ac_climate",
"power": "power",
"hvac_modes": {
"off": {"power": "off"},
"heat": {"power": "on", "mode": "heat"},
"cool": {"power": "on", "mode": "cool"},
"fan_only": {"power": "on", "mode": "fan"},
"dry": {"power": "on", "mode": "dryauto"},
"auto": {"power": "on", "mode": "dryconstant"},
# Note:
# For Colmo Turing AC, dry and auto mode is not displayed in the app/controller explicitly.
# Instead it defined 2 custom modes: dryauto (自动抽湿) and dryconstant (温湿灵控/恒温恒湿).
# So I mapped the custom modes to the similar pre-defineds:
# - auto -> dryconstant (温湿灵控/恒温恒湿): able to set target T and H, and auto adjust them to maintain a comfortable environment.
# - dry -> dryauto (自动抽湿): dehumidification mode, under which temperature is not adjustable.
# Translations are also modified (for only colmo_turing_central_ac_climate) accordingly.
},
"preset_modes": {
"none": {
"energy_save": "off",
},
"sleep": {"energy_save": "on"}
},
"fan_modes": {
"silent": {"wind_speed": 20},
"low": {"wind_speed": 40},
"medium": {"wind_speed": 60},
"high": {"wind_speed": 80},
"full": {"wind_speed": 100},
"auto": {"wind_speed": 102}
},
"target_temperature": ["temperature", "small_temperature"],
"current_temperature": "indoor_temperature",
"target_humidity": "dehumidity",
"current_humidity": "indoor_humidity",
"pre_mode": "mode",
"aux_heat": "ptc",
"min_temp": 16,
"max_temp": 30,
"min_humidity": 45,
"max_humidity": 65,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_HALVES,
}
},
Platform.SENSOR: {
"mode": {
"device_class": SensorDeviceClass.ENUM,
},
"indoor_temperature": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
},
"indoor_humidity": {
"device_class": SensorDeviceClass.HUMIDITY,
"unit_of_measurement": "%",
"state_class": SensorStateClass.MEASUREMENT
},
"wind_speed_real": {
"device_class": SensorDeviceClass.WIND_SPEED,
"unit_of_measurement": "%",
"state_class": SensorStateClass.MEASUREMENT
}
},
Platform.SWITCH: {
"power": {
"name": "电源",
"device_class": SwitchDeviceClass.SWITCH,
},
},
}
}
}

View File

@@ -0,0 +1,53 @@
from homeassistant.const import Platform, UnitOfTemperature, UnitOfVolume, UnitOfTime, PERCENTAGE, PRECISION_HALVES, \
UnitOfEnergy, UnitOfPower
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [],
"entities": {
Platform.SWITCH: {
"lock": {
"device_class": SwitchDeviceClass.SWITCH,
},
"screen_close": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.CLIMATE: {
"electric_heater": {
"power": "power",
"hvac_modes": {
"off": {"power": "off"},
"heat": {"power": "on"}
},
"target_temperature": "temperature",
"current_temperature": "cur_temperature",
"min_temp": 5,
"max_temp": 35,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_HALVES,
}
},
Platform.SELECT: {
"gear": {
"options": {
"low": {"gear": 1},
"high": {"gear": 3}
}
}
},
Platform.SENSOR: {
"power_statistics": {
"device_class": SensorDeviceClass.POWER,
"unit_of_measurement": UnitOfPower.WATT,
"state_class": SensorStateClass.MEASUREMENT
}
}
}
}
}

View File

@@ -0,0 +1,26 @@
{
"entity": {
"climate": {
"thermostat": {
"state_attributes": {
"fan_mode": {
"state": {
"silent": "mdi:weather-night",
"full": "mdi:fan"
}
}
}
},
"colmo_turing_central_ac_climate": {
"state_attributes": {
"fan_mode": {
"state": {
"silent": "mdi:weather-night",
"full": "mdi:fan"
}
}
}
}
}
}
}

View File

@@ -336,10 +336,32 @@
"name": "Storage Zone"
},
"thermostat": {
"name": "Thermostat"
"name": "Thermostat",
"state_attributes": {
"fan_mode": {
"state": {
"silent": "Silent",
"full": "Full"
}
}
}
},
"colmo_turing_central_ac_climate": {
"name": "Thermostat",
"state_attributes": {
"fan_mode": {
"state": {
"silent": "Silent",
"full": "Full"
}
}
}
},
"water_heater": {
"name": "Water Heater"
},
"electric_heater": {
"name": "Electric Heater"
}
},
"humidifier": {
@@ -1511,6 +1533,9 @@
}
},
"switch": {
"screen_close": {
"name": "Screen Close"
},
"anion": {
"name": "Anion"
},

View File

@@ -336,10 +336,36 @@
"name": "冷藏区"
},
"thermostat": {
"name": "温控器"
"name": "温控器",
"state_attributes": {
"fan_mode": {
"state": {
"silent": "静音",
"full": "强劲"
}
}
}
},
"colmo_turing_central_ac_climate": {
"name": "温控器",
"state_attributes": {
"fan_mode": {
"state": {
"silent": "静音",
"full": "强劲"
}
}
},
"state": {
"auto": "温湿灵控",
"dry": "自动抽湿"
}
},
"water_heater": {
"name": "热水器"
},
"electric_heater": {
"name": "取暖器"
}
},
"humidifier": {
@@ -1511,6 +1537,9 @@
}
},
"switch": {
"screen_close": {
"name": "屏幕关闭"
},
"anion": {
"name": "负离子"
},