Skip to content

Commit 4482749

Browse files
committed
expose scheduling of light calibration
1 parent 0121d4a commit 4482749

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

plugwise_usb/api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,13 @@ async def set_motion_sensitivity_level(
680680
681681
"""
682682

683+
async def scan_calibrate_light(self) -> bool:
684+
"""Request to calibration light sensitivity of Scan device.
685+
686+
Description:
687+
Request to calibration light sensitivity of Scan device.
688+
"""
689+
683690
async def set_relay_init(self, state: bool) -> bool:
684691
"""Change the initial state of the relay.
685692

plugwise_usb/nodes/scan.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(
8686

8787
self._motion_state = MotionState()
8888
self._motion_config = MotionConfig()
89-
89+
self._scan_calibrate_light_scheduled: bool = False
9090
self._configure_daylight_mode_task: Task[Coroutine[Any, Any, None]] | None = (
9191
None
9292
)
@@ -449,6 +449,8 @@ async def _run_awake_tasks(self) -> None:
449449
await super()._run_awake_tasks()
450450
if self._motion_config.dirty:
451451
await self._configure_scan_task()
452+
if self._scan_calibrate_light_scheduled:
453+
await self._scan_calibrate_light()
452454
await self.publish_feature_update_to_subscribers(
453455
NodeFeature.MOTION_CONFIG,
454456
self._motion_config,
@@ -511,14 +513,19 @@ async def _scan_configure_update(self) -> None:
511513
self.save_cache(),
512514
)
513515

514-
async def scan_calibrate_light(self) -> bool:
516+
async def scan_calibrate_light(self) -> None:
517+
"""Schedule light sensitivity calibration of Scan device."""
518+
self._scan_calibrate_light_scheduled = True
519+
520+
async def _scan_calibrate_light(self) -> bool:
515521
"""Request to calibration light sensitivity of Scan device."""
516522
request = ScanLightCalibrateRequest(self._send, self._mac_in_bytes)
517523
if (response := await request.send()) is not None:
518524
if (
519525
response.node_ack_type
520526
== NodeAckResponseType.SCAN_LIGHT_CALIBRATION_ACCEPTED
521527
):
528+
self._scan_calibrate_light_scheduled = False
522529
return True
523530
return False
524531
raise NodeTimeout(

0 commit comments

Comments
 (0)