mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-18 16:10:44 +08:00
Compare commits
5 Commits
662216ccb1
...
84534dcfa7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84534dcfa7 | ||
|
|
a11c3e2fda | ||
|
|
1258d3f3d3 | ||
|
|
64d9d54170 | ||
|
|
059eee33e0 |
@ -224,6 +224,15 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
|
|||||||
_prop_fan_level: Optional[MIoTSpecProperty]
|
_prop_fan_level: Optional[MIoTSpecProperty]
|
||||||
_fan_mode_map: Optional[dict[int, str]]
|
_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,
|
def __init__(self, miot_device: MIoTDevice,
|
||||||
entity_data: MIoTEntityData) -> None:
|
entity_data: MIoTEntityData) -> None:
|
||||||
"""Initialize the feature class."""
|
"""Initialize the feature class."""
|
||||||
@ -243,7 +252,13 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
|
|||||||
self.entity_id)
|
self.entity_id)
|
||||||
continue
|
continue
|
||||||
self._fan_mode_map = prop.value_list.to_map()
|
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._attr_supported_features |= ClimateEntityFeature.FAN_MODE
|
||||||
self._prop_fan_level = prop
|
self._prop_fan_level = prop
|
||||||
elif prop.name == 'on' and prop.service.name == 'fan-control':
|
elif prop.name == 'on' and prop.service.name == 'fan-control':
|
||||||
@ -264,7 +279,11 @@ class FeatureFanMode(MIoTServiceEntity, ClimateEntity):
|
|||||||
if fan_mode == FAN_ON:
|
if fan_mode == FAN_ON:
|
||||||
await self.set_property_async(prop=self._prop_fan_on, value=True)
|
await self.set_property_async(prop=self._prop_fan_on, value=True)
|
||||||
return
|
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(
|
if mode_value is None or not await self.set_property_async(
|
||||||
prop=self._prop_fan_level, value=mode_value):
|
prop=self._prop_fan_level, value=mode_value):
|
||||||
raise RuntimeError(f'set climate prop.fan_mode failed, {fan_mode}, '
|
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:
|
if self._prop_fan_level is None and self._prop_fan_on:
|
||||||
return (FAN_ON if self.get_prop_value(
|
return (FAN_ON if self.get_prop_value(
|
||||||
prop=self._prop_fan_on) else FAN_OFF)
|
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,
|
map_=self._fan_mode_map,
|
||||||
key=self.get_prop_value(prop=self._prop_fan_level))
|
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):
|
class FeatureSwingMode(MIoTServiceEntity, ClimateEntity):
|
||||||
|
|||||||
@ -5,6 +5,12 @@
|
|||||||
"service:003:property:001:valuelist:001": "Dry"
|
"service:003:property:001:valuelist:001": "Dry"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"urn:miot-spec-v2:device:fan:0000A005:zhimi-za1": {
|
||||||
|
"zh-Hans": {
|
||||||
|
"service:002:property:005:valuelist:000": "自然风",
|
||||||
|
"service:002:property:005:valuelist:001": "直吹风"
|
||||||
|
}
|
||||||
|
},
|
||||||
"urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1": {
|
"urn:miot-spec-v2:device:gateway:0000A019:xiaomi-hub1": {
|
||||||
"de": {
|
"de": {
|
||||||
"service:001": "Geräteinformationen",
|
"service:001": "Geräteinformationen",
|
||||||
@ -274,13 +280,13 @@
|
|||||||
"service:002:property:002": "Air Conditioner Mode",
|
"service:002:property:002": "Air Conditioner Mode",
|
||||||
"service:004": "Air Conditioner"
|
"service:004": "Air Conditioner"
|
||||||
},
|
},
|
||||||
"zh_cn": {
|
"zh-Hans": {
|
||||||
"service:002": "地暖",
|
"service:002": "地暖",
|
||||||
"service:004": "空调"
|
"service:004": "空调"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"urn:miot-spec-v2:device:vacuum:0000A006:ijai-v1": {
|
"urn:miot-spec-v2:device:vacuum:0000A006:ijai-v1": {
|
||||||
"zh_cn": {
|
"zh-Hans": {
|
||||||
"service:007:property:005:valuelist:000": "安静",
|
"service:007:property:005:valuelist:000": "安静",
|
||||||
"service:007:property:005:valuelist:001": "标准",
|
"service:007:property:005:valuelist:001": "标准",
|
||||||
"service:007:property:005:valuelist:002": "中档",
|
"service:007:property:005:valuelist:002": "中档",
|
||||||
|
|||||||
@ -82,6 +82,22 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"urn:miot-spec-v2:device:speaker:0000A015:xiaomi-l05b:1": [
|
||||||
|
{
|
||||||
|
"iid": 3,
|
||||||
|
"type": "urn:miot-spec-v2:service:play:0000781D:xiaomi-l05b:1",
|
||||||
|
"description": "Play Control",
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"iid": 2,
|
||||||
|
"type": "urn:miot-spec-v2:action:play:0000280B:xiaomi-l05b:1",
|
||||||
|
"description": "Play",
|
||||||
|
"in": [],
|
||||||
|
"out": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"urn:miot-spec-v2:device:thermostat:0000A031:tofan-wk01:1:0000C822": [
|
"urn:miot-spec-v2:device:thermostat:0000A031:tofan-wk01:1:0000C822": [
|
||||||
{
|
{
|
||||||
"iid": 2,
|
"iid": 2,
|
||||||
@ -1660,6 +1676,24 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"urn:miot-spec-v2:device:vacuum:0000A006:roidmi-v60:3": [
|
||||||
|
{
|
||||||
|
"iid": 2,
|
||||||
|
"type": "urn:miot-spec-v2:service:vacuum:00007810:roidmi-v60:1",
|
||||||
|
"description": "Robot Cleaner",
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"iid": 3,
|
||||||
|
"type": "urn:miot-spec-v2:action:start-room-sweep:00002826:roidmi-v60:1",
|
||||||
|
"description": "Start Room Sweep",
|
||||||
|
"in": [
|
||||||
|
9
|
||||||
|
],
|
||||||
|
"out": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"urn:miot-spec-v2:device:water-heater:0000A02A:viomi-m1:2": [
|
"urn:miot-spec-v2:device:water-heater:0000A02A:viomi-m1:2": [
|
||||||
{
|
{
|
||||||
"iid": 2,
|
"iid": 2,
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
urn:miot-spec-v2:device:air-conditioner:0000A004:090615-ktf:
|
urn:miot-spec-v2:device:air-conditioner:0000A004:090615-ktf:
|
||||||
services:
|
services:
|
||||||
- '4'
|
- '4'
|
||||||
|
urn:miot-spec-v2:device:air-conditioner:0000A004:759413-iez:
|
||||||
|
properties:
|
||||||
|
- '2.3'
|
||||||
urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ma4:
|
urn:miot-spec-v2:device:air-purifier:0000A007:zhimi-ma4:
|
||||||
properties:
|
properties:
|
||||||
- 9.*
|
- 9.*
|
||||||
@ -44,6 +47,13 @@ urn:miot-spec-v2:device:motion-sensor:0000A014:xiaomi-pir1:
|
|||||||
services:
|
services:
|
||||||
- '1'
|
- '1'
|
||||||
- '5'
|
- '5'
|
||||||
|
urn:miot-spec-v2:device:speaker:0000A015:xiaomi-l15a:
|
||||||
|
properties:
|
||||||
|
- '3.3'
|
||||||
|
- '6.1'
|
||||||
|
- '6.2'
|
||||||
|
- '6.3'
|
||||||
|
- '6.4'
|
||||||
urn:miot-spec-v2:device:thermostat:0000A031:tofan-wk01:
|
urn:miot-spec-v2:device:thermostat:0000A031:tofan-wk01:
|
||||||
services:
|
services:
|
||||||
- '2'
|
- '2'
|
||||||
@ -54,3 +64,6 @@ urn:miot-spec-v2:device:vacuum:0000A006:narwa-001:
|
|||||||
urn:miot-spec-v2:device:vacuum:0000A006:narwa-ax11:
|
urn:miot-spec-v2:device:vacuum:0000A006:narwa-ax11:
|
||||||
services:
|
services:
|
||||||
- '*'
|
- '*'
|
||||||
|
urn:miot-spec-v2:device:vacuum:0000A006:roidmi-v60:
|
||||||
|
actions:
|
||||||
|
- '2.3'
|
||||||
|
|||||||
@ -48,6 +48,18 @@ urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-mt0:2: urn:miot-spec-v2:
|
|||||||
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:1:
|
urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:1:
|
||||||
prop.10.6:
|
prop.10.6:
|
||||||
unit: none
|
unit: none
|
||||||
|
prop.3.12:
|
||||||
|
name: vertical-swing-left-up
|
||||||
|
prop.3.13:
|
||||||
|
name: vertical-swing-left-down
|
||||||
|
prop.3.14:
|
||||||
|
name: vertical-swing-right-up
|
||||||
|
prop.3.15:
|
||||||
|
name: vertical-swing-right-down
|
||||||
|
prop.3.20:
|
||||||
|
name: horizontal-swing-left
|
||||||
|
prop.3.22:
|
||||||
|
name: horizontal-swing-right
|
||||||
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: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: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-conditioner:0000A004:xiaomi-rr0r00:4: urn:miot-spec-v2:device:air-conditioner:0000A004:xiaomi-rr0r00:1
|
||||||
@ -72,6 +84,8 @@ urn:miot-spec-v2:device:airer:0000A00D:hyd-lyjpro:1:
|
|||||||
name: target-position-a
|
name: target-position-a
|
||||||
prop.2.9:
|
prop.2.9:
|
||||||
name: target-position-b
|
name: target-position-b
|
||||||
|
prop.2.11:
|
||||||
|
expr: (100-src_value)
|
||||||
urn:miot-spec-v2:device:airer:0000A00D:hyd-znlyj5:1:
|
urn:miot-spec-v2:device:airer:0000A00D:hyd-znlyj5:1:
|
||||||
prop.2.3:
|
prop.2.3:
|
||||||
value-range:
|
value-range:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user