diff --git a/CHANGELOG.md b/CHANGELOG.md index ef3c596..f60eb14 100644 --- a/CHANGELOG.md +++ b/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) diff --git a/custom_components/xiaomi_home/manifest.json b/custom_components/xiaomi_home/manifest.json index 9632041..9db0ec1 100644 --- a/custom_components/xiaomi_home/manifest.json +++ b/custom_components/xiaomi_home/manifest.json @@ -25,7 +25,7 @@ "cryptography", "psutil" ], - "version": "v0.4.5", + "version": "v0.4.6", "zeroconf": [ "_miot-central._tcp.local." ] diff --git a/custom_components/xiaomi_home/miot/miot_device.py b/custom_components/xiaomi_home/miot/miot_device.py index a585800..011676c 100644 --- a/custom_components/xiaomi_home/miot/miot_device.py +++ b/custom_components/xiaomi_home/miot/miot_device.py @@ -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( diff --git a/custom_components/xiaomi_home/miot/specs/specv2entity.py b/custom_components/xiaomi_home/miot/specs/specv2entity.py index c824ecd..adb96cf 100644 --- a/custom_components/xiaomi_home/miot/specs/specv2entity.py +++ b/custom_components/xiaomi_home/miot/specs/specv2entity.py @@ -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'} } }