Skip to content

Commit f2ce6cf

Browse files
committed
Add direct, not under module-key
1 parent a179a5e commit f2ce6cf

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

plugwise/__init__.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ def collect_module_data(result: dict[str, Any] , count=1) -> dict[str, Any]:
7777

7878

7979
def add_module_to_appliance(
80-
appliance: list[dict[str, Any]],
80+
appliance: dict[str, Any],
8181
modules: list[dict[str, Any]]
8282
) -> tuple[dict[str, Any], bool]:
8383
"""Add module data to appliance."""
8484
module_set = False
85+
new_appliance: dict[str, Any] = {}
8586
for module in modules:
86-
for log in appliance["logs"]["point_log"]: # list-type
87+
for log in appliance["logs"]["point_log"]:
8788
for value in log.values():
8889
if isinstance(value, dict) and "id" in value:
8990
if value["id"] == module:
90-
appliance["module"] = modules[module]
91+
appliance.update( modules[module])
9192
module_set = True
9293

9394
return (appliance, module_set)
@@ -175,23 +176,25 @@ async def connect(self) -> Version:
175176
result_dict["domain_objects"].pop(key, None)
176177

177178
modules = collect_module_data(result_dict)
178-
for appliance in result_dict["domain_objects"]["appliance"]: # list-type
179+
for appliance in result_dict["domain_objects"]["appliance"]:
179180
(appliance, module_set) = add_module_to_appliance(appliance, modules)
180181
# Set gateway firmwware_version
181182
if appliance["type"] == "gateway":
182-
appliance["module"]["firmware_version"] = result_dict["domain_objects"]["gateway"]["firmware_version"]
183+
appliance["firmware_version"] = result_dict["domain_objects"]["gateway"]["firmware_version"]
183184
# TODO set zigbee mac(s)
184185
if not module_set:
185186
modules = collect_module_data(result, count=2) # repeat trying with 2nd id
186187
for appliance in result_dict["domain_objects"]["appliance"]:
187188
(appliance, module_set) = add_module_to_appliance(appliance, modules)
188189
if not module_set:
189-
appliance["module"] = {
190-
"firmware_version": None,
191-
"hardware_version": None,
192-
"vendor_model": None,
193-
"vendor_name": None,
194-
}
190+
appliance.update(
191+
{
192+
"firmware_version": None,
193+
"hardware_version": None,
194+
"vendor_model": None,
195+
"vendor_name": None,
196+
}
197+
)
195198

196199
result_dict["domain_objects"].pop("module", None)
197200
LOGGER.debug("HOI result_dict: %s", json.dumps(result_dict, indent=4))

0 commit comments

Comments
 (0)