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

Remove resources selection from Nut config flow #59450

Merged
merged 4 commits into from Nov 10, 2021

Conversation

ollo69
Copy link
Contributor

@ollo69 ollo69 commented Nov 9, 2021

Proposed change

Remove the initial selection of Nut resources from the config flow. Only main resources will be automatically enabled, all the others are created in state disabled. Import of existing configuration is implemented.
Test has been changed to not consider anymore the CONF_RESOURCES settings.

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

  • 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
  • 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 @bdraco, mind taking a look at this pull request as it has been labeled with an integration (nut) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@project-bot project-bot bot added this to Needs review in Dev Nov 9, 2021
@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Nov 9, 2021
homeassistant/components/nut/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/nut/sensor.py Outdated Show resolved Hide resolved
@@ -48,25 +44,13 @@ def _base_schema(discovery_info):
return vol.Schema(base_schema)


def _resource_schema_base(available_resources, selected_resources):
"""Resource selection schema."""
def _check_available_resouces(available_resources):
Copy link
Member

Choose a reason for hiding this comment

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

I think we should remove this check. It's not the config flow responsibility to determine available sensors. The config flow should just validate the connection with the provided config data and then create the entry if the connection to the device or service is successful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This could eventually create integration without entity. is this OK? Before it was not possible because user was forced to select at least 1 resource to complete the config flow.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should create a device entry for the UPS explicitly if this isn't already done. Then there will always be at least a device entry. The entities is ok to not be any.

Copy link
Member

Choose a reason for hiding this comment

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

Will you follow up with a PR to add a device explicitly to the device registry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I lost this point. There is a reference to an integration that do the same, I never did it?

Copy link
Member

Choose a reason for hiding this comment

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

Here's an example:

device_registry = dr.async_get(hass)
device_registry.async_get_or_create(
config_entry_id=config_entry_id,
identifiers={(DOMAIN, hub.bond_id)},
manufacturer=BRIDGE_MAKE,
name=hub_name,
model=hub.target,
sw_version=hub.fw_ver,
suggested_area=hub.location,
)

Copy link
Member

Choose a reason for hiding this comment

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

Should we merge this PR, and save it for a follow up, or do you want to do it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, please, merge it, I will create follow up.

Dev automation moved this from By Code Owner to Review in progress Nov 10, 2021
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good!

Dev automation moved this from Review in progress to Reviewer approved Nov 10, 2021
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
@MartinHjelmare MartinHjelmare merged commit 6cba03a into home-assistant:dev Nov 10, 2021
Dev automation moved this from Reviewer approved to Done Nov 10, 2021
@ollo69 ollo69 deleted the nut-remove-resources branch November 10, 2021 20:42
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants