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

Aurora abb defer unique_id assignment during yaml import #58887

Merged
merged 18 commits into from
Nov 3, 2021

Conversation

davet2001
Copy link
Contributor

@davet2001 davet2001 commented Nov 1, 2021

Breaking change

Proposed change

As implemented in #58504, the yaml import now allows the unique_id to be left as None until the setup can complete properly. This is preferred over the old solution of assigning an arbitrary unique_id.

It also means that serial numbers, FW versions etc can be assigned correctly etc rather than using dummy values.

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:

@davet2001 davet2001 changed the title Aurora abb defer unique_id assignment during yaml import (WIP) Aurora abb defer unique_id assignment during yaml import Nov 1, 2021
@davet2001 davet2001 marked this pull request as ready for review November 1, 2021 23:45
@davet2001
Copy link
Contributor Author

I have tried rebasing to see if that fixes the test failures (which seemed to be unrelated to this change).

@MartinHjelmare MartinHjelmare added this to the 2021.11.0 milestone Nov 2, 2021
Comment on lines 49 to 51
raise ConfigEntryNotReady(
"Failed to connect to inverter: no such COM port"
) from error
Copy link
Member

Choose a reason for hiding this comment

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

If there is no such device, it can't recover and so we should mark setup as failed instead of "failed but might work in a bit"

Suggested change
raise ConfigEntryNotReady(
"Failed to connect to inverter: no such COM port"
) from error
return False

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If device is a USB-RS485 adaptor perhaps it will work when it is plugged back in?

But retry every 5sec is probably not a good idea in this case.

I don't really mind. My initial approach was 'no response' is the only one we want to allow deferring for. All others are errors which should stop. But that means restart HA is the only way to 'try again'.

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 have switched them to log errors then return False. Hopefully that satisfies all.

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.

Thanks!

@MartinHjelmare MartinHjelmare merged commit 51be7d5 into home-assistant:dev Nov 3, 2021
frenck pushed a commit that referenced this pull request Nov 3, 2021
* Defer unique_id assignment during yaml import if dark

* Back out variable name change to simplify.

* Allow config flow yaml setup deferral.

* Fix deferred yaml import

* Code review: only wrap necessary lines in try blk

* Code review: catch possible duplicate unique_id

* Simplify assignment.

* Code review: use timedelta to retry yaml import

* Code review: if a different error occurs, raise it

* Remove current config entry if duplicate unique_id

* Code review: remove unnecessary line.

* Code review: revert change, leave to other PR.

* Code review: remove unnecessary patch & min->sec

* Remove unnecessary else after raise.

* Increase test coverage.

* Check the number of config entries at each stage

* Raise ConfigEntryNotReady when connection fails.

* Log & return false for error on yaml import
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2021
@davet2001 davet2001 deleted the aurora_abb_unique_id branch November 8, 2021 12:43
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.

5 participants