Skip to content

Conversation

@iMicknl
Copy link
Owner

@iMicknl iMicknl commented Jan 29, 2026

Breaking

  • The Device class no longer includes the id property, and the following fields have been moved into device.identifier.{}: protocol, gateway_id, device_address, and subsystem_id.

Enhancement

  • Device class now has helper methods for retrieving the state value, commands and definition.
  • Device class now has an identifier property with protocol, gateway_id, device_address, and subsystem_id fields.

Full changelog

Fixes #1923

This pull request refactors and enhances the device modeling logic in pyoverkiz/models.py, introducing a new DeviceIdentifier class to encapsulate device URL parsing and related properties. It also adds several helper methods to the Device, States, Definition, and CommandDefinitions classes, improving code clarity and testability. Extensive new tests are added to ensure the correctness of these helpers and the new identifier logic.

Device identifier and URL parsing improvements:

  • Introduced a new DeviceIdentifier class to encapsulate parsing and properties of device URLs, replacing scattered parsing logic and related fields in the Device class. Device URL parsing now raises a ValueError for invalid formats. (pyoverkiz/models.py)
  • Refactored the Device class to use the new identifier property instead of separate protocol, gateway_id, device_address, and subsystem_id fields. (pyoverkiz/models.py) [1] [2]

Helper methods and API enhancements:

  • Added helper methods to Device, States, Definition, and CommandDefinitions classes (e.g., get_supported_command_name, has_supported_command, get_state_value, get_state_definition, select, has_any) to simplify common queries and checks. (pyoverkiz/models.py) [1] [2] [3] [4]

Testing improvements:

  • Updated and expanded tests to cover the new DeviceIdentifier logic, helper methods, and error handling for invalid device URLs. Added new test cases for the helper methods in Device, States, Definition, and CommandDefinitions. (tests/test_client.py, tests/test_models.py) [1] [2] [3] [4] [5] [6]

Code cleanup:

  • Removed legacy or redundant fields and parsing logic from the Device class, and improved fallback logic for ui_class and widget properties. (pyoverkiz/models.py) [1] [2]

These changes improve the maintainability and usability of the device modeling code, making it easier to work with device URLs and query device capabilities in a robust and testable way.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors device modeling around a new DeviceIdentifier type and enriches the models API with helpers for querying device states, commands, and definitions, along with corresponding tests.

Changes:

  • Introduces DeviceIdentifier to encapsulate device URL parsing and identifier fields, and updates Device to use identifier instead of protocol, gateway_id, device_address, and subsystem_id (removing id as well).
  • Adds helper methods on Device, States, Definition, and CommandDefinitions (e.g., get_supported_command_name, has_supported_command, select, select_value, has_any, get_state_value, get_state_definition, get_attribute_value) and improves ui_class / widget resolution.
  • Extends and updates tests in tests/test_models.py and tests/test_client.py to validate the new identifier parsing behaviour, helper methods, and client setup parsing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pyoverkiz/models.py Adds DeviceIdentifier, refactors Device to use identifier, introduces new helper methods on Device, Definition, CommandDefinitions, and States, and tightens ui_class/widget resolution.
tests/test_models.py Expands model tests to cover DeviceIdentifier parsing, new Device helpers, and the added helper methods on States, CommandDefinitions, and Definition.
tests/test_client.py Adjusts setup tests to assert device identifiers via the new device.identifier API rather than the removed flat fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@iMicknl
Copy link
Owner Author

iMicknl commented Jan 29, 2026

TODO:
Type the dataproperties:

    "dataProperties": [
      {
        "value": "5000",
        "qualifiedName": "core:identifyInterval"
      }
    ]

python3 -c "import json; data = json.load(open('tests/fixtures/setup/setup_tahoma_1.json')); device = data['devices'][0]; print(json.dumps(device, indent=2)[:2000])"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants