Skip to content

Commit

Permalink
Merge pull request #1 from austinc3030/percamera_snooze
Browse files Browse the repository at this point in the history
Initial Commit
  • Loading branch information
austinc3030 authored Jul 5, 2024
2 parents 2e48b0c + 8d2f830 commit 8e67f68
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
32 changes: 32 additions & 0 deletions blinkpy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,38 @@ async def request_update_config(
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 == "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
):
Expand Down
43 changes: 43 additions & 0 deletions blinkpy/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
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(
Expand Down Expand Up @@ -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

0 comments on commit 8e67f68

Please sign in to comment.