Skip to content

Commit

Permalink
Merge pull request #830 from fronzbot/dev
Browse files Browse the repository at this point in the history
0.22.4
  • Loading branch information
fronzbot authored Dec 18, 2023
2 parents 3d7e49a + 30dce56 commit 0944fed
Show file tree
Hide file tree
Showing 23 changed files with 237 additions and 539 deletions.
18 changes: 18 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ Changelog

A list of changes between each release

0.22.4 (2023-12-18)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**Bugfixes**

- Allow kwargs to throttled functions, await sleep in throttle (`mkmer #823 <https://github.com/fronzbot/blinkpy/pull/800>`__)
- add missing entry in type_key_map (`@Rosi2143 <https://github.com/fronzbot/blinkpy/pull/813>`__)

** Other Changes **

- Delete ReadTheDocs
- python formatter
- docstring format changes
- Bump ruff to 0.1.8
- Bump black to 23.12.0
- Bump pygments to 2.17.2


0.22.3 (2023-11-05)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
5 changes: 1 addition & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
blinkpy |Build Status| |Coverage Status| |Docs| |PyPi Version| |Codestyle|
blinkpy |Build Status| |Coverage Status| |PyPi Version| |Codestyle|
=============================================================================================
A Python library for the Blink Camera system (Python 3.8+)

Expand Down Expand Up @@ -39,7 +39,6 @@ To install the current development version, perform the following steps. Note t
If you'd like to contribute to this library, please read the `contributing instructions <https://github.com/fronzbot/blinkpy/blob/dev/CONTRIBUTING.rst>`__.

For more information on how to use this library, please `read the docs <https://blinkpy.readthedocs.io/en/latest/>`__.

Purpose
-------
Expand Down Expand Up @@ -249,7 +248,5 @@ API steps
:target: https://codecov.io/gh/fronzbot/blinkpy
.. |PyPi Version| image:: https://img.shields.io/pypi/v/blinkpy.svg
:target: https://pypi.python.org/pypi/blinkpy
.. |Docs| image:: https://readthedocs.org/projects/blinkpy/badge/?version=latest
:target: http://blinkpy.readthedocs.io/en/latest/?badge=latest
.. |Codestyle| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
46 changes: 27 additions & 19 deletions blinkpy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def request_syncmodule(blink, network):


@Throttle(seconds=MIN_THROTTLE_TIME)
async def request_system_arm(blink, network):
async def request_system_arm(blink, network, **kwargs):
"""
Arm system.
Expand All @@ -148,7 +148,7 @@ async def request_system_arm(blink, network):


@Throttle(seconds=MIN_THROTTLE_TIME)
async def request_system_disarm(blink, network):
async def request_system_disarm(blink, network, **kwargs):
"""
Disarm system.
Expand Down Expand Up @@ -177,14 +177,14 @@ async def request_command_status(blink, network, command_id):


@Throttle(seconds=MIN_THROTTLE_TIME)
async def request_homescreen(blink):
async def request_homescreen(blink, **kwargs):
"""Request homescreen info."""
url = f"{blink.urls.base_url}/api/v3/accounts/{blink.account_id}/homescreen"
return await http_get(blink, url)


@Throttle(seconds=MIN_THROTTLE_TIME)
async def request_sync_events(blink, network):
async def request_sync_events(blink, network, **kwargs):
"""
Request events from sync module.
Expand All @@ -196,7 +196,7 @@ async def request_sync_events(blink, network):


@Throttle(seconds=MIN_THROTTLE_TIME)
async def request_new_image(blink, network, camera_id):
async def request_new_image(blink, network, camera_id, **kwargs):
"""
Request to capture new thumbnail for camera.
Expand All @@ -211,7 +211,7 @@ async def request_new_image(blink, network, camera_id):


@Throttle(seconds=MIN_THROTTLE_TIME)
async def request_new_video(blink, network, camera_id):
async def request_new_video(blink, network, camera_id, **kwargs):
"""
Request to capture new video clip.
Expand All @@ -226,7 +226,7 @@ async def request_new_video(blink, network, camera_id):


@Throttle(seconds=MIN_THROTTLE_TIME)
async def request_video_count(blink):
async def request_video_count(blink, **kwargs):
"""Request total video count."""
url = f"{blink.urls.base_url}/api/v2/videos/count"
return await http_get(blink, url)
Expand Down Expand Up @@ -304,14 +304,14 @@ async def request_camera_sensors(blink, network, camera_id):
:param blink: Blink instance.
:param network: Sync module network id.
:param camera_id: Camera ID of camera to request sesnor info from.
:param camera_id: Camera ID of camera to request sensor info from.
"""
url = f"{blink.urls.base_url}/network/{network}/camera/{camera_id}/signals"
return await http_get(blink, url)


@Throttle(seconds=MIN_THROTTLE_TIME)
async def request_motion_detection_enable(blink, network, camera_id):
async def request_motion_detection_enable(blink, network, camera_id, **kwargs):
"""
Enable motion detection for a camera.
Expand All @@ -326,8 +326,9 @@ async def request_motion_detection_enable(blink, network, camera_id):


@Throttle(seconds=MIN_THROTTLE_TIME)
async def request_motion_detection_disable(blink, network, camera_id):
"""Disable motion detection for a camera.
async def request_motion_detection_disable(blink, network, camera_id, **kwargs):
"""
Disable motion detection for a camera.
:param blink: Blink instance.
:param network: Sync module network id.
Expand All @@ -340,7 +341,8 @@ async def request_motion_detection_disable(blink, network, camera_id):


async def request_local_storage_manifest(blink, network, sync_id):
"""Update local manifest.
"""
Update local manifest.
Request creation of an updated manifest of video clips stored in
sync module local storage.
Expand All @@ -360,7 +362,8 @@ async def request_local_storage_manifest(blink, network, sync_id):


async def get_local_storage_manifest(blink, network, sync_id, manifest_request_id):
"""Request manifest of video clips stored in sync module local storage.
"""
Request manifest of video clips stored in sync module local storage.
:param blink: Blink instance.
:param network: Sync module network id.
Expand All @@ -377,7 +380,8 @@ async def get_local_storage_manifest(blink, network, sync_id, manifest_request_i


async def request_local_storage_clip(blink, network, sync_id, manifest_id, clip_id):
"""Prepare video clip stored in the sync module to be downloaded.
"""
Prepare video clip stored in the sync module to be downloaded.
:param blink: Blink instance.
:param network: Sync module network id.
Expand All @@ -400,7 +404,8 @@ async def request_local_storage_clip(blink, network, sync_id, manifest_id, clip_


async def request_get_config(blink, network, camera_id, product_type="owl"):
"""Get camera configuration.
"""
Get camera configuration.
:param blink: Blink instance.
:param network: Sync module network id.
Expand All @@ -427,7 +432,8 @@ async def request_get_config(blink, network, camera_id, product_type="owl"):
async def request_update_config(
blink, network, camera_id, product_type="owl", data=None
):
"""Update camera configuration.
"""
Update camera configuration.
:param blink: Blink instance.
:param network: Sync module network id.
Expand Down Expand Up @@ -455,7 +461,8 @@ async def request_update_config(
async def http_get(
blink, url, stream=False, json=True, is_retry=False, timeout=TIMEOUT
):
"""Perform an http get request.
"""
Perform an http get request.
:param url: URL to perform get request.
:param stream: Stream response? True/FALSE
Expand All @@ -474,9 +481,10 @@ async def http_get(


async def http_post(blink, url, is_retry=False, data=None, json=True, timeout=TIMEOUT):
"""Perform an http post request.
"""
Perform an http post request.
:param url: URL to perfom post request.
:param url: URL to perform 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
Expand Down
6 changes: 3 additions & 3 deletions blinkpy/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, login_data=None, no_prompt=False, session=None):
- username
- password
:param no_prompt: Should any user input prompts
be supressed? True/FALSE
be suppressed? True/FALSE
"""
if login_data is None:
login_data = {}
Expand Down Expand Up @@ -152,8 +152,8 @@ async def query(
is_retry=False,
timeout=TIMEOUT,
):
"""Perform server requests."""
"""
"""Perform server requests.
:param url: URL to perform request
:param data: Data to send
:param headers: Headers to send
Expand Down
13 changes: 8 additions & 5 deletions blinkpy/blinkpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(
Useful for preventing motion_detected property
from de-asserting too quickly.
:param no_owls: Disable searching for owl entries (blink mini cameras \
only known entity). Prevents an uneccessary API call \
only known entity). Prevents an unnecessary API call \
if you don't have these in your network.
"""
self.auth = Auth(session=session)
Expand Down Expand Up @@ -101,7 +101,7 @@ async def refresh(self, force=False, force_cache=False):
# Prevents rapid clearing of motion detect property
self.last_refresh = int(time.time())
last_refresh = datetime.datetime.fromtimestamp(self.last_refresh)
_LOGGER.debug(f"last_refresh={last_refresh}")
_LOGGER.debug("last_refresh = %s", last_refresh)

return True
return False
Expand All @@ -128,8 +128,9 @@ async def start(self):
# Initialize last_refresh to be just before the refresh delay period.
self.last_refresh = int(time.time() - self.refresh_rate * 1.05)
_LOGGER.debug(
f"Initialized last_refresh to {self.last_refresh} == "
f"{datetime.datetime.fromtimestamp(self.last_refresh)}"
"Initialized last_refresh to %s == %s",
self.last_refresh,
datetime.datetime.fromtimestamp(self.last_refresh),
)

return await self.setup_post_verify()
Expand Down Expand Up @@ -167,12 +168,13 @@ async def setup_sync_module(self, name, network_id, cameras):
await self.sync[name].start()

async def get_homescreen(self):
"""Get homecreen information."""
"""Get homescreen information."""
if self.no_owls:
_LOGGER.debug("Skipping owl extraction.")
self.homescreen = {}
return
self.homescreen = await api.request_homescreen(self)
_LOGGER.debug("homescreen = %s", util.json_dumps(self.homescreen))

async def setup_owls(self):
"""Check for mini cameras."""
Expand Down Expand Up @@ -234,6 +236,7 @@ async def setup_camera_list(self):
response = await api.request_camera_usage(self)
try:
for network in response["networks"]:
_LOGGER.info("network = %s", util.json_dumps(network))
camera_network = str(network["network_id"])
if camera_network not in all_cameras:
all_cameras[camera_network] = []
Expand Down
Loading

0 comments on commit 0944fed

Please sign in to comment.