Skip to content

Commit

Permalink
fix: handle IndexError selecting value "below 1 Lux" for icr_custom_v…
Browse files Browse the repository at this point in the history
…alue (#283)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
RaHehl and pre-commit-ci[bot] authored Nov 20, 2024
1 parent a9931fa commit 41f5a3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
13 changes: 1 addition & 12 deletions src/uiprotect/data/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,7 @@
from .nvr import Event, Liveview

PRIVACY_ZONE_NAME = "pyufp_privacy_zone"
LUX_MAPPING_VALUES = [
30,
25,
20,
15,
12,
10,
7,
5,
3,
1,
]
LUX_MAPPING_VALUES = [30, 25, 20, 15, 12, 10, 7, 5, 3, 1, 0]

_LOGGER = logging.getLogger(__name__)

Expand Down
8 changes: 7 additions & 1 deletion tests/data/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,7 @@ async def test_camera_disable_co(camera_obj: Camera | None, status: bool):
@pytest.mark.parametrize(
("value", "lux"),
[
(0, 0),
(1, 1),
(2, 3),
(3, 5),
Expand All @@ -1110,7 +1111,12 @@ async def test_camera_set_icr_custom_lux(
pytest.skip("No camera_obj obj found")

camera_obj.feature_flags.has_led_ir = True
camera_obj.isp_settings.icr_custom_value = 0
if (
value == 0
): # without this there is no change that gets send if the test value is 0
camera_obj.isp_settings.icr_custom_value = 1
else:
camera_obj.isp_settings.icr_custom_value = 0

camera_obj.api.api_request.reset_mock()

Expand Down

0 comments on commit 41f5a3b

Please sign in to comment.