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

Add config flow to synology_srm #35412

Closed

Conversation

aerialls
Copy link
Contributor

@aerialls aerialls commented May 9, 2020

Breaking change

The Synology SRM integration is now "config flow" compatible. The previous YAML integration is done and the configuration should be done in the UI and not in the YAML file.

Proposed change

Type of change

Migration to the "config flow" workflow. Support addition, updates and removal of entities (even if I would like feedbacks on the latest because I'm not sure of the global workflow).

  • 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

Example entry for configuration.yaml:

# Example configuration.yaml

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:

PR incoming to update the documentation.

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@project-bot project-bot bot added this to Needs review in Dev May 9, 2020
@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev May 9, 2020
@Quentame Quentame changed the title Update synology_srm component to use the new config flow workflow Add config flow to synology_srm May 30, 2020
Copy link
Member

@Quentame Quentame left a comment

Choose a reason for hiding this comment

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

homeassistant/components/synology_srm/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/synology_srm/router.py Outdated Show resolved Hide resolved
homeassistant/components/synology_srm/router.py Outdated Show resolved Hide resolved
homeassistant/components/synology_srm/router.py Outdated Show resolved Hide resolved
homeassistant/components/synology_srm/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/synology_srm/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/synology_srm/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/synology_srm/device_tracker.py Outdated Show resolved Hide resolved
homeassistant/components/synology_srm/device_tracker.py Outdated Show resolved Hide resolved
Dev automation moved this from By Code Owner to Review in progress May 30, 2020
@aerialls
Copy link
Contributor Author

Thanks @Quentame for your feedback. I've updated the PR will all your remarks and I've added more tests to increase coverage up to 100%!

@Quentame Quentame self-requested a review May 31, 2020 10:19
@@ -71,3 +76,9 @@ def get_srm_client_from_user_data(data) -> synology_srm.Client:
client.http.disable_https_verify()

return client


def fetch_srm_device_id(client: SynologyClient):
Copy link
Member

Choose a reason for hiding this comment

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

Why are you putting this function here since it's used only in the confug_flow ?

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 moved the function because it's always mocked in tests to I cannot have 100% coverage in this situation. It's also make sense in the end because I've another function just at the top to generate the client, so both functions handling the SynologyClient are at the same place.

@@ -46,21 +35,18 @@ async def async_step_user(self, user_input=None):
try:
client = get_srm_client_from_user_data(user_input)
device_id = await self.hass.async_add_executor_job(
_login_and_fetch_device_id, client
fetch_srm_device_id, client
Copy link
Member

Choose a reason for hiding this comment

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

What is the device_id actually ?

A MAC adress, serial number, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

device_id can be compared with a serial number. For instance, it's in the following format synology_irr436p_rt2600ac. It's much easier to fetch it from the API with a simple endpoint and the device ID is also written in the back of the device so it's a good device ID to display to the user IMO.

homeassistant/components/synology_srm/config_flow.py Outdated Show resolved Hide resolved
@aerialls
Copy link
Contributor Author

aerialls commented May 31, 2020

I pushed the change and rebased into one commit.

@Quentame
Copy link
Member

Please don't squash commits when someone starts to review your PR, so we can follow the diff better (GitHub does not have the diff tool as GitLab has).

I agree this can be kinda ugly sometimes but no worries your commits will be squashed at merge 😉

@Quentame
Copy link
Member

So then, you should not force push except if you rebase (not interactively)

@aerialls
Copy link
Contributor Author

Right, my bad! Forgot about that. I only pushed the change on https://github.com/home-assistant/core/pull/35412/files#diff-1262a40b266ddf89f36e596d9c1b0d62R46.

@stale
Copy link

stale bot commented Jul 3, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Jul 3, 2020
@aerialls
Copy link
Contributor Author

aerialls commented Jul 3, 2020

Still waiting for comments 😄

@stale stale bot removed the stale label Jul 3, 2020
@stale
Copy link

stale bot commented Aug 2, 2020

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@stale stale bot added the stale label Aug 2, 2020
@aerialls
Copy link
Contributor Author

aerialls commented Aug 3, 2020

I'm not using the Synology SRM router anymore and it seems nobody wants this PR merged so I will close it.

@aerialls aerialls closed this Aug 3, 2020
Dev automation moved this from Review in progress to Cancelled Aug 3, 2020
@Quentame
Copy link
Member

Quentame commented Aug 3, 2020

Sorry @aerialls I was very busy those weeks 😢

@i00 Would you like to create a new PR for this ?
Then we can take care of #31523

Ping me when it's done (also available on Discord, found me in the official HA server https://discord.gg/KxdbHtS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Dev
  
Cancelled
Development

Successfully merging this pull request may close these issues.

None yet

3 participants