mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-16 06:30:44 +08:00
Compare commits
3 Commits
e332074ffc
...
1908368fb2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1908368fb2 | ||
|
|
947169f18d | ||
|
|
059eee33e0 |
@ -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):
|
||||
|
||||
@ -89,6 +89,7 @@ SUPPORTED_PLATFORMS: list = [
|
||||
|
||||
UNSUPPORTED_MODELS: list = [
|
||||
'chuangmi.ir.v2',
|
||||
'hmpace.motion.v6nfc',
|
||||
'xiaomi.router.rd03'
|
||||
]
|
||||
|
||||
|
||||
@ -22,6 +22,10 @@ urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-c35:2: urn:miot-spec-v2:
|
||||
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-h43h00:1:
|
||||
prop.10.6:
|
||||
unit: none
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-h43h00:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-h43h00:1
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-m16:1:
|
||||
prop.10.6:
|
||||
unit: none
|
||||
@ -41,6 +45,12 @@ 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-conditioner:0000A004:xiaomi-rr0r00:1:
|
||||
prop.10.6:
|
||||
unit: none
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:2: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:1
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:3: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:1
|
||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:4: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:1
|
||||
urn:miot-spec-v2:device:air-monitor:0000A008:cgllc-cgd1st:1:
|
||||
prop.3.7:
|
||||
value-range:
|
||||
@ -130,6 +140,12 @@ urn:miot-spec-v2:device:fan:0000A005:xiaomi-p51:1:
|
||||
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:xiaomi-p70:1:0000D062:
|
||||
prop.2.4:
|
||||
name: fan-level-a
|
||||
urn:miot-spec-v2:device:fan:0000A005:xiaomi-p76: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
|
||||
@ -175,6 +191,10 @@ urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:2: urn:miot-spec-v2:device:hood
|
||||
urn:miot-spec-v2:device:hood:0000A01B:cykj-jyj22:3:
|
||||
prop.3.1:
|
||||
name: on-ventilation
|
||||
urn:miot-spec-v2:device:humidifier:0000A00E:zhimi-ca4:2:
|
||||
prop.2.7:
|
||||
unit: percentage
|
||||
expr: round(src_value*0.83)
|
||||
urn:miot-spec-v2:device:kettle:0000A009:yunmi-r3:1:
|
||||
prop.3.1:
|
||||
unit: ppm
|
||||
|
||||
Loading…
Reference in New Issue
Block a user