mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2025-07-18 05:29:16 +08:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
4c2e10038c | |||
9afc62f39a | |||
b46805b92c | |||
a43447ef61 | |||
e5165f34da | |||
9fbbb26d33 | |||
5b1d003bb2 | |||
6069eaaba8 | |||
fd57e7c565 | |||
096b33f3c9 | |||
664787ca58 | |||
d659d13e49 | |||
3402587b1c | |||
028399c0b1 | |||
5179e97e38 | |||
9fdbf3dff2 | |||
d0508ead25 | |||
d05bdcbba9 |
28
CHANGELOG.md
28
CHANGELOG.md
@ -1,4 +1,32 @@
|
||||
# CHANGELOG
|
||||
## v0.3.4
|
||||
### Added
|
||||
- Exclude the unsupported device models. [#1205](https://github.com/XiaoMi/ha_xiaomi_home/pull/1205)
|
||||
### Changed
|
||||
- Subscribe the BLE device upstream messages even though the device is offline. [#1207](https://github.com/XiaoMi/ha_xiaomi_home/pull/1207)
|
||||
- Record "opening", "closing" and "closed" status of the airer service that occur frequently and do not record "stop" status for the cover entity. [#1235](https://github.com/XiaoMi/ha_xiaomi_home/pull/1235)
|
||||
- Modify README about spec_filter.yaml and the event attributes. [#1237](https://github.com/XiaoMi/ha_xiaomi_home/pull/1237)
|
||||
### Fixed
|
||||
- Fix the reconnect delay time to be reset when the client is connected to the broker. [#1200](https://github.com/XiaoMi/ha_xiaomi_home/pull/1200)
|
||||
- Fix the HA warning in the logs related to vacuum state setting. [#694](https://github.com/XiaoMi/ha_xiaomi_home/pull/694)
|
||||
- Fix the operation mode when the device does not have a mode property. [#1199](https://github.com/XiaoMi/ha_xiaomi_home/pull/1199)
|
||||
- Fix 090615.aircondition.ktf environment temperature. [#1210](https://github.com/XiaoMi/ha_xiaomi_home/pull/1210)
|
||||
- Fix a missing variable in translation it.json. [#1215](https://github.com/XiaoMi/ha_xiaomi_home/pull/1215)
|
||||
- Fix yutai.plug.fsov8m power consumption and ignore bjkcz.curtain.kczble curtain status. [#1236](https://github.com/XiaoMi/ha_xiaomi_home/pull/1236)
|
||||
|
||||
## v0.3.3
|
||||
### Changed
|
||||
- Change the log level of error "mips unsub internal error, 4, None". [#1135](https://github.com/XiaoMi/ha_xiaomi_home/pull/1135)
|
||||
- Add necessary logs for distinguishing the set_properties command source. [#1160](https://github.com/XiaoMi/ha_xiaomi_home/pull/1160)
|
||||
### Fixed
|
||||
- Fix tofan.airrtc.wk01 thermostat and air conditioner service. [#1160](https://github.com/XiaoMi/ha_xiaomi_home/pull/1160)
|
||||
- Fix mrbond.airer.m1t closing status. [#1134](https://github.com/XiaoMi/ha_xiaomi_home/pull/1134)
|
||||
- Fix the MIoT-Spec-V2 of xiaomi.fan.p69 fan service, ainice.sensor_occupy.3b people number, cykj.hood.jyj22 ventilation switch status, xiaomi.fan.p43 fan level, zhimi.airp.ua1a pm10 density, 090615.switch.x1tpm switch status, dmaker.fan.p33 fan-level. [#1132](https://github.com/XiaoMi/ha_xiaomi_home/pull/1132)
|
||||
- Fix cubee.airrtc.th123e and cubee.airrtc.th123w MIoT-Spec-V2 instance descriptions in Russian.
|
||||
- Fix ijai.vacuum.v1 suction-state value-list descriptions in Chinese.
|
||||
- Fix the misuse of Chinese brackets in multi_lang.json.
|
||||
- The unit of the humidity-range property of xiaomi.aircondition.mt0, xiaomi.aircondition.c35, xiaomi.aircondition.c24 and xiaomi.aircondition.c20 is "none". [#1187](https://github.com/XiaoMi/ha_xiaomi_home/pull/1187)
|
||||
|
||||
## v0.3.2
|
||||
> Xiaomi Home has been added to the Home Assistant Community Store (HACS) as a default since May 8, 2025.
|
||||
### Added
|
||||
|
48
README.md
48
README.md
@ -155,6 +155,8 @@ In MIoT-Spec-V2 protocol, a product is defined as a device. A device contains se
|
||||
|
||||
MIoT-Spec-V2 event is transformed to Event entity in Home Assistant. The event's parameters are also passed to entity's `_trigger_event`.
|
||||
|
||||
MIoT-Spec-V2 event's arguments field is the list of parameters of the event. The list elements represent the piid of the property in the same service. For example, the [MIoT-Spec-V2](http://poc.miot-spec.srv/miot-spec-v2/instance?type=urn:miot-spec-v2:device:remote-control:0000A021:xiaomi-mcn002:1:0000D057) of the Xiaomi Wireless Double-key Switch contains the siid=2 Switch Sensor service. The eiid=1014 Long Press event of the service is triggered when a button is long pressed. The debug level log will print `Press and hold, attributes: {'Button Type': 1}`. This is an example log that the button type is 1, which means the right button is long pressed.
|
||||
|
||||
- Action
|
||||
|
||||
| in | Entity in Home Assistant |
|
||||
@ -289,39 +291,37 @@ The value of the event instance name indicates `_attr_device_class` of the Home
|
||||
|
||||
### MIoT-Spec-V2 Filter
|
||||
|
||||
`spec_filter.json` is used to filter out the MIoT-Spec-V2 instance that will not be converted to Home Assistant entity.
|
||||
`spec_filter.yaml` is used to filter out the MIoT-Spec-V2 instance that will not be converted to Home Assistant entity.
|
||||
|
||||
The format of `spec_filter.json` is as follows.
|
||||
|
||||
```
|
||||
{
|
||||
"<MIoT-Spec-V2 device instance>":{
|
||||
"services": list<service_iid: str>,
|
||||
"properties": list<service_iid.property_iid: str>,
|
||||
"events": list<service_iid.event_iid: str>,
|
||||
"actions": list<service_iid.action_iid: str>,
|
||||
}
|
||||
}
|
||||
```yaml
|
||||
<MIoT-Spec-V2 device instance urn without the version field>:
|
||||
services: list<service_iid: str>
|
||||
properties: list<service_iid.property_iid: str>
|
||||
events: list<service_iid.event_iid: str>
|
||||
actions: list<service_iid.action_iid: str>
|
||||
```
|
||||
|
||||
The key of `spec_filter.json` dictionary is the urn excluding the "version" field of the MIoT-Spec-V2 device instance. The firmware of different versions of the same product may be associated with the MIoT-Spec-V2 device instances of different versions. It is required that the MIoT-Spec-V2 instance of a higher version must contain all MIoT-Spec-V2 instances of the lower versions when a vendor defines the MIoT-Spec-V2 of its product on MIoT platform. Thus, the key of `spec_filter.json` does not need to specify the version number of MIoT-Spec-V2 device instance.
|
||||
The key of `spec_filter.yaml` dictionary is the urn excluding the "version" field of the MIoT-Spec-V2 device instance. The firmware of different versions of the same product may be associated with the MIoT-Spec-V2 device instances of different versions. It is required that the MIoT-Spec-V2 instance of a higher version must contain all MIoT-Spec-V2 instances of the lower versions when a vendor defines the MIoT-Spec-V2 of its product on MIoT platform. Thus, the key of `spec_filter.yaml` does not need to specify the version number of MIoT-Spec-V2 device instance.
|
||||
|
||||
The value of "services", "properties", "events" or "actions" fields under "device instance" is the instance id (iid) of the service, property, event or action that will be ignored in the conversion process. Wildcard matching is supported.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
{
|
||||
"urn:miot-spec-v2:device:television:0000A010:xiaomi-rmi1":{
|
||||
"services": ["*"] # Filter out all services. It is equivalent to completely ignoring the device with such MIoT-Spec-V2 device instance.
|
||||
},
|
||||
"urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1": {
|
||||
"services": ["3"], # Filter out the service whose iid=3.
|
||||
"properties": ["4.*"] # Filter out all properties in the service whose iid=4.
|
||||
"events": ["4.1"], # Filter out the iid=1 event in the iid=4 service.
|
||||
"actions": ["4.1"] # Filter out the iid=1 action in the iid=4 service.
|
||||
}
|
||||
}
|
||||
```yaml
|
||||
urn:miot-spec-v2:device:television:0000A010:xiaomi-rmi1:
|
||||
services:
|
||||
- '*' # Filter out all services. It is equivalent to completely ignoring the device with such MIoT-Spec-V2.
|
||||
urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1:
|
||||
services:
|
||||
- '3' # Filter out the siid=3 service.
|
||||
properties:
|
||||
- '4.*' # Filter out all properties in the siid=4 service.
|
||||
events:
|
||||
- '4.1' # Filter out the eiid=1 event in the siid=4 service.
|
||||
actions:
|
||||
- '4.1' # Filter out the aiid=1 action in the siid=4 service.
|
||||
```
|
||||
|
||||
Device information service (urn:miot-spec-v2:service:device-information:00007801) of all devices will never be converted to Home Assistant entity.
|
||||
@ -376,7 +376,7 @@ Example:
|
||||
}
|
||||
```
|
||||
|
||||
> If you edit `specv2entity.py`, `spec_filter.json` or `multi_lang.json` in the `custom_components/xiaomi_home/miot/specs` directory in your Home Assistant, you need to update the entity conversion rule in the integration's CONFIGURE page to take effect. Method: [Settings > Devices & services > Configured > Xiaomi Home](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home) > CONFIGURE > Update Entity Conversion Rule
|
||||
> If you edit any files in the `custom_components/xiaomi_home/miot/specs` directory (`spec_filter.yaml`, `spec_modify.yaml`, `multi_lang.json`, etc.) in your Home Assistant, you need to update the entity conversion rule in the integration's CONFIGURE page to take effect. Method: [Settings > Devices & services > Configured > Xiaomi Home](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home) > CONFIGURE > Update entity conversion rules
|
||||
|
||||
## Documents
|
||||
|
||||
|
@ -46,8 +46,9 @@ off Xiaomi or its affiliates' products.
|
||||
Cover entities for Xiaomi Home.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import logging
|
||||
from typing import Any, Optional
|
||||
import re
|
||||
import logging
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -97,7 +98,6 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
_prop_status: Optional[MIoTSpecProperty]
|
||||
_prop_status_opening: Optional[list[int]]
|
||||
_prop_status_closing: Optional[list[int]]
|
||||
_prop_status_stop: Optional[list[int]]
|
||||
_prop_status_closed: Optional[list[int]]
|
||||
_prop_current_position: Optional[MIoTSpecProperty]
|
||||
_prop_target_position: Optional[MIoTSpecProperty]
|
||||
@ -122,7 +122,6 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
self._prop_status = None
|
||||
self._prop_status_opening = []
|
||||
self._prop_status_closing = []
|
||||
self._prop_status_stop = []
|
||||
self._prop_status_closed = []
|
||||
self._prop_current_position = None
|
||||
self._prop_target_position = None
|
||||
@ -159,13 +158,21 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
self.entity_id)
|
||||
continue
|
||||
for item in prop.value_list.items:
|
||||
if item.name in {'opening', 'open', 'up'}:
|
||||
item_str: str = item.name
|
||||
item_name: str = re.sub(r'[^a-z]', '', item_str)
|
||||
if item_name in {
|
||||
'opening', 'open', 'up', 'uping', 'rise', 'rising'
|
||||
}:
|
||||
self._prop_status_opening.append(item.value)
|
||||
elif item.name in {'closing', 'close', 'down'}:
|
||||
elif item_name in {
|
||||
'closing', 'close', 'down', 'dowm', 'falling',
|
||||
'dropping', 'downing', 'lower'
|
||||
}:
|
||||
self._prop_status_closing.append(item.value)
|
||||
elif item.name in {'stop', 'stopped', 'pause'}:
|
||||
self._prop_status_stop.append(item.value)
|
||||
elif item.name in {'closed'}:
|
||||
elif item_name in {
|
||||
'stopatlowest', 'stoplowerlimit', 'lowerlimitstop',
|
||||
'floor', 'lowerlimit'
|
||||
}:
|
||||
self._prop_status_closed.append(item.value)
|
||||
self._prop_status = prop
|
||||
elif prop.name == 'current-position':
|
||||
|
@ -25,7 +25,7 @@
|
||||
"cryptography",
|
||||
"psutil"
|
||||
],
|
||||
"version": "v0.3.2",
|
||||
"version": "v0.3.4",
|
||||
"zeroconf": [
|
||||
"_miot-central._tcp.local."
|
||||
]
|
||||
|
@ -85,6 +85,11 @@ SUPPORTED_PLATFORMS: list = [
|
||||
'water_heater',
|
||||
]
|
||||
|
||||
UNSUPPORTED_MODELS: list = [
|
||||
'chuangmi.ir.v2',
|
||||
'xiaomi.router.rd03'
|
||||
]
|
||||
|
||||
DEFAULT_CLOUD_SERVER: str = 'cn'
|
||||
CLOUD_SERVERS: dict = {
|
||||
'cn': '中国大陆',
|
||||
|
@ -629,11 +629,14 @@ class MIoTClient:
|
||||
mips = self._mips_local.get(device_gw['group_id'], None)
|
||||
if mips is None:
|
||||
_LOGGER.error(
|
||||
'no gw route, %s, try control throw cloud',
|
||||
'no gateway route, %s, try control through cloud',
|
||||
device_gw)
|
||||
else:
|
||||
result = await mips.set_prop_async(
|
||||
did=did, siid=siid, piid=piid, value=value)
|
||||
_LOGGER.debug(
|
||||
'gateway set prop, %s.%d.%d, %s -> %s',
|
||||
did, siid, piid, value, result)
|
||||
rc = (result or {}).get(
|
||||
'code', MIoTErrorCode.CODE_MIPS_INVALID_RESULT.value)
|
||||
if rc in [0, 1]:
|
||||
@ -663,7 +666,7 @@ class MIoTClient:
|
||||
{'did': did, 'siid': siid, 'piid': piid, 'value': value}
|
||||
])
|
||||
_LOGGER.debug(
|
||||
'set prop response, %s.%d.%d, %s, result, %s',
|
||||
'cloud set prop, %s.%d.%d, %s -> %s',
|
||||
did, siid, piid, value, result)
|
||||
if result and len(result) == 1:
|
||||
rc = result[0].get(
|
||||
@ -1351,6 +1354,11 @@ class MIoTClient:
|
||||
"""Update cloud devices.
|
||||
NOTICE: This function will operate the cloud_list
|
||||
"""
|
||||
# MIoT cloud service may not publish the online state updating message
|
||||
# for the BLE device. Assume that all BLE devices are online.
|
||||
for did, info in cloud_list.items():
|
||||
if did.startswith('blt.'):
|
||||
info['online'] = True
|
||||
for did, info in self._device_list_cache.items():
|
||||
if filter_dids and did not in filter_dids:
|
||||
continue
|
||||
|
@ -59,6 +59,7 @@ import aiohttp
|
||||
# pylint: disable=relative-beyond-top-level
|
||||
from .common import calc_group_id
|
||||
from .const import (
|
||||
UNSUPPORTED_MODELS,
|
||||
DEFAULT_OAUTH2_API_HOST,
|
||||
MIHOME_HTTP_API_TIMEOUT,
|
||||
OAUTH2_AUTH_URL)
|
||||
@ -573,6 +574,10 @@ class MIoTHttpClient:
|
||||
# were implemented.
|
||||
_LOGGER.info('ignore miwifi.* device, cloud, %s', did)
|
||||
continue
|
||||
if model in UNSUPPORTED_MODELS:
|
||||
_LOGGER.info('ignore unsupported model %s, cloud, %s',
|
||||
model, did)
|
||||
continue
|
||||
device_infos[did] = {
|
||||
'did': did,
|
||||
'uid': device.get('uid', None),
|
||||
|
@ -1207,10 +1207,9 @@ class MIoTPropertyEntity(Entity):
|
||||
self._attr_available = miot_device.online
|
||||
|
||||
_LOGGER.info(
|
||||
'new miot property entity, %s, %s, %s, %s, %s, %s, %s',
|
||||
'new miot property entity, %s, %s, %s, %s, %s',
|
||||
self.miot_device.name, self._attr_name, spec.platform,
|
||||
spec.device_class, self.entity_id, self._value_range,
|
||||
self._value_list)
|
||||
spec.device_class, self.entity_id)
|
||||
|
||||
@property
|
||||
def device_info(self) -> Optional[DeviceInfo]:
|
||||
|
@ -60,6 +60,7 @@ from typing import Any, Callable, Optional, final, Coroutine
|
||||
|
||||
from paho.mqtt.client import (
|
||||
MQTT_ERR_SUCCESS,
|
||||
MQTT_ERR_NO_CONN,
|
||||
MQTT_ERR_UNKNOWN,
|
||||
Client,
|
||||
MQTTv5,
|
||||
@ -67,7 +68,7 @@ from paho.mqtt.client import (
|
||||
|
||||
# pylint: disable=relative-beyond-top-level
|
||||
from .common import MIoTMatcher
|
||||
from .const import MIHOME_MQTT_KEEPALIVE
|
||||
from .const import UNSUPPORTED_MODELS, MIHOME_MQTT_KEEPALIVE
|
||||
from .miot_error import MIoTErrorCode, MIoTMipsError
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -215,7 +216,7 @@ class _MipsClient(ABC):
|
||||
MQTT_INTERVAL_S = 1
|
||||
MIPS_QOS: int = 2
|
||||
UINT32_MAX: int = 0xFFFFFFFF
|
||||
MIPS_RECONNECT_INTERVAL_MIN: float = 30
|
||||
MIPS_RECONNECT_INTERVAL_MIN: float = 10
|
||||
MIPS_RECONNECT_INTERVAL_MAX: float = 600
|
||||
MIPS_SUB_PATCH: int = 300
|
||||
MIPS_SUB_INTERVAL: float = 1
|
||||
@ -533,7 +534,7 @@ class _MipsClient(ABC):
|
||||
return
|
||||
try:
|
||||
result, mid = self._mqtt.unsubscribe(topic=topic)
|
||||
if result == MQTT_ERR_SUCCESS:
|
||||
if (result == MQTT_ERR_SUCCESS) or (result == MQTT_ERR_NO_CONN):
|
||||
self.log_debug(
|
||||
f'mips unsub internal success, {result}, {mid}, {topic}')
|
||||
return
|
||||
@ -640,6 +641,7 @@ class _MipsClient(ABC):
|
||||
if not self._mqtt.is_connected():
|
||||
return
|
||||
self.log_info(f'mips connect, {flags}, {rc}, {props}')
|
||||
self.__reset_reconnect_time()
|
||||
self._mqtt_state = True
|
||||
self._internal_loop.call_soon(
|
||||
self._on_mips_connect, rc, props)
|
||||
@ -821,7 +823,7 @@ class _MipsClient(ABC):
|
||||
self._internal_loop.stop()
|
||||
|
||||
def __get_next_reconnect_time(self) -> float:
|
||||
if self._mips_reconnect_interval == 0:
|
||||
if self._mips_reconnect_interval < self.MIPS_RECONNECT_INTERVAL_MIN:
|
||||
self._mips_reconnect_interval = self.MIPS_RECONNECT_INTERVAL_MIN
|
||||
else:
|
||||
self._mips_reconnect_interval = min(
|
||||
@ -829,6 +831,9 @@ class _MipsClient(ABC):
|
||||
self.MIPS_RECONNECT_INTERVAL_MAX)
|
||||
return self._mips_reconnect_interval
|
||||
|
||||
def __reset_reconnect_time(self) -> None:
|
||||
self._mips_reconnect_interval = 0
|
||||
|
||||
|
||||
class MipsCloudClient(_MipsClient):
|
||||
"""MIoT Pub/Sub Cloud Client."""
|
||||
@ -1173,7 +1178,7 @@ class MipsLocalClient(_MipsClient):
|
||||
or 'piid' not in msg
|
||||
or 'value' not in msg
|
||||
):
|
||||
# self.log_error(f'on_prop_msg, recv unknown msg, {payload}')
|
||||
self.log_info('unknown prop msg, %s', payload)
|
||||
return
|
||||
if handler:
|
||||
self.log_debug('local, on properties_changed, %s', payload)
|
||||
@ -1360,6 +1365,9 @@ class MipsLocalClient(_MipsClient):
|
||||
if name is None or urn is None or model is None:
|
||||
self.log_error(f'invalid device info, {did}, {info}')
|
||||
continue
|
||||
if model in UNSUPPORTED_MODELS:
|
||||
self.log_info(f'unsupported model, {model}, {did}')
|
||||
continue
|
||||
device_list[did] = {
|
||||
'did': did,
|
||||
'name': name,
|
||||
|
@ -168,7 +168,7 @@
|
||||
"service:003:property:1021:valuelist:002": "已上锁(反锁)",
|
||||
"service:003:property:1021:valuelist:003": "已上锁(反锁+童锁)",
|
||||
"service:003:property:1021:valuelist:004": "已开锁",
|
||||
"service:003:property:1021:valuelist:008": "门未关(门超时未关)",
|
||||
"service:003:property:1021:valuelist:008": "门未关(门超时未关)",
|
||||
"service:003:property:1021:valuelist:012": "门虚掩"
|
||||
}
|
||||
},
|
||||
@ -181,6 +181,13 @@
|
||||
"service:002:property:003": "光照强度"
|
||||
}
|
||||
},
|
||||
"urn:miot-spec-v2:device:switch:0000A003:090615-x1tpm": {
|
||||
"en": {
|
||||
"service:027:property:001": "Fan Switch",
|
||||
"service:027:property:003": "Light Switch",
|
||||
"service:027:property:004": "Fan and Light Switch"
|
||||
}
|
||||
},
|
||||
"urn:miot-spec-v2:device:switch:0000A003:lumi-acn040": {
|
||||
"en": {
|
||||
"service:011": "Right Button On and Off",
|
||||
@ -194,5 +201,90 @@
|
||||
"service:016:action:001": "中键确认",
|
||||
"service:017:action:001": "右键确认"
|
||||
}
|
||||
},
|
||||
"urn:miot-spec-v2:device:thermostat:0000A031:cubee-th123e": {
|
||||
"ru": {
|
||||
"service:002": "термостат",
|
||||
"service:002:property:001": "выключатель",
|
||||
"service:002:property:002": "режим нагрузки",
|
||||
"service:002:property:002:valuelist:000": "без подогрева",
|
||||
"service:002:property:002:valuelist:001": "нагрев",
|
||||
"service:002:property:003": "неисправность",
|
||||
"service:002:property:003:valuelist:000": "ошибка датчика",
|
||||
"service:002:property:003:valuelist:001": "без ошибок",
|
||||
"service:002:property:003:valuelist:002": "защита от высоких температур",
|
||||
"service:002:property:003:valuelist:003": "криогенная защита",
|
||||
"service:002:property:004": "режим",
|
||||
"service:002:property:004:valuelist:000": "ручной режим",
|
||||
"service:002:property:004:valuelist:001": "домашний режим",
|
||||
"service:002:property:004:valuelist:002": "режим выхода из дома",
|
||||
"service:002:property:004:valuelist:003": "автоматический режим",
|
||||
"service:002:property:004:valuelist:004": "Режим сна",
|
||||
"service:002:property:005": "температура цели",
|
||||
"service:002:property:007": "текущая температура",
|
||||
"service:004": "Пользовательские услуги",
|
||||
"service:004:property:001": "детский замок",
|
||||
"service:004:property:002": "тип датчика",
|
||||
"service:004:property:002:valuelist:000": "внутренний датчик",
|
||||
"service:004:property:002:valuelist:001": "выносной датчик",
|
||||
"service:004:property:002:valuelist:002": "встроенный и внешний датчик",
|
||||
"service:004:property:003": "пусковая разность температур",
|
||||
"service:004:property:004": "компенсационная температура",
|
||||
"service:004:property:005": "температура выносного датчика",
|
||||
"service:004:property:006": "максимальная температура цели",
|
||||
"service:004:property:007": "минимальная температура цели "
|
||||
}
|
||||
},
|
||||
"urn:miot-spec-v2:device:thermostat:0000A031:cubee-th123w": {
|
||||
"ru": {
|
||||
"service:002": "термостат",
|
||||
"service:002:property:001": "выключатель",
|
||||
"service:002:property:002": "режим нагрузки",
|
||||
"service:002:property:002:valuelist:000": "нагрев",
|
||||
"service:002:property:002:valuelist:001": "без подогрева",
|
||||
"service:002:property:003": "неисправность",
|
||||
"service:002:property:003:valuelist:000": "без ошибок",
|
||||
"service:002:property:003:valuelist:001": "ошибка датчика",
|
||||
"service:002:property:003:valuelist:002": "защита от высоких температур",
|
||||
"service:002:property:003:valuelist:003": "криогенная защита",
|
||||
"service:002:property:004": "режим",
|
||||
"service:002:property:004:valuelist:000": "ручной режим",
|
||||
"service:002:property:004:valuelist:001": "домашний режим",
|
||||
"service:002:property:004:valuelist:002": "режим выхода из дома",
|
||||
"service:002:property:004:valuelist:003": "автоматический режим",
|
||||
"service:002:property:004:valuelist:004": "Режим сна",
|
||||
"service:002:property:005": "температура цели",
|
||||
"service:002:property:007": "текущая температура",
|
||||
"service:004": "Пользовательские услуги",
|
||||
"service:004:property:001": "детский замок",
|
||||
"service:004:property:002": "тип датчика",
|
||||
"service:004:property:002:valuelist:000": "внутренний датчик",
|
||||
"service:004:property:002:valuelist:001": "выносной датчик",
|
||||
"service:004:property:002:valuelist:002": "встроенный и внешний датчик",
|
||||
"service:004:property:003": "пусковая разность температур",
|
||||
"service:004:property:004": "компенсационная температура",
|
||||
"service:004:property:005": "температура выносного датчика",
|
||||
"service:004:property:006": "максимальная температура цели",
|
||||
"service:004:property:007": "минимальная температура цели "
|
||||
}
|
||||
},
|
||||
"urn:miot-spec-v2:device:thermostat:0000A031:tofan-wk01": {
|
||||
"en": {
|
||||
"service:002": "Thermostat",
|
||||
"service:002:property:002": "Air Conditioner Mode",
|
||||
"service:004": "Air Conditioner"
|
||||
},
|
||||
"zh_cn": {
|
||||
"service:002": "地暖",
|
||||
"service:004": "空调"
|
||||
}
|
||||
},
|
||||
"urn:miot-spec-v2:device:vacuum:0000A006:ijai-v1": {
|
||||
"zh_cn": {
|
||||
"service:007:property:005:valuelist:000": "安静",
|
||||
"service:007:property:005:valuelist:001": "标准",
|
||||
"service:007:property:005:valuelist:002": "中档",
|
||||
"service:007:property:005:valuelist:003": "强力"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,29 @@
|
||||
{
|
||||
"urn:miot-spec-v2:device:air-conditioner:0000A004:090615-ktf:1": [
|
||||
{
|
||||
"iid": 4,
|
||||
"type": "urn:miot-spec-v2:service:environment:0000780A:090615-ktf:1",
|
||||
"description": "Environment",
|
||||
"properties": [
|
||||
{
|
||||
"iid": 2,
|
||||
"type": "urn:miot-spec-v2:property:temperature:00000020:090615-ktf:1",
|
||||
"description": "Temperature",
|
||||
"format": "float",
|
||||
"access": [
|
||||
"read",
|
||||
"notify"
|
||||
],
|
||||
"unit": "celsius",
|
||||
"value-range": [
|
||||
-30,
|
||||
100,
|
||||
1
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"urn:miot-spec-v2:device:airer:0000A00D:hyd-lyjpro:1": [
|
||||
{
|
||||
"iid": 3,
|
||||
@ -19,6 +44,165 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"urn:miot-spec-v2:device:thermostat:0000A031:tofan-wk01:1:0000C822": [
|
||||
{
|
||||
"iid": 2,
|
||||
"type": "urn:miot-spec-v2:service:thermostat:0000784A:tofan-wk01:1",
|
||||
"description": "Thermostat",
|
||||
"properties": [
|
||||
{
|
||||
"iid": 1,
|
||||
"type": "urn:miot-spec-v2:property:on:00000006:tofan-wk01:1",
|
||||
"description": "Switch Status",
|
||||
"format": "bool",
|
||||
"access": [
|
||||
"read",
|
||||
"write",
|
||||
"notify"
|
||||
]
|
||||
},
|
||||
{
|
||||
"iid": 2,
|
||||
"type": "urn:miot-spec-v2:property:mode-a:00000008:tofan-wk01:1",
|
||||
"description": "Mode",
|
||||
"format": "uint8",
|
||||
"access": [
|
||||
"read",
|
||||
"write",
|
||||
"notify"
|
||||
],
|
||||
"value-list": [
|
||||
{
|
||||
"value": 0,
|
||||
"description": "Auto"
|
||||
},
|
||||
{
|
||||
"value": 1,
|
||||
"description": "Cool"
|
||||
},
|
||||
{
|
||||
"value": 2,
|
||||
"description": "Heat"
|
||||
},
|
||||
{
|
||||
"value": 3,
|
||||
"description": "Fan"
|
||||
},
|
||||
{
|
||||
"value": 4,
|
||||
"description": "Dry"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"iid": 3,
|
||||
"type": "urn:miot-spec-v2:property:fault:00000009:tofan-wk01:1",
|
||||
"description": "Device Fault",
|
||||
"format": "uint8",
|
||||
"access": [
|
||||
"read",
|
||||
"notify"
|
||||
],
|
||||
"value-list": [
|
||||
{
|
||||
"value": 0,
|
||||
"description": "No Faults"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"iid": 4,
|
||||
"type": "urn:miot-spec-v2:property:target-temperature:00000021:tofan-wk01:1",
|
||||
"description": "Target Temperature",
|
||||
"format": "uint8",
|
||||
"access": [
|
||||
"read",
|
||||
"write",
|
||||
"notify"
|
||||
],
|
||||
"unit": "celsius",
|
||||
"value-range": [
|
||||
16,
|
||||
35,
|
||||
1
|
||||
]
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"iid": 1,
|
||||
"type": "urn:miot-spec-v2:action:toggle:00002811:tofan-wk01:1",
|
||||
"description": "Toggle",
|
||||
"in": [],
|
||||
"out": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"iid": 4,
|
||||
"type": "urn:miot-spec-v2:service:air-conditioner:0000780F:tofan-wk01:1",
|
||||
"description": "Air Conditioner",
|
||||
"properties": [
|
||||
{
|
||||
"iid": 1,
|
||||
"type": "urn:miot-spec-v2:property:on:00000006:tofan-wk01:1",
|
||||
"description": "Switch Status",
|
||||
"format": "bool",
|
||||
"access": [
|
||||
"read",
|
||||
"write",
|
||||
"notify"
|
||||
]
|
||||
},
|
||||
{
|
||||
"iid": 2,
|
||||
"type": "urn:miot-spec-v2:property:target-temperature:00000021:tofan-wk01:1",
|
||||
"description": "Target Temperature",
|
||||
"format": "uint8",
|
||||
"access": [
|
||||
"read",
|
||||
"write",
|
||||
"notify"
|
||||
],
|
||||
"unit": "celsius",
|
||||
"value-range": [
|
||||
16,
|
||||
32,
|
||||
1
|
||||
]
|
||||
},
|
||||
{
|
||||
"iid": 3,
|
||||
"type": "urn:miot-spec-v2:property:fan-level:00000016:tofan-wk01:1",
|
||||
"description": "Fan Level",
|
||||
"format": "uint8",
|
||||
"access": [
|
||||
"read",
|
||||
"write",
|
||||
"notify"
|
||||
],
|
||||
"value-list": [
|
||||
{
|
||||
"value": 0,
|
||||
"description": "Auto"
|
||||
},
|
||||
{
|
||||
"value": 2,
|
||||
"description": "Low"
|
||||
},
|
||||
{
|
||||
"value": 3,
|
||||
"description": "Medium"
|
||||
},
|
||||
{
|
||||
"value": 4,
|
||||
"description": "High"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"urn:miot-spec-v2:device:water-heater:0000A02A:xiaomi-yms2:1": [
|
||||
{
|
||||
"iid": 2,
|
||||
|
@ -1,3 +1,6 @@
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:090615-ktf:
|
||||
services:
|
||||
- '4'
|
||||
urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ma4:
|
||||
properties:
|
||||
- 9.*
|
||||
@ -41,6 +44,7 @@ urn:miot-spec-v2:device:motion-sensor:0000A014:xiaomi-pir1:
|
||||
services:
|
||||
- '1'
|
||||
- '5'
|
||||
urn:miot-spec-v2:device:router:0000A036:xiaomi-rd03:
|
||||
urn:miot-spec-v2:device:thermostat:0000A031:tofan-wk01:
|
||||
services:
|
||||
- '*'
|
||||
- '2'
|
||||
- '4'
|
||||
|
@ -1,6 +1,18 @@
|
||||
urn:miot-spec-v2:device:air-condition-outlet:0000A045:lumi-mcn04:1:
|
||||
prop.3.4:
|
||||
format: uint8
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c20:1:
|
||||
prop.10.6:
|
||||
unit: none
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c20:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c20:1
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c24:1:
|
||||
prop.10.6:
|
||||
unit: none
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c24:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c24:1
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c35:1:
|
||||
prop.10.6:
|
||||
unit: none
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c35:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c35:1
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:1: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:3: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6
|
||||
@ -9,9 +21,19 @@ urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:5: urn:miot-spec-v2:d
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6:
|
||||
prop.10.6:
|
||||
unit: none
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:7: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m9:6
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-mt0:1:
|
||||
prop.10.6:
|
||||
unit: none
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-mt0:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-mt0:1
|
||||
urn:miot-spec-v2:device:air-monitor:0000A008:cgllc-s1:1:
|
||||
prop.2.5:
|
||||
name: voc-density
|
||||
urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ua1a:1: urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ua1a:3
|
||||
urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ua1a:2: urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ua1a:3
|
||||
urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ua1a:3:
|
||||
prop.3.5:
|
||||
expr: (src_value*6)
|
||||
urn:miot-spec-v2:device:airer:0000A00D:hyd-lyjpro:1:
|
||||
prop.2.3:
|
||||
name: current-position-a
|
||||
@ -26,6 +48,9 @@ urn:miot-spec-v2:device:airer:0000A00D:hyd-znlyj5:1:
|
||||
- 1
|
||||
- 1
|
||||
urn:miot-spec-v2:device:airer:0000A00D:hyd-znlyj5:2: urn:miot-spec-v2:device:airer:0000A00D:hyd-znlyj5:1
|
||||
urn:miot-spec-v2:device:airer:0000A00D:mrbond-m1t:1:
|
||||
prop.2.3:
|
||||
name: current-position-a
|
||||
urn:miot-spec-v2:device:airer:0000A00D:mrbond-m33a:1:
|
||||
prop.2.3:
|
||||
name: current-position-a
|
||||
@ -50,12 +75,30 @@ urn:miot-spec-v2:device:bath-heater:0000A028:opple-acmoto:1:
|
||||
urn:miot-spec-v2:device:bath-heater:0000A028:xiaomi-s1:1:
|
||||
prop.4.4:
|
||||
name: fan-level-ventilation
|
||||
urn:miot-spec-v2:device:curtain:0000A00C:bjkcz-kczble:1:0000D031:
|
||||
prop.2.2:
|
||||
name: status-a
|
||||
urn:miot-spec-v2:device:fan:0000A005:dmaker-p33:1:
|
||||
prop.2.2:
|
||||
name: fan-level-a
|
||||
prop.2.6:
|
||||
name: fan-level
|
||||
access:
|
||||
- read
|
||||
- write
|
||||
- notify
|
||||
urn:miot-spec-v2:device:fan:0000A005:dmaker-p5:1:
|
||||
prop.2.4:
|
||||
name: fan-level-a
|
||||
urn:miot-spec-v2:device:fan:0000A005:xiaomi-p43:1:
|
||||
prop.2.2:
|
||||
name: fan-level-a
|
||||
urn:miot-spec-v2:device:fan:0000A005:xiaomi-p51:1:
|
||||
prop.2.2:
|
||||
name: fan-level-a
|
||||
urn:miot-spec-v2:device:fan:0000A005:xiaomi-p69:1:0000D062:
|
||||
prop.2.4:
|
||||
name: fan-level-a
|
||||
urn:miot-spec-v2:device:fan:0000A005:zhimi-sa1:3:
|
||||
prop.2.2:
|
||||
name: fan-level-a
|
||||
@ -96,6 +139,11 @@ urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1:1:
|
||||
- notify
|
||||
urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1:2: urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1:1
|
||||
urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1:3: urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1:1
|
||||
urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:1: urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:3
|
||||
urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:2: urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:3
|
||||
urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:3:
|
||||
prop.3.1:
|
||||
name: on-ventilation
|
||||
urn:miot-spec-v2:device:kettle:0000A009:yunmi-r3:1:
|
||||
prop.3.1:
|
||||
unit: ppm
|
||||
@ -108,6 +156,11 @@ urn:miot-spec-v2:device:light:0000A001:shhf-sfla12:1:
|
||||
urn:miot-spec-v2:device:magnet-sensor:0000A016:linp-m1:1:
|
||||
prop.2.1004:
|
||||
name: contact-state
|
||||
value-list:
|
||||
- value: 0
|
||||
description: open
|
||||
- value: 1
|
||||
description: closed
|
||||
expr: src_value!=1
|
||||
urn:miot-spec-v2:device:motion-sensor:0000A014:lumi-acn001:1:
|
||||
prop.3.2:
|
||||
@ -115,6 +168,10 @@ urn:miot-spec-v2:device:motion-sensor:0000A014:lumi-acn001:1:
|
||||
- read
|
||||
- notify
|
||||
unit: mV
|
||||
urn:miot-spec-v2:device:occupancy-sensor:0000A0BF:ainice-3b:1: urn:miot-spec-v2:device:occupancy-sensor:0000A0BF:ainice-3b:2
|
||||
urn:miot-spec-v2:device:occupancy-sensor:0000A0BF:ainice-3b:2:
|
||||
prop.2.8:
|
||||
name: people-number
|
||||
urn:miot-spec-v2:device:occupancy-sensor:0000A0BF:izq-24:2:0000C824:
|
||||
prop.2.6:
|
||||
unit: cm
|
||||
@ -155,6 +212,9 @@ urn:miot-spec-v2:device:outlet:0000A002:qmi-psv3:1:0000C816:
|
||||
unit: mV
|
||||
prop.3.4:
|
||||
unit: mA
|
||||
urn:miot-spec-v2:device:outlet:0000A002:yutai-fsov8m:1:0000C816:
|
||||
prop.4.1:
|
||||
expr: round(src_value/10000, 2)
|
||||
urn:miot-spec-v2:device:outlet:0000A002:zimi-zncz01:1:0000C816: urn:miot-spec-v2:device:outlet:0000A002:zimi-zncz01:2:0000C816
|
||||
urn:miot-spec-v2:device:outlet:0000A002:zimi-zncz01:2:0000C816:
|
||||
prop.3.1:
|
||||
@ -184,6 +244,11 @@ urn:miot-spec-v2:device:safe-box:0000A042:loock-v1:1:
|
||||
prop.5.1:
|
||||
name: contact-state
|
||||
expr: src_value!=1
|
||||
urn:miot-spec-v2:device:switch:0000A003:090615-x1tpm:1:0000D042:
|
||||
prop.27.3:
|
||||
name: light-on
|
||||
prop.27.4:
|
||||
name: light-fan-on
|
||||
urn:miot-spec-v2:device:switch:0000A003:lxzn-cbcsmj:1:0000D00D:
|
||||
prop.3.1:
|
||||
expr: round(src_value/100, 2)
|
||||
|
@ -113,7 +113,7 @@
|
||||
},
|
||||
"config_options": {
|
||||
"title": "Opzioni di Configurazione",
|
||||
"description": "### Ciao, {nick_name}\r\n\r\nID Xiaomi: {uid}\r\nRegione di Login Corrente: {cloud_server}\r\n\r\nSeleziona le opzioni che desideri configurare, poi clicca AVANTI.",
|
||||
"description": "### Ciao, {nick_name}\r\n\r\nID Xiaomi: {uid}\r\nRegione di Login Corrente: {cloud_server}\r\nID istanza di integrazione: {instance_id}\r\n\r\nSeleziona le opzioni che desideri configurare, poi clicca AVANTI.",
|
||||
"data": {
|
||||
"integration_language": "Lingua dell'Integrazione",
|
||||
"update_user_info": "Aggiorna le informazioni dell'utente",
|
||||
|
@ -47,29 +47,26 @@ Vacuum entities for Xiaomi Home.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
from typing import Any, Optional
|
||||
import re
|
||||
import logging
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.components.vacuum import (
|
||||
StateVacuumEntity,
|
||||
VacuumEntityFeature
|
||||
)
|
||||
from homeassistant.components.vacuum import (StateVacuumEntity,
|
||||
VacuumEntityFeature)
|
||||
|
||||
from .miot.const import DOMAIN
|
||||
from .miot.miot_device import MIoTDevice, MIoTServiceEntity, MIoTEntityData
|
||||
from .miot.miot_spec import (
|
||||
MIoTSpecAction,
|
||||
MIoTSpecProperty)
|
||||
from .miot.miot_spec import (MIoTSpecAction, MIoTSpecProperty)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
device_list: list[MIoTDevice] = hass.data[DOMAIN]['devices'][
|
||||
config_entry.entry_id]
|
||||
@ -99,10 +96,12 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity):
|
||||
_status_map: Optional[dict[int, str]]
|
||||
_fan_level_map: Optional[dict[int, str]]
|
||||
|
||||
def __init__(
|
||||
self, miot_device: MIoTDevice, entity_data: MIoTEntityData
|
||||
) -> None:
|
||||
_device_name: str
|
||||
|
||||
def __init__(self, miot_device: MIoTDevice,
|
||||
entity_data: MIoTEntityData) -> None:
|
||||
super().__init__(miot_device=miot_device, entity_data=entity_data)
|
||||
self._device_name = miot_device.name
|
||||
self._attr_supported_features = VacuumEntityFeature(0)
|
||||
|
||||
self._prop_status = None
|
||||
@ -121,21 +120,21 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity):
|
||||
for prop in entity_data.props:
|
||||
if prop.name == 'status':
|
||||
if not prop.value_list:
|
||||
_LOGGER.error(
|
||||
'invalid status value_list, %s', self.entity_id)
|
||||
_LOGGER.error('invalid status value_list, %s',
|
||||
self.entity_id)
|
||||
continue
|
||||
self._status_map = prop.value_list.to_map()
|
||||
self._attr_supported_features |= VacuumEntityFeature.STATE
|
||||
self._prop_status = prop
|
||||
elif prop.name == 'fan-level':
|
||||
if not prop.value_list:
|
||||
_LOGGER.error(
|
||||
'invalid fan-level value_list, %s', self.entity_id)
|
||||
_LOGGER.error('invalid fan-level value_list, %s',
|
||||
self.entity_id)
|
||||
continue
|
||||
self._fan_level_map = prop.value_list.to_map()
|
||||
self._attr_fan_speed_list = list(self._fan_level_map.values())
|
||||
self._attr_supported_features |= VacuumEntityFeature.FAN_SPEED
|
||||
self._prop_fan_level = prop
|
||||
|
||||
elif prop.name == 'battery-level':
|
||||
self._attr_supported_features |= VacuumEntityFeature.BATTERY
|
||||
self._prop_battery_level = prop
|
||||
@ -155,16 +154,24 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity):
|
||||
elif action.name == 'stop-and-gocharge':
|
||||
self._attr_supported_features |= VacuumEntityFeature.RETURN_HOME
|
||||
self._action_stop_and_gocharge = action
|
||||
|
||||
elif action.name == 'identify':
|
||||
self._attr_supported_features |= VacuumEntityFeature.LOCATE
|
||||
self._action_identify = action
|
||||
|
||||
async def async_start(self) -> None:
|
||||
"""Start or resume the cleaning task."""
|
||||
if self.state.lower() in ['paused', '暂停中']:
|
||||
await self.action_async(action=self._action_continue_sweep)
|
||||
return
|
||||
try: # VacuumActivity is introduced in HA core 2025.1.0
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from homeassistant.components.vacuum import VacuumActivity
|
||||
if (self.activity
|
||||
== VacuumActivity.PAUSED) and self._action_continue_sweep:
|
||||
await self.action_async(action=self._action_continue_sweep)
|
||||
return
|
||||
except ImportError:
|
||||
if self.state and (self.state in {'paused', 'pause'
|
||||
}) and self._action_continue_sweep:
|
||||
await self.action_async(action=self._action_continue_sweep)
|
||||
return
|
||||
await self.action_async(action=self._action_start_sweep)
|
||||
|
||||
async def async_stop(self, **kwargs: Any) -> None:
|
||||
@ -179,31 +186,92 @@ class Vacuum(MIoTServiceEntity, StateVacuumEntity):
|
||||
"""Set the vacuum cleaner to return to the dock."""
|
||||
await self.action_async(action=self._action_stop_and_gocharge)
|
||||
|
||||
async def async_clean_spot(self, **kwargs: Any) -> None:
|
||||
"""Perform a spot clean-up."""
|
||||
|
||||
async def async_locate(self, **kwargs: Any) -> None:
|
||||
"""Locate the vacuum cleaner."""
|
||||
await self.action_async(action=self._action_identify)
|
||||
|
||||
async def async_set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None:
|
||||
"""Set fan speed."""
|
||||
fan_level_value = self.get_map_key(map_=self._fan_level_map,
|
||||
value=fan_speed)
|
||||
await self.set_property_async(prop=self._prop_fan_level,
|
||||
value=fan_level_value)
|
||||
|
||||
@property
|
||||
def name(self) -> Optional[str]:
|
||||
"""Name of the vacuum entity."""
|
||||
return self._device_name
|
||||
|
||||
@property
|
||||
def state(self) -> Optional[str]:
|
||||
"""Return the current state of the vacuum cleaner."""
|
||||
return self.get_map_value(
|
||||
map_=self._status_map,
|
||||
key=self.get_prop_value(prop=self._prop_status))
|
||||
"""Return the current state of the vacuum cleaner.
|
||||
|
||||
To fix the HA warning below:
|
||||
Detected that custom integration 'xiaomi_home' is setting state
|
||||
directly.Entity XXX(<class 'custom_components.xiaomi_home.vacuum
|
||||
.Vacuum'>)should implement the 'activity' property and return
|
||||
its state using the VacuumActivity enum.This will stop working in
|
||||
Home Assistant 2026.1.
|
||||
|
||||
Refer to
|
||||
https://developers.home-assistant.io/blog/2024/12/08/new-vacuum-state-property
|
||||
|
||||
There are only 6 states in VacuumActivity enum. To be compatible with
|
||||
more constants, try get matching VacuumActivity enum first, return state
|
||||
string as before if there is no match. In Home Assistant 2026.1, every
|
||||
state should map to a VacuumActivity enum.
|
||||
"""
|
||||
return self.activity
|
||||
|
||||
@property
|
||||
def activity(self) -> Optional[str]:
|
||||
"""The current vacuum activity."""
|
||||
status = self.get_prop_value(prop=self._prop_status)
|
||||
if status is None:
|
||||
return None
|
||||
status_value = self.get_map_value(map_=self._status_map, key=status)
|
||||
if status_value is None:
|
||||
return None
|
||||
try:
|
||||
# pylint: disable=import-outside-toplevel
|
||||
from homeassistant.components.vacuum import VacuumActivity
|
||||
status_value = status_value.lower()
|
||||
status_str = re.sub(r'[^a-z]', '', status_value)
|
||||
if status_str in {
|
||||
'charging', 'charged', 'chargingcompleted', 'fullcharge',
|
||||
'fullpower', 'findchargerpause', 'drying', 'washing',
|
||||
'wash', 'inthewash', 'inthedry', 'stationworking',
|
||||
'dustcollecting', 'upgrade', 'upgrading', 'updating'
|
||||
}:
|
||||
return VacuumActivity.DOCKED
|
||||
if status_str in {'paused', 'pause'}:
|
||||
return VacuumActivity.PAUSED
|
||||
if status_str in {
|
||||
'gocharging', 'cleancompletegocharging', 'findchargewash',
|
||||
'backtowashmop', 'gowash', 'gowashing', 'summon'
|
||||
}:
|
||||
return VacuumActivity.RETURNING
|
||||
if (status_str.find('sweeping')
|
||||
!= -1) or (status_str.find('mopping')
|
||||
!= -1) or (status_str in {
|
||||
'cleaning', 'remoteclean', 'continuesweep',
|
||||
'busy', 'building', 'buildingmap', 'mapping'
|
||||
}):
|
||||
return VacuumActivity.CLEANING
|
||||
if status_str in {'error', 'breakcharging', 'gochargebreak'}:
|
||||
return VacuumActivity.ERROR
|
||||
return VacuumActivity.IDLE
|
||||
except ImportError:
|
||||
return status_value
|
||||
|
||||
@property
|
||||
def battery_level(self) -> Optional[int]:
|
||||
"""Return the current battery level of the vacuum cleaner."""
|
||||
"""The current battery level of the vacuum cleaner."""
|
||||
return self.get_prop_value(prop=self._prop_battery_level)
|
||||
|
||||
@property
|
||||
def fan_speed(self) -> Optional[str]:
|
||||
"""Return the current fan speed of the vacuum cleaner."""
|
||||
"""The current fan speed of the vacuum cleaner."""
|
||||
return self.get_map_value(
|
||||
map_=self._fan_level_map,
|
||||
key=self.get_prop_value(prop=self._prop_fan_level))
|
||||
|
@ -141,12 +141,11 @@ class WaterHeater(MIoTServiceEntity, WaterHeaterEntity):
|
||||
continue
|
||||
self._mode_map = prop.value_list.to_map()
|
||||
self._attr_operation_list = list(self._mode_map.values())
|
||||
self._attr_supported_features |= (
|
||||
WaterHeaterEntityFeature.OPERATION_MODE)
|
||||
self._prop_mode = prop
|
||||
if not self._attr_operation_list:
|
||||
self._attr_operation_list = [STATE_ON]
|
||||
self._attr_operation_list.append(STATE_OFF)
|
||||
self._attr_supported_features |= WaterHeaterEntityFeature.OPERATION_MODE
|
||||
|
||||
async def async_turn_on(self) -> None:
|
||||
"""Turn the water heater on."""
|
||||
@ -197,5 +196,5 @@ class WaterHeater(MIoTServiceEntity, WaterHeaterEntity):
|
||||
return STATE_OFF
|
||||
if not self._prop_mode and self.get_prop_value(prop=self._prop_on):
|
||||
return STATE_ON
|
||||
return self.get_map_value(map_=self._mode_map,
|
||||
key=self.get_prop_value(prop=self._prop_mode))
|
||||
return (None if self._prop_mode is None else self.get_map_value(
|
||||
map_=self._mode_map, key=self.get_prop_value(prop=self._prop_mode)))
|
||||
|
@ -157,6 +157,8 @@ git checkout v1.0.0
|
||||
|
||||
转换后的实体为 Event,事件参数同时传递给实体的 `_trigger_event` 。
|
||||
|
||||
MIoT-Spec-V2 事件的 arguments 字段是事件的参数列表,列表元素代表同服务下属性的 piid 。例如,小米智能无线开关(双开)的 [MIoT-Spec-V2](http://poc.miot-spec.srv/miot-spec-v2/instance?type=urn:miot-spec-v2:device:remote-control:0000A021:xiaomi-mcn002:1:0000D057)的 siid=2 无线开关服务下包含 eiid=1014 长按事件,该事件触发时会携带一个 piid=2 的按键类型属性作为事件参数, debug 等级日志会打印 `长按, attributes: {'按键类型': 1}` (日志示例,按键类型为 1 表示右键触发了长按事件)。
|
||||
|
||||
- 方法(Action)
|
||||
|
||||
| in(输入参数列表) | 转换后的实体 |
|
||||
@ -291,39 +293,37 @@ event instance name 下的值表示转换后实体所用的 `_attr_device_class`
|
||||
|
||||
### MIoT-Spec-V2 过滤规则
|
||||
|
||||
`spec_filter.json` 用于过滤掉不需要的 MIoT-Spec-V2 实例,过滤掉的实例不会转换成 Home Assistant 实体。
|
||||
`spec_filter.yaml` 用于过滤掉不需要的 MIoT-Spec-V2 实例,过滤掉的实例不会转换成 Home Assistant 实体。
|
||||
|
||||
`spec_filter.json`的格式如下:
|
||||
`spec_filter.yaml`的格式如下:
|
||||
|
||||
```
|
||||
{
|
||||
"<MIoT-Spec-V2 device instance>":{
|
||||
"services": list<service_iid: str>,
|
||||
"properties": list<service_iid.property_iid: str>,
|
||||
"events": list<service_iid.event_iid: str>,
|
||||
"actions": list<service_iid.action_iid: str>,
|
||||
}
|
||||
}
|
||||
```yaml
|
||||
<MIoT-Spec-V2 device instance urn without the version field>:
|
||||
services: list<service_iid: str>
|
||||
properties: list<service_iid.property_iid: str>
|
||||
events: list<service_iid.event_iid: str>
|
||||
actions: list<service_iid.action_iid: str>
|
||||
```
|
||||
|
||||
`spec_filter.json` 的键值为 MIoT-Spec-V2 设备实例的 urn (不含版本号“version”字段)。一个产品的不同版本的固件可能会关联不同版本的 MIoT-Spec-V2 设备实例。 MIoT 平台要求厂商定义产品的 MIoT-Spec-V2 时,高版本的 MIoT-Spec-V2 实例必须包含全部低版本的 MIoT-Spec-V2 实例。因此, `spec_filter.json` 的键值不需要指定设备实例的版本号。
|
||||
`spec_filter.yaml` 的键值为 MIoT-Spec-V2 设备实例的 urn (不含版本号“version”字段)。一个产品的不同版本的固件可能会关联不同版本的 MIoT-Spec-V2 设备实例。 MIoT 平台要求厂商定义产品的 MIoT-Spec-V2 时,高版本的 MIoT-Spec-V2 实例必须包含全部低版本的 MIoT-Spec-V2 实例。因此, `spec_filter.yaml` 的键值不需要指定设备实例的版本号。
|
||||
|
||||
设备实例下的 services 、 properties 、 events 、 actions 域的值表示需要过滤掉的服务、属性、事件、方法的实例号( iid ,即 instance id )。支持通配符匹配。
|
||||
|
||||
示例:
|
||||
|
||||
```
|
||||
{
|
||||
"urn:miot-spec-v2:device:television:0000A010:xiaomi-rmi1":{
|
||||
"services": ["*"] # Filter out all services. It is equivalent to completely ignoring the device with such MIoT-Spec-V2 device instance.
|
||||
},
|
||||
"urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1": {
|
||||
"services": ["3"], # Filter out the service whose iid=3.
|
||||
"properties": ["4.*"] # Filter out all properties in the service whose iid=4.
|
||||
"events": ["4.1"], # Filter out the iid=1 event in the iid=4 service.
|
||||
"actions": ["4.1"] # Filter out the iid=1 action in the iid=4 service.
|
||||
}
|
||||
}
|
||||
```yaml
|
||||
urn:miot-spec-v2:device:television:0000A010:xiaomi-rmi1:
|
||||
services:
|
||||
- '*' # 排除所有服务,相当于排除拥有该 MIoT-Spec-V2 的设备。
|
||||
urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1:
|
||||
services:
|
||||
- '3' # 排除 siid=3 的服务。
|
||||
properties:
|
||||
- '4.*' # 排除 siid=4 服务的所有属性。
|
||||
events:
|
||||
- '4.1' # 排除 siid=4 服务的 eiid=1 的事件。
|
||||
actions:
|
||||
- '4.1' # 排除 siid=4 服务的 aiid=1 的方法。
|
||||
```
|
||||
|
||||
所有设备的设备信息服务( urn:miot-spec-v2:service:device-information:00007801 )均不会生成 Home Assistant 实体。
|
||||
@ -378,7 +378,7 @@ siid、piid、eiid、aiid、value 均为十进制三位整数。
|
||||
}
|
||||
```
|
||||
|
||||
> 在 Home Assistant 中修改了 `custom_components/xiaomi_home/miot/specs` 路径下的 `specv2entity.py`、`spec_filter.json`、`multi_lang.json` 文件的内容,需要在集成配置中更新实体转换规则才能生效。方法:[设置 > 设备与服务 > 已配置 > Xiaomi Home](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home) > 配置 > 更新实体转换规则
|
||||
> 在 Home Assistant 中修改了 `custom_components/xiaomi_home/miot/specs` 路径下的任何文件(`spec_filter.yaml`、`spec_modify.yaml`、`multi_lang.json`等),需要在集成配置中更新实体转换规则才能生效。方法:[设置 > 设备与服务 > 已配置 > Xiaomi Home](https://my.home-assistant.io/redirect/integration/?domain=xiaomi_home) > 配置 > 更新实体转换规则
|
||||
|
||||
## 文档
|
||||
|
||||
|
Reference in New Issue
Block a user