diff --git a/blinkpy/api.py b/blinkpy/api.py index 95dc280b..9809e976 100644 --- a/blinkpy/api.py +++ b/blinkpy/api.py @@ -491,6 +491,42 @@ async def request_update_config( return None return await http_post(blink, url, json=False, data=data) +async def request_camera_snooze( + blink, network, camera_id, product_type="owl", data=None + ): + """ + Update camera snooze configuration. + + :param blink: Blink instance. + :param network: Sync module network id. + :param camera_id: ID of camera + :param product_type: Camera product type "owl" or "catalina" + :param data: string w/JSON dict of parameters/values to update + """ + if product_type == "catalina": + url = ( + f"{blink.urls.base_url}/api/v1/accounts/{blink.account_id}/" + f"networks/{network}/cameras/{camera_id}/snooze" + ) + elif product_type == "owl": + url = ( + f"{blink.urls.base_url}/api/v1/accounts/{blink.account_id}/" + f"networks/{network}/owls/{camera_id}/snooze" + ) + elif product_type == "doorbell": + url = ( + f"{blink.urls.base_url}/api/v1/accounts/{blink.account_id}/" + f"networks/{network}/doorbells/{camera_id}/snooze" + ) + else: + _LOGGER.info( + "Camera %s with product type %s snooze update not implemented.", + camera_id, + product_type, + ) + return None + return await http_post(blink, url, json=False, data=data) + async def http_get( blink, url, stream=False, json=True, is_retry=False, timeout=TIMEOUT diff --git a/blinkpy/camera.py b/blinkpy/camera.py index b3c4a4b7..eeaa8156 100644 --- a/blinkpy/camera.py +++ b/blinkpy/camera.py @@ -170,6 +170,35 @@ async def async_set_night_vision(self, value): return await res.json() return None + @property + async def snooze_till(self): + """Return snooze_till status.""" + res = await api.request_get_config( + self.sync.blink, + self.network_id, + self.camera_id, + product_type=self.product_type, + ) + if res is None: + return None + if self.product_type == "catalina": + res = res.get("camera", [{}])[0]["snooze_till"] + return res + + async def async_snooze(self): + """Set camera snooze status.""" + data = dumps({"snooze_time": 240}) + res = await api.request_camera_snooze( + self.sync.blink, + self.network_id, + self.camera_id, + product_type=self.product_type, + data=data, + ) + if res and res.status == 200: + return await res.json() + return None + async def record(self): """Initiate clip recording.""" return await api.request_new_video( @@ -625,3 +654,17 @@ async def get_liveview(self): server = response["server"] link = server.replace("immis://", "rtsps://") return link + + async def async_snooze(self): + """Set camera snooze status.""" + data = dumps({"snooze_time": 240}) + res = await api.request_camera_snooze( + self.sync.blink, + self.network_id, + self.camera_id, + product_type="doorbell", + data=data, + ) + if res and res.status == 200: + return await res.json() + return None