Compare commits

...

5 Commits

Author SHA1 Message Date
Yi Zhai
0008c39795
Merge 3546517093 into 9af59e28bd 2024-12-24 00:00:03 +08:00
Li Shuzhen
9af59e28bd
docs: specify the download process in HACS installation (#371)
Some checks are pending
Tests / check-rule-format (push) Waiting to run
Validate / validate-hassfest (push) Waiting to run
Validate / validate-hacs (push) Waiting to run
Validate / validate-lint (push) Waiting to run
Validate / validate-setup (push) Waiting to run
* docs: specify the download process in HACS installation

* docs: revoke login authorization
2024-12-23 22:40:57 +08:00
Yi Zhai
3546517093
fix: Update specv2entity.py for missing "binary_sensor"
fix: Update specv2entity.py for missing "binary_sensor"

fix typo which forgets to  adding "binary_sensor" entity in `SPEC_PROP_TRANS_MAP`.
2024-12-19 17:18:55 +08:00
Yi Zhai
9cc2c52d44
fix: revert value of door and windows sensor with binary sensor class
fix: revert value of door and windows sensor with binary sensor class

Binary sensor class in Home Assistant uses true to indicate open, which is opposite of Xiaomi Home.
This commit reverts the value of  door and windows sensor to make them the same.
2024-12-19 16:59:39 +08:00
Yi Zhai
162f943924
fix: use binary sensor class for door and windows sensor and water leak sensor
fix: use Binary sensor class for door&windows and water leak sensor

The original version uses a sensor class for various sensors, such as door and windows sensors, water leak sensors, occupancy sensors, motion sensors, etc., which prevents the HomeKit Bridge from generating corresponding entities.
This fix is to use binary sensor class for door andwindows sensor and water leak sensor.

Correspoding issue: https://github.com/XiaoMi/ha_xiaomi_home/issues/206
2024-12-19 16:55:28 +08:00
4 changed files with 22 additions and 2 deletions

View File

@ -32,7 +32,7 @@ git checkout v1.0.0
### Method 2: [HACS](https://hacs.xyz/)
HACS > Overflow Menu > Custom repositories > Repository: https://github.com/XiaoMi/ha_xiaomi_home.git & Category: Integration > ADD
HACS > Overflow Menu > Custom repositories > Repository: https://github.com/XiaoMi/ha_xiaomi_home.git & Category: Integration > ADD > Xiaomi Home in New or Available for download section of HACS > DOWNLOAD
> Xiaomi Home has not been added to the HACS store as a default yet. It's coming soon.
@ -76,6 +76,8 @@ Method: [Settings > Devices & services > Configured > Xiaomi Home](https://my.ho
Xiaomi Home Integration and the affiliated cloud interface is provided by Xiaomi officially. You need to use your Xiaomi account to login to get your device list. Xiaomi Home Integration implements OAuth 2.0 login process, which does not keep your account password in the Home Assistant application. However, due to the limitation of the Home Assistant platform, the user information (including device information, certificates, tokens, etc.) of your Xiaomi account will be saved in the Home Assistant configuration file in clear text after successful login. You need to ensure that your Home Assistant configuration file is properly stored. The exposure of your configuration file may result in others logging in with your identity.
> If you suspect that your OAuth 2.0 token has been leaked, you can revoke the login authorization of your Xiaomi account by the following steps: Xiaomi Home APP -> Profile -> Click your username and get into Xiaomi Account management page -> Basic info: Apps -> Xiaomi Home (Home Assistant Integration) -> Remove
## FAQ
- Does Xiaomi Home Integration support all Xiaomi Home devices?

View File

@ -88,4 +88,7 @@ class BinarySensor(MIoTPropertyEntity, BinarySensorEntity):
@property
def is_on(self) -> bool:
"""On/Off state. True if the binary sensor is on, False otherwise."""
"""If it is a door and windows sensor, revert the value."""
if self._attr_device_class == 'door':
return not (self._value is True)
return self._value is True

View File

@ -47,6 +47,7 @@ Conversion rules of MIoT-Spec-V2 instance to Home Assistant entity.
"""
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.components.event import EventDeviceClass
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
# pylint: disable=pointless-string-statement
"""SPEC_DEVICE_TRANS_MAP
@ -336,6 +337,10 @@ SPEC_PROP_TRANS_MAP: dict[str, dict | str] = {
'format': {'int', 'float'},
'access': {'read'}
},
'binary_sensor': {
'format': {'bool'},
'access': {'read'}
},
'switch': {
'format': {'bool'},
'access': {'read', 'write'}
@ -391,6 +396,14 @@ SPEC_PROP_TRANS_MAP: dict[str, dict | str] = {
'device_class': SensorDeviceClass.DURATION,
'entity': 'sensor'
},
'submersion-state': {
'device_class': BinarySensorDeviceClass.MOISTURE,
'entity': 'binary_sensor'
},
'contact-state': {
'device_class': BinarySensorDeviceClass.DOOR,
'entity': 'binary_sensor'
},
'has-someone-duration': 'no-one-determine-time',
'no-one-duration': 'no-one-determine-time'
}

View File

@ -32,7 +32,7 @@ git checkout v1.0.0
### 方法 2: [HACS](https://hacs.xyz/)
HACS > Overflow Menu > Custom repositories > Repository: https://github.com/XiaoMi/ha_xiaomi_home.git & Category: Integration > ADD
HACS > 右上角三个点 > Custom repositories > Repository: https://github.com/XiaoMi/ha_xiaomi_home.git & Category: Integration > ADD > 点击 HACS 的 New 或 Available for download 分类下的 Xiaomi Home ,进入集成详情页 > DOWNLOAD
> 米家集成暂未添加到 HACS 商店,敬请期待。
@ -76,6 +76,8 @@ HACS > Overflow Menu > Custom repositories > Repository: https://github.com/Xiao
米家集成及其使用的云端接口由小米官方提供。您需要使用小米账号登录以获取设备列表。米家集成使用 OAuth 2.0 的登录方式,不会在 Home Assistant 中保存您的小米账号密码。但由于 Home Assistant 平台的限制,登录成功后,您的小米用户信息(包括设备信息、证书、 token 等)会明文保存在 Home Assistant 的配置文件中。因此,您需要保管好自己 Home Assistant 配置文件。一旦该文件泄露,其他人可能会冒用您的身份登录。
> 如果您怀疑您的 OAuth 2.0 令牌已泄露,您可以通过以下步骤取消小米账号的登录授权: 米家 APP -> 我的 -> 点击用户名进入小米账号页面 -> 应用授权 -> Xiaomi Home (Home Assistant Integration) -> 取消授权
## 常见问题
- 米家集成是否支持所有的小米米家设备?