Sync Module Snooze#1274
Conversation
- Add snoozed async property to BlinkSyncModule - Add async_snooze() method to BlinkSyncModule - Add request_sync_snooze() API function - Tests
There was a problem hiding this comment.
Pull request overview
This PR adds network-level “snooze” support for Blink sync modules by introducing an API helper to get/set snooze state and exposing it on BlinkSyncModule via an async snoozed property and async_snooze() setter, with accompanying test coverage.
Changes:
- Added
request_sync_snooze()API helper (GET to read, POST to set). - Added
BlinkSyncModule.snoozed(async property) andBlinkSyncModule.async_snooze()to read/set snooze state. - Added tests covering snoozed parsing and snooze set behavior, plus API request coverage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
blinkpy/sync_module.py |
Adds snooze read/set surface area on BlinkSyncModule and parses snooze_till into a boolean state. |
blinkpy/api.py |
Introduces request_sync_snooze() endpoint wrapper used by sync modules and tests. |
tests/test_sync_module.py |
Adds unit tests for snoozed and async_snooze() behavior. |
tests/test_api.py |
Adds unit test for the new request_sync_snooze() API helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| snooze_till = res.get("snooze_till") | ||
| if not snooze_till: | ||
| return False | ||
| expiry = datetime.datetime.fromisoformat(snooze_till) |
There was a problem hiding this comment.
Addressed in commit 8daedf5 — normalized trailing Z to +00:00 before fromisoformat(), switched snooze payload to compact JSON via indent=None, and added test_snoozed_expired and test_snoozed_z_suffix tests covering the expiry and UTC-suffix cases.
|
|
||
| async def async_snooze(self, snooze_time=240): | ||
| """Set sync snooze status.""" | ||
| data = json_dumps({"snooze_time": snooze_time}) |
There was a problem hiding this comment.
Addressed in commit 8daedf5 — normalized trailing Z to +00:00 before fromisoformat(), switched snooze payload to compact JSON via indent=None, and added test_snoozed_expired and test_snoozed_z_suffix tests covering the expiry and UTC-suffix cases.
| """Check that we get snoozed status.""" | ||
| result = await self.blink.sync["test"].snoozed | ||
| self.assertTrue(result) | ||
|
|
There was a problem hiding this comment.
Addressed in commit 8daedf5 — normalized trailing Z to +00:00 before fromisoformat(), switched snooze payload to compact JSON via indent=None, and added test_snoozed_expired and test_snoozed_z_suffix tests covering the expiry and UTC-suffix cases.
Description:
Adds
async_snooze()and asnoozedproperty toBlinkSyncModulefor snoozing at the network level. Uses GET to read snooze state and POST to set it via a newrequest_sync_snooze()API function. Thesnoozedproperty checks thesnooze_tilltimestamp against the current time so it correctly returnsFalseonce a snooze has expired.Checklist:
toxrun successfully PR cannot be meged unless tests pass