-
-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Use KNX UI entity platform controller class #123128
Conversation
instead of KNXConfigStore to add and reload UI entities
Hey there @Julius2342, @marvin-w, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
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.
Looks good! There were some annotations about missing coverage that I recommend addressing before merging, if correct.
async def create_entity( | ||
self, platform: Platform, data: dict[str, Any] | ||
) -> str | None: | ||
"""Create a new entity.""" | ||
if platform not in self.async_add_entity: | ||
raise ConfigStoreException(f"Entity platform not ready: {platform}") | ||
try: | ||
platform_controller = self._platform_controllers[platform] | ||
except KeyError as err: | ||
raise ConfigStoreException( | ||
f"Entity platform not ready: {platform}" | ||
) from err |
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.
I don't really know how to write a test against this.
All UI supported platforms should create and add their platform_controllers on integration load.
The websocket call triggering create_entity
will be voluptuous validated to not create an unsupported platform. So in theory this can never raise. If it did, it would just forward the error message in the UI.
Would you prefer to remove the try-except block in this case, or should it stay?
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.
How is the supported platform validated in the websocket? Does it check that the platform is setup? Cause that's what is required here. If the config entry is loaded we can assume that platforms are setup. If the websocket API checks that the config entry is loaded would be enough.
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.
I'd test this by setting up the config entry and then unloading it, and then calling the websocket API.
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.
To be clear, I don't think we need to catch the error here but we need to handle an unloaded config entry in the websocket API.
Are you going to handle an unloaded config entry in a separate PR? |
Yes, that would probably be a good idea. |
-> #123178 Should this PR be marked with 2024.8 milestone or can it wait for next release? |
Since the other PRs have been added to the release branch I suggest we add this too. |
Proposed change
Use KNX UI entity platform controller class to add and reload UI entities instead of KNXConfigStore.
First commit is where the logic is built, second where it is used and third is only some renaming.
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: