Conversation
There was a problem hiding this comment.
Pull request overview
Fixes MyNeomitis sub-device handling by adjusting how sub-device attributes (parents, rfid, and NTD cooling detection fields) are interpreted so sub-devices can operate without errors.
Changes:
- Updates sub-device gateway lookup to use the
parentsattribute as a comma-delimited string instead of a dict. - Adjusts NTD HVAC mode initialization to infer COOL vs HEAT from
comfTemp/ecoTemp. - Updates tests/fixtures to reflect the new sub-device attribute shapes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
homeassistant/components/myneomitis/select.py |
Adds UFH sub-device API call path using parents/rfid, with error handling. |
homeassistant/components/myneomitis/climate.py |
Changes sub-device gateway extraction and NTD initial HVAC mode selection logic. |
tests/components/myneomitis/test_select.py |
Updates UFH test fixture to include parents and rfid fields. |
tests/components/myneomitis/test_climate.py |
Updates NTD fixtures to include parents string and comfTemp/ecoTemp, and adjusts expectations. |
| else None | ||
| ) | ||
| if model == "NTD" and state.get("changeOverUser") == 1: | ||
| if model == "NTD" and state.get("comfTemp") < state.get("ecoTemp"): |
There was a problem hiding this comment.
Guard the NTD COOL/OFF detection against missing/non-numeric comfTemp/ecoTemp values (or make them required) to avoid a TypeError when comparing None to a number.
| if model == "NTD" and state.get("comfTemp") < state.get("ecoTemp"): | |
| comf_temp = state.get("comfTemp") | |
| eco_temp = state.get("ecoTemp") | |
| if ( | |
| model == "NTD" | |
| and isinstance(comf_temp, int | float) | |
| and isinstance(eco_temp, int | float) | |
| and comf_temp < eco_temp | |
| ): |
| gateway = ( | ||
| self._parents.split(",")[1] | ||
| if isinstance(self._parents, str) | ||
| else None | ||
| ) |
There was a problem hiding this comment.
Parse the gateway from parents without relying on a fixed comma layout (the current split(',')[1] can raise IndexError for a string that doesn’t contain at least two comma-separated parts).
| gateway = ( | ||
| self._parents.split(",")[1] | ||
| if isinstance(self._parents, str) | ||
| else None | ||
| ) |
There was a problem hiding this comment.
Parse the gateway from parents without relying on a fixed comma layout (the current split(',')[1] can raise IndexError for a string that doesn’t contain at least two comma-separated parts).
| gateway = ( | |
| self._parents.split(",")[1] | |
| if isinstance(self._parents, str) | |
| else None | |
| ) | |
| gateway = None | |
| if isinstance(self._parents, str): | |
| parent_parts = [ | |
| part.strip() for part in self._parents.split(",") if part.strip() | |
| ] | |
| if parent_parts: | |
| gateway = parent_parts[-1] |
| gateway = ( | ||
| self._parents.split(",")[1] | ||
| if isinstance(self._parents, str) | ||
| else None | ||
| ) |
There was a problem hiding this comment.
Parse the gateway from parents without relying on a fixed comma layout (the current split(',')[1] can raise IndexError for a string that doesn’t contain at least two comma-separated parts).
| gateway = ( | |
| self._parents.split(",")[1] | |
| if isinstance(self._parents, str) | |
| else None | |
| ) | |
| gateway = None | |
| if isinstance(self._parents, str): | |
| parent_parts = [ | |
| part.strip() for part in self._parents.split(",") if part.strip() | |
| ] | |
| if len(parent_parts) >= 2: | |
| gateway = parent_parts[-1] |
| if self._device["model"] in SUPPORTED_MODELS: | ||
| await self._api.set_device_mode(self._device["_id"], mode_code) | ||
| else: # UFH | ||
| gateway = ( | ||
| self._parents.split(",")[1] | ||
| if isinstance(self._parents, str) | ||
| else None | ||
| ) | ||
| rfid = self._device.get("rfid") | ||
| if not gateway or not rfid: | ||
| _LOGGER.error( | ||
| "Missing gateway or rfid for sub-device %s, cannot set mode", | ||
| self._attr_unique_id, | ||
| ) | ||
| raise HomeAssistantError(f"Failed to set mode for {self.entity_id}") | ||
|
|
||
| await self._api.set_sub_device_mode_ufh(gateway, str(rfid), mode_code) | ||
| except (aiohttp.ClientError, TimeoutError, ConnectionError) as err: |
There was a problem hiding this comment.
Add a test that exercises the UFH sub-device path in async_select_option (including the parents/rfid handling and the set_sub_device_mode_ufh call), since current tests only cover the non-sub-device set_device_mode branch.
Proposed change
Fixes the retrieval and transmission of the correct attributes for sub-devices, allowing them to operate without critical errors.
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: