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 august open action #113795

Merged
merged 30 commits into from
May 29, 2024
Merged

Add august open action #113795

merged 30 commits into from
May 29, 2024

Conversation

m10x
Copy link
Contributor

@m10x m10x commented Mar 19, 2024

Proposed change

Added support for opening locks

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 Ruff (ruff format 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:

@m10x m10x requested a review from bdraco as a code owner March 19, 2024 07:54
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.

Hi @m10x

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!

@home-assistant
Copy link

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

Hey there @bdraco, mind taking a look at this pull request as it has been labeled with an integration (august) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of august can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign august Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

homeassistant/components/august/lock.py Outdated Show resolved Hide resolved
homeassistant/components/august/lock.py Outdated Show resolved Hide resolved
@MartinHjelmare MartinHjelmare changed the title august integration: open action Add august open action Mar 19, 2024
@m10x
Copy link
Contributor Author

m10x commented Mar 19, 2024

Works flawlessly in my fresh dev docker and my yale linus L2. The question is, what if a smart lock only has lock/unlock but no open action

homeassistant/components/august/lock.py Outdated Show resolved Hide resolved
@mbay0r
Copy link

mbay0r commented Apr 24, 2024

Hi, when will this be included in the stable version? Thank you!

@m10x
Copy link
Contributor Author

m10x commented Apr 24, 2024

Hi, when will this be included in the stable version? Thank you!

There are 2 problems afaik that need to be solved before that:

  1. Coverage for one method is missing (Add august open action #113795 (comment)) I added a PR for that, but one of the checks is failing and I don't get why.

  2. It should only be set for devices that support the open action (Add august open action #113795 (comment)) However, I have no idea what the best way is to solve this.

I'm waiting for feedback on these 2 problems

@mbay0r
Copy link

mbay0r commented Apr 29, 2024

  1. missing

Can I somehow integrate this into my system now? Do you perhaps have a hint?
I only have devices that support open

It still seems to take a while.

Thank you!

@m10x
Copy link
Contributor Author

m10x commented Apr 29, 2024

I'm eagerly waiting for it to be merged, too. I can see if it's possible to create a new repo and add the required files to turn It into a HACS compatible Integration. That way it might be easy to add it as custom Repository in HACS, so we can use it that way until this PR gets merged. However, I've never done this before, so not sure if it works.

@mbay0r
Copy link

mbay0r commented May 27, 2024

could someone please be so kind and help @m10x ? it has been dragging on for two months now and no end in sight :(
thanks a lot!

@bdraco
Copy link
Member

bdraco commented May 27, 2024

It's on my review list. There are still ~30 PRs ahead of it. Please be patient; there are a lot of people who need help. If the test gets solved before I have a large enough time block to be able to analyze whats needed, I will come back to it sooner as I have much more small time blocks than large ones.

@bdraco
Copy link
Member

bdraco commented May 29, 2024

@coderabbitai review

Copy link

coderabbitai bot commented May 29, 2024

Walkthrough

The updates to the Home Assistant august component introduce new asynchronous methods for unlatching devices, enhance lock entity features, and add comprehensive test coverage. The changes aim to improve the device handling capabilities and ensure robust error handling through extensive testing.

Changes

File Path Summary
homeassistant/components/august/__init__.py Added async_unlatch and async_unlatch_async methods for device unlatching.
homeassistant/components/august/lock.py Introduced LockEntityFeature for supported features and added async_open method.
tests/components/august/fixtures/...json Added JSON fixture for a smart lock with unlatching capabilities.
tests/components/august/mocks.py Updated mocks to handle async_unlatch and async_unlatch_async methods.
tests/components/august/test_init.py Added test for handling unsupported service errors.
tests/components/august/test_lock.py Added tests for lock opening operations and error handling.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant HomeAssistant
    participant AugustComponent
    participant LockDevice

    User->>HomeAssistant: Trigger unlock service
    HomeAssistant->>AugustComponent: Call async_unlatch
    AugustComponent->>LockDevice: Send unlatch command
    LockDevice-->>AugustComponent: Acknowledge command
    AugustComponent-->>HomeAssistant: Return response
    HomeAssistant-->>User: Confirm unlock status
Loading
sequenceDiagram
    participant TestRunner
    participant HomeAssistant
    participant AugustComponent
    participant MockLockDevice

    TestRunner->>HomeAssistant: Run test_open_lock_operation
    HomeAssistant->>AugustComponent: Call async_open
    AugustComponent->>MockLockDevice: Simulate unlatch command
    MockLockDevice-->>AugustComponent: Return mock response
    AugustComponent-->>HomeAssistant: Return test result
    HomeAssistant-->>TestRunner: Test result
Loading

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 76aa504 and 33ce84f.
Files selected for processing (6)
  • homeassistant/components/august/init.py (1 hunks)
  • homeassistant/components/august/lock.py (3 hunks)
  • tests/components/august/fixtures/get_lock.online_with_unlatch.json (1 hunks)
  • tests/components/august/mocks.py (3 hunks)
  • tests/components/august/test_init.py (3 hunks)
  • tests/components/august/test_lock.py (4 hunks)
Additional comments not posted (11)
tests/components/august/fixtures/get_lock.online_with_unlatch.json (1)

1-94: The JSON fixture is well-structured and provides comprehensive mock data for a smart lock device, suitable for testing the new unlatch feature.

tests/components/august/mocks.py (1)

194-196: The new mocks for async_unlatch and async_unlatch_async are correctly implemented and integrated into the test setup. These changes are essential for ensuring comprehensive testing of the new unlatch functionality.

Also applies to: 250-253, 259-260

tests/components/august/test_init.py (1)

167-176: The new test test_open_throws_hass_service_not_supported_error is correctly implemented to ensure that the SERVICE_OPEN raises the appropriate exception when the service is not supported. This is crucial for robust error handling in the integration.

tests/components/august/test_lock.py (6)

21-21: Addition of SERVICE_OPEN to the list of services.

This addition is necessary to support the new open/unlatch functionality for locks.


29-29: Import of HomeAssistantError.

This is required for raising exceptions in the new test cases that handle unsupported services.


38-39: Addition of _mock_lock_with_unlatch to the mock functions.

This mock is essential for testing the new open/unlatch functionality.


163-177: New test function test_open_lock_operation.

This test validates the basic functionality of the open service for locks that support unlatching. It correctly sets up the lock, invokes the open service, and checks the lock state.


179-215: New test function test_open_lock_operation_pubnub_connected.

This test ensures that the open service works correctly when PubNub is connected, simulating real-time updates. It's well-structured and covers the interaction with PubNub effectively.


512-520: New test function test_open_throws_hass_service_not_supported_error.

This test is crucial for ensuring that the open service correctly handles the scenario where a lock does not support the open action. It uses exception handling to check for the appropriate error message.

homeassistant/components/august/__init__.py (2)

384-391: Addition of async_unlatch method.

This method provides the functionality to unlatch/open a lock. It's well-implemented with proper error handling and integration with the existing API structure.


393-401: Addition of async_unlatch_async method.

This asynchronous version of the unlatch method is designed to work with PubNub for real-time updates. It's a necessary addition to support the new open/unlatch feature without waiting for a response.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@bdraco
Copy link
Member

bdraco commented May 29, 2024

@coderabbitai review

@bdraco
Copy link
Member

bdraco commented May 29, 2024

@coderabbitai review

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

homeassistant/components/august/lock.py Show resolved Hide resolved
@bdraco
Copy link
Member

bdraco commented May 29, 2024

Thanks @m10x

I took care of anonymizing the test data and adding the missing coverage.

@bdraco bdraco merged commit 05d0174 into home-assistant:dev May 29, 2024
24 checks passed
raman325 added a commit to raman325/home-assistant that referenced this pull request May 29, 2024
* dev: (8244 commits)
  Update zwave_js WS APIs for provisioning (home-assistant#117400)
  Add OSO Energy binary sensors (home-assistant#117174)
  Add august open action (home-assistant#113795)
  Add smoke detector temperature to Yale Smart Alarm (home-assistant#116306)
  Don't report entities with invalid unique id when loading the entity registry (home-assistant#118290)
  Fix epic_games_store mystery game URL (home-assistant#118314)
  Use runtime_data in ping (home-assistant#118332)
  Fix last_reported_timestamp not being updated when last_reported is changed (home-assistant#118341)
  Replace pop calls with del where the result is discarded in restore_state (home-assistant#118339)
  Improve websocket message coalescing to handle thundering herds better (home-assistant#118268)
  Add cache to more complex entity filters (home-assistant#118344)
  Reduce the intent response data sent to LLMs (home-assistant#118346)
  Small speed up to connecting dispatchers (home-assistant#118342)
  Tweak Assist LLM API prompt (home-assistant#118343)
  Add Conversation command to timers (home-assistant#118325)
  LLM Assist API to ignore intents if not needed for exposed entities or calling device (home-assistant#118283)
  Replace pop calls with del where the result is discarded in entity (home-assistant#118340)
  Replace pop calls with del where the result is discarded in mqtt (home-assistant#118338)
  Use del instead of pop in the entity platform remove (home-assistant#118337)
  Update the recommended model for Google Gen AI (home-assistant#118323)
  ...
raman325 added a commit to raman325/home-assistant that referenced this pull request May 29, 2024
* dev: (1785 commits)
  Update zwave_js WS APIs for provisioning (home-assistant#117400)
  Add OSO Energy binary sensors (home-assistant#117174)
  Add august open action (home-assistant#113795)
  Add smoke detector temperature to Yale Smart Alarm (home-assistant#116306)
  Don't report entities with invalid unique id when loading the entity registry (home-assistant#118290)
  Fix epic_games_store mystery game URL (home-assistant#118314)
  Use runtime_data in ping (home-assistant#118332)
  Fix last_reported_timestamp not being updated when last_reported is changed (home-assistant#118341)
  Replace pop calls with del where the result is discarded in restore_state (home-assistant#118339)
  Improve websocket message coalescing to handle thundering herds better (home-assistant#118268)
  Add cache to more complex entity filters (home-assistant#118344)
  Reduce the intent response data sent to LLMs (home-assistant#118346)
  Small speed up to connecting dispatchers (home-assistant#118342)
  Tweak Assist LLM API prompt (home-assistant#118343)
  Add Conversation command to timers (home-assistant#118325)
  LLM Assist API to ignore intents if not needed for exposed entities or calling device (home-assistant#118283)
  Replace pop calls with del where the result is discarded in entity (home-assistant#118340)
  Replace pop calls with del where the result is discarded in mqtt (home-assistant#118338)
  Use del instead of pop in the entity platform remove (home-assistant#118337)
  Update the recommended model for Google Gen AI (home-assistant#118323)
  ...
@github-actions github-actions bot locked and limited conversation to collaborators May 30, 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