Compare commits

...

4 Commits

Author SHA1 Message Date
ohyeah521
6525ccbc71
Merge 059eee33e0 into 3f2c2a648b 2025-08-01 16:40:09 +08:00
Li Shuzhen
3f2c2a648b
Fix specs (#1329)
Some checks failed
Tests / check-rule-format (push) Has been cancelled
Validate / validate-hassfest (push) Has been cancelled
Validate / validate-hacs (push) Has been cancelled
Validate / validate-lint (push) Has been cancelled
Validate / validate-setup (push) Has been cancelled
* fix: cuco.plug.cp2d electric current (#1279)

* fix: xiaomi.fan.p45 fan level (#1291)

* docs: add necessary notices

* fix: xiaomi.aircondition.c17 humidity-range unit (#1308)

* fix: xiaomi.airc.h40h00 humidity-range unit

* fix: sanmei.valve.s1 power consumption, current and voltage (#1327)

* fix: xiaomi.aircondition.m16 humidity-range unit
2025-08-01 14:56:42 +08:00
Li Shuzhen
f11b2f2f68
fix: hide sensitive info in printing logs (#1328) 2025-08-01 14:54:33 +08:00
ohyeah521
059eee33e0
Fix #1309 #1124
# HomeKit Bridge: fan_modes must be "auto"、"low"、"medium"、"high"
2025-07-28 23:23:21 +08:00
5 changed files with 71 additions and 9 deletions

View File

@ -5,8 +5,8 @@ body:
attributes:
label: Describe the Bug / 描述问题
description: |
> A clear and concise description of what the bug is.
> 清晰且简明地描述问题。
> A clear and concise description of what the bug is. Please include the device model information (Like xiaomi.gateway.hub1 which can be found in Device info page).
> 清晰且简明地描述问题。请注明设备 model 信息(例如 xiaomi.gateway.hub1可在设备详情页查询
validations:
required: true

View File

@ -224,6 +224,15 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
_prop_fan_level: Optional[MIoTSpecProperty]
_fan_mode_map: Optional[dict[int, str]]
# HomeKit Bridge: fan_modes must be "auto"、"low"、"medium"、"high"
_fan_mode_translation_map = {
"自动": "auto",
"低风": "low",
"中风": "medium",
"高风": "high",
}
_fan_mode_translation_map_rev = {v: k for k, v in _fan_mode_translation_map.items()}
def __init__(self, miot_device: MIoTDevice,
entity_data: MIoTEntityData) -> None:
"""Initialize the feature class."""
@ -243,7 +252,13 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
self.entity_id)
continue
self._fan_mode_map = prop.value_list.to_map()
self._attr_fan_modes = prop.value_list.descriptions
# save org fan speed
self._raw_fan_modes = prop.value_list.descriptions
self._attr_fan_modes = [
self._fan_mode_translation_map.get(mode, mode)
for mode in self._raw_fan_modes
]
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
self._prop_fan_level = prop
elif prop.name == 'on' and prop.service.name == 'fan-control':
@ -264,7 +279,11 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
if fan_mode == FAN_ON:
await self.set_property_async(prop=self._prop_fan_on, value=True)
return
mode_value = self.get_map_key(map_=self._fan_mode_map, value=fan_mode)
chinese_fan_mode = self._fan_mode_translation_map_rev.get(fan_mode, fan_mode)
mode_value = self.get_map_key(map_=self._fan_mode_map, value=chinese_fan_mode)
if mode_value is None or not await self.set_property_async(
prop=self._prop_fan_level, value=mode_value):
raise RuntimeError(f'set climate prop.fan_mode failed, {fan_mode}, '
@ -278,9 +297,15 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
if self._prop_fan_level is None and self._prop_fan_on:
return (FAN_ON if self.get_prop_value(
prop=self._prop_fan_on) else FAN_OFF)
return self.get_map_value(
current_chinese_mode = self.get_map_value(
map_=self._fan_mode_map,
key=self.get_prop_value(prop=self._prop_fan_level))
if current_chinese_mode is None:
return None
return self._fan_mode_translation_map.get(current_chinese_mode, current_chinese_mode)
class FeatureSwingMode(MIoTServiceEntity, ClimateEntity):

View File

@ -253,7 +253,18 @@ class MIoTClient:
if not self._user_config:
# Integration need to be add again
raise MIoTClientError('load_user_config_async error')
_LOGGER.debug('user config, %s', json.dumps(self._user_config))
# Hide sensitive info in printing
p_user_config: dict = deepcopy(self._user_config)
p_access_token: str = p_user_config['auth_info']['access_token']
p_refresh_token: str = p_user_config['auth_info']['refresh_token']
p_mac_key: str = p_user_config['auth_info']['mac_key']
p_user_config['auth_info'][
'access_token'] = f"{p_access_token[:5]}***{p_access_token[-5:]}"
p_user_config['auth_info'][
'refresh_token'] = f"{p_refresh_token[:5]}***{p_refresh_token[-5:]}"
p_user_config['auth_info'][
'mac_key'] = f"{p_mac_key[:5]}***{p_mac_key[-5:]}"
_LOGGER.debug('user config, %s', json.dumps(p_user_config))
# MIoT i18n client
self._i18n = MIoTI18n(
lang=self._entry_data.get(

View File

@ -1,6 +1,10 @@
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-c17:1:
prop.10.6:
unit: none
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c17:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c17:1
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c20:1:
prop.10.6:
unit: none
@ -15,6 +19,15 @@ 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-h40h00:1:
prop.10.6:
unit: none
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m16:1:
prop.10.6:
unit: none
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m16:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m16:1
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m16:3: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m16:1
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m16:4: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m16: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
@ -86,6 +99,13 @@ urn:miot-spec-v2:device:bath-heater:0000A028:xiaomi-s1:1:
urn:miot-spec-v2:device:curtain:0000A00C:bjkcz-kczble:1:0000D031:
prop.2.2:
name: status-a
urn:miot-spec-v2:device:electronic-valve:0000A0A7:sanmei-s1:1:
prop.3.1:
expr: round(src_value/100, 2)
prop.3.2:
expr: round(src_value/100, 2)
prop.3.3:
expr: round(src_value/10, 1)
urn:miot-spec-v2:device:fan:0000A005:dmaker-p33:1:
prop.2.2:
name: fan-level-a
@ -101,6 +121,9 @@ urn:miot-spec-v2:device:fan:0000A005:dmaker-p5:1:
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-p45:1:0000D062:
prop.2.4:
name: fan-level-a
urn:miot-spec-v2:device:fan:0000A005:xiaomi-p51:1:
prop.2.2:
name: fan-level-a
@ -172,7 +195,7 @@ urn:miot-spec-v2:device:magnet-sensor:0000A016:linp-m1:1:
description: open
- value: 1
description: closed
expr: src_value!=1
expr: (src_value!=1)
urn:miot-spec-v2:device:motion-sensor:0000A014:lumi-acn001:1:
prop.3.2:
access:
@ -213,6 +236,9 @@ urn:miot-spec-v2:device:outlet:0000A002:cuco-cp2:2:
unit: mA
prop.3.2:
expr: round(src_value/10, 1)
urn:miot-spec-v2:device:outlet:0000A002:cuco-cp2d:1:
prop.3.2:
expr: round(src_value/1000, 2)
urn:miot-spec-v2:device:outlet:0000A002:cuco-v3:1:
prop.11.1:
name: power-consumption
@ -257,7 +283,7 @@ urn:miot-spec-v2:device:router:0000A036:xiaomi-rd08:1:
urn:miot-spec-v2:device:safe-box:0000A042:loock-v1:1:
prop.5.1:
name: contact-state
expr: src_value!=1
expr: (src_value!=1)
urn:miot-spec-v2:device:switch:0000A003:090615-x1tpm:1:0000D042:
prop.27.3:
name: light-on

View File

@ -93,7 +93,7 @@ git checkout v1.0.0
- 米家集成是否支持本地化控制?
米家集成支持通过[小米中枢网关](https://www.mi.com/shop/buy/detail?product_id=15755&cfrom=search)(固件版本 3.4.0_000 以上)或内置中枢网关(软件版本 0.8.0 以上)的米家设备实现本地化控制。如果没有小米中枢网关或其他带中枢网关功能的设备,那么所有控制指令都会通过小米云发送。支持 Home Assistant 本地化控制的小米中枢网关(含内置中枢网关)的固件尚未发布,固件升级计划请参阅 MIoT 团队的通知。
米家集成支持通过[小米中枢网关](https://www.mi.com/shop/buy/detail?product_id=15755&cfrom=search)(固件版本 3.3.0_0023 及以上)或内置中枢网关(软件版本 0.8.9 及以上)的米家设备实现本地化控制。如果没有小米中枢网关或其他带中枢网关功能的设备,那么所有控制指令都会通过小米云发送。支持 Home Assistant 本地化控制的小米中枢网关(含内置中枢网关)的固件尚未发布,固件升级计划请参阅 MIoT 团队的通知。
小米中枢网关仅在中国大陆可用,在其他地区不可用。