-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Handle ESPHome discoveries with uninitialized Z-Wave antennas #153790
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
Conversation
|
Hey there @home-assistant/z-wave, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
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.
Pull Request Overview
This PR fixes a bug in the Z-Wave JS integration's ESPHome discovery flow where devices without a Home ID would cause issues. The change adds validation to abort the configuration flow when the Home ID is missing, which can occur with ESPHome running on PoE adapters.
- Adds a check to abort ESPHome discovery when
zwave_home_idisNone - Provides a descriptive error message for the abort scenario
- Includes comprehensive test coverage for the new validation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
homeassistant/components/zwave_js/config_flow.py |
Adds validation to check for missing Home ID and abort discovery flow |
homeassistant/components/zwave_js/strings.json |
Adds user-facing error message for the missing Home ID scenario |
tests/components/zwave_js/test_config_flow.py |
Adds test case to verify proper handling of ESPHome discoveries without Home ID |
| if ( | ||
| ( | ||
| current_config_entries := self._async_current_entries( | ||
| include_ignore=False | ||
| ) | ||
| ) | ||
| ) | ||
| and (home_id := str(discovery_info.zwave_home_id)) | ||
| and ( | ||
| existing_entry := next( | ||
| ( | ||
| entry | ||
| for entry in current_config_entries | ||
| if entry.unique_id == home_id | ||
| ), | ||
| None, | ||
| and (home_id := str(discovery_info.zwave_home_id)) | ||
| and ( | ||
| existing_entry := next( | ||
| ( | ||
| entry | ||
| for entry in current_config_entries | ||
| if entry.unique_id == home_id | ||
| ), | ||
| None, | ||
| ) | ||
| ) | ||
| # Only update existing entries that are configured via sockets | ||
| and existing_entry.data.get(CONF_SOCKET_PATH) | ||
| # And use the add-on | ||
| and existing_entry.data.get(CONF_USE_ADDON) | ||
| ): | ||
| await self._async_set_addon_config( | ||
| {CONF_ADDON_SOCKET: discovery_info.socket_path} | ||
| ) | ||
| # Reloading will sync add-on options to config entry data | ||
| self.hass.config_entries.async_schedule_reload(existing_entry.entry_id) | ||
| return self.async_abort(reason="already_configured") |
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.
This diff is big because I split out if discovery_info.zwave_home_id and so it got indented.
Breaking change
Proposed change
In #153522 we switched to always set the Home ID. However, there are 2 cases where this is not the case: when a PoE adapter running ESPHome is not connected to ZWA-2 and when a Z-Wave antenna has never been used. With this PR, those 2 cases will now no longer cause duplicate discoveries once configured.
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: