Skip to content
Draft
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
eca817e
Initial typed xml reading attempt (incomplete)
CoMPaTech Dec 28, 2025
408682b
Further progress
CoMPaTech Dec 29, 2025
6c6b3f2
Further progress - appliance typos
CoMPaTech Dec 29, 2025
709e84c
Some progress
CoMPaTech Dec 29, 2025
660acd8
More progress
CoMPaTech Dec 29, 2025
826c387
Further cleaning
CoMPaTech Dec 29, 2025
baf3419
Gateway progress
CoMPaTech Dec 31, 2025
9cd1b54
Fix after rebase
bouwew Jan 24, 2026
91b6877
Contents -> content
bouwew Jan 24, 2026
e2ad185
Fix module_data
bouwew Jan 24, 2026
9c011df
Fix another contents
bouwew Jan 24, 2026
6d09ec6
Add xmltodict to requirements
bouwew Apr 5, 2026
04698e7
Change index from 5 to 4
bouwew Apr 5, 2026
7e393f5
Update _appl_heater_central_info()
bouwew Apr 6, 2026
1d36e07
Update check_heater_central()
bouwew Apr 7, 2026
7c84129
And use
bouwew Apr 7, 2026
39ab2b3
Fixes
bouwew Apr 7, 2026
d7fa9f7
More _appl_heater_central_info() updating
bouwew Apr 13, 2026
85bfdda
Fix contents
bouwew Apr 13, 2026
613cbb3
Update _appl_thermostat_info()
bouwew Apr 13, 2026
aeee690
Update _get_appliances_with_offset_functionality()
bouwew Apr 13, 2026
8e3c64c
get_groups()
bouwew Apr 13, 2026
a4a8822
Disable prints, add logger
bouwew Apr 17, 2026
6728175
Disable initial Adam testcase
bouwew Apr 17, 2026
bbe0e9d
Add _create_gw_entities() call
bouwew Apr 17, 2026
a998ae0
Extend Appliance class
bouwew Apr 18, 2026
51f9db4
Correct to appl.id
bouwew Apr 18, 2026
17e6798
Various improvements
bouwew Apr 18, 2026
e9d0d42
fixup: typing_1_b Python code fixed using ruff
Apr 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update check_heater_central()
  • Loading branch information
bouwew committed Apr 7, 2026
commit 1d36e07d9e0f16750eb6a46569281142133ec035
29 changes: 15 additions & 14 deletions plugwise/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
SpecialType,
SwitchType,
)
from plugiwse.model import PlugwiseData

from defusedxml import ElementTree as etree
from munch import Munch
Expand Down Expand Up @@ -75,27 +76,27 @@ def in_alternative_location(loc: Munch, legacy: bool) -> bool:
return present


def check_heater_central(xml: etree.Element) -> str:
def check_heater_central(data: PlugwiseData) -> str:
"""Find the valid heater_central, helper-function for _appliance_info_finder().

Solution for Core Issue #104433,
for a system that has two heater_central appliances.
"""
locator = "./appliance[type='heater_central']"
heater_central_count = 0
heater_central_list: list[dict[str, bool]] = []
for heater_central in xml.findall(locator):
if (heater_central_id := heater_central.get("id")) is None:
continue # pragma: no cover

if (heater_central_name := heater_central.find("name")) is None:
continue # pragma: no cover

has_actuators = heater_central.find("actuator_functionalities/") is not None
# Filter for Plug/Circle/Stealth heater_central -- Pw-Beta Issue #739
if heater_central_name.text == "Central heating boiler":
heater_central_list.append({heater_central_id: has_actuators})
heater_central_count += 1
for appliance in data.appliance:
Comment on lines +79 to +87

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Type annotation contradicts actual caller usage — data is a DomainObjects, not PlugwiseData.

plugwise/smilecomm.py line 175 assigns self.data = root.domain_objects (a DomainObjects), and plugwise/common.py line 93 calls check_heater_central(self.data). The iteration for appliance in data.appliance only works because DomainObjects.appliance is the list — PlugwiseData exposes .domain_objects, not .appliance, so the current annotation would fail at runtime if anyone actually passed a PlugwiseData.

Fix the annotation (and the import) to match reality:

🩹 Proposed fix
-from plugwise.model import PlugwiseData
+from plugwise.model import DomainObjects
@@
-def check_heater_central(data: PlugwiseData) -> str:
+def check_heater_central(data: DomainObjects) -> str:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def check_heater_central(data: PlugwiseData) -> str:
"""Find the valid heater_central, helper-function for _appliance_info_finder().
Solution for Core Issue #104433,
for a system that has two heater_central appliances.
"""
locator = "./appliance[type='heater_central']"
heater_central_count = 0
heater_central_list: list[dict[str, bool]] = []
for heater_central in xml.findall(locator):
if (heater_central_id := heater_central.get("id")) is None:
continue # pragma: no cover
if (heater_central_name := heater_central.find("name")) is None:
continue # pragma: no cover
has_actuators = heater_central.find("actuator_functionalities/") is not None
# Filter for Plug/Circle/Stealth heater_central -- Pw-Beta Issue #739
if heater_central_name.text == "Central heating boiler":
heater_central_list.append({heater_central_id: has_actuators})
heater_central_count += 1
for appliance in data.appliance:
from plugwise.model import DomainObjects
def check_heater_central(data: DomainObjects) -> str:
"""Find the valid heater_central, helper-function for _appliance_info_finder().
Solution for Core Issue `#104433`,
for a system that has two heater_central appliances.
"""
heater_central_count = 0
heater_central_list: list[dict[str, bool]] = []
for appliance in data.appliance:
🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[failure] 79-79: Refactor this function to reduce its Cognitive Complexity from 19 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=plugwise_python-plugwise&issues=AZ2lNrmWWySueEBauAgp&open=AZ2lNrmWWySueEBauAgp&pullRequest=870

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugwise/util.py` around lines 79 - 87, The type annotation for the
check_heater_central function is incorrect: update the parameter type from
PlugwiseData to DomainObjects (and import DomainObjects) because callers pass
root.domain_objects; adjust the function signature for
check_heater_central(data: DomainObjects) and update the import list to include
DomainObjects so iteration over data.appliance matches the actual object shape
used by smilecomm.py and common.py.

if appliance.type == "heater_central":
if (heater_central_id := appliance.id) is None:
continue # pragma: no cover

if (heater_central_name := appliance.name) is None:
continue # pragma: no cover

has_actuators = heater_central.actuator_functionalities is not None
# Filter for Plug/Circle/Stealth heater_central -- Pw-Beta Issue #739
if heater_central_name == "Central heating boiler":
heater_central_list.append({heater_central_id: has_actuators})
heater_central_count += 1

if not heater_central_list:
return NONE # pragma: no cover
Expand Down