mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-16 14:40:43 +08:00
Compare commits
6 Commits
a5767e1ab1
...
9ed7a4c9f3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9ed7a4c9f3 | ||
|
|
75390a3d83 | ||
|
|
86a739b503 | ||
|
|
30a78c7689 | ||
|
|
eec13826d2 | ||
|
|
bf1caf50e1 |
15
CHANGELOG.md
15
CHANGELOG.md
@ -1,4 +1,19 @@
|
||||
# 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
|
||||
### Changed
|
||||
- Ignore mdns REMOVED package. [#1296](https://github.com/XiaoMi/ha_xiaomi_home/pull/1296)
|
||||
|
||||
@ -107,6 +107,7 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
_prop_position_value_range: Optional[int]
|
||||
_prop_pos_closing: bool
|
||||
_prop_pos_opening: bool
|
||||
_reverse_position: bool
|
||||
|
||||
def __init__(self, miot_device: MIoTDevice,
|
||||
entity_data: MIoTEntityData) -> None:
|
||||
@ -134,6 +135,8 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
self._prop_position_value_range = None
|
||||
self._prop_pos_closing = False
|
||||
self._prop_pos_opening = False
|
||||
# 新增:针对airer类型设备反转位置
|
||||
self._reverse_position = (entity_data.spec.device_class == CoverDeviceClass.BLIND)
|
||||
|
||||
# properties
|
||||
for prop in entity_data.props:
|
||||
@ -143,6 +146,8 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
self.entity_id)
|
||||
continue
|
||||
for item in prop.value_list.items:
|
||||
item_str: str = item.name
|
||||
item_name: str = re.sub(r'[^a-z]', '', item_str)
|
||||
if item.name in {'open', 'up'}:
|
||||
self._attr_supported_features |= (
|
||||
CoverEntityFeature.OPEN)
|
||||
@ -255,6 +260,10 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
if current is not None:
|
||||
self._prop_pos_opening = pos > current
|
||||
self._prop_pos_closing = pos < current
|
||||
# 针对airer类型设备反转位置
|
||||
if self._reverse_position:
|
||||
pos = 100 - pos
|
||||
|
||||
pos = round(pos * self._prop_position_value_range / 100)
|
||||
await self.set_property_async(prop=self._prop_target_position,
|
||||
value=pos)
|
||||
@ -282,6 +291,9 @@ class Cover(MIoTServiceEntity, CoverEntity):
|
||||
pos = 0
|
||||
elif pos >= (100 - self._cover_dead_zone_width):
|
||||
pos = 100
|
||||
# 针对airer类型设备反转位置
|
||||
if self._reverse_position:
|
||||
pos = 100 - pos
|
||||
return pos
|
||||
|
||||
@property
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
"cryptography",
|
||||
"psutil"
|
||||
],
|
||||
"version": "v0.4.5",
|
||||
"version": "v0.4.6",
|
||||
"zeroconf": [
|
||||
"_miot-central._tcp.local."
|
||||
]
|
||||
|
||||
@ -436,7 +436,8 @@ class MIoTDevice:
|
||||
optional_properties: dict
|
||||
required_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:
|
||||
required_properties = SPEC_DEVICE_TRANS_MAP[spec_name][
|
||||
'required'].get(
|
||||
@ -454,6 +455,23 @@ class MIoTDevice:
|
||||
'required'].get(
|
||||
service.name, {}
|
||||
).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:
|
||||
required_properties = SPEC_DEVICE_TRANS_MAP[spec_name][
|
||||
'optional'].get(
|
||||
@ -471,22 +489,23 @@ class MIoTDevice:
|
||||
'optional'].get(
|
||||
service.name, {}
|
||||
).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:
|
||||
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
|
||||
for prop in service.properties:
|
||||
if prop.name in set.union(
|
||||
|
||||
@ -331,6 +331,7 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
||||
'actions': {'play'}
|
||||
},
|
||||
'optional': {
|
||||
'properties': {'play-loop-mode'},
|
||||
'actions': {'pause', 'stop', 'next', 'previous'}
|
||||
}
|
||||
}
|
||||
@ -362,9 +363,49 @@ SPEC_DEVICE_TRANS_MAP: dict = {
|
||||
},
|
||||
'optional': {
|
||||
'play-control': {
|
||||
'required': {},
|
||||
'required': {
|
||||
'properties': {
|
||||
'playing-state': {'read'}
|
||||
}
|
||||
},
|
||||
'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'}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user