From 3402587b1c3f6eec08fc7942fa797b09e473d47a Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Mon, 23 Jun 2025 16:21:39 +0800 Subject: [PATCH 1/7] Fix specs (#1187) * fix: 090615.switch.x1tpm English switch name (#1122) * fix: dmaker.fan.p33 fan-level (#1165) * fix: humidity-range string value unit (#1179) --- .../xiaomi_home/miot/specs/multi_lang.json | 7 +++++ .../xiaomi_home/miot/specs/spec_modify.yaml | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/custom_components/xiaomi_home/miot/specs/multi_lang.json b/custom_components/xiaomi_home/miot/specs/multi_lang.json index d1f51ca..68d2fb9 100644 --- a/custom_components/xiaomi_home/miot/specs/multi_lang.json +++ b/custom_components/xiaomi_home/miot/specs/multi_lang.json @@ -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", diff --git a/custom_components/xiaomi_home/miot/specs/spec_modify.yaml b/custom_components/xiaomi_home/miot/specs/spec_modify.yaml index 3d034fa..b3d2b8f 100644 --- a/custom_components/xiaomi_home/miot/specs/spec_modify.yaml +++ b/custom_components/xiaomi_home/miot/specs/spec_modify.yaml @@ -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,6 +21,11 @@ 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 @@ -58,6 +75,15 @@ 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: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 From d659d13e49ca87dca7f55e34c5543d9f99b20740 Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Mon, 23 Jun 2025 16:40:29 +0800 Subject: [PATCH 2/7] docs: update changelog and version to v0.3.3 (#1188) --- CHANGELOG.md | 14 ++++++++++++++ custom_components/xiaomi_home/manifest.json | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65d5922..1a18c3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,18 @@ # CHANGELOG +## 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 diff --git a/custom_components/xiaomi_home/manifest.json b/custom_components/xiaomi_home/manifest.json index 9d3c97e..5c97f6a 100644 --- a/custom_components/xiaomi_home/manifest.json +++ b/custom_components/xiaomi_home/manifest.json @@ -25,7 +25,7 @@ "cryptography", "psutil" ], - "version": "v0.3.2", + "version": "v0.3.3", "zeroconf": [ "_miot-central._tcp.local." ] From 664787ca5839e2da54883976774a600d7979a3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A9=E6=88=90?= Date: Fri, 27 Jun 2025 17:52:39 +0800 Subject: [PATCH 3/7] fix: ptx air-conditioner environment temperature (#1210) * fix: ptx air-conditioner temperature #1163 * fix: environment temperature siid and piid --- .../xiaomi_home/miot/specs/spec_add.json | 25 +++++++++++++++++++ .../xiaomi_home/miot/specs/spec_filter.yaml | 3 +++ 2 files changed, 28 insertions(+) diff --git a/custom_components/xiaomi_home/miot/specs/spec_add.json b/custom_components/xiaomi_home/miot/specs/spec_add.json index dac4a9a..64f5113 100644 --- a/custom_components/xiaomi_home/miot/specs/spec_add.json +++ b/custom_components/xiaomi_home/miot/specs/spec_add.json @@ -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, diff --git a/custom_components/xiaomi_home/miot/specs/spec_filter.yaml b/custom_components/xiaomi_home/miot/specs/spec_filter.yaml index 12625ac..c1bca60 100644 --- a/custom_components/xiaomi_home/miot/specs/spec_filter.yaml +++ b/custom_components/xiaomi_home/miot/specs/spec_filter.yaml @@ -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.* From 096b33f3c9a9ba91fd59b49d9360c9349e62946f Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Mon, 30 Jun 2025 11:11:36 +0800 Subject: [PATCH 4/7] fix: the operation mode when the device does not have a mode property (#1199) --- custom_components/xiaomi_home/water_heater.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/custom_components/xiaomi_home/water_heater.py b/custom_components/xiaomi_home/water_heater.py index 8830197..e28e8ff 100644 --- a/custom_components/xiaomi_home/water_heater.py +++ b/custom_components/xiaomi_home/water_heater.py @@ -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))) From fd57e7c565e82a397615a198e445fedabf958392 Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Mon, 30 Jun 2025 11:12:18 +0800 Subject: [PATCH 5/7] fix: reconnect delay time (#1200) * fix: reset the reconnect interval when connected (#1175) * feat: set the default reconnect delay time as 10 seconds * fix: get the minimum reconnect interval --- custom_components/xiaomi_home/miot/miot_mips.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/xiaomi_home/miot/miot_mips.py b/custom_components/xiaomi_home/miot/miot_mips.py index 4513aef..5cf884d 100644 --- a/custom_components/xiaomi_home/miot/miot_mips.py +++ b/custom_components/xiaomi_home/miot/miot_mips.py @@ -216,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 @@ -641,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) @@ -822,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( @@ -830,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.""" From 6069eaaba8dbd51ee6159a878d0ff9eb4152a42d Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Mon, 30 Jun 2025 11:12:58 +0800 Subject: [PATCH 6/7] feat: exclude unsupported model (#1205) * feat: ignore unsupported models (#933) * fix: remove unnecessary logs --- custom_components/xiaomi_home/miot/const.py | 5 +++++ custom_components/xiaomi_home/miot/miot_cloud.py | 5 +++++ custom_components/xiaomi_home/miot/miot_device.py | 5 ++--- custom_components/xiaomi_home/miot/miot_mips.py | 5 ++++- custom_components/xiaomi_home/miot/specs/spec_filter.yaml | 3 --- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/custom_components/xiaomi_home/miot/const.py b/custom_components/xiaomi_home/miot/const.py index 275b297..ba356b8 100644 --- a/custom_components/xiaomi_home/miot/const.py +++ b/custom_components/xiaomi_home/miot/const.py @@ -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': '中国大陆', diff --git a/custom_components/xiaomi_home/miot/miot_cloud.py b/custom_components/xiaomi_home/miot/miot_cloud.py index 0b301e8..91d94b0 100644 --- a/custom_components/xiaomi_home/miot/miot_cloud.py +++ b/custom_components/xiaomi_home/miot/miot_cloud.py @@ -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), diff --git a/custom_components/xiaomi_home/miot/miot_device.py b/custom_components/xiaomi_home/miot/miot_device.py index e3394c9..500734c 100644 --- a/custom_components/xiaomi_home/miot/miot_device.py +++ b/custom_components/xiaomi_home/miot/miot_device.py @@ -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]: diff --git a/custom_components/xiaomi_home/miot/miot_mips.py b/custom_components/xiaomi_home/miot/miot_mips.py index 5cf884d..8eab9ee 100644 --- a/custom_components/xiaomi_home/miot/miot_mips.py +++ b/custom_components/xiaomi_home/miot/miot_mips.py @@ -68,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__) @@ -1365,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, diff --git a/custom_components/xiaomi_home/miot/specs/spec_filter.yaml b/custom_components/xiaomi_home/miot/specs/spec_filter.yaml index c1bca60..a7116fb 100644 --- a/custom_components/xiaomi_home/miot/specs/spec_filter.yaml +++ b/custom_components/xiaomi_home/miot/specs/spec_filter.yaml @@ -44,9 +44,6 @@ urn:miot-spec-v2:device:motion-sensor:0000A014:xiaomi-pir1: services: - '1' - '5' -urn:miot-spec-v2:device:router:0000A036:xiaomi-rd03: - services: - - '*' urn:miot-spec-v2:device:thermostat:0000A031:tofan-wk01: services: - '2' From 5b1d003bb233549a323fed0fe016af4a631fafba Mon Sep 17 00:00:00 2001 From: Li Shuzhen Date: Mon, 30 Jun 2025 11:27:12 +0800 Subject: [PATCH 7/7] feat: subscribe the BLE device up messages even though the device is offline (#1207) * feat: subscribe the BLE device up messages even though the device is offline (#1170) * fix: set all BLE devices online --- custom_components/xiaomi_home/miot/miot_client.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/custom_components/xiaomi_home/miot/miot_client.py b/custom_components/xiaomi_home/miot/miot_client.py index cdfe110..377822d 100644 --- a/custom_components/xiaomi_home/miot/miot_client.py +++ b/custom_components/xiaomi_home/miot/miot_client.py @@ -1354,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