Create, update and delete KNX entities from WS-commands
Proposed change
Create, update and delete KNX entities from Websocket commands.
Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
Additional information
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request:
Checklist
- [ ] The code change is tested and works locally.
- [ ] Local tests pass. Your PR cannot be merged unless tests pass
- [ ] There is no commented out code in this PR.
- [ ] I have followed the development checklist
- [ ] I have followed the perfect PR recommendations
- [ ] The code has been formatted using Black (
black --fast homeassistant tests) - [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [ ] The manifest file has all fields filled out correctly.
Updated and included derived files by running:python3 -m script.hassfest. - [ ] New or updated dependencies have been added to
requirements_all.txt.
Updated by runningpython3 -m script.gen_requirements_all. - [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
- [ ] Untested files have been added to
.coveragerc.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other open pull requests in this repository.
Hey there @julius2342, @marvin-w, mind taking a look at this pull request as it has been labeled with an integration (knx) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of knx can trigger bot actions by commenting:
-
@home-assistant closeCloses the pull request. -
@home-assistant rename Awesome new titleRenames the pull request. -
@home-assistant reopenReopen the pull request. -
@home-assistant unassign knxRemoves the current integration label and assignees on the pull request, add the integration domain after the command.
@coderabbitai review
Actions Performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Walkthrough
The updates to the KNX component in Home Assistant introduce new functionalities, restructure existing code, and enhance the configuration management. Key changes include the introduction of a KNXConfigStore class for managing KNX entity configurations, modifications to the setup and unloading processes for KNX entries, and new methods for entity creation, validation, and deletion via WebSocket commands. Additionally, new test cases and fixtures have been added to ensure the robustness of these changes.
Changes
| Files | Change Summary |
|---|---|
homeassistant/components/knx/__init__.py |
Added new imports, updated platform constants, setup/unload entry adjustments, new method for removing config entry devices, introduced KNXConfigStore class. |
homeassistant/components/knx/config_flow.py |
Updated import paths for keyring-related functions. |
homeassistant/components/knx/const.py |
Adjusted ColorTempModes enum values, changed SUPPORTED_PLATFORMS to dictionaries for YAML and UI configurations. |
homeassistant/components/knx/storage/config_store.py |
Introduced KNXConfigStore class for managing KNX entity configurations. |
homeassistant/components/knx/storage/entity_store_schema.py |
Defined schemas for entity store data, including base entity schema, switch schema, and data schema. |
homeassistant/components/knx/storage/entity_store_validation.py |
Added functionality for validating entity store data, including validation errors and successes. |
homeassistant/components/knx/storage/knx_selector.py |
Introduced GASelector class for handling KNX group address structures. |
homeassistant/components/knx/switch.py |
Added new imports, refactored setup function, introduced KnxYamlSwitch and KnxUiSwitch classes, modified base class _KnxSwitch. |
homeassistant/components/knx/validation.py |
Added maybe_ga_validator function for validating group addresses. |
homeassistant/components/knx/websocket.py |
Added new WebSocket functions for validating, creating, updating, and deleting KNX entities. |
tests/components/knx/README.md |
Added optional response parameter to knx.assert_read function. |
tests/components/knx/__init__.py |
Updated imports for Awaitable and Callable, added KnxEntityGenerator type signature. |
tests/components/knx/conftest.py |
Added imports and fixtures for KNX storage and entity registry. |
tests/components/knx/fixtures/config_store.json |
Defined configurations for KNX devices, including switch and light entities. |
tests/components/knx/test_config_flow.py |
Updated import paths for keyring-related functions. |
tests/components/knx/test_config_store.py |
Added test cases for creating, updating, deleting, and validating KNX entities. |
tests/components/knx/test_device.py |
Added test functions for creating and removing KNX devices. |
tests/components/knx/test_interface_device.py |
Renamed test module, added imports, introduced test function for device removal. |
tests/components/knx/test_knx_selectors.py |
Added test function test_ga_selector for testing GASelector functionality. |
tests/components/knx/test_switch.py |
Added test function test_switch_ui_create for testing switch creation and state assertion. |
tests/components/knx/test_websocket.py |
Added assertion for KNX project storage key, modified handling of project file removal. |
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>. -
Generate unit testing code for this file. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai generate interesting stats about this repository and render them as a table. -
@coderabbitai show all the console.log statements in this repository. -
@coderabbitai read src/utils.ts and generate unit testing code. -
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format. -
@coderabbitai help me debug CodeRabbit configuration file.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
-
@coderabbitai pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Really looking forward seeing this PR in the release soon :)
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
FYI pushed a new commit to fix the mypy errors / type ignores. @joostlek messaged me on discord about https://github.com/home-assistant/core/pull/104079#discussion_r1683559580 and I figured it'd probably be easier to push the changes directly then leaving a long comment. The gist of it though is to use the VolSchemaType and VolDictType type aliases when annotating schemas / dicts. It's not always necessary but when you encounter a type error, that usually resolves it.
That was the last thing remaining for this PR. Much thanks @cdce8p
Thanks for your review @joostlek and thanks for the typing help @cdce8p 😃