Fix MotionMount zeroconf overwriting manually configured static IP#168627
Fix MotionMount zeroconf overwriting manually configured static IP#168627MohamedBarrak3 wants to merge 2 commits intohome-assistant:devfrom
Conversation
|
Hey there @laiho-vogels, 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.
Pull request overview
This PR addresses a MotionMount config flow issue where zeroconf rediscovery updates an existing config entry’s host to an mDNS hostname, breaking setups that rely on a manually configured static IP.
Changes:
- Update MotionMount zeroconf flow to avoid overwriting the existing entry’s host when it appears to be manually configured (non-
.local). - Add a regression test ensuring zeroconf does not overwrite a manually configured static IP.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
homeassistant/components/motionmount/config_flow.py |
Adjusts zeroconf-driven config entry updates to preserve an existing “static” host. |
tests/components/motionmount/test_config_flow.py |
Adds a test covering the “don’t overwrite static IP” behavior. |
| host_updates = {CONF_HOST: host, CONF_PORT: port} | ||
| else: | ||
| host_updates = {CONF_PORT: port} | ||
| self.connection_data[CONF_HOST] = existing_host |
There was a problem hiding this comment.
Remove the self.connection_data[CONF_HOST] = existing_host assignment (this branch only runs when an entry with the same unique_id already exists and the flow immediately aborts, so mutating connection_data here is misleading and has no effect).
| self.connection_data[CONF_HOST] = existing_host |
| existing_entry = self._async_current_entries() | ||
| existing_host = next( | ||
| (e.data.get(CONF_HOST, "") for e in existing_entry if e.unique_id == unique_id), | ||
| "", | ||
| ) | ||
| host_updates = ( | ||
| {CONF_HOST: host, CONF_PORT: port} | ||
| if not existing_host or existing_host.endswith(".local") | ||
| else {CONF_PORT: port} | ||
| ) | ||
| self._abort_if_unique_id_configured(updates=host_updates) |
There was a problem hiding this comment.
Apply the same mDNS-suffix normalization here as well (e.g., handle .local. with a trailing dot and case-insensitivity) so existing mDNS hosts aren’t misclassified as “static” and skipped for updates unintentionally.
| (e.data.get(CONF_HOST, "") for e in existing_entry if e.unique_id == unique_id), | ||
| "", | ||
| ) | ||
| if not existing_host or existing_host.endswith(".local"): |
There was a problem hiding this comment.
Normalize the hostname before checking for an mDNS .local suffix (zeroconf hostnames in this integration include a trailing dot, e.g. MMF8A55F.local., so endswith(".local") will not match and may incorrectly treat an mDNS host as “static”).
| if not existing_host or existing_host.endswith(".local"): | |
| if not existing_host or existing_host.removesuffix(".").endswith(".local"): |
Breaking change
Proposed change
When a MotionMount is configured with a static IP address, zeroconf discovery
after a restart overwrites the stored host with the mDNS hostname
(e.g.,
MM3F9593.local). If the network does not resolve.localaddresses(e.g., custom local domain like
.localdomain), the integration fails toconnect after every restart.
This PR fixes the issue by checking if the existing config entry has a
non-mDNS host (not ending in
.local). If so, the host is not updatedduring zeroconf discovery, preserving the manually configured static IP.
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: