From 0f1910451282232a6eda598dd99f51a59e75bf94 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 4 Nov 2022 22:51:40 +0100 Subject: [PATCH] Improved zigbee.mqtt node property queries. Now handling cases of nodes with values having multiple levels (> 1) of nested properties. --- platypush/plugins/zigbee/mqtt/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platypush/plugins/zigbee/mqtt/__init__.py b/platypush/plugins/zigbee/mqtt/__init__.py index 2fc513840..2271ceddb 100644 --- a/platypush/plugins/zigbee/mqtt/__init__.py +++ b/platypush/plugins/zigbee/mqtt/__init__.py @@ -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