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

feat: add option to force on flood light for light devices #154

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

zevmela
Copy link

@zevmela zevmela commented Jul 21, 2024

Description of change

The Ubiquiti Protect UI has an option to "force on" the flood light. I added the command and tested on a UDM Pro and a UNVR running current software and UP Floodlight.

Pull-Request Checklist

  • Code is up-to-date with the main branch
  • This pull request follows the contributing guidelines.
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change
  • The new commits follow conventions outlined in the conventional commit spec, such as "fix(api): prevent racing of requests".
  • If pre-commit.ci is failing, try pre-commit run -a for further information.
  • If CI / test is failing, try poetry run pytest for further information.

Summary by CodeRabbit

  • New Features
    • Introduced a new command in the CLI to enable or disable the flood light feature for light devices.
    • Added an asynchronous method in the Device class to control the flood light state, allowing for direct management of the light functionality.

These enhancements improve user control over their light devices through expanded command-line functionalities.

Copy link
Contributor

coderabbitai bot commented Jul 21, 2024

Walkthrough

The recent changes introduce a new command in the CLI application for light devices, allowing users to enable or disable the flood light feature. This functionality is supported by an asynchronous method in the Device class, enhancing user control over the device's lighting capabilities. Overall, these updates expand the control framework for managing light features comprehensively.

Changes

Files Change Summary
src/uiprotect/cli/lights.py Added set_flood_light command to CLI for enabling/disabling flood light, requiring device ID context.
src/uiprotect/data/devices.py Introduced asynchronous set_flood_light method in Device class to manage flood light functionality.

Poem

🐰 In the glow of lights so bright,
A flood of joy, a new delight.
With a flick, the feature's set,
Control your world, no need to fret!
Hopping high with glee and cheer,
Our floods are on—let's spread the cheer!
🌟


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 Configuration 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.

Copy link

codecov bot commented Jul 21, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Files Patch % Lines
src/uiprotect/data/devices.py 25.00% 3 Missing ⚠️
Files Coverage Δ
src/uiprotect/data/devices.py 85.12% <25.00%> (-0.14%) ⬇️

Copy link
Contributor

@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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1102f41 and b5b4af1.

Files selected for processing (2)
  • src/uiprotect/cli/lights.py (1 hunks)
  • src/uiprotect/data/devices.py (1 hunks)
Additional context used
GitHub Check: codecov/patch
src/uiprotect/data/devices.py

[warning] 177-178: src/uiprotect/data/devices.py#L177-L178
Added lines #L177 - L178 were not covered by tests


[warning] 180-180: src/uiprotect/data/devices.py#L180
Added line #L180 was not covered by tests

Additional comments not posted (2)
src/uiprotect/cli/lights.py (1)

123-128: LGTM!

The code changes are approved.

src/uiprotect/data/devices.py (1)

174-180: LGTM!

The code changes are approved.

Tools
GitHub Check: codecov/patch

[warning] 177-178: src/uiprotect/data/devices.py#L177-L178
Added lines #L177 - L178 were not covered by tests


[warning] 180-180: src/uiprotect/data/devices.py#L180
Added line #L180 was not covered by tests

Comment on lines +122 to +128
@app.command()
def set_flood_light(ctx: typer.Context, enabled: bool) -> None:
"""Sets flood light (force on) for light device."""
base.require_device_id(ctx)
obj: Light = ctx.obj.device

base.run(ctx, obj.set_flood_light(enabled))
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder: Add tests.

The new function set_flood_light lacks unit tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Comment on lines +174 to +180
async def set_flood_light(self, enabled: bool) -> None:
"""Sets the flood light (force on) for the light"""

def callback() -> None:
self.light_on_settings.is_led_force_on = enabled

await self.queue_update(callback)
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder: Add tests.

The new method set_flood_light lacks unit tests.

Do you want me to generate the unit testing code or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 177-178: src/uiprotect/data/devices.py#L177-L178
Added lines #L177 - L178 were not covered by tests


[warning] 180-180: src/uiprotect/data/devices.py#L180
Added line #L180 was not covered by tests

@bdraco bdraco changed the title Add option to force on flood light for light devices feat: add option to force on flood light for light devices Jul 21, 2024
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.

@zevmela Thanks for the PR. Can you add some test coverage to get the CI passing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants