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

Upgrade aionanoleaf to 0.2.1 #83669

Merged
merged 1 commit into from
Jan 11, 2023

Conversation

milanmeu
Copy link
Contributor

@milanmeu milanmeu commented Dec 9, 2022

Proposed change

Some Nanoleaf devices have connectivity issues. The library will now retry several times to connect before throwing the Unavailable exception.

https://github.com/milanmeu/aionanoleaf/releases/tag/v0.2.1

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

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.

To help with the load of incoming pull requests:

@balloob
Copy link
Member

balloob commented Dec 10, 2022

you could have done that change easier instead of re-assigning err in your lib.

except Exception as e:
    if attempt < 3:
        continue

@balloob
Copy link
Member

balloob commented Dec 10, 2022

Also, you're reraising the exception ? You can use if isinstance(err, ClientError). Also, you don't catch all possible client errors, you should catch ClientError

@balloob
Copy link
Member

balloob commented Dec 10, 2022

And also, you're not checking the status code of the client error, so you don't know if it's unavailable because the internet is down (connection error), the nanoleaf server is down (connection error or maybe timeout) or the auth is wrong. I would actually not wrap those errors in Unavailable. HA update coordinator also knows already how to deal with aiohttp and timeout errors too :)

bachya
bachya previously approved these changes Dec 11, 2022
@bachya bachya dismissed their stale review December 11, 2022 16:28

Wrong PR

@LunaCodeGirl
Copy link

Can we get some movement on this? @balloob your comments make sense but the existing behavior around error handling hasn't really changed other than retrying a few times. Can we assume that this change will be no worse than 0.2.0 and save the updates to the error handling in this case for later? My home assistant nanoleaf integration is basically worthless at the moment because HA is saying its almost always unavailable.

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.

I think the library change looks ok, although Paulus' suggestions are good to consider for the future.

@@ -3,7 +3,7 @@
"name": "Nanoleaf",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/nanoleaf",
"requirements": ["aionanoleaf==0.2.0"],
"requirements": ["aionanoleaf==0.2.1"],
Copy link
Member

Choose a reason for hiding this comment

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

Note that the retries are hardcoded to 3 instead of using the available parameter.

https://github.com/milanmeu/aionanoleaf/blob/4372e32146bbe6731990d3f649847669807bfb84/aionanoleaf/nanoleaf.py#L76

@MartinHjelmare MartinHjelmare merged commit e603645 into home-assistant:dev Jan 11, 2023
@MartinHjelmare MartinHjelmare added this to the 2023.1.4 milestone Jan 12, 2023
balloob pushed a commit that referenced this pull request Jan 12, 2023
@balloob balloob mentioned this pull request Jan 12, 2023
@milanmeu
Copy link
Contributor Author

I'll address the comments in a future update. Sorry, I couldn't find time to look at this sooner.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 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.

Nanoleaf - Connection Issues and Errors Nanoleaf and ha 2021.11.1
5 participants