Enhance BaseDevice initialization and error handling

- Updated the `BaseDevice` class constructor to accept an optional `name` parameter for better context in error messages.
- Improved the `_validate_contract` method to raise an `OxiAPIError` with a descriptive message if the node is not found.
- Modified the `_run_ttp` method to include a check for node existence, returning `None` if not found.
- Changed the test file name in the `Eltex` model to reflect a more descriptive context for testing node not found scenarios.
This commit is contained in:
IluaAir
2026-04-18 19:21:25 +03:00
parent 9fd0ce1516
commit 5fa56d46af
3 changed files with 19 additions and 3 deletions

View File

@@ -60,7 +60,7 @@ class NodeConfig:
self._device: type[BaseDevice] = device_registry.get(self._model.lower())
if self._device is None:
raise ValueError(f"Device model '{self._model}' not found in registry")
self._parsed_data = self._device(self.text).parse()
self._parsed_data = self._device(self.text, name=self._full_name).parse()
@cached_property
def _response(self):