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
This commit is contained in:
Setsuna
2025-10-16 00:27:04 +08:00
parent 224d6b0bbc
commit 80e646637a
6 changed files with 219 additions and 6 deletions

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
@@ -100,10 +101,16 @@ async def load_device_config(hass: HomeAssistant, device_type, sn8):
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:
json_data = mapping_module.DEVICE_MAPPING["default"]
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
else:
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}")