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 microBees integration #99573

Merged
merged 93 commits into from
Feb 19, 2024
Merged

Add microBees integration #99573

merged 93 commits into from
Feb 19, 2024

Conversation

marcolettieri
Copy link
Contributor

@marcolettieri marcolettieri commented Sep 4, 2023

Breaking change

Proposed change

New Custom integration microBees for HomeAssistant

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
  • 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:

@home-assistant
Copy link

home-assistant bot commented Sep 4, 2023

Hi @FedDam

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

@home-assistant home-assistant bot marked this pull request as draft September 4, 2023 09:55
@home-assistant
Copy link

home-assistant bot commented Sep 4, 2023

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant
Copy link

home-assistant bot commented Sep 4, 2023

Hi @marcolettieri

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@marcolettieri marcolettieri marked this pull request as ready for review September 4, 2023 10:39
@MartinHjelmare MartinHjelmare changed the title microBees HomeAssistant integration Add microBees HomeAssistant integration Sep 4, 2023
Copy link
Contributor Author

@marcolettieri marcolettieri left a comment

Choose a reason for hiding this comment

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

limited included platforms to a single platform

@home-assistant home-assistant bot marked this pull request as draft February 19, 2024 08:38
@marcolettieri marcolettieri marked this pull request as ready for review February 19, 2024 08:44
@home-assistant home-assistant bot marked this pull request as draft February 19, 2024 08:46
@marcolettieri marcolettieri marked this pull request as ready for review February 19, 2024 08:48
tests/components/microbees/test_config_flow.py Outdated Show resolved Hide resolved
tests/components/microbees/test_config_flow.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft February 19, 2024 11:29
@marcolettieri marcolettieri marked this pull request as ready for review February 19, 2024 11:53
@joostlek joostlek dismissed stale reviews from raman325 and frenck February 19, 2024 14:11

Coverage fixed

@joostlek joostlek changed the title Add microBees HomeAssistant integration Add microBees integration Feb 19, 2024
@joostlek joostlek merged commit 3a4c6fc into home-assistant:dev Feb 19, 2024
49 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 20, 2024
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.

Please address the comments in a new PR. Thanks!

from homeassistant.helpers import config_entry_oauth2_flow


class ConfigEntryAuth:
Copy link
Member

@MartinHjelmare MartinHjelmare Apr 1, 2024

Choose a reason for hiding this comment

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

This isn't used anywhere. The idea with this class is that it should inherit the library client class and help the library to refresh the access token since Home Assistant is in control of it instead of the library.

https://developers.home-assistant.io/docs/api_lib_auth#oauth2

The only time the token is refreshed currently is when the config entry is setup. So the user needs to reload the config entry to refresh the token. This is not how it's supposed to work.

Before every request the client should call async_get_access_token (check_and_refresh_token) to get a valid token.

async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on the switch."""
send_command = await self.coordinator.microbees.sendCommand(self.actuator_id, 1)
if send_command:
Copy link
Member

Choose a reason for hiding this comment

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

Invert the check and raise if true. Then we can outdent below.

"authorize_url_timeout": "[%key:common::config_flow::abort::oauth2_authorize_url_timeout%]",
"no_url_available": "[%key:common::config_flow::abort::oauth2_no_url_available%]",
"user_rejected_authorize": "[%key:common::config_flow::abort::oauth2_user_rejected_authorize%]"
},
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 strings for abort reasons for invalid_auth, unknown, and wrong_account.

@home-assistant home-assistant unlocked this conversation Apr 1, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2024
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.

7 participants