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
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/uiprotect/cli/lights.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,12 @@ def set_duration(
obj: Light = ctx.obj.device

base.run(ctx, obj.set_duration(timedelta(seconds=duration)))


@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))
Comment on lines +122 to +128
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?

8 changes: 8 additions & 0 deletions src/uiprotect/data/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@
self.camera_id = camera.id
await self.save_device(data_before_changes, force_emit=True)

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

Check warning on line 178 in src/uiprotect/data/devices.py

View check run for this annotation

Codecov / codecov/patch

src/uiprotect/data/devices.py#L177-L178

Added lines #L177 - L178 were not covered by tests

await self.queue_update(callback)

Check warning on line 180 in src/uiprotect/data/devices.py

View check run for this annotation

Codecov / codecov/patch

src/uiprotect/data/devices.py#L180

Added line #L180 was not covered by tests
Comment on lines +174 to +180
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


async def set_status_light(self, enabled: bool) -> None:
"""Sets the status indicator light for the light"""

Expand Down
Loading