Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Blink Mini arming control #546

Merged
merged 4 commits into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions blinkpy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,21 @@ def http_get(blink, url, stream=False, json=True, is_retry=False, timeout=TIMEOU
)


def http_post(blink, url, is_retry=False, timeout=TIMEOUT):
def http_post(blink, url, is_retry=False, data=None, json=True, timeout=TIMEOUT):
"""
Perform an http post request.

:param url: URL to perfom post request.
:param is_retry: Is this part of a re-auth attempt?
:param data: str body for post request
:param json: Return json response? TRUE/False
"""
_LOGGER.debug("Making POST request to %s", url)
return blink.auth.query(
url=url, headers=blink.auth.header, reqtype="post", is_retry=is_retry
url=url,
headers=blink.auth.header,
reqtype="post",
is_retry=is_retry,
json_resp=json,
data=data,
)
7 changes: 4 additions & 3 deletions blinkpy/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
from blinkpy import api
from blinkpy.helpers.constants import TIMEOUT_MEDIA
from json import dumps

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -252,9 +253,9 @@ def arm(self):
@arm.setter
def arm(self, value):
"""Set camera arm status."""
_LOGGER.warning(
"Individual camera motion detection enable/disable for Blink Mini cameras is unsupported at this time."
)
url = f"{self.sync.urls.base_url}/api/v1/accounts/{self.sync.blink.account_id}/networks/{self.network_id}/owls/{self.camera_id}/config"
data = dumps({"enabled": value})
return api.http_post(self.sync.blink, url, json=False, data=data)

def snap_picture(self):
"""Snap picture for a blink mini camera."""
Expand Down