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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Reolink DHCP IP update #103654

Merged
merged 6 commits into from Nov 10, 2023
Merged

Conversation

starkillerOG
Copy link
Contributor

@starkillerOG starkillerOG commented Nov 8, 2023

Breaking change

Proposed change

When DHCP indicates the IP adress of a Reolink camera has changed, first a connection is attempted to confirm the new IP actually works.
Unfortunetly the old IP is used in this attempt instead of the newly discovered IP, sorry my mistake when writing that code...
This fixes that mistake.

Tested in my production enviroment (changed the IP to some random value in core.config_entries file and let the DHCP set it back correctly).

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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
  • I have followed the perfect PR recommendations
  • 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.

To help with the load of incoming pull requests:

@@ -113,7 +113,9 @@ async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowRes
raise AbortFlow("already_configured")

# check if the camera is reachable at the new IP
host = ReolinkHost(self.hass, existing_entry.data, existing_entry.options)
new_config = dict(existing_entry.data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this is missing test coverage if it can be changed without updating tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well there is a check that goes over this code, but since the test controlls if a ConnectionError occurs or not it does not mather if the IP is valid or not.
The IP that is eventually saved to the config is checked, but that is correct, see line 142:
self._abort_if_unique_id_configured(updates={CONF_HOST: discovery_info.ip})
Where the correct discovery_info.ip is used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added some extra assertions (assert_called_with) in the tests so that it would now fail if this would be changed in the future.

@frenck frenck marked this pull request as draft November 9, 2023 08:02
@starkillerOG starkillerOG marked this pull request as ready for review November 9, 2023 11:08
@starkillerOG starkillerOG merged commit 9f6eef7 into home-assistant:dev Nov 10, 2023
19 checks passed
@starkillerOG starkillerOG deleted the reolink_fix_DHCP branch November 10, 2023 08:27
frenck pushed a commit that referenced this pull request Nov 10, 2023
@frenck frenck mentioned this pull request Nov 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants