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 better connection management for Idasen Desk #102135

Merged
merged 4 commits into from
Oct 18, 2023

Conversation

abmantis
Copy link
Contributor

@abmantis abmantis commented Oct 16, 2023

Proposed change

This adds better connection management, by automatically reconnecting in case of a
disconnect. It is a split from a bigger PR: #100830

Diff for the supporting lib: abmantis/idasen-ha@1.4.1...2.3

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: 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
  • I have followed the perfect PR recommendations
  • 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:

@abmantis
Copy link
Contributor Author

The failing tests don't seem related to this change.

) -> None:
"""Initialize an Idasen Desk cover."""
super().__init__(coordinator)
self._desk = desk
self._attr_name = device_info[ATTR_NAME]
self._desk: Desk = coordinator.desk
Copy link
Member

@bdraco bdraco Oct 17, 2023

Choose a reason for hiding this comment

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

Is this type hint needed? If the library is missing a py.typed file per https://peps.python.org/pep-0561/ it would be better to type the Desk object in the coordinator instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

self._desk = desk
self._attr_name = device_info[ATTR_NAME]
self._desk: Desk = coordinator.desk
self._attr_name = device_info.get(ATTR_NAME)
Copy link
Member

Choose a reason for hiding this comment

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

Is the name now not always going to be there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is still always there. I am now using pyright and it complains with:

Pyright: Could not access item in TypedDict
     "name" is not a required key in "DeviceInfo", so access may result in runtime exception [reportTypedDictNotRequiredAccess]

Should I revert it back?

(I can't use pylance since I am not using vscode)

Copy link
Member

@bdraco bdraco Oct 18, 2023

Choose a reason for hiding this comment

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

vscode doesn't complain about it.

We know its there because you set it in async_setup_entry so it would be a bug if it wasn't. Please revert it back. We want it to blow up if future refactoring would have it be missing so it doesn't generate a hard to find bug

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to merge once this outstanding review comment is addresesed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done now

@abmantis abmantis requested a review from bdraco October 18, 2023 00:15
@bdraco
Copy link
Member

bdraco commented Oct 18, 2023

look like 3.11 5 failed for an unrelated reason. I restarted the CI runner

@abmantis abmantis requested a review from bdraco October 18, 2023 20:59
Copy link
Member

@bdraco bdraco left a comment

Choose a reason for hiding this comment

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

Thanks @abmantis

@bdraco bdraco added the smash Indicator this PR is close to finish for merging or closing label Oct 18, 2023
@abmantis
Copy link
Contributor Author

@bdraco the diff codecov is failing. The line that is missing coverage will only be used on the other PR that I'll update as soon as this one is in. Is it ok to merge this as-is? Otherwise I'll just delete the 3 lines.

@bdraco
Copy link
Member

bdraco commented Oct 18, 2023

It's fine to leave them since they aren't critical and I already have a good idea what is coming.

We are tight on ci resources at the moment anyways due to having two supported python versions so best not to do another run just to remove them when you are going to add them right back anyways.

@bdraco bdraco merged commit 606b76c into home-assistant:dev Oct 18, 2023
zweckj pushed a commit to zweckj/home-assistant-core that referenced this pull request Oct 19, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2023
hass,
_LOGGER,
name=entry.title,
coordinator: IdasenDeskCoordinator = IdasenDeskCoordinator(
Copy link
Member

Choose a reason for hiding this comment

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

We're missing a type annotation for the data type of the coordinator. The coordinator class is generic. See other integrations that implement a custom coordinator class for examples.

@abmantis abmantis deleted the idasen_coordinator_connection branch December 1, 2023 23:00
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.

3 participants