-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Fix ESPHome unnecessary probing on DHCP discovery #149713
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 @jesserockz, @kbx81, 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 an issue where the ESPHome integration was unnecessarily probing devices during DHCP discovery events, even when the IP address hadn't changed. The problem occurred because DHCP discovery passes port=None, but the code was comparing this against the configured port (e.g., 6053 == None), which always failed and triggered unnecessary device probing.
Key changes:
- Modified the host/port comparison logic to handle
Noneport values from DHCP discovery - Added a test case to verify the fix prevents unnecessary probing
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| homeassistant/components/esphome/config_flow.py | Updated comparison logic to skip port matching when port is None from DHCP discovery |
| tests/components/esphome/test_config_flow.py | Added test case to verify DHCP discovery doesn't probe when host matches and port is None |
|
Thanks |
Proposed change
Fix ESPHome integration unnecessarily probing devices on DHCP discovery events.
When ESPHome devices renew their DHCP lease or reconnect to the network, the integration was probing them even when the IP address hadn't changed. This was causing rapid connect/disconnect cycles visible in ESPHome logs:
The issue occurred because DHCP discovery passes
port=None, but the code was comparingconfigured_port == port(e.g.,6053 == None), which always failed and triggered unnecessary probing.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: