Skip to content

Add reconfiguration support for keenetic_ndms2 integration #142191

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

foxel
Copy link
Contributor

@foxel foxel commented Apr 3, 2025

Proposed change

Adds reconfiguration ability to Keenetic NDMS2 integration.

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: implements feature request Change password to keenetic_ndms2 frontend#24890
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend 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 Ruff (ruff format 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.

To help with the load of incoming pull requests:

@foxel
Copy link
Contributor Author

foxel commented Apr 21, 2025

Hi @MartinHjelmare . Can you or some one else please do a review of this code?

@MartinHjelmare
Copy link
Member

Why did you tag me?

Please split the PR so the fix is in a separate PR from the new feature (reconfigure flow).

@MartinHjelmare MartinHjelmare marked this pull request as draft April 21, 2025 12:55
@foxel foxel force-pushed the keenetic-reconfigure branch from 63a8981 to c502d5c Compare April 22, 2025 18:16
@foxel
Copy link
Contributor Author

foxel commented Apr 22, 2025

Why did you tag me?

Please split the PR so the fix is in a separate PR from the new feature (reconfigure flow).

Hi @MartinHjelmare . I've tagged you because you were the last one involved in my PRs review :)

I've separated the fix changes from the improvements. THis one now holds only the improvements. The fix was moved to #143475

@foxel foxel force-pushed the keenetic-reconfigure branch from c502d5c to 0d8b94b Compare June 7, 2025 19:30
Introduce a reconfiguration flow to allow updates to existing configuration entries. This includes a new `async_step_reconfigure` method, updated config flow handling, and additional tests for reconfiguration logic.
@foxel foxel force-pushed the keenetic-reconfigure branch from 0d8b94b to 98cc346 Compare June 20, 2025 23:17
@foxel foxel marked this pull request as ready for review June 20, 2025 23:17
Comment on lines +117 to +124
async def async_step_reconfigure(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle reconfiguration."""
existing_entry_data = dict(self._get_reconfigure_entry().data)
self._host = existing_entry_data[CONF_HOST]

return await self.async_step_user(user_input)
Copy link
Member

Choose a reason for hiding this comment

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

Can you change username in the software?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean in the router software? Yes. You can create/remove users there.

Copy link
Member

Choose a reason for hiding this comment

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

How is the intergation currently built? Does it connect to a single user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You configure the integration with any router user credentials, and it will connect to the router and do its job on behalf of that user.
Best you create a dedicated user on the router specifically for HA access. The integration in its current form needs only read access via telnet.

Copy link
Member

Choose a reason for hiding this comment

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

Right. Is there a way we can make sure we connect to the same router again?

Copy link
Contributor Author

@foxel foxel Jun 25, 2025

Choose a reason for hiding this comment

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

Currently, the integration does not store the identification information of the router. But it's possible to fetch the serial number of the device.

I see what you are thinking about: ensuring that it's the same device after the reconfiguration.

The thing is that if you replace your router with a new one (more powerful, etc.) should we make you remove the integration and all of its tracked devices and connected automatons? I don't think we should - the MACs of your devices will stay the same, and you most probably copied the config from the old device...

@home-assistant home-assistant bot marked this pull request as draft June 23, 2025 21:52
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@foxel foxel marked this pull request as ready for review June 24, 2025 05:37
@home-assistant home-assistant bot requested a review from joostlek June 24, 2025 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants