Improved zigbee.mqtt node property queries.

Now handling cases of nodes with values having multiple levels (> 1) of
nested properties.
This commit is contained in:
Fabio Manganiello 2022-11-04 22:51:40 +01:00
parent 5ca3c06f96
commit 0f19104512
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -716,9 +716,13 @@ class ZigbeeMqttPlugin(MqttPlugin): # lgtm [py/missing-call-to-init]
@staticmethod
def build_device_get_request(values: List[Dict[str, Any]]) -> dict:
def extract_value(value: dict, root: dict):
def extract_value(value: dict, root: dict, depth: int = 0):
for feature in value.get('features', []):
extract_value(feature, root)
new_root = root
if depth > 0:
new_root = root[value['property']] = root.get(value['property'], {})
extract_value(feature, new_root, depth=depth + 1)
if not value.get('access', 1) & 0x4:
# Property not readable/query-able