Skip to content

Commit bee71c1

Browse files
committed
Move module-data of interest into appliance
Remove module-list
1 parent 6517faf commit bee71c1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

plugwise/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from __future__ import annotations
77

88
import json
9-
import xmltodict
109
from typing import cast
1110

1211
from plugwise.constants import (
@@ -42,6 +41,7 @@
4241
from defusedxml import ElementTree as etree
4342
from munch import Munch
4443
from packaging.version import Version, parse
44+
import xmltodict
4545

4646

4747
class Smile(SmileComm):
@@ -124,7 +124,6 @@ async def connect(self) -> Version:
124124
result_dict = dict(xmltodict.parse(result_str, attr_prefix=""))
125125
for key in ["ame_regulation", "template"]:
126126
result_dict["domain_objects"].pop(key, None)
127-
LOGGER.debug("HOI result_dict: %s", json.dumps(result_dict, indent=4))
128127
modules: dict[str, dict[str, str]] = {}
129128
for module in result_dict["domain_objects"]["module"]:
130129
link_id: str | None = None
@@ -148,7 +147,16 @@ async def connect(self) -> Version:
148147
"vendor_name": module["vendor_name"],
149148
}
150149

151-
LOGGER.debug ("HOI modules: %s", modules)
150+
for appliance in result_dict["domain_objects"]["appliance"]:
151+
for module in modules:
152+
for log in appliance["logs"]["point_log"]:
153+
for _, item in log.items():
154+
if isinstance(item, dict) and "id" in item:
155+
if item["id"] == module:
156+
appliance["module"] = modules[module]
157+
158+
result_dict["domain_objects"].pop("module")
159+
LOGGER.debug("HOI result_dict: %s", json.dumps(result_dict, indent=4))
152160

153161
# Work-around for Stretch fw 2.7.18
154162
if not (vendor_names := result.findall("./module/vendor_name")):

0 commit comments

Comments
 (0)