Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESPHome prevent connecting to different hosts when IP reassigned #64559

Merged
merged 10 commits into from
Jan 24, 2022

Conversation

OttoWinter
Copy link
Member

@OttoWinter OttoWinter commented Jan 20, 2022

Proposed change

Prevent ESPHome connecting to the incorrect host when the old one got reassigned to a new IP address but HA hasn't received the updated mDNS record yet.

This change required a protocol addition (both sides still support older peers), hence the minor aioesphomepi version bump.

More information here: esphome/aioesphomeapi#122 and #52239

Changelog: https://github.com/esphome/aioesphomeapi/releases/tag/v10.8.0 and https://github.com/esphome/aioesphomeapi/releases/tag/v10.8.1

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

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
  • 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:

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 running python3 -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.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link

Hey there @jesserockz, mind taking a look at this pull request as it has been labeled with an integration (esphome) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@OttoWinter
Copy link
Member Author

OttoWinter commented Jan 20, 2022

esphome/__init__.py is excluded from coverage, so not sure what codecov is complaining about here:

homeassistant/components/esphome/__init__.py

Edit: ah, apparently it calcuates in the changes from the initial branching point (months ago), and compared to that some coverage changed in mqtt and so on (but doesn't affect this PR)

@jesserockz
Copy link
Member

How does this look in the HA UI, and how would a user go about fixing it?

@OttoWinter
Copy link
Member Author

How does this look in the HA UI, and how would a user go about fixing it?

Right, I didn't think about that.

We can catch this issue in on_connect_error (by checking if it's an instance of BadNameAPIError). But not sure what we want to display then.

Background:

  1. This (probably) mostly gets triggered temporarily when a device is reassigned to a new IP (and a different ESPHome device gets the previous IP).
  2. Or if the user has a bad mDNS setup, and HA never gets the new updated IP.
  3. Or if the user changes the name of the device (which is already quite complex process outside of HA).

For 1 I think the maximum we should do is printing an error.

For 2 the user must have set up the device manually (without discovery) by entering an IP. In this case I think it's expected that if the IP changes it stops working, and a log error should be enough.

For 3 a config flow would be best, but since the process is already complicated I guess we can just add an additional step to the ESPHome guide about changing nodes' names.

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Jan 23, 2022
@OttoWinter OttoWinter merged commit a65a0b5 into home-assistant:dev Jan 24, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bugfix by-code-owner cla-signed integration: esphome small-pr PRs with less than 30 lines. smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESPHome config flow discovery uses wrong host
4 participants