mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2026-01-17 07:10:44 +08:00
fix: required property in optional service
This commit is contained in:
parent
593d7d3c0a
commit
24ef393474
@ -436,7 +436,7 @@ 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, 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 +454,21 @@ 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, 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 +486,22 @@ 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(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user