39 Commits

Author SHA1 Message Date
sususweet
6166ebf4f7 feat: version 0.1.16 2025-10-31 23:25:56 +08:00
sususweet
39cc28b4dd fix: lua base library location error. 2025-10-31 23:21:39 +08:00
sususweet
e4b939780f feat: update support for device T0x15. 2025-10-31 23:01:09 +08:00
Yingqi Tang
c12e95f2a1 Fix duplicate import of 'os' in lua_runtime.py
Removed duplicate import of 'os' in lua_runtime.py
2025-10-31 22:56:07 +08:00
Yingqi Tang
6129248fed Merge pull request #41 from happyhaha1/master
feat(lua): enhance runtime environment with resilient module loading
2025-10-31 22:54:17 +08:00
Yingqi Tang
3b2d817dd6 Merge branch 'master' into master 2025-10-31 22:54:04 +08:00
sususweet
e9f8f95826 feat: add support for device T0x15. 2025-10-31 22:47:43 +08:00
sususweet
7a28c62ac5 fix: fix lua library error. 2025-10-31 22:46:52 +08:00
sususweet
f2735fd729 feat: add new entity include button and number. 2025-10-31 22:46:29 +08:00
happyhaha1
05e30ab414 feat(lua): enhance runtime environment with resilient module loading
Introduce robust Lua module deployment strategy that ensures proper library
availability across different system configurations. The implementation now
prioritizes Home Assistant's configuration directory for persistent storage,
with automatic failover to temporary locations when permission restrictions
occur. Additionally, the runtime now validates module dependencies during
initialization and provides clear diagnostic warnings for any loading failures.
2025-10-31 10:44:42 +08:00
Yingqi Tang
af6f2d1789 Update README.md 2025-10-28 22:58:02 +08:00
sususweet
665763bb22 feat: update readme 2025-10-28 22:53:26 +08:00
sususweet
aa553cd3a8 feat: version v0.1.14 2025-10-28 22:47:39 +08:00
sususweet
7ee22880ab feat: add support for T0xFA. 2025-10-28 22:44:58 +08:00
sususweet
e941dfc547 Merge remote-tracking branch 'origin/master' 2025-10-28 22:04:45 +08:00
sususweet
059cf3aebf feat: add device support for T0xAC(106J6363). 2025-10-28 22:04:27 +08:00
Yingqi Tang
48fac5ec42 Refactor device mapping for default configuration. 2025-10-28 16:16:40 +08:00
sususweet
c503b14d33 feat: add device support for T0x3D. 2025-10-27 23:05:30 +08:00
sususweet
171d76ee3e feat: add device support for T0x21 switch. 2025-10-27 22:38:12 +08:00
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
sususweet
224d6b0bbc feat: fix device support for T0x13. 2025-10-14 20:37:39 +08:00
sususweet
341796a8d4 feat: fix device support for T0x13. 2025-10-14 20:36:27 +08:00
sususweet
57b5cf811c Merge remote-tracking branch 'origin/master' 2025-10-14 20:30:07 +08:00
sususweet
187c46168c feat: add device support for T0x13. 2025-10-14 20:29:35 +08:00
sususweet
6491570e70 Merge pull request #30 from zy900906/master
传感器增加running_status
2025-10-13 23:10:07 +08:00
zy900906
a5d40b7d65 Update en.json
sensor,running_status
2025-10-13 12:47:47 +08:00
zy900906
d8c298f608 Update zh-Hans.json
sensor,running_status
2025-10-13 12:46:49 +08:00
zy900906
85c51c2090 Update T0xDC.py
running_status
2025-10-13 12:44:20 +08:00
sususweet
b1e42526f6 feat: add device for central air conditioner gateway(T0x21). 2025-10-12 12:53:13 +08:00
sususweet
b87729d016 fix: resolve error when lua file is none 2025-10-11 23:52:54 +08:00
sususweet
1172f66a17 feat: version 0.1.10 2025-10-11 20:53:03 +08:00
sususweet
1ddfa9f020 feat: update device mapping for T0xB6. Fix #26. 2025-10-11 20:44:33 +08:00
sususweet
160957abb8 feat: update translation 2025-10-11 14:59:16 +08:00
sususweet
69098292f0 feat: update contribution doc. 2025-10-11 14:21:11 +08:00
sususweet
b3e9a11394 fix: humidifier entity control mapping. 2025-10-11 11:48:42 +08:00
37 changed files with 2150 additions and 354 deletions

1
.gitignore vendored
View File

@@ -153,6 +153,7 @@ cython_debug/
.idea
decrypt_lua.py
test.py
*.lua

123
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,123 @@
# 贡献指南
感谢您考虑为我们的项目做出贡献!您的努力将使我们的项目变得更好。
在您开始贡献之前,请花一点时间阅读以下准则:
## 我可以如何贡献?
### 报告问题
如果您在项目中遇到错误,请在 GitHub 上[报告问题](https://github.com/sususweet/midea_auto_cloud/issues/new/),并提供关于错误的详细信息,包括复现步骤、 debug 级日志以及错误出现的时间。
集成开启 debug 级日志的[方法](https://www.home-assistant.io/integrations/logger/#log-filters)
```
# configuration.yaml 设置打印日志等级
logger:
default: critical
logs:
custom_components.xiaomi_home: debug
```
### 建议增强功能
如果您有增强或新功能的想法,欢迎您在 GitHub 讨论区[创建想法](https://github.com/sususweet/midea_auto_cloud/discussions/new?category=ideas) 。我们期待您的建议!
### 贡献代码
1. Fork 该仓库并从 `master` 创建您的分支。
2. 确保您的代码符合项目的编码规范。
3. 确保您的提交消息描述清晰。
4. 提交请求应附有明确的问题描述和解决方案。
5. 如果必要,请更新文档。
6. 请运行测试并确保测试通过。
## 适配设备
要适配本项目中暂未包含的设备,可以按照以下步骤进行:
1. 在Homeassistant中安装本插件安装完成后登录自己的账号可以看到自己名下的设备。
2. 在集成中找到需要适配的设备,点击设备的相关字段进入详情页面,如下图:
![img_2.png](./img/img_2.png)
3. 点击传感器中的`连通性`,可以看到该设备可以被读取和访问的状态,如下图:
![img_3.png](./img/img_3.png)
着重关注Device type、Subtype这两个字段这是后续获得设备控制对应lua文件的基础。
4. 进入Homeassistant的安装目录`.storage/midea_auto_cloud/lua/`目录下找到T_0000_`Device type`_`Subtype`_***.lua文件例如上面干衣机设备的lua文件是 T_0000_DC_12852_2021121701.lua。
5. 可用人工分析或者AI分析的方法解析lua文件结合美的官方APP的控制界面提取出需要控制的设备属性把修改合并到`device_mapping`中对应设备`Device type`的py文件中。
6. `device_mapping`中设备映射文件的编写方法可参考之前编写过的,`default`是默认的映射可以作为参考默认改这个就可以。如果自己设备的映射跟通用的差别太大目前发现有空调、新风系统设备类型都是T0xAC但可控制的变量差别比较大可以根据设备的sn8来新建字段。
7. 完成上述步骤,编写好`device_mapping`中对应设备的py文件即可在自己的机器上测试测试好后就可以提pr。
## 拉取请求准则
在提交拉取请求之前,请确保满足以下要求:
- 您的拉取请求解决了单个问题或功能。
- 您已在本地测试过您的更改。
- 您的代码遵循项目的代码规范。
- 所有现有测试都通过,并且如果适用,您已添加了新的测试。
- 任何依赖更改都有文档说明。
## 代码规范
本项目的代码格式遵循 [Google Style](https://google.github.io/styleguide/pyguide.html) 。请确保您的贡献符合该指南。
## Commit Message 格式
```
<type>: <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```
type :有以下几种变更类型
- feat新增功能。
- fix修复问题。
- docs仅仅修改了文档。
- style仅仅是对格式进行修改如逗号、缩进、空格等不改变代码逻辑。
- refactor代码重构没有新增功能或修复问题。
- perf优化性能。
- test增加或修改测试用例。
- chore修改编译流程或变更依赖库和工具等。
- revert版本回滚。
subject :简洁的标题,描述本次提交的概要。使用祈使句、现在时态,首字母小写,结尾不加句号。
body :描述本次提交的详细内容,解释为什么需要这些变更。除 docs 之外的变更类型必须包含 body。
footer :(可选)关联的 issue 或 pull request 编号。
## 命名规范
### 第三方平台命名规范
- 描述“Home Assistant”时必须使用“Home Assistant”变量可以使用“hass”或“hass_xxx”。
### 其它命名规范
- 文档中的中文语句包含英文时,如果英文没有被中文引号括起来,那么中文与英文之间必须有一个空格。(最好代码注释也这么写)
## 许可
在为本项目做出贡献时,您同意您的贡献遵循本项目的[许可证](../LICENSE.md) 。
当您第一次提交拉取请求时GitHub Action 会提示您签署贡献者许可协议Contributor License AgreementCLA。只有签署了 CLA ,本项目才会合入您的拉取请求。
## 获取帮助
如果您需要帮助或有疑问,可在 GitHub 的[讨论区](https://github.com/sususweet/midea_auto_cloud/discussions/)询问。
您还可以联系 sususweetcandy@qq.com

View File

@@ -1,55 +1,66 @@
# Midea Auto Cloud
[![Stable](https://img.shields.io/github/v/release/sususweet/midea-meiju-codec)](https://github.com/sususweet/midea-meiju-codec/releases/latest)
通过网络获取你美居家庭中的设备,并且通过美的云端进行控制。
[![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_hans.md)
## 版本说明
Get devices from MSmartHome/Midea Meiju homes through the network and control them via Midea's cloud API.
- 所有设备默认可生成一个名为Status的二进制传感器其属性中列出了设备可访问的所有属性当然有些值不可设置
- Status实体前几项列出了该设备的分类信息供参考
- Automatically discover and find devices
- Automatically download device protocol files
- Update device status to visible device attributes
## 目前支持的设备类型
## Version Notes
- T0x26 浴霸
- T0xA1 除湿机
- T0xAC 空调
- T0xB2 电蒸箱
- T0xB3 消毒碗柜
- T0xB7 燃气灶
- T0xB8 智能扫地机器人
- T0xCA 对开门冰箱
- T0xCC 中央空调(风管机)Wi-Fi线控器
- T0xCE 新风机
- T0xCF 中央空调暖家
- T0xD9 复式洗衣机
- T0xDB 滚筒洗衣机
- T0xDC 干衣机
- T0xE1 洗碗机
- T0xE2 电热水器
- T0xE3 恒温式燃气热水器
- T0xEA 电饭锅
- T0xED 软水机
- T0xFA 电风扇
- T0xFD 加湿器
- 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
欢迎合作开发添加更多设备支持。
## Currently Supported Device Types
合作开发方法:添加本插件后,找到未能正确识别的设备,点击对应设备`传感器`分类下的`连通性`
- T0x13 Electric Light
- T0x15 Water Heater
- T0x21 Central Air Conditioning Gateway
- T0x26 Bath Heater
- T0x3D Water 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
![img.png](img.png)
Welcome to collaborate on adding support for more devices.
展开下面的`属性`卡片把里面这些字段复制给我或随issue提交等待适配就可以了。
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_1.png](img_1.png)
![img.png](./img/img.png)
## 实体映射
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.
映射文件位于`device_mapping`下, 每个大的品类一个映射文件,目前支持映射的实体类型如下:
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
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
@@ -58,8 +69,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.

76
README_hans.md Normal file
View File

@@ -0,0 +1,76 @@
# 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 电灯
- T0x15 养生壶
- T0x21 中央空调网关
- T0x26 浴霸
- T0x3D 电热水瓶
- 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
@@ -55,7 +56,10 @@ PLATFORMS: list[Platform] = [
Platform.SELECT,
Platform.WATER_HEATER,
Platform.FAN,
Platform.HUMIDIFIER
Platform.LIGHT,
Platform.HUMIDIFIER,
Platform.NUMBER,
Platform.BUTTON
]
@@ -95,16 +99,22 @@ 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:
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:
# if not json_data:
device_path = f".device_mapping.{'T0x%02X' % device_type}"
try:
mapping_module = import_module(device_path, __package__)
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"]
except ModuleNotFoundError:
MideaLogger.warning(f"Can't load mapping file for type {'T0x%02X' % device_type}")
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}")
save_data = {sn8: json_data}
# offload save_json as well
@@ -130,20 +140,51 @@ async def update_listener(hass: HomeAssistant, config_entry: ConfigEntry):
async def async_setup(hass: HomeAssistant, config: ConfigType):
hass.data.setdefault(DOMAIN, {})
cjson = os.getcwd() + "/cjson.lua"
bit = os.getcwd() + "/bit.lua"
# if not os.path.exists(cjson):
from .const import CJSON_LUA
cjson_lua = base64.b64decode(CJSON_LUA.encode("utf-8")).decode("utf-8")
with open(cjson, "wt") as fp:
fp.write(cjson_lua)
# if not os.path.exists(bit):
from .const import BIT_LUA
bit_lua = base64.b64decode(BIT_LUA.encode("utf-8")).decode("utf-8")
with open(bit, "wt") as fp:
fp.write(bit_lua)
return True
# 使用Home Assistant配置目录而不是当前工作目录
config_dir = hass.config.path(DOMAIN)
os.makedirs(config_dir, exist_ok=True)
os.makedirs(hass.config.path(STORAGE_PATH), exist_ok=True)
lua_path = hass.config.path(STORAGE_PATH)
cjson = os.path.join(lua_path, "cjson.lua")
bit = os.path.join(lua_path, "bit.lua")
# 只有文件不存在时才创建
if not os.path.exists(cjson):
from .const import CJSON_LUA
cjson_lua = base64.b64decode(CJSON_LUA.encode("utf-8")).decode("utf-8")
try:
with open(cjson, "wt") as fp:
fp.write(cjson_lua)
except PermissionError as e:
MideaLogger.error(f"Failed to create cjson.lua at {cjson}: {e}")
# 如果无法创建文件,尝试使用临时目录
import tempfile
temp_dir = tempfile.gettempdir()
cjson = os.path.join(temp_dir, "cjson.lua")
with open(cjson, "wt") as fp:
fp.write(cjson_lua)
MideaLogger.warning(f"Using temporary file for cjson.lua: {cjson}")
if not os.path.exists(bit):
from .const import BIT_LUA
bit_lua = base64.b64decode(BIT_LUA.encode("utf-8")).decode("utf-8")
try:
with open(bit, "wt") as fp:
fp.write(bit_lua)
except PermissionError as e:
MideaLogger.error(f"Failed to create bit.lua at {bit}: {e}")
# 如果无法创建文件,尝试使用临时目录
import tempfile
temp_dir = tempfile.gettempdir()
bit = os.path.join(temp_dir, "bit.lua")
with open(bit, "wt") as fp:
fp.write(bit_lua)
MideaLogger.warning(f"Using temporary file for bit.lua: {bit}")
return True
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
device_type = config_entry.data.get(CONF_TYPE)

View File

@@ -0,0 +1,99 @@
from homeassistant.components.button import ButtonEntity
from homeassistant.const import Platform
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from .core.logger import MideaLogger
from .midea_entity import MideaEntity
from . import load_device_config
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up button entities for Midea devices."""
account_bucket = hass.data.get(DOMAIN, {}).get("accounts", {}).get(config_entry.entry_id)
if not account_bucket:
async_add_entities([])
return
device_list = account_bucket.get("device_list", {})
coordinator_map = account_bucket.get("coordinator_map", {})
devs = []
for device_id, info in device_list.items():
device_type = info.get("type")
sn8 = info.get("sn8")
config = await load_device_config(hass, device_type, sn8) or {}
entities_cfg = (config.get("entities") or {}).get(Platform.BUTTON, {})
manufacturer = config.get("manufacturer")
rationale = config.get("rationale")
coordinator = coordinator_map.get(device_id)
device = coordinator.device if coordinator else None
for entity_key, ecfg in entities_cfg.items():
devs.append(MideaButtonEntity(
coordinator, device, manufacturer, rationale, entity_key, ecfg
))
async_add_entities(devs)
class MideaButtonEntity(MideaEntity, ButtonEntity):
"""Midea button entity."""
def __init__(self, coordinator, device, manufacturer, rationale, entity_key, config):
super().__init__(
coordinator,
device.device_id,
device.device_name,
f"T0x{device.device_type:02X}",
device.sn,
device.sn8,
device.model,
entity_key,
device=device,
manufacturer=manufacturer,
rationale=rationale,
config=config,
)
async def async_press(self) -> None:
"""Handle the button press."""
# 从配置中获取要执行的命令或操作
command = self._config.get("command")
attribute = self._config.get("attribute", self._entity_key)
value = self._config.get("value")
# 判断是否为中央空调设备T0x21
is_central_ac = self._device.device_type == 0x21 if self._device else False
if command:
# 如果配置中指定了命令,执行该命令
if isinstance(command, dict):
# 如果是字典,可能需要发送多个属性
await self.async_set_attributes(command)
elif isinstance(command, str):
# 如果是字符串,可能是特殊命令类型
await self._async_execute_command(command)
elif value is not None:
# 如果配置中指定了值,设置该属性值
await self.async_set_attribute(attribute, value)
else:
# 默认行为:如果没有指定命令或值,记录警告
MideaLogger.warning(
f"Button {self._entity_key} has no command or value configured"
)
async def _async_execute_command(self, command: str) -> None:
"""Execute a special command."""
# 这里可以处理特殊的命令类型
# 例如:重启、重置、测试等
if command == "reset" or command == "restart":
# 可以在这里实现重置或重启逻辑
MideaLogger.debug(f"Executing {command} command for button {self._entity_key}")
else:
# 对于其他命令,可以通过 coordinator 发送
await self.coordinator.async_send_command(0, command)

View File

@@ -51,6 +51,9 @@ async def async_setup_entry(
class MideaClimateEntity(MideaEntity, ClimateEntity):
def __init__(self, coordinator, device, manufacturer, rationale, entity_key, config):
# 自动判断是否为中央空调设备T0x21
self._is_central_ac = device.device_type == 0x21
super().__init__(
coordinator,
device.device_id,
@@ -76,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")
@@ -86,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:
@@ -108,23 +117,53 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
@property
def target_temperature(self):
if isinstance(self._key_target_temperature, list):
temp_int = self._get_nested_value(self._key_target_temperature[0])
tem_dec = self._get_nested_value(self._key_target_temperature[1])
if temp_int is not None and tem_dec is not None:
try:
return float(temp_int) + float(tem_dec)
except (ValueError, TypeError):
return None
if self._is_central_ac:
run_mode = self._get_nested_value(self._key_power) or "0"
if run_mode == "2": # 制冷模式
return self._get_nested_value("cool_temp_set")
elif run_mode == "3": # 制热模式
return self._get_nested_value("cool_temp_set")
return None
else:
temp = self._get_nested_value(self._key_target_temperature)
if temp is not None:
try:
return float(temp)
except (ValueError, TypeError):
return None
return None
if isinstance(self._key_target_temperature, list):
temp_int = self._get_nested_value(self._key_target_temperature[0])
tem_dec = self._get_nested_value(self._key_target_temperature[1])
if temp_int is not None and tem_dec is not None:
try:
return float(temp_int) + float(tem_dec)
except (ValueError, TypeError):
return None
return None
else:
temp = self._get_nested_value(self._key_target_temperature)
if temp is not None:
try:
return float(temp)
except (ValueError, TypeError):
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):
@@ -140,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
@@ -148,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())
@@ -166,11 +227,21 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
@property
def swing_modes(self):
return list(self._key_swing_modes.keys())
if self._is_central_ac:
return ["off", "on"]
else:
return list(self._key_swing_modes.keys())
@property
def swing_mode(self):
return self._dict_get_selected(self._key_swing_modes)
if self._is_central_ac:
extflag = self._get_nested_value("extflag") or "0"
# extflag: 4=摇摆, 6=电辅热+摇摆
if extflag in ["4", "6"]:
return "on"
return "off"
else:
return self._dict_get_selected(self._key_swing_modes)
@property
def is_on(self) -> bool:
@@ -204,35 +275,87 @@ class MideaClimateEntity(MideaEntity, ClimateEntity):
if ATTR_TEMPERATURE not in kwargs:
return
temperature = kwargs.get(ATTR_TEMPERATURE)
temp_int, temp_dec = divmod(temperature, 1)
temp_int = int(temp_int)
hvac_mode = kwargs.get(ATTR_HVAC_MODE)
if hvac_mode is not None:
new_status = self._key_hvac_modes.get(hvac_mode)
if self._is_central_ac:
run_mode = self._get_nested_value(self._key_power) or "0"
control = {}
if run_mode == "2": # 制冷模式
control["cooling_temp"] = str(temperature)
elif run_mode == "3": # 制热模式
control["cooling_temp"] = str(temperature)
control["heating_temp"] = str(temperature)
if control:
await self.coordinator.async_send_central_ac_control(control)
else:
new_status = {}
if isinstance(self._key_target_temperature, list):
new_status[self._key_target_temperature[0]] = temp_int
new_status[self._key_target_temperature[1]] = temp_dec
else:
new_status[self._key_target_temperature] = temperature
temp_int, temp_dec = divmod(temperature, 1)
temp_int = int(temp_int)
hvac_mode = kwargs.get(ATTR_HVAC_MODE)
if hvac_mode is not None:
new_status = self._key_hvac_modes.get(hvac_mode)
else:
new_status = {}
if isinstance(self._key_target_temperature, list):
new_status[self._key_target_temperature[0]] = temp_int
new_status[self._key_target_temperature[1]] = temp_dec
else:
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):
new_status = self._key_fan_modes.get(fan_mode)
await self.async_set_attributes(new_status)
if self._is_central_ac:
fan_speed = self._key_fan_modes.get(fan_mode)
await self.coordinator.async_send_central_ac_control(fan_speed)
else:
new_status = self._key_fan_modes.get(fan_mode)
await self.async_set_attributes(new_status)
async def async_set_preset_mode(self, preset_mode: str):
new_status = self._key_preset_modes.get(preset_mode)
await self.async_set_attributes(new_status)
if self._is_central_ac:
new_status = self._key_preset_modes.get(preset_mode)
await self.coordinator.async_send_central_ac_control(new_status)
else:
new_status = self._key_preset_modes.get(preset_mode)
await self.async_set_attributes(new_status)
async def async_set_hvac_mode(self, hvac_mode: str):
new_status = self._key_hvac_modes.get(hvac_mode)
await self.async_set_attributes(new_status)
if self._is_central_ac:
run_mode = self._key_hvac_modes.get(hvac_mode)
await self.coordinator.async_send_central_ac_control(run_mode)
else:
new_status = self._key_hvac_modes.get(hvac_mode)
await self.async_set_attributes(new_status)
async def async_set_swing_mode(self, swing_mode: str):
new_status = self._key_swing_modes.get(swing_mode)
await self.async_set_attributes(new_status)
if self._is_central_ac:
current_extflag = self._get_nested_value("extflag") or "0"
if swing_mode == "on":
# 开启摆风:如果当前有电辅热(2)则设为6(电辅热+摆风)否则设为4(摆风)
if current_extflag == "2":
new_extflag = "6" # 电辅热+摆风
else:
new_extflag = "4" # 仅摆风
else:
# 关闭摆风如果当前是6(电辅热+摆风)则设为2(仅电辅热)否则设为0(关闭)
if current_extflag == "6":
new_extflag = "2" # 仅电辅热
else:
new_extflag = "0" # 关闭
control = {"extflag": new_extflag}
await self.coordinator.async_send_central_ac_control(control)
else:
new_status = self._key_swing_modes.get(swing_mode)
await self.async_set_attributes(new_status)
async def async_turn_aux_heat_on(self) -> None:
await self._async_set_status_on_off(self._key_aux_heat, True)

View File

@@ -63,7 +63,7 @@ class MideaCloud:
def _make_general_data(self):
return {}
async def _api_request(self, endpoint: str, data: dict, header=None) -> dict | None:
async def _api_request(self, endpoint: str, data: dict, header=None, method="POST") -> dict | None:
header = header or {}
if not data.get("reqId"):
data.update({
@@ -91,15 +91,18 @@ class MideaCloud:
_LOGGER.debug(f"Midea cloud API header: {header}")
_LOGGER.debug(f"Midea cloud API dump_data: {dump_data}")
try:
r = await self._session.request("POST", url, headers=header, data=dump_data, timeout=5)
r = await self._session.request(method, url, headers=header, data=dump_data, timeout=5)
raw = await r.read()
_LOGGER.debug(f"Midea cloud API url: {url}, data: {data}, response: {raw}")
response = json.loads(raw)
except Exception as e:
_LOGGER.debug(f"API request attempt failed: {e}")
if int(response["code"]) == 0 and "data" in response:
return response["data"]
if int(response["code"]) == 0:
if "data" in response:
return response["data"]
else:
return {"message": "ok"}
return None
@@ -198,6 +201,18 @@ class MideaCloud:
async def send_device_control(self, appliance_code: int, control: dict, status: dict | None = None) -> bool:
"""Send control to a device via cloud. Subclasses should implement if supported."""
raise NotImplementedError()
async def send_central_ac_control(self, appliance_code: int, nodeid: str, modelid: str, idtype: int, control: dict) -> bool:
"""Send control to central AC subdevice. Subclasses should implement if supported."""
raise NotImplementedError()
async def get_central_ac_status(self, appliance_codes: list) -> dict | None:
"""Get status of central AC devices. Subclasses should implement if supported."""
raise NotImplementedError()
async def send_switch_control(self, device_id: str, nodeid: str, switch_control: dict) -> bool:
"""Send control to switch device. Subclasses should implement if supported."""
raise NotImplementedError()
class MeijuCloud(MideaCloud):
@@ -223,6 +238,7 @@ class MeijuCloud(MideaCloud):
password=password,
api_url=clouds[cloud_name]["api_url"]
)
self._homegroup_id = None
async def login(self) -> bool:
if login_id := await self._get_login_id():
@@ -275,6 +291,8 @@ class MeijuCloud(MideaCloud):
return None
async def list_appliances(self, home_id) -> dict | None:
# 存储当前使用的 homegroupId 用于后续的中央空调控制
self._homegroup_id = str(home_id)
data = {
"homegroupId": home_id
}
@@ -304,11 +322,11 @@ class MeijuCloud(MideaCloud):
return appliances
return None
async def get_device_status(self, appliance_code: int) -> dict | None:
async def get_device_status(self, appliance_code: int, query: dict) -> dict | None:
data = {
"applianceCode": str(appliance_code),
"command": {
"query": {}
"query": query
}
}
if response := await self._api_request(
@@ -333,6 +351,99 @@ class MeijuCloud(MideaCloud):
data=data
)
return response is not None
async def send_central_ac_control(self, appliance_code: int, nodeid: str, modelid: str, idtype: int, control: dict) -> bool:
"""Send control to central AC subdevice using the special T0x21 API."""
import uuid
import json
# 构建中央空调控制命令
command_data = {
"nodeid": nodeid,
"acattri_ctrl": {
"aclist": [{
"nodeid": nodeid,
"modelid": modelid,
"type": idtype
}],
"event": control
}
}
# 构建完整的请求数据
request_data = {
"applianceCode": str(appliance_code),
"modelId": modelid,
"topic": "/subdevice/multicontrol",
"command": command_data,
"msgId": str(uuid.uuid4()).replace("-", "")
}
request_data_str = json.dumps(request_data).encode("utf-8")
MideaLogger.debug(f"Sending control to central AC device {appliance_code}: {request_data_str}")
# 发送到特殊的中央空调API
if response := await self._api_request(
endpoint="/v1/gateway/transport/send",
data={
'applianceCode': str(appliance_code),
'order': self._security.aes_encrypt(request_data_str).hex(),
'homegroupId': self._homegroup_id,
}
):
if response and response.get('reply'):
reply_data = self._security.aes_decrypt(bytes.fromhex(response['reply']))
MideaLogger.debug(f"[{appliance_code}] Gateway command response: {reply_data}")
return reply_data
else:
MideaLogger.warning(f"[{appliance_code}] Gateway command failed: {response}")
async def get_central_ac_status(self, appliance_codes: list) -> dict | None:
"""Get status of central AC devices using the aggregator API."""
# 构建请求数据
request_data = {
"entities": ["endlist", "tips"],
"appliances": [{"id": str(code), "type": "0x21"} for code in appliance_codes],
}
response = await self._api_request(
endpoint="/api/v1/aggregator/appliances",
data=request_data
)
return response
async def send_switch_control(self, device_id: str, nodeid: str, switch_control: dict) -> bool:
"""Send control to switch device using the controlPanelFour API with PUT method."""
import uuid
# switch_control 格式: {"endPoint": 1, "attribute": 0}
end_point = switch_control.get("endPoint", 1)
attribute = switch_control.get("attribute", 0)
# 构建请求数据
request_data = {
"msgId": str(uuid.uuid4()).replace("-", ""),
"deviceControlList": [{
"endPoint": end_point,
"attribute": attribute
}],
"deviceId": device_id,
"nodeId": nodeid
}
MideaLogger.debug(f"Sending switch control to device {device_id}: {request_data}")
# 使用PUT方法发送到开关控制API
if response := await self._api_request(
endpoint="/v1/appliance/operation/controlPanelFour/" + device_id,
data=request_data,
method="PUT"
):
MideaLogger.debug(f"[{device_id}] Switch control response: {response}")
return True
else:
MideaLogger.warning(f"[{device_id}] Switch control failed: {response}")
return False
async def download_lua(
self, path: str,

View File

@@ -166,14 +166,15 @@ class MiedaDevice(threading.Thread):
# Convert dot-notation attributes to nested structure for transmission
nested_status = self._convert_to_nested_structure(new_status)
try:
if set_cmd := self._lua_runtime.build_control(nested_status, status=self._attributes):
await self._build_send(set_cmd)
return
except Exception as e:
MideaLogger.debug(f"LuaRuntimeError in set_attribute {nested_status}: {repr(e)}")
traceback.print_exc()
if self._lua_runtime is not None:
try:
if set_cmd := self._lua_runtime.build_control(nested_status, status=self._attributes):
await self._build_send(set_cmd)
return
except Exception as e:
MideaLogger.debug(f"LuaRuntimeError in set_attribute {nested_status}: {repr(e)}")
traceback.print_exc()
cloud = self._cloud
if cloud and hasattr(cloud, "send_device_control"):
@@ -193,13 +194,14 @@ class MiedaDevice(threading.Thread):
nested_status = self._convert_to_nested_structure(new_status)
if has_new:
try:
if set_cmd := self._lua_runtime.build_control(nested_status, status=self._attributes):
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()
if self._lua_runtime is not None:
try:
if set_cmd := self._lua_runtime.build_control(nested_status, status=self._attributes):
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()
cloud = self._cloud
if cloud and hasattr(cloud, "send_device_control"):
@@ -267,8 +269,9 @@ class MiedaDevice(threading.Thread):
async def refresh_status(self):
for query in self._queries:
if query_cmd := self._lua_runtime.build_query(query):
await self._build_send(query_cmd)
if self._lua_runtime is not None:
if query_cmd := self._lua_runtime.build_query(query):
await self._build_send(query_cmd)
def _parse_cloud_message(self, decrypted):
# MideaLogger.debug(f"Received: {decrypted}")

View File

@@ -1,5 +1,5 @@
import os
import traceback
import lupa
import threading
import json
@@ -9,6 +9,23 @@ from .logger import MideaLogger
class LuaRuntime:
def __init__(self, file):
self._runtimes = lupa.lua51.LuaRuntime()
# 设置Lua路径包含cjson.lua和bit.lua的目录
lua_dir = os.path.dirname(os.path.abspath(file))
self._runtimes.execute(f'package.path = package.path .. ";{lua_dir}/?.lua"')
# 加载必需的Lua库
try:
self._runtimes.execute('require "cjson"')
except Exception as e:
MideaLogger.warning(f"Failed to load cjson: {e}")
try:
self._runtimes.execute('require "bit"')
except Exception as e:
MideaLogger.warning(f"Failed to load bit: {e}")
# 加载设备特定的Lua文件
string = f'dofile("{file}")'
self._runtimes.execute(string)
self._lock = threading.Lock()

View File

@@ -90,17 +90,11 @@ class MideaDataUpdateCoordinator(DataUpdateCoordinator[MideaDeviceData]):
return self.data
try:
await self.device.refresh_status()
# # 使用传入的 cloud 实例(若可用)
# cloud = self._cloud
# if cloud and hasattr(cloud, "get_device_status"):
# try:
# status = await cloud.get_device_status(self._device_id)
# if isinstance(status, dict) and len(status) > 0:
# for k, v in status.items():
# self.device.attributes[k] = v
# except Exception as e:
# MideaLogger.debug(f"Cloud status fetch failed: {e}")
# 检查是否为中央空调设备T0x21
if self.device.device_type == 0x21:
await self._poll_central_ac_state()
else:
await self.device.refresh_status()
# 返回并推送当前状态
updated = MideaDeviceData(
@@ -117,6 +111,76 @@ class MideaDataUpdateCoordinator(DataUpdateCoordinator[MideaDeviceData]):
available=False,
connected=False,
)
async def _poll_central_ac_state(self) -> None:
"""轮询中央空调状态"""
try:
cloud = self._cloud
if cloud and hasattr(cloud, "get_central_ac_status"):
status_data = await cloud.get_central_ac_status([self._device_id])
if status_data and "appliances" in status_data:
# 找到对应的设备数据并更新到设备属性中
for appliance in status_data["appliances"]:
if appliance.get("type") == "0x21" and "extraData" in appliance:
extra_data = appliance["extraData"]
if "attr" in extra_data:
if "nodeid" in extra_data["attr"]:
self.device._attributes["nodeid"] = extra_data["attr"]["nodeid"]
if "masterId" in extra_data["attr"]:
self.device._attributes["masterId"] = extra_data["attr"]["masterId"]
if "modelid" in extra_data["attr"]:
self.device._attributes["modelid"] = extra_data["attr"]["modelid"]
if "idType" in extra_data["attr"]:
self.device._attributes["idType"] = extra_data["attr"]["idType"]
if "state" in extra_data["attr"] and "condition_attribute" in extra_data["attr"]["state"]:
state = extra_data["attr"]["state"]
condition = state["condition_attribute"]
# 将状态数据更新到设备属性中
for key, value in condition.items():
# 尝试将数字字符串转换为数字
if key.find("temp") > -1:
try:
# 尝试转换为整数
if '.' not in value:
self.device._attributes[key] = int(value)
else:
# 尝试转换为浮点数
self.device._attributes[key] = float(value)
except (ValueError, TypeError):
# 如果转换失败,保持原值
self.device._attributes[key] = value
else:
self.device._attributes[key] = value
if "endlist" in extra_data["attr"]:
endlist = extra_data["attr"]["endlist"]
# endlist是一个数组包含多个endpoint对象
if isinstance(endlist, list):
for endpoint in endlist:
if "event" in endpoint:
event = endpoint["event"]
endpoint_id = endpoint.get("endpoint", 1)
endpoint_name = endpoint.get("name", f"按键{endpoint_id}")
# 为每个endpoint创建独立的状态属性
for key, value in event.items():
# 创建带endpoint标识的属性名
attr_key = f"endpoint_{endpoint_id}_{key}"
attr_name_key = f"endpoint_{endpoint_id}_name"
# 保存endpoint名称
self.device._attributes[attr_name_key] = endpoint_name
self.device._attributes[attr_key] = value
# 同时保持原有的属性名(用于兼容性)
for key, value in event.items():
# 尝试将数字字符串转换为数字
self.device._attributes[key] = value
break
except Exception as e:
MideaLogger.debug(f"Error polling central AC state: {e}")
async def async_set_attribute(self, attribute: str, value) -> None:
"""Set a device attribute."""
@@ -140,4 +204,147 @@ class MideaDataUpdateCoordinator(DataUpdateCoordinator[MideaDeviceData]):
self.device.send_command(cmd_type, cmd_body_bytes)
except ValueError as e:
_LOGGER.error(f"Invalid command body: {e}")
raise
raise
async def async_send_central_ac_control(self, control: dict) -> bool:
"""发送中央空调控制命令"""
try:
cloud = self._cloud
if cloud and hasattr(cloud, "send_central_ac_control"):
# 从设备属性中获取nodeid
masterid = self.device.attributes.get("masterId")
nodeid = self.device.attributes.get("nodeid")
modelid = self.device.attributes.get("modelid")
idtype = int(self.device.attributes.get("idType"))
if not nodeid:
MideaLogger.warning(f"No nodeid found for central AC device {self._device_id}")
return False
# 构建完整的控制命令包含centralized中的所有字段
full_control = self._build_full_central_ac_control(control)
MideaLogger.debug(f"Sending control to {self.device.device_name}: {full_control}")
success = await cloud.send_central_ac_control(
masterid,
nodeid,
modelid,
idtype,
full_control
)
if success:
# 更新本地状态
self.device.attributes.update(control)
self.mute_state_update_for_a_while()
self.async_update_listeners()
return True
else:
MideaLogger.debug(f"Failed to send control to {self.device.device_name}")
return False
else:
MideaLogger.debug("Cloud service not available for central AC control")
return False
except Exception as e:
MideaLogger.debug(f"Error sending control to {self.device.device_name}: {e}")
return False
async def async_send_switch_control(self, control: dict) -> bool:
"""发送开关控制命令subtype为00000000的设备"""
try:
cloud = self._cloud
if cloud and hasattr(cloud, "send_switch_control"):
# 获取设备ID和nodeId
masterid = str(self.device.attributes.get("masterId"))
nodeid = str(self.device.attributes.get("nodeid"))
if not nodeid:
MideaLogger.warning(f"No nodeid found for switch device {self._device_id}")
return False
# 根据控制命令确定endPoint和attribute值
end_point = control.get("endpoint", 1) # 从control中获取endpoint默认1
attribute = 0 # 默认attribute
# 根据control内容设置attribute值
if "run_mode" in control:
if control["run_mode"] == "1":
attribute = 1 # 开启
else:
attribute = 0 # 关闭
# 构建控制数据
switch_control = {
"endPoint": end_point,
"attribute": attribute
}
MideaLogger.debug(f"Sending switch control to {self.device.device_name}: {switch_control}")
success = await cloud.send_switch_control(masterid, nodeid, switch_control)
if success:
# 更新本地状态 - 使用类似poll_central的解析方法
await self._update_switch_status_from_control(control)
self.mute_state_update_for_a_while()
self.async_update_listeners()
return True
else:
MideaLogger.debug(f"Failed to send switch control to {self.device.device_name}")
return False
else:
MideaLogger.debug("Cloud service not available for switch control")
return False
except Exception as e:
MideaLogger.debug(f"Error sending switch control to {self.device.device_name}: {e}")
return False
async def _update_switch_status_from_control(self, control: dict) -> None:
"""根据控制命令更新开关状态参照poll_central的解析方法"""
try:
# 获取endpoint ID
endpoint_id = control.get("endpoint", 1)
run_mode = control.get("run_mode", "0")
# 模拟endlist数据结构来更新状态
# 根据run_mode设置OnOff状态
onoff_value = "1" if run_mode == "1" else "0"
# 更新endpoint特定的状态属性
attr_key = f"endpoint_{endpoint_id}_OnOff"
self.device._attributes[attr_key] = onoff_value
# 同时更新兼容性属性
self.device._attributes["OnOff"] = onoff_value
MideaLogger.debug(f"Updated switch status for endpoint {endpoint_id}: OnOff={onoff_value}")
except Exception as e:
MideaLogger.debug(f"Error updating switch status from control: {e}")
def _build_full_central_ac_control(self, new_control: dict) -> dict:
"""构建完整控制命令"""
full_control = {}
full_control["run_mode"] = self.device.attributes.get("run_mode")
full_control["cooling_temp"] = str(self.device.attributes.get("cool_temp_set") or 26.0)
full_control["heating_temp"] = str(self.device.attributes.get("heat_temp_set") or 20.0)
full_control["fan_speed"] = self.device.attributes.get("fan_speed")
swing_mode = self.device.attributes.get("is_swing")
is_elec_heat = self.device.attributes.get("is_elec_heat")
if swing_mode == "1":
# 开启摆风:如果当前有电辅热(2)则设为6(电辅热+摆风)否则设为4(摆风)
if is_elec_heat == "1":
new_extflag = "6" # 电辅热+摆风
else:
new_extflag = "4" # 仅摆风
else:
# 关闭摆风如果当前是6(电辅热+摆风)则设为2(仅电辅热)否则设为0(关闭)
if is_elec_heat == "1":
new_extflag = "2" # 仅电辅热
else:
new_extflag = "0" # 关闭
full_control["extflag"] = new_extflag
# 然后用新的控制值覆盖
full_control.update(new_control)
return full_control

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,68 @@
from homeassistant.const import Platform
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [],
"entities": {
Platform.LIGHT: {
"light": {
"power": "power",
"brightness": {"brightness": [1, 100]},
"color_temp": {"color_temperature": [3000, 5700]}, # 添加色温配置
"preset_modes": {
"night": {"scene_light": "night"},
"read": {"scene_light": "read"},
"mild": {"scene_light": "mild"},
"life": {"scene_light": "life"},
"film": {"scene_light": "film"},
"manual": {"scene_light": "manual"},
}
}
}
}
},
"M0200015": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [],
"entities": {
Platform.LIGHT: {
"light": {
"power": "led_power",
"brightness": {"brightness": [1, 100]},
"color_temp": {"color_temperature": [2700, 6500]},
"preset_modes": {
"work": {"led_scene_light": "work"},
"eating": {"led_scene_light": "eating"},
"film": {"led_scene_light": "film"},
"night": {"led_scene_light": "night"},
"ledmanual": {"led_scene_light": "ledmanual"},
}
}
},
Platform.FAN: {
"fan": {
"power": "fan_power",
"speeds": [
{"fan_speed": "1"},
{"fan_speed": "2"},
{"fan_speed": "3"},
{"fan_speed": "4"},
{"fan_speed": "5"},
{"fan_speed": "6"},
],
"preset_modes": {
"breathing_wind": {"fan_scene": "breathing_wind"},
"const_temperature": {"fan_scene": "const_temperature"},
"fanmanual": {"fan_scene": "fanmanual"},
"baby_wind": {"fan_scene": "baby_wind"},
"sleep_wind": {"fan_scene": "sleep_wind"},
"forest_wind": {"fan_scene": "forest_wind"}
}
}
}
}
}
}

View File

@@ -0,0 +1,60 @@
from homeassistant.const import Platform, UnitOfTemperature, UnitOfVolume, UnitOfTime, PERCENTAGE, PRECISION_HALVES, \
UnitOfEnergy, UnitOfPower, PRECISION_WHOLE
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": ["warm_target_temp", "boil_target_temp", "meate_select", "max_work_time", "warm_time_min"],
"entities": {
Platform.BINARY_SENSOR: {
"islack_water": {
"device_class": BinarySensorDeviceClass.PROBLEM,
}
},
Platform.NUMBER: {
"warm_time_min": {
"min": 0,
"max": 480,
"step": 60
},
"max_work_time": {
"min": 0,
"max": 12,
"step": 1
},
"warm_target_temp": {
"min": 0,
"max": 100,
"step": 1
},
"boil_target_temp": {
"min": 0,
"max": 100,
"step": 1
},
},
Platform.SELECT: {
"work_mode": {
"options": {
"取消": {"work_mode": "0", "work_switch": "cancel"},
"烧水": {"work_mode": "1", "work_switch": "start"},
"除氯": {"work_mode": "2", "work_switch": "start"},
"花草茶": {"work_mode": "4", "work_switch": "start"},
"养生汤": {"work_mode": "5", "work_switch": "start"},
}
}
},
Platform.SENSOR: {
"current_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
}
}
}
}
}

View File

@@ -0,0 +1,106 @@
from homeassistant.const import Platform, UnitOfTemperature, PRECISION_HALVES
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"00000000": {
"rationale": ["0", "1"],
"queries": [{}],
"centralized": [],
"entities": {
Platform.SWITCH: {
"endpoint_1_OnOff": {
"device_class": SwitchDeviceClass.SWITCH,
"rationale": ['0', '1']
},
"endpoint_2_OnOff": {
"device_class": SwitchDeviceClass.SWITCH,
"rationale": ['0', '1']
}
},
}
},
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": ["run_mode", "fan_speed", "cooling_temp", "heating_temp", "extflag"],
"entities": {
Platform.CLIMATE: {
"thermostat": {
"power": "run_mode",
"hvac_modes": {
"off": {"run_mode": "0"},
"fan_only": {"run_mode": "1"},
"cool": {"run_mode": "2"},
"heat": {"run_mode": "3"},
"auto": {"run_mode": "4"},
"dry": {"run_mode": "5"}
},
"fan_modes": {
"off": {"fan_speed": "0"},
"1": {"fan_speed": "1"},
"2": {"fan_speed": "2"},
"3": {"fan_speed": "3"},
"4": {"fan_speed": "4"},
"5": {"fan_speed": "5"},
"6": {"fan_speed": "6"},
"7": {"fan_speed": "7"},
"auto": {"fan_speed": "8"}
},
"preset_modes": {
"none": {"extflag": "0"},
"electric_heat": {"extflag": "2"},
"swing": {"extflag": "4"},
"electric_heat_swing": {"extflag": "6"}
},
"target_temperature": ["temperature", "small_temperature"],
"current_temperature": "room_temp",
"pre_mode": "mode",
"aux_heat": "ptc",
"min_temp": 17,
"max_temp": 30,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_HALVES,
}
},
Platform.SWITCH: {
"is_lock_heat": {
"device_class": SwitchDeviceClass.SWITCH,
"rationale": ['0', '1']
},
"is_lock_cool": {
"device_class": SwitchDeviceClass.SWITCH,
"rationale": ['0', '1']
},
"fan_speed_lock": {
"device_class": SwitchDeviceClass.SWITCH,
"rationale": ['0', '1']
},
"is_lock_rc": {
"device_class": SwitchDeviceClass.SWITCH,
"rationale": ['0', '1']
},
},
Platform.SENSOR: {
"room_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT,
"precision": PRECISION_HALVES
},
"cool_temp_set": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT,
"precision": PRECISION_HALVES
},
"heat_temp_set": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT,
"precision": PRECISION_HALVES
},
}
}
}
}

View File

@@ -0,0 +1,48 @@
from homeassistant.const import Platform, UnitOfTemperature, UnitOfVolume, UnitOfTime, PERCENTAGE, PRECISION_HALVES, \
UnitOfEnergy, UnitOfPower, PRECISION_WHOLE
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: {
"work_switch": {
"device_class": SwitchDeviceClass.SWITCH,
"rationale": ['cancel', 'work']
}
},
Platform.SELECT: {
"warm_target_temp": {
"options": {
"45℃": {"warm_target_temp": "45"},
"55℃": {"warm_target_temp": "55"},
"65℃": {"warm_target_temp": "65"},
"75℃": {"warm_target_temp": "75"},
"85℃": {"warm_target_temp": "85"}
}
},
"boil_target_temp": {
"options": {
"45℃": {"boil_target_temp": "45"},
"55℃": {"boil_target_temp": "55"},
"65℃": {"boil_target_temp": "65"},
"75℃": {"boil_target_temp": "75"},
"85℃": {"boil_target_temp": "85"}
}
}
},
Platform.SENSOR: {
"cur_temp": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
"state_class": SensorStateClass.MEASUREMENT
}
}
}
}
}

View File

@@ -25,6 +25,7 @@ DEVICE_MAPPING = {
},
"filter_tip": {
"device_class": SwitchDeviceClass.SWITCH,
"rationale": [0, 1]
},
},
Platform.HUMIDIFIER: {

View File

@@ -1,4 +1,4 @@
from homeassistant.const import Platform, UnitOfTemperature, PRECISION_HALVES
from homeassistant.const import Platform, UnitOfTemperature, PRECISION_HALVES, PRECISION_WHOLE
from homeassistant.components.sensor import SensorStateClass, SensorDeviceClass
# from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.components.switch import SwitchDeviceClass
@@ -132,6 +132,32 @@ DEVICE_MAPPING = {
}
}
},
"106J6363": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [],
"entities": {
Platform.CLIMATE: {
"thermostat": {
"power": "water_model_power",
"hvac_modes": {
"off": {"water_model_power": "off"},
"heat": {"water_model_power": "on", "water_model_temperature_auto": "off"},
"auto": {"water_model_power": "on", "water_model_temperature_auto": "on"},
},
"preset_modes": {
"none": {"water_model_go_out": "off"},
"go out": {"water_model_go_out": "on"},
},
"target_temperature": "water_model_temperature_set",
"min_temp": 25,
"max_temp": 60,
"temperature_unit": UnitOfTemperature.CELSIUS,
"precision": PRECISION_WHOLE,
}
},
}
},
"26093139": {
"rationale": [0, 3],
"queries": [{}, {"query_type": "run_status"}],
@@ -267,5 +293,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,34 @@
from homeassistant.const import Platform
from homeassistant.components.switch import SwitchDeviceClass
DEVICE_MAPPING = {
"default": {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [],
"entities": {
Platform.SWITCH: {
"power": {
"device_class": SwitchDeviceClass.SWITCH,
},
"light": {
"device_class": SwitchDeviceClass.SWITCH,
},
"wisdom_wind": {
"device_class": SwitchDeviceClass.SWITCH,
}
},
Platform.SELECT: {
"wind_pressure": {
"options": {
"off": {"wind_pressure": "0"},
"low": {"wind_pressure": "1"},
"medium": {"wind_pressure": "2"},
"high": {"wind_pressure": "3"},
"extreme": {"wind_pressure": "4"},
}
},
},
}
}
}

View File

@@ -133,6 +133,9 @@ DEVICE_MAPPING = {
}
},
Platform.SENSOR: {
"running_status": {
"device_class": SensorDeviceClass.ENUM
},
"appointment_time": {
"device_class": SensorDeviceClass.DURATION,
"unit_of_measurement": UnitOfTime.MINUTES,

View File

@@ -66,30 +66,30 @@ DEVICE_MAPPING = {
Platform.SELECT: {
"mode": {
"options": {
"Rice": {"mode": "essence_rice", "work_status": "cooking"},
"Porridge": {"mode": "gruel", "work_status": "cooking"},
"精华饭": {"mode": "essence_rice", "work_status": "cooking"},
"稀饭": {"mode": "gruel", "work_status": "cooking"},
"热饭": {"mode": "heat_rice", "work_status": "cooking"},
"Congee": {"mode": "boil_congee", "work_status": "cooking"},
"Soup": {"mode": "cook_soup", "work_status": "cooking"},
"Steam": {"mode": "stewing", "work_status": "cooking"},
"煮粥": {"mode": "boil_congee", "work_status": "cooking"},
"煲汤": {"mode": "cook_soup", "work_status": "cooking"},
"蒸煮": {"mode": "stewing", "work_status": "cooking"},
}
},
"rice_type": {
"options": {
"None": {"rice_type": "none"},
"Northeast rice": {"rice_type": "northeast"},
"Long-grain rice": {"rice_type": "longrain"},
"Fragrant rice": {"rice_type": "fragrant"},
"Wuchang rice": {"rice_type": "five"},
"": {"rice_type": "none"},
"东北大米": {"rice_type": "northeast"},
"长粒米": {"rice_type": "longrain"},
"香米": {"rice_type": "fragrant"},
"五常大米": {"rice_type": "five"},
}
},
"work_status": {
"options": {
"Stop": {"work_status": "cancel"},
"Cooking": {"work_status": "cooking"},
"Warming": {"work_status": "keep_warm"},
"Soaking": {"work_status": "awakening_rice"},
"Delay": {"work_status": "schedule"}
"停止": {"work_status": "cancel"},
"烹饪": {"work_status": "cooking"},
"保温": {"work_status": "keep_warm"},
"醒米": {"work_status": "awakening_rice"},
"预约": {"work_status": "schedule"}
}
}
}

View File

@@ -182,12 +182,12 @@ DEVICE_MAPPING = {
"water_consumption_today": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.MEASUREMENT
"state_class": SensorStateClass.TOTAL_INCREASING
},
"water_consumption_average": {
"device_class": SensorDeviceClass.VOLUME,
"unit_of_measurement": UnitOfVolume.LITERS,
"state_class": SensorStateClass.MEASUREMENT
"state_class": SensorStateClass.TOTAL_INCREASING
},
"soft_available_big": {
"device_class": SensorDeviceClass.VOLUME,

View File

@@ -8,34 +8,38 @@ DEVICE_MAPPING = {
"rationale": ["off", "on"],
"queries": [{}],
"centralized": [
"power", "humidify", "swing", "anion", "display_on_off",
"dust_reset", "temp_wind_switch", "filter_reset"
"power", "swing", "display_on_off", "temp_wind_switch",
],
"entities": {
Platform.BINARY_SENSOR: {
"power": {
"device_class": BinarySensorDeviceClass.POWER,
},
"humidify": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
"swing": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
"anion": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
Platform.SWITCH: {
"display_on_off": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
"dust_reset": {
"device_class": BinarySensorDeviceClass.RUNNING,
"device_class": SwitchDeviceClass.SWITCH,
"rationale": ["on", "off"]
},
"temp_wind_switch": {
"device_class": BinarySensorDeviceClass.RUNNING,
"device_class": SwitchDeviceClass.SWITCH,
},
"filter_reset": {
"device_class": BinarySensorDeviceClass.RUNNING,
},
Platform.FAN: {
"fan": {
"power": "power",
"speeds": [
{"gear": "1"},
{"gear": "2"},
{"gear": "3"},
{"gear": "4"},
{"gear": "5"},
{"gear": "6"},
{"gear": "7"},
{"gear": "8"},
{"gear": "9"},
],
"oscillate": "swing",
"preset_modes": {
"normal": {"mode": "normal"},
"sleep": {"mode": "sleep"},
"baby": {"mode": "baby"}
}
}
},
Platform.SELECT: {
@@ -65,16 +69,6 @@ DEVICE_MAPPING = {
"both": {"swing_direction": "both"}
}
},
"scene": {
"options": {
"none": {"scene": "none"},
"auto": {"scene": "auto"},
"sleep": {"scene": "sleep"},
"work": {"scene": "work"},
"study": {"scene": "study"},
"party": {"scene": "party"}
}
},
"sleep_sensor": {
"options": {
"none": {"sleep_sensor": "none"},
@@ -83,27 +77,6 @@ DEVICE_MAPPING = {
"both": {"sleep_sensor": "both"}
}
},
"mode": {
"options": {
"normal": {"mode": "normal"},
"auto": {"mode": "auto"},
"manual": {"mode": "manual"},
"sleep": {"mode": "sleep"},
"turbo": {"mode": "turbo"},
"quiet": {"mode": "quiet"}
}
},
"gear": {
"options": {
"1": {"gear": "1"},
"2": {"gear": "2"},
"3": {"gear": "3"},
"4": {"gear": "4"},
"5": {"gear": "5"},
"6": {"gear": "6"},
"auto": {"gear": "auto"}
}
}
},
Platform.SENSOR: {
"real_gear": {
@@ -120,19 +93,6 @@ DEVICE_MAPPING = {
"unit_of_measurement": UnitOfTime.HOURS,
"state_class": SensorStateClass.MEASUREMENT
},
"battery_status": {
"device_class": SensorDeviceClass.BATTERY,
"state_class": SensorStateClass.MEASUREMENT
},
"battery_level": {
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"error_code": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
},
"temperature_feedback": {
"device_class": SensorDeviceClass.TEMPERATURE,
"unit_of_measurement": UnitOfTemperature.CELSIUS,
@@ -162,10 +122,6 @@ DEVICE_MAPPING = {
"unit_of_measurement": UnitOfTime.MINUTES,
"state_class": SensorStateClass.MEASUREMENT
},
"version": {
"device_class": SensorDeviceClass.ENUM,
"state_class": SensorStateClass.MEASUREMENT
},
"pm25": {
"device_class": SensorDeviceClass.PM25,
"unit_of_measurement": "µg/m³",
@@ -176,22 +132,22 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"lr_diy_down_percent": {
"device_class": SensorDeviceClass.ENUM,
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"lr_diy_up_percent": {
"device_class": SensorDeviceClass.ENUM,
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"ud_diy_down_percent": {
"device_class": SensorDeviceClass.ENUM,
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
},
"ud_diy_up_percent": {
"device_class": SensorDeviceClass.ENUM,
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
}

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

@@ -145,7 +145,7 @@ DEVICE_MAPPING = {
"state_class": SensorStateClass.MEASUREMENT
},
"tank_status": {
"device_class": SensorDeviceClass.POWER_FACTOR,
"device_class": SensorDeviceClass.BATTERY,
"unit_of_measurement": PERCENTAGE,
"state_class": SensorStateClass.MEASUREMENT
}

View File

@@ -62,7 +62,7 @@ class MideaHumidifierEntity(MideaEntity, HumidifierEntity):
config=config,
)
self._attr_supported_features = HumidifierEntityFeature.MODES
self._attr_available_modes = self._config.get("modes").keys()
self._attr_available_modes = list(self._config.get("modes").keys())
@property
def device_class(self):
@@ -124,13 +124,14 @@ class MideaHumidifierEntity(MideaEntity, HumidifierEntity):
"""Turn the humidifier on."""
power_key = self._config.get("power")
if power_key:
await self._device.set_attribute(power_key, True)
await self._device.set_attribute(power_key, self._rationale[int(True)])
async def async_turn_off(self, **kwargs):
"""Turn the humidifier off."""
power_key = self._config.get("power")
if power_key:
await self._device.set_attribute(power_key, False)
await self._device.set_attribute(power_key, self._rationale[int(False)])
await self._device.set_attribute(power_key, self._rationale[int(False)])
async def async_set_humidity(self, humidity: int):
"""Set the target humidity."""

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

@@ -0,0 +1,283 @@
from homeassistant.components.light import LightEntity, LightEntityFeature, ColorMode
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from .core.logger import MideaLogger
from .midea_entity import MideaEntity
from . import load_device_config
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
account_bucket = hass.data.get(DOMAIN, {}).get("accounts", {}).get(config_entry.entry_id)
if not account_bucket:
async_add_entities([])
return
device_list = account_bucket.get("device_list", {})
coordinator_map = account_bucket.get("coordinator_map", {})
devs = []
for device_id, info in device_list.items():
device_type = info.get("type")
sn8 = info.get("sn8")
config = await load_device_config(hass, device_type, sn8) or {}
entities_cfg = (config.get("entities") or {}).get(Platform.LIGHT, {})
manufacturer = config.get("manufacturer")
rationale = config.get("rationale")
coordinator = coordinator_map.get(device_id)
device = coordinator.device if coordinator else None
for entity_key, ecfg in entities_cfg.items():
devs.append(MideaLightEntity(coordinator, device, manufacturer, rationale, entity_key, ecfg))
async_add_entities(devs)
class MideaLightEntity(MideaEntity, LightEntity):
def __init__(self, coordinator, device, manufacturer, rationale, entity_key, config):
super().__init__(
coordinator,
device.device_id,
device.device_name,
f"T0x{device.device_type:02X}",
device.sn,
device.sn8,
device.model,
entity_key,
device=device,
manufacturer=manufacturer,
rationale=rationale,
config=config,
)
self._key_power = self._config.get("power")
self._key_preset_modes = self._config.get("preset_modes")
self._key_brightness = self._config.get("brightness")
self._key_color_temp = self._config.get("color_temp")
self._key_oscillate = self._config.get("oscillate")
self._key_directions = self._config.get("directions")
# 检测亮度配置类型:范围 [min, max] 或嵌套格式 {"brightness": [min, max]}
self._brightness_is_range = False
self._brightness_min = 0
self._brightness_max = 255
self._brightness_key = "brightness" # 默认键名
if self._key_brightness:
if isinstance(self._key_brightness, list) and len(self._key_brightness) == 2:
# 直接范围格式:[min, max]
if isinstance(self._key_brightness[0], (int, float)) and isinstance(self._key_brightness[1], (int, float)):
self._brightness_is_range = True
self._brightness_min = self._key_brightness[0]
self._brightness_max = self._key_brightness[1]
elif isinstance(self._key_brightness, dict):
# 嵌套格式:{"brightness": [min, max]} 或其他键名
for key, value in self._key_brightness.items():
if isinstance(value, list) and len(value) == 2:
if isinstance(value[0], (int, float)) and isinstance(value[1], (int, float)):
self._brightness_is_range = True
self._brightness_min = value[0]
self._brightness_max = value[1]
self._brightness_key = key
break
# 检测色温配置类型:范围 [min_kelvin, max_kelvin] 或嵌套格式 {"color_temp": [min_kelvin, max_kelvin]}
self._color_temp_is_range = False
self._color_temp_min = 2700 # 默认最小色温(暖白)
self._color_temp_max = 6500 # 默认最大色温(冷白)
self._color_temp_key = "color_temp" # 默认键名
if self._key_color_temp:
if isinstance(self._key_color_temp, list) and len(self._key_color_temp) == 2:
# 直接范围格式:[min_kelvin, max_kelvin]
if isinstance(self._key_color_temp[0], (int, float)) and isinstance(self._key_color_temp[1], (int, float)):
self._color_temp_is_range = True
self._color_temp_min = self._key_color_temp[0]
self._color_temp_max = self._key_color_temp[1]
elif isinstance(self._key_color_temp, dict):
# 嵌套格式:{"color_temp": [min_kelvin, max_kelvin]} 或其他键名
for key, value in self._key_color_temp.items():
if isinstance(value, list) and len(value) == 2:
if isinstance(value[0], (int, float)) and isinstance(value[1], (int, float)):
self._color_temp_is_range = True
self._color_temp_min = value[0]
self._color_temp_max = value[1]
self._color_temp_key = key
break
@property
def supported_features(self):
features = LightEntityFeature(0)
if self._key_preset_modes is not None and len(self._key_preset_modes) > 0:
features |= LightEntityFeature.EFFECT
return features
@property
def supported_color_modes(self):
"""返回支持的色彩模式"""
modes = set()
if self._brightness_is_range and self._color_temp_is_range:
# 如果同时支持亮度和色温,优先支持色温模式(更高级的功能)
modes.add(ColorMode.COLOR_TEMP)
elif self._brightness_is_range:
modes.add(ColorMode.BRIGHTNESS)
elif self._color_temp_is_range:
modes.add(ColorMode.COLOR_TEMP)
else:
modes.add(ColorMode.ONOFF)
return modes
@property
def color_mode(self):
"""返回当前色彩模式"""
if self._brightness_is_range and self._color_temp_is_range:
# 如果同时支持亮度和色温优先返回色温模式与supported_color_modes保持一致
return ColorMode.COLOR_TEMP
elif self._brightness_is_range:
return ColorMode.BRIGHTNESS
elif self._color_temp_is_range:
return ColorMode.COLOR_TEMP
return ColorMode.ONOFF
@property
def is_on(self) -> bool:
return self._get_status_on_off(self._key_power)
@property
def effect_list(self):
return list(self._key_preset_modes.keys())
@property
def effect(self):
return self._dict_get_selected(self._key_preset_modes)
@property
def brightness(self):
"""返回0-255范围内的亮度值Home Assistant标准"""
if not self._brightness_is_range:
return None
# 范围模式:从设备属性读取亮度值,使用配置的键名
brightness_value = self._get_nested_value(self._brightness_key)
if brightness_value is not None:
brightness_value = int(brightness_value)
if brightness_value is not None:
# 如果配置是[0, 255]但实际设备范围是1-100需要特殊处理
if self._brightness_min == 0 and self._brightness_max == 255:
# 特殊处理设备1-100范围映射到HA的0-255范围
ha_brightness = round(brightness_value * 2.55) # 1-100 -> 0-255
return max(1, min(255, ha_brightness))
else:
# 正常范围映射
device_range = self._brightness_max - self._brightness_min
if device_range > 0:
ha_brightness = round((brightness_value - self._brightness_min) * 255 / device_range)
return max(1, min(255, ha_brightness))
return None
@property
def color_temp_kelvin(self):
"""返回当前色温值(开尔文)"""
if not self._color_temp_is_range:
return None
# 从设备属性读取色温值1-100范围
color_temp_value = self._get_nested_value(self._color_temp_key)
if color_temp_value is not None:
try:
device_color_temp = int(color_temp_value)
# 将设备的1-100值转换为开尔文值
kelvin_range = self._color_temp_max - self._color_temp_min
if kelvin_range > 0:
# 将1-100范围映射回开尔文范围
ha_color_temp = self._color_temp_min + device_color_temp * kelvin_range / 100
return round(ha_color_temp)
else:
return self._color_temp_min
except (ValueError, TypeError):
return None
return None
@property
def min_color_temp_kelvin(self):
"""返回支持的最小色温值(开尔文)"""
if self._color_temp_is_range:
return self._color_temp_min
return None
@property
def max_color_temp_kelvin(self):
"""返回支持的最大色温值(开尔文)"""
if self._color_temp_is_range:
return self._color_temp_max
return None
async def async_turn_on(
self,
brightness: int | None = None,
brightness_pct: int | None = None,
percentage: int | None = None,
color_temp_kelvin: int | None = None,
effect: str | None = None,
preset_mode: str | None = None,
**kwargs,
):
new_status = {}
if effect is not None and self._key_preset_modes is not None:
effect_config = self._key_preset_modes.get(effect, {})
new_status.update(effect_config)
# 处理亮度设置 - 支持多种参数格式
target_brightness = None
if brightness is not None:
# Home Assistant标准0-255范围
target_brightness = brightness
elif brightness_pct is not None:
# 百分比格式0-100范围转换为0-255
target_brightness = round(brightness_pct * 255 / 100)
elif percentage is not None:
# 兼容旧格式0-100范围转换为0-255
target_brightness = round(percentage * 255 / 100)
if target_brightness is not None and self._key_brightness and self._brightness_is_range:
# 范围模式将Home Assistant的0-255映射到设备范围
# 如果配置是[0, 255]但实际设备范围是1-100需要特殊处理
if self._brightness_min == 0 and self._brightness_max == 255:
# 特殊处理:配置[0,255]但实际设备范围是1-100
device_brightness = round(target_brightness / 2.55) # 0-255 -> 0-100
device_brightness = max(1, min(100, device_brightness)) # 确保在1-100范围内
else:
# 正常范围映射
device_range = self._brightness_max - self._brightness_min
if device_range > 0:
device_brightness = round(self._brightness_min + (target_brightness / 255.0) * device_range)
device_brightness = max(self._brightness_min, min(self._brightness_max, device_brightness))
else:
return
new_status[self._brightness_key] = device_brightness
# 处理色温设置
if color_temp_kelvin is not None and self._color_temp_is_range:
# 确保色温值在配置的范围内
ha_color_temp = max(self._color_temp_min, min(self._color_temp_max, color_temp_kelvin))
# 将开尔文值转换为设备范围1-100
kelvin_range = self._color_temp_max - self._color_temp_min
if kelvin_range > 0:
# 将开尔文值映射到1-100范围
device_color_temp = round((ha_color_temp - self._color_temp_min) * 100 / kelvin_range)
device_color_temp = max(0, min(100, device_color_temp))
else:
device_color_temp = 50 # 默认中间值
new_status[self._color_temp_key] = str(device_color_temp)
await self._async_set_status_on_off(self._key_power, True)
if new_status:
await self.async_set_attributes(new_status)
async def async_turn_off(self):
await self._async_set_status_on_off(self._key_power, False)

View File

@@ -7,5 +7,5 @@
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/sususweet/midea-meiju-codec/issues",
"requirements": ["lupa>=2.0"],
"version": "v0.1.8"
"version": "v0.1.16"
}

View File

@@ -0,0 +1,117 @@
from homeassistant.components.number import NumberEntity
from homeassistant.const import Platform
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from .core.logger import MideaLogger
from .midea_entity import MideaEntity
from . import load_device_config
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up number entities for Midea devices."""
account_bucket = hass.data.get(DOMAIN, {}).get("accounts", {}).get(config_entry.entry_id)
if not account_bucket:
async_add_entities([])
return
device_list = account_bucket.get("device_list", {})
coordinator_map = account_bucket.get("coordinator_map", {})
devs = []
for device_id, info in device_list.items():
device_type = info.get("type")
sn8 = info.get("sn8")
config = await load_device_config(hass, device_type, sn8) or {}
entities_cfg = (config.get("entities") or {}).get(Platform.NUMBER, {})
manufacturer = config.get("manufacturer")
rationale = config.get("rationale")
coordinator = coordinator_map.get(device_id)
device = coordinator.device if coordinator else None
for entity_key, ecfg in entities_cfg.items():
devs.append(MideaNumberEntity(
coordinator, device, manufacturer, rationale, entity_key, ecfg
))
async_add_entities(devs)
class MideaNumberEntity(MideaEntity, NumberEntity):
"""Midea number entity."""
def __init__(self, coordinator, device, manufacturer, rationale, entity_key, config):
super().__init__(
coordinator,
device.device_id,
device.device_name,
f"T0x{device.device_type:02X}",
device.sn,
device.sn8,
device.model,
entity_key,
device=device,
manufacturer=manufacturer,
rationale=rationale,
config=config,
)
# 从配置中读取数值范围,如果没有则使用默认值
self._min_value = self._config.get("min", 0.0)
self._max_value = self._config.get("max", 100.0)
self._step = self._config.get("step", 1.0)
self._mode = self._config.get("mode", "auto") # auto, box, slider
@property
def native_value(self) -> float | None:
"""Return the current value."""
# Use attribute from config if available, otherwise fall back to entity_key
attribute = self._config.get("attribute", self._entity_key)
value = self._get_nested_value(attribute)
if value is None:
return None
# 确保返回的是数值类型
try:
return float(value)
except (ValueError, TypeError):
MideaLogger.warning(
f"Failed to convert value '{value}' to float for number entity {self._entity_key}"
)
return None
@property
def native_min_value(self) -> float:
"""Return the minimum value."""
return float(self._min_value)
@property
def native_max_value(self) -> float:
"""Return the maximum value."""
return float(self._max_value)
@property
def native_step(self) -> float:
"""Return the step value."""
return float(self._step)
@property
def mode(self) -> str:
"""Return the mode of the number entity."""
return self._mode
async def async_set_native_value(self, value: float) -> None:
"""Set the value of the number entity."""
# 确保值在有效范围内
value = max(self._min_value, min(self._max_value, value))
# Use attribute from config if available, otherwise fall back to entity_key
attribute = self._config.get("attribute", self._entity_key)
# 如果配置中指定了转换函数或映射,可以在这里处理
# 否则直接设置属性值
await self.async_set_attribute(attribute, str(int(value)))

View File

@@ -5,6 +5,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from .core.logger import MideaLogger
from .midea_entity import MideaEntity
from . import load_device_config
@@ -43,6 +44,9 @@ class MideaSwitchEntity(MideaEntity, SwitchEntity):
"""Midea switch entity."""
def __init__(self, coordinator, device, manufacturer, rationale, entity_key, config):
# 自动判断是否为中央空调设备T0x21
self._is_central_ac = device.device_type == 0x21
super().__init__(
coordinator,
device.device_id,
@@ -67,12 +71,37 @@ class MideaSwitchEntity(MideaEntity, SwitchEntity):
async def async_turn_on(self):
"""Turn the switch on."""
# Use attribute from config if available, otherwise fall back to entity_key
attribute = self._config.get("attribute", self._entity_key)
await self._async_set_status_on_off(attribute, True)
if self._is_central_ac:
await self._async_set_central_ac_switch_status(True)
else:
await self._async_set_status_on_off(attribute, True)
async def async_turn_off(self):
"""Turn the switch off."""
# Use attribute from config if available, otherwise fall back to entity_key
attribute = self._config.get("attribute", self._entity_key)
await self._async_set_status_on_off(attribute, False)
if self._is_central_ac:
await self._async_set_central_ac_switch_status(False)
else:
await self._async_set_status_on_off(attribute, False)
async def _async_set_central_ac_switch_status(self, is_on: bool):
"""设置中央空调开关设备的状态"""
# 从entity_key中提取endpoint ID
# entity_key格式: endpoint_1_OnOff -> 提取出 1
endpoint_id = 1 # 默认值
if self._entity_key.startswith("endpoint_"):
try:
# 提取endpoint_后面的数字
parts = self._entity_key.split("_")
if len(parts) >= 2:
endpoint_id = int(parts[1])
except (ValueError, IndexError):
MideaLogger.warning(f"Failed to extract endpoint ID from {self._entity_key}, using default 1")
# 构建控制命令
control = {
"run_mode": "1" if is_on else "0",
"endpoint": endpoint_id
}
await self.coordinator.async_send_switch_control(control)

View File

@@ -291,38 +291,11 @@
"execute": {
"name": "Execute"
},
"power": {
"name": "Power"
},
"humidify": {
"name": "Humidify"
},
"swing": {
"name": "Swing"
},
"anion": {
"name": "Anion"
},
"display_on_off": {
"name": "Display On/Off"
},
"dust_reset": {
"name": "Dust Reset"
},
"temp_wind_switch": {
"name": "Temp Wind Switch"
},
"filter_reset": {
"name": "Filter Reset"
},
"heat_status": {
"name": "Heat Status"
},
"standby_status": {
"name": "Standby Status"
},
"tank_status": {
"name": "Tank Status"
}
},
"climate": {
@@ -339,10 +312,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": {
@@ -354,6 +349,12 @@
}
},
"select": {
"warm_target_temp": {
"name": "Warm Target Temperature"
},
"boil_target_temp": {
"name": "Boil Target Temperature"
},
"add_rinse": {
"name": "Add Rinse"
},
@@ -623,9 +624,18 @@
},
"power_off_time": {
"name": "Power Off Time"
},
"wind_pressure": {
"name": "Wind Pressure"
}
},
"sensor": {
"running_status": {
"name": "Running Status"
},
"tank_status": {
"name": "Tank Status"
},
"fan_level": {
"name": "Fan Level"
},
@@ -1483,9 +1493,34 @@
},
"water_full_level": {
"name": "Water Full Level"
},
"room_temp": {
"name": "Room Temperature"
},
"cool_temp_set": {
"name": "Cool Temperature Set"
},
"heat_temp_set": {
"name": "Heat Temperature Set"
}
},
"light": {
"light": {
"name": "Light"
}
},
"fan": {
"fan": {
"name": "Fan"
}
},
"switch": {
"temp_wind_switch": {
"name": "Wind Change with Temperature"
},
"screen_close": {
"name": "Screen Close"
},
"anion": {
"name": "Anion"
},
@@ -2325,7 +2360,46 @@
},
"cold_water_master": {
"name": "Cold Water Master"
},
"is_lock_heat": {
"name": "Heat Lock"
},
"is_lock_cool": {
"name": "Cool Lock"
},
"fan_speed_lock": {
"name": "Fan Speed Lock"
},
"is_lock_rc": {
"name": "Remote Control Lock"
},
"endpoint_1_onoff": {
"name": "Button 1"
},
"endpoint_2_onoff": {
"name": "Button 2"
},
"endpoint_3_onoff": {
"name": "Button 3"
},
"endpoint_4_onoff": {
"name": "Button 4"
},
"endpoint_5_onoff": {
"name": "Button 5"
},
"endpoint_6_onoff": {
"name": "Button 6"
},
"endpoint_7_onoff": {
"name": "Button 7"
},
"endpoint_8_onoff": {
"name": "Button 8"
},
"work_switch": {
"name": "Work Switch"
}
}
}
}
}

View File

@@ -291,38 +291,11 @@
"execute": {
"name": "执行"
},
"power": {
"name": "电源"
},
"humidify": {
"name": "加湿"
},
"swing": {
"name": "摆风"
},
"anion": {
"name": "负离子"
},
"display_on_off": {
"name": "显示开关"
},
"dust_reset": {
"name": "灰尘重置"
},
"temp_wind_switch": {
"name": "温风开关"
},
"filter_reset": {
"name": "滤网重置"
},
"heat_status": {
"name": "加热状态"
},
"standby_status": {
"name": "待机状态"
},
"tank_status": {
"name": "水箱状态"
}
},
"climate": {
@@ -339,10 +312,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": {
@@ -354,6 +353,12 @@
}
},
"select": {
"warm_target_temp": {
"name": "保温目标温度"
},
"boil_target_temp": {
"name": "煮沸目标温度"
},
"add_rinse": {
"name": "加漂洗"
},
@@ -623,9 +628,18 @@
},
"power_off_time": {
"name": "关机时间"
},
"wind_pressure": {
"name": "风压"
}
},
"sensor": {
"running_status": {
"name": "运行状态"
},
"tank_status": {
"name": "水箱状态"
},
"fan_level": {
"name": "风扇档位"
},
@@ -1483,9 +1497,34 @@
},
"water_full_level": {
"name": "满水水位"
},
"room_temp": {
"name": "室内温度"
},
"cool_temp_set": {
"name": "制冷设定温度"
},
"heat_temp_set": {
"name": "制热设定温度"
}
},
"light": {
"light": {
"name": "电灯"
}
},
"fan": {
"fan": {
"name": "风扇"
}
},
"switch": {
"temp_wind_switch": {
"name": "风随温变"
},
"screen_close": {
"name": "屏幕关闭"
},
"anion": {
"name": "负离子"
},
@@ -2325,6 +2364,45 @@
},
"cold_water_master": {
"name": "单次零冷水"
},
"is_lock_heat": {
"name": "制热锁定"
},
"is_lock_cool": {
"name": "制冷锁定"
},
"fan_speed_lock": {
"name": "风速锁定"
},
"is_lock_rc": {
"name": "遥控锁定"
},
"endpoint_1_onoff": {
"name": "按键一"
},
"endpoint_2_onoff": {
"name": "按键二"
},
"endpoint_3_onoff": {
"name": "按键三"
},
"endpoint_4_onoff": {
"name": "按键四"
},
"endpoint_5_onoff": {
"name": "按键五"
},
"endpoint_6_onoff": {
"name": "按键六"
},
"endpoint_7_onoff": {
"name": "按键七"
},
"endpoint_8_onoff": {
"name": "按键八"
},
"work_switch": {
"name": "工作开关"
}
}
}

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

BIN
img/img_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
img/img_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB