-
Notifications
You must be signed in to change notification settings - Fork 8
Typing 1 b #870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Typing 1 b #870
Changes from all commits
eca817e
408682b
6c6b3f2
709e84c
660acd8
826c387
baf3419
9cd1b54
91b6877
e2ad185
9c011df
6d09ec6
04698e7
7e393f5
1d36e07
7c84129
39ab2b3
d7fa9f7
85bfdda
613cbb3
aeee690
8e3c64c
a4a8822
6728175
bbe0e9d
a998ae0
51f9db4
17e6798
e9d0d42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -41,6 +41,8 @@ | |||||||||||||||||||||||||||||||||||||||||
| from munch import Munch | ||||||||||||||||||||||||||||||||||||||||||
| from packaging.version import Version, parse | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| from .model import GatewayData, PlugwiseData | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| class Smile(SmileComm): | ||||||||||||||||||||||||||||||||||||||||||
| """The main Plugwise Smile API class.""" | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -74,18 +76,8 @@ | |||||||||||||||||||||||||||||||||||||||||
| self._smile_api: SmileAPI | SmileLegacyAPI | ||||||||||||||||||||||||||||||||||||||||||
| self._stretch_v2 = False | ||||||||||||||||||||||||||||||||||||||||||
| self._target_smile: str = NONE | ||||||||||||||||||||||||||||||||||||||||||
| self.smile: Munch = Munch() | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.anna_p1 = False | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.hostname = NONE | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.hw_version = None | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.legacy = False | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.mac_address = None | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.model = NONE | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.model_id = None | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.name = NONE | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.type = NONE | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.version = Version("0.0.0") | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.zigbee_mac_address = None | ||||||||||||||||||||||||||||||||||||||||||
| self.data: PlugwiseData | ||||||||||||||||||||||||||||||||||||||||||
| self.smile = GatewayData(hostname="smile") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| @property | ||||||||||||||||||||||||||||||||||||||||||
| def cooling_present(self) -> bool: | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -117,23 +109,19 @@ | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| async def connect(self) -> Version: | ||||||||||||||||||||||||||||||||||||||||||
| """Connect to the Plugwise Gateway and determine its name, type, version, and other data.""" | ||||||||||||||||||||||||||||||||||||||||||
| result = await self._request(DOMAIN_OBJECTS) | ||||||||||||||||||||||||||||||||||||||||||
| # Work-around for Stretch fw 2.7.18 | ||||||||||||||||||||||||||||||||||||||||||
| if not (vendor_names := result.findall("./module/vendor_name")): | ||||||||||||||||||||||||||||||||||||||||||
| result = await self._request(MODULES) | ||||||||||||||||||||||||||||||||||||||||||
| vendor_names = result.findall("./module/vendor_name") | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| names: list[str] = [] | ||||||||||||||||||||||||||||||||||||||||||
| for name in vendor_names: | ||||||||||||||||||||||||||||||||||||||||||
| names.append(name.text) | ||||||||||||||||||||||||||||||||||||||||||
| await self._request(DOMAIN_OBJECTS, new=True) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| vendor_models = result.findall("./module/vendor_model") | ||||||||||||||||||||||||||||||||||||||||||
| models: list[str] = [] | ||||||||||||||||||||||||||||||||||||||||||
| for model in vendor_models: | ||||||||||||||||||||||||||||||||||||||||||
| models.append(model.text) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| dsmrmain = result.find("./module/protocols/dsmrmain") | ||||||||||||||||||||||||||||||||||||||||||
| if "Plugwise" not in names and dsmrmain is None: # pragma: no cover | ||||||||||||||||||||||||||||||||||||||||||
| # Work-around for Stretch fw 2.7.18 | ||||||||||||||||||||||||||||||||||||||||||
| dsmrmain: bool = False | ||||||||||||||||||||||||||||||||||||||||||
| vendor_names: list = [] | ||||||||||||||||||||||||||||||||||||||||||
| vendor_models: list = [] | ||||||||||||||||||||||||||||||||||||||||||
| for module in self.data.module: | ||||||||||||||||||||||||||||||||||||||||||
| vendor_names.append(module.vendor_name) | ||||||||||||||||||||||||||||||||||||||||||
| vendor_models.append(module.vendor_model) | ||||||||||||||||||||||||||||||||||||||||||
| if "dsmrmain" in module.protocols: | ||||||||||||||||||||||||||||||||||||||||||
| dsmrmain = True | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+115
to
+122
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Confirm Module.protocols typing and any fixtures with protocols=None
ast-grep --pattern 'class Module($_):
$$$'
rg -nP '"dsmrmain"' --type=pyRepository: plugwise/python-plugwise Length of output: 1189 🏁 Script executed: #!/bin/bash
# Read the full context around the problematic code
sed -n '105,130p' plugwise/__init__.py | cat -n
# Search for test fixtures or actual data with None values
grep -r "protocols.*None" --include="*.py" | head -20
grep -r "vendor_name.*None" --include="*.py" | head -20Repository: plugwise/python-plugwise Length of output: 2469 🏁 Script executed: #!/bin/bash
# Find where Module objects are created/populated with data
grep -n "Module(" plugwise/*.py | head -20
# Check the XML parsing in common.py to see how protocols are set
sed -n '1,100p' plugwise/common.py | grep -A 5 -B 5 "protocols"
# Search for test data or fixtures with Module objects
find . -path ./node_modules -prune -o -name "*.json" -o -name "*.xml" | xargs grep -l "protocols" 2>/dev/null | head -5Repository: plugwise/python-plugwise Length of output: 1573 🏁 Script executed: #!/bin/bash
# Check test data structure to see if protocols/vendor_name are optional
head -200 ./userdata/adam_jip/core.domain_objects.xml | grep -A 5 -B 5 "module" | head -50
# Also check if there's any module without protocols in test data
grep -c "<protocols" ./userdata/adam_jip/core.domain_objects.xml || echo "No protocols found"
</parameter>Repository: plugwise/python-plugwise Length of output: 1837 🏁 Script executed: #!/bin/bash
# Count total modules and modules with protocols to see if any are missing
echo "Total modules in adam_jip:"
grep -c "<module " ./userdata/adam_jip/core.domain_objects.xml
echo "Modules with protocols:"
grep -c "<protocols" ./userdata/adam_jip/core.domain_objects.xml
# Check another test file
echo ""
echo "Total modules in adam_bad_thermostat:"
grep -c "<module " ./userdata/adam_bad_thermostat/core.domain_objects.xml
echo "Modules with protocols in adam_bad_thermostat:"
grep -c "<protocols" ./userdata/adam_bad_thermostat/core.domain_objects.xml
# Look at the actual code that parses modules to see what happens with missing protocols
sed -n '1,300p' plugwise/common.py | grep -A 10 "def.*module" | head -30Repository: plugwise/python-plugwise Length of output: 1110 Guard against
🩹 Proposed fix- for module in self.data.module:
- vendor_names.append(module.vendor_name)
- vendor_models.append(module.vendor_model)
- if "dsmrmain" in module.protocols:
- dsmrmain = True
+ for module in self.data.module:
+ if module.vendor_name:
+ vendor_names.append(module.vendor_name)
+ if module.vendor_model:
+ vendor_models.append(module.vendor_model)
+ if module.protocols and "dsmrmain" in module.protocols:
+ dsmrmain = True🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if "Plugwise" not in vendor_names and dsmrmain is None: # pragma: no cover | ||||||||||||||||||||||||||||||||||||||||||
|
Check failure on line 124 in plugwise/__init__.py
|
||||||||||||||||||||||||||||||||||||||||||
| LOGGER.error( | ||||||||||||||||||||||||||||||||||||||||||
| "Connected but expected text not returned, we got %s. Please create" | ||||||||||||||||||||||||||||||||||||||||||
| " an issue on http://github.com/plugwise/python-plugwise", | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -142,14 +130,14 @@ | |||||||||||||||||||||||||||||||||||||||||
| raise ResponseError | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Check if Anna is connected to an Adam | ||||||||||||||||||||||||||||||||||||||||||
| if "159.2" in models: | ||||||||||||||||||||||||||||||||||||||||||
| if "159.2" in vendor_models: | ||||||||||||||||||||||||||||||||||||||||||
| LOGGER.error( | ||||||||||||||||||||||||||||||||||||||||||
| "Your Anna is connected to an Adam, make sure to only add the Adam as integration." | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| raise InvalidSetupError | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Determine smile specifics | ||||||||||||||||||||||||||||||||||||||||||
| await self._smile_detect(result, dsmrmain) | ||||||||||||||||||||||||||||||||||||||||||
| await self._smile_detect() | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| self._smile_api = ( | ||||||||||||||||||||||||||||||||||||||||||
| SmileAPI( | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -162,6 +150,7 @@ | |||||||||||||||||||||||||||||||||||||||||
| self._request, | ||||||||||||||||||||||||||||||||||||||||||
| self._schedule_old_states, | ||||||||||||||||||||||||||||||||||||||||||
| self.smile, | ||||||||||||||||||||||||||||||||||||||||||
| self.data, | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| if not self.smile.legacy | ||||||||||||||||||||||||||||||||||||||||||
| else SmileLegacyAPI( | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -173,45 +162,57 @@ | |||||||||||||||||||||||||||||||||||||||||
| self._stretch_v2, | ||||||||||||||||||||||||||||||||||||||||||
| self._target_smile, | ||||||||||||||||||||||||||||||||||||||||||
| self.smile, | ||||||||||||||||||||||||||||||||||||||||||
| self.data, | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Update all endpoints on first connect | ||||||||||||||||||||||||||||||||||||||||||
| await self._smile_api.full_xml_update() | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return cast(Version, self.smile.version) | ||||||||||||||||||||||||||||||||||||||||||
| return self.smile.firmware_version | ||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return-type mismatch:
- return self.smile.firmware_version
+ return parse(self.smile.firmware_version) if self.smile.firmware_version else Version("0.0.0")Note also that 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| async def _smile_detect( | ||||||||||||||||||||||||||||||||||||||||||
| self, result: etree.Element, dsmrmain: etree.Element | ||||||||||||||||||||||||||||||||||||||||||
| ) -> None: | ||||||||||||||||||||||||||||||||||||||||||
| async def _smile_detect(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||
| """Helper-function for connect(). | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Detect which type of Plugwise Gateway is being connected. | ||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||
| # print(f"HOI14 {self}") | ||||||||||||||||||||||||||||||||||||||||||
|
Check warning on line 179 in plugwise/__init__.py
|
||||||||||||||||||||||||||||||||||||||||||
| # print(f"HOI14 {self.smile}") | ||||||||||||||||||||||||||||||||||||||||||
| model: str = "Unknown" | ||||||||||||||||||||||||||||||||||||||||||
| if (gateway := result.find("./gateway")) is not None: | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.version = parse(gateway.find("firmware_version").text) | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.hw_version = gateway.find("hardware_version").text | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.hostname = gateway.find("hostname").text | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.mac_address = gateway.find("mac_address").text | ||||||||||||||||||||||||||||||||||||||||||
| if (vendor_model := gateway.find("vendor_model")) is None: | ||||||||||||||||||||||||||||||||||||||||||
| if self.data.gateway is not None: | ||||||||||||||||||||||||||||||||||||||||||
| if self.data.gateway.vendor_model is None: | ||||||||||||||||||||||||||||||||||||||||||
| return # pragma: no cover | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| model = vendor_model.text | ||||||||||||||||||||||||||||||||||||||||||
| elec_measurement = gateway.find( | ||||||||||||||||||||||||||||||||||||||||||
| "gateway_environment/electricity_consumption_tariff_structure" | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.firmware_version = self.data.gateway.firmware_version | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.hardware_version = self.data.gateway.hardware_version | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.hostname = self.data.gateway.hostname | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.mac_address = self.data.gateway.mac_address | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # print(f"HOI11a {self.data.gateway}") | ||||||||||||||||||||||||||||||||||||||||||
|
Check warning on line 191 in plugwise/__init__.py
|
||||||||||||||||||||||||||||||||||||||||||
| # print(f"HOI11b {self.data.gateway.gateway_environment}") | ||||||||||||||||||||||||||||||||||||||||||
| # if ( | ||||||||||||||||||||||||||||||||||||||||||
| # "electricity_consumption_tariff_structure" | ||||||||||||||||||||||||||||||||||||||||||
| # in self.data.gateway.gateway_environment | ||||||||||||||||||||||||||||||||||||||||||
| # ): | ||||||||||||||||||||||||||||||||||||||||||
| # print( | ||||||||||||||||||||||||||||||||||||||||||
| # f"HOI11c {self.data.gateway.gateway_environment.electricity_consumption_tariff_structure}" | ||||||||||||||||||||||||||||||||||||||||||
| # ) | ||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||
| elec_measurement is not None | ||||||||||||||||||||||||||||||||||||||||||
| and elec_measurement.text | ||||||||||||||||||||||||||||||||||||||||||
| and model == "smile_thermo" | ||||||||||||||||||||||||||||||||||||||||||
| "electricity_consumption_tariff_structure" | ||||||||||||||||||||||||||||||||||||||||||
| in self.data.gateway.gateway_environment | ||||||||||||||||||||||||||||||||||||||||||
| and self.data.gateway.gateway_environment.electricity_consumption_tariff_structure | ||||||||||||||||||||||||||||||||||||||||||
| and self.smile.vendor_model == "smile_thermo" | ||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.anna_p1 = True | ||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||
| model = await self._smile_detect_legacy(result, dsmrmain, model) | ||||||||||||||||||||||||||||||||||||||||||
| # TODO | ||||||||||||||||||||||||||||||||||||||||||
|
Check warning on line 208 in plugwise/__init__.py
|
||||||||||||||||||||||||||||||||||||||||||
| self.smile.vendor_model = await self._smile_detect_legacy( | ||||||||||||||||||||||||||||||||||||||||||
| result, dsmrmain, model | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+208
to
+211
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Undefined variables The variables 💡 Suggested approachEither:
- async def _smile_detect(self) -> None:
+ async def _smile_detect(self, dsmrmain: bool) -> None:And in - await self._smile_detect()
+ await self._smile_detect(dsmrmain)For 🧰 Tools🪛 GitHub Actions: Latest commit[error] 210-210: ruff check failed: F821 Undefined name [error] 210-210: ruff check failed: F821 Undefined name 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if model == "Unknown" or self.smile.version == Version( | ||||||||||||||||||||||||||||||||||||||||||
| "0.0.0" | ||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||
| self.data.gateway.vendor_model == "Unknown" | ||||||||||||||||||||||||||||||||||||||||||
|
Check warning on line 214 in plugwise/__init__.py
|
||||||||||||||||||||||||||||||||||||||||||
| or self.smile.firmware_version == Version("0.0.0") | ||||||||||||||||||||||||||||||||||||||||||
| ): # pragma: no cover | ||||||||||||||||||||||||||||||||||||||||||
| # Corner case check | ||||||||||||||||||||||||||||||||||||||||||
| LOGGER.error( | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -220,8 +221,8 @@ | |||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| raise UnsupportedDeviceError | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| version_major = str(self.smile.version.major) | ||||||||||||||||||||||||||||||||||||||||||
| self._target_smile = f"{model}_v{version_major}" | ||||||||||||||||||||||||||||||||||||||||||
| version_major = Version(self.smile.firmware_version).major | ||||||||||||||||||||||||||||||||||||||||||
| self._target_smile = f"{self.data.gateway.vendor_model}_v{version_major}" | ||||||||||||||||||||||||||||||||||||||||||
| LOGGER.debug("Plugwise identified as %s", self._target_smile) | ||||||||||||||||||||||||||||||||||||||||||
| if self._target_smile not in SMILES: | ||||||||||||||||||||||||||||||||||||||||||
| LOGGER.error( | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -242,7 +243,7 @@ | |||||||||||||||||||||||||||||||||||||||||
| raise UnsupportedDeviceError # pragma: no cover | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| self.smile.model = "Gateway" | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.model_id = model | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.model_id = self.data.gateway.vendor_model | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.name = SMILES[self._target_smile].smile_name | ||||||||||||||||||||||||||||||||||||||||||
| self.smile.type = SMILES[self._target_smile].smile_type | ||||||||||||||||||||||||||||||||||||||||||
| if self.smile.name == "Smile Anna" and self.smile.anna_p1: | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -251,9 +252,9 @@ | |||||||||||||||||||||||||||||||||||||||||
| if self.smile.type == "stretch": | ||||||||||||||||||||||||||||||||||||||||||
| self._stretch_v2 = int(version_major) == 2 | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| self._process_for_thermostat(result) | ||||||||||||||||||||||||||||||||||||||||||
| self._process_for_thermostat() | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def _process_for_thermostat(self, result: etree.Element) -> None: | ||||||||||||||||||||||||||||||||||||||||||
| def _process_for_thermostat(self) -> None: | ||||||||||||||||||||||||||||||||||||||||||
| """Extra processing for thermostats.""" | ||||||||||||||||||||||||||||||||||||||||||
| if self.smile.type != "thermostat": | ||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -262,18 +263,22 @@ | |||||||||||||||||||||||||||||||||||||||||
| # For Adam, Anna, determine the system capabilities: | ||||||||||||||||||||||||||||||||||||||||||
| # Find the connected heating/cooling device (heater_central), | ||||||||||||||||||||||||||||||||||||||||||
| # e.g. heat-pump or gas-fired heater | ||||||||||||||||||||||||||||||||||||||||||
| onoff_boiler = result.find("./module/protocols/onoff_boiler") | ||||||||||||||||||||||||||||||||||||||||||
| open_therm_boiler = result.find("./module/protocols/open_therm_boiler") | ||||||||||||||||||||||||||||||||||||||||||
| self._on_off_device = onoff_boiler is not None | ||||||||||||||||||||||||||||||||||||||||||
| self._opentherm_device = open_therm_boiler is not None | ||||||||||||||||||||||||||||||||||||||||||
| self._on_off_device: bool = ( | ||||||||||||||||||||||||||||||||||||||||||
| True | ||||||||||||||||||||||||||||||||||||||||||
| if "protocols" in self.data.module | ||||||||||||||||||||||||||||||||||||||||||
| and "on_off_boiler" in self.data.module.protocols | ||||||||||||||||||||||||||||||||||||||||||
| else False | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| self._opentherm_device: bool = ( | ||||||||||||||||||||||||||||||||||||||||||
| True | ||||||||||||||||||||||||||||||||||||||||||
| if "protocols" in self.data.module | ||||||||||||||||||||||||||||||||||||||||||
| and "open_therm_boiler" in self.data.module.protocols | ||||||||||||||||||||||||||||||||||||||||||
| else False | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+266
to
+277
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type error: Lines 118-122 iterate over 🐛 Proposed fix - iterate over modules- self._on_off_device: bool = (
- True
- if "protocols" in self.data.module
- and "on_off_boiler" in self.data.module.protocols
- else False
- )
- self._opentherm_device: bool = (
- True
- if "protocols" in self.data.module
- and "open_therm_boiler" in self.data.module.protocols
- else False
- )
+ self._on_off_device = False
+ self._opentherm_device = False
+ for module in self.data.module:
+ if module.protocols:
+ if "on_off_boiler" in module.protocols:
+ self._on_off_device = True
+ if "open_therm_boiler" in module.protocols:
+ self._opentherm_device = True📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Determine the presence of special features | ||||||||||||||||||||||||||||||||||||||||||
| locator_1 = "./gateway/features/cooling" | ||||||||||||||||||||||||||||||||||||||||||
| locator_2 = "./gateway/features/elga_support" | ||||||||||||||||||||||||||||||||||||||||||
| if result.find(locator_1) is not None: | ||||||||||||||||||||||||||||||||||||||||||
| self._cooling_present = True | ||||||||||||||||||||||||||||||||||||||||||
| if result.find(locator_2) is not None: | ||||||||||||||||||||||||||||||||||||||||||
| self._elga = True | ||||||||||||||||||||||||||||||||||||||||||
| self._cooling_present = "cooling" in self.data.gateway.features | ||||||||||||||||||||||||||||||||||||||||||
| self._elga = "elga_support" in self.data.gateway.features | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| async def _smile_detect_legacy( | ||||||||||||||||||||||||||||||||||||||||||
| self, result: etree.Element, dsmrmain: etree.Element, model: str | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this bullet back under
## Ongoing.At its current position Line 17 renders as part of
v1.11.3, not the ongoing section.🤖 Prompt for AI Agents