mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-17 23:50:42 +08:00
Compare commits
6 Commits
4e48d42cd1
...
73ab8fa9f7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73ab8fa9f7 | ||
|
|
75390a3d83 | ||
|
|
86a739b503 | ||
|
|
1258d3f3d3 | ||
|
|
64d9d54170 | ||
|
|
059eee33e0 |
15
CHANGELOG.md
15
CHANGELOG.md
@ -1,4 +1,19 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
## v0.4.6
|
||||||
|
### Added
|
||||||
|
- Add tv-box device as the media player entity. [#1562](https://github.com/XiaoMi/ha_xiaomi_home/pull/1562)
|
||||||
|
- Set play-control service's play-loop-mode property as the sound mode. [#1562](https://github.com/XiaoMi/ha_xiaomi_home/pull/1562)
|
||||||
|
### Changed
|
||||||
|
- Use constant value to indicate the cloud MQTT broker host domain. [#1530](https://github.com/XiaoMi/ha_xiaomi_home/pull/1530)
|
||||||
|
- Use constant value to indicate the timer delay of refreshing devices. [#1555](https://github.com/XiaoMi/ha_xiaomi_home/pull/1555)
|
||||||
|
- Set the playing-state property as the required property in the play-control service of the speaker device. [#1552](https://github.com/XiaoMi/ha_xiaomi_home/pull/1552)
|
||||||
|
- Set the playing-state property as the required property in the optional play-control service of the television. [#1562](https://github.com/XiaoMi/ha_xiaomi_home/pull/1562)
|
||||||
|
### Fixed
|
||||||
|
- Catch paho-mqtt subscribe error properly. [#1551](https://github.com/XiaoMi/ha_xiaomi_home/pull/1551)
|
||||||
|
- After the network resumes, keep retrying to fetch the device list until it succeeds. [#1555](https://github.com/XiaoMi/ha_xiaomi_home/pull/1555)
|
||||||
|
- Catch the http post error properly. [#1555](https://github.com/XiaoMi/ha_xiaomi_home/pull/1555)
|
||||||
|
- Fixed the format and the access field of daikin.aircondition.k2 and fix: daikin.airfresh.k33 string value properties. [#1561](https://github.com/XiaoMi/ha_xiaomi_home/pull/1561)
|
||||||
|
|
||||||
## v0.4.5
|
## v0.4.5
|
||||||
### Changed
|
### Changed
|
||||||
- Ignore mdns REMOVED package. [#1296](https://github.com/XiaoMi/ha_xiaomi_home/pull/1296)
|
- Ignore mdns REMOVED package. [#1296](https://github.com/XiaoMi/ha_xiaomi_home/pull/1296)
|
||||||
|
|||||||
@ -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):
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
"cryptography",
|
"cryptography",
|
||||||
"psutil"
|
"psutil"
|
||||||
],
|
],
|
||||||
"version": "v0.4.5",
|
"version": "v0.4.6",
|
||||||
"zeroconf": [
|
"zeroconf": [
|
||||||
"_miot-central._tcp.local."
|
"_miot-central._tcp.local."
|
||||||
]
|
]
|
||||||
|
|||||||
@ -436,7 +436,8 @@ class MIoTDevice:
|
|||||||
optional_properties: dict
|
optional_properties: dict
|
||||||
required_actions: set
|
required_actions: set
|
||||||
optional_actions: set
|
optional_actions: set
|
||||||
# 2. The service shall have all required properties, actions.
|
# 2. The required service shall have all required properties
|
||||||
|
# and actions.
|
||||||
if service.name in required_services:
|
if service.name in required_services:
|
||||||
required_properties = SPEC_DEVICE_TRANS_MAP[spec_name][
|
required_properties = SPEC_DEVICE_TRANS_MAP[spec_name][
|
||||||
'required'].get(
|
'required'].get(
|
||||||
@ -454,6 +455,23 @@ class MIoTDevice:
|
|||||||
'required'].get(
|
'required'].get(
|
||||||
service.name, {}
|
service.name, {}
|
||||||
).get('optional', {}).get('actions', set({}))
|
).get('optional', {}).get('actions', set({}))
|
||||||
|
if not {
|
||||||
|
prop.name for prop in service.properties if prop.access
|
||||||
|
}.issuperset(set(required_properties.keys())):
|
||||||
|
return None
|
||||||
|
if not {
|
||||||
|
action.name for action in service.actions
|
||||||
|
}.issuperset(required_actions):
|
||||||
|
return None
|
||||||
|
# 3. The required property in required service shall have all
|
||||||
|
# required access mode.
|
||||||
|
for prop in service.properties:
|
||||||
|
if prop.name in required_properties:
|
||||||
|
if not set(prop.access).issuperset(
|
||||||
|
required_properties[prop.name]):
|
||||||
|
return None
|
||||||
|
# 4. The optional service shall have all required properties
|
||||||
|
# and actions.
|
||||||
elif service.name in optional_services:
|
elif service.name in optional_services:
|
||||||
required_properties = SPEC_DEVICE_TRANS_MAP[spec_name][
|
required_properties = SPEC_DEVICE_TRANS_MAP[spec_name][
|
||||||
'optional'].get(
|
'optional'].get(
|
||||||
@ -471,22 +489,23 @@ class MIoTDevice:
|
|||||||
'optional'].get(
|
'optional'].get(
|
||||||
service.name, {}
|
service.name, {}
|
||||||
).get('optional', {}).get('actions', set({}))
|
).get('optional', {}).get('actions', set({}))
|
||||||
|
if not {
|
||||||
|
prop.name for prop in service.properties if prop.access
|
||||||
|
}.issuperset(set(required_properties.keys())):
|
||||||
|
continue
|
||||||
|
if not {
|
||||||
|
action.name for action in service.actions
|
||||||
|
}.issuperset(required_actions):
|
||||||
|
continue
|
||||||
|
# 5. The required property in optional service shall have all
|
||||||
|
# required access mode.
|
||||||
|
for prop in service.properties:
|
||||||
|
if prop.name in required_properties:
|
||||||
|
if not set(prop.access).issuperset(
|
||||||
|
required_properties[prop.name]):
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
if not {
|
|
||||||
prop.name for prop in service.properties if prop.access
|
|
||||||
}.issuperset(set(required_properties.keys())):
|
|
||||||
return None
|
|
||||||
if not {
|
|
||||||
action.name for action in service.actions
|
|
||||||
}.issuperset(required_actions):
|
|
||||||
return None
|
|
||||||
# 3. The required property shall have all required access mode.
|
|
||||||
for prop in service.properties:
|
|
||||||
if prop.name in required_properties:
|
|
||||||
if not set(prop.access).issuperset(
|
|
||||||
required_properties[prop.name]):
|
|
||||||
return None
|
|
||||||
# property
|
# property
|
||||||
for prop in service.properties:
|
for prop in service.properties:
|
||||||
if prop.name in set.union(
|
if prop.name in set.union(
|
||||||
|
|||||||
@ -331,6 +331,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
'actions': {'play'}
|
'actions': {'play'}
|
||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
|
'properties': {'play-loop-mode'},
|
||||||
'actions': {'pause', 'stop', 'next', 'previous'}
|
'actions': {'pause', 'stop', 'next', 'previous'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,9 +363,49 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
|||||||
},
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
'play-control': {
|
'play-control': {
|
||||||
'required': {},
|
'required': {
|
||||||
|
'properties': {
|
||||||
|
'playing-state': {'read'}
|
||||||
|
}
|
||||||
|
},
|
||||||
'optional': {
|
'optional': {
|
||||||
'properties': {'playing-state'},
|
'properties': {'play-loop-mode'},
|
||||||
|
'actions': {'play', 'pause', 'stop', 'next', 'previous'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'entity': 'television'
|
||||||
|
},
|
||||||
|
'tv-box':{
|
||||||
|
'required': {
|
||||||
|
'speaker': {
|
||||||
|
'required': {
|
||||||
|
'properties': {
|
||||||
|
'volume': {'read', 'write'}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'optional': {
|
||||||
|
'properties': {'mute'}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'tv-box': {
|
||||||
|
'required': {
|
||||||
|
'actions': {'turn-off'}
|
||||||
|
},
|
||||||
|
'optional': {
|
||||||
|
'actions': {'turn-on'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'optional': {
|
||||||
|
'play-control': {
|
||||||
|
'required': {
|
||||||
|
'properties': {
|
||||||
|
'playing-state': {'read'}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'optional': {
|
||||||
|
'properties': {'play-loop-mode'},
|
||||||
'actions': {'play', 'pause', 'stop', 'next', 'previous'}
|
'actions': {'play', 'pause', 'stop', 'next', 'previous'}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user