Skip to content

Commit

Permalink
📚 add comment for device customizes
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Mar 4, 2025
1 parent d636345 commit 3f23f19
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions custom_components/xiaomi_miot/core/device_customizes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
"""
This is a device customization built into the component, `DEVICE_CUSTOMIZES` is for device model customization.
Through these customizations, you can expand the functionality of the device in HA, such as:
- `sensor_properties`/`switch_properties` can map miot attributes to HA entities
- `exclude_miot_properties` can exclude redundant miot attributes, as some devices may become unresponsive due to polling too many attributes
- `chunk_coordinators` can group poll different attributes, which can synchronize the device's key attributes faster
More customization options can be found at https://github.com/al-one/hass-xiaomi-miot/issues/600.
If you want to change these customizations, you should prioritize defining them through the configuration stream (issues/600) or the `configuration.yaml` configuration file.
Assuming one of your devices lacks a temperature and humidity sensor, you can first find the corresponding attribute name on the website home.miot-spec.com and configure it in the following format:
```yaml
xiaomi_miot:
device_customizes:
your.device.model: # <-- replace it
sensor_properties: temperature,relative_humidity
switch_properties: uv,switch
```
It is worth noting:
- The `-` in miot property names needs to be replaced with `_`
- Your configuration will override the built-in customizations of the component
"""

from .converters import *

CHUNK_1 = {
Expand Down

1 comment on commit 3f23f19

@al-one
Copy link
Owner Author

@al-one al-one commented on 3f23f19 Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是一个组件内置的设备自定义,DEVICE_CUSTOMIZES是针对设备型号的自定义,通过这些自定义,可以扩展设备在HA中的功能,比如:

  • sensor_properties/switch_properties可以讲miot属性映射为HA实体
  • exclude_miot_properties可以排除多余的miot属性,部分设备因为轮训过多的属性导致无响应
  • chunk_coordinators可以分组轮训不同的属性,可以更快同步设备的关键属性

更多的自定义选项可以在 #600 中找到。
如果你想改变这些自定义,应该优先通过配置流(issues/600)或配置文件configuration.yaml来定义。
假设你的某个设备缺少温湿度传感器,可以先从网站 home.miot-spec.com 找到相应的属性名称,按照以下格式来配置:

xiaomi_miot:
  device_customizes:
    your.device.model: # <-- replace it
      sensor_properties: temperature,relative_humidity
      switch_properties: uv,switch

值得注意的是:

  • miot属性名中的-需要被替换为_
  • 你的配置会覆盖组件内置的自定义

Please sign in to comment.