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

0.22.7 #912

Merged
merged 51 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6804178
Dev bump
fronzbot Jan 25, 2024
bb47175
Merge pull request #871 from fronzbot/dev-version-bump
fronzbot Jan 25, 2024
0f5c5da
readd battery_voltage and wifi_strength
dashrb Jan 30, 2024
1ded4eb
only cache mini and doorbells
dashrb Jan 30, 2024
c7bb408
include tests for battery_voltage and wifi_strength
dashrb Jan 30, 2024
9f059a0
update missing tests
dashrb Jan 30, 2024
a445353
Update CONTRIBUTING.rst with typo fix
dashrb Jan 30, 2024
a50c425
expose battery_voltage as a property for easy access from HA
dashrb Jan 30, 2024
575e37a
shorten comment to appease lint gods
dashrb Jan 30, 2024
7e6b3ca
Bump pytest-sugar from 0.9.7 to 1.0.0
dependabot[bot] Feb 2, 2024
14665e7
Bump ruff from 0.1.14 to 0.2.0
dependabot[bot] Feb 2, 2024
0882c5f
Merge pull request #877 from dashrb/dashrb-patch-batteryvoltage
fronzbot Feb 4, 2024
0ec0346
Merge pull request #880 from fronzbot/dependabot/pip/ruff-0.2.0
fronzbot Feb 4, 2024
8d3801c
Bump pytest from 7.4.4 to 8.0.2
dependabot[bot] Feb 26, 2024
eacd157
Bump ruff from 0.2.0 to 0.3.0
dependabot[bot] Feb 29, 2024
851451f
Test for none type in command function
mkmer Mar 6, 2024
d704a01
Fix test
mkmer Mar 7, 2024
5a61a53
Merge pull request #892 from mkmer/test-for-none
fronzbot Mar 7, 2024
fdf74f9
Merge pull request #889 from fronzbot/dependabot/pip/ruff-0.3.0
fronzbot Mar 7, 2024
09998cd
Merge pull request #888 from fronzbot/dependabot/pip/pytest-8.0.2
fronzbot Mar 7, 2024
72f69ac
Merge pull request #879 from fronzbot/dependabot/pip/pytest-sugar-1.0.0
fronzbot Mar 7, 2024
85ab1f1
Bump pytest-timeout from 2.2.0 to 2.3.1
dependabot[bot] Mar 8, 2024
7abee33
Bump pytest from 8.0.2 to 8.1.1
dependabot[bot] Mar 11, 2024
5e73b37
Bump pytest-cov from 4.1.0 to 5.0.0
dependabot[bot] Mar 25, 2024
3811235
TIdy up the aiofiles imports
mkmer Apr 12, 2024
c7bb530
Fix pyproject.toml warnings
mkmer Apr 12, 2024
e769d54
Update to node20
mkmer Apr 12, 2024
49744c0
Fix lint errors
mkmer Apr 12, 2024
0a91e49
Merge pull request #907 from mkmer/Update-to-node20
fronzbot Apr 12, 2024
edb6b62
Merge pull request #902 from fronzbot/dependabot/pip/pytest-cov-5.0.0
fronzbot Apr 12, 2024
f472131
Merge branch 'dev' into dependabot/pip/pytest-8.1.1
fronzbot Apr 12, 2024
0a4a08b
Update coverage.yml
fronzbot Apr 12, 2024
5b38e5d
Update codecov.yml
fronzbot Apr 12, 2024
e355969
Update codecov.yml
fronzbot Apr 12, 2024
7e0f7b7
Update codecov.yml
fronzbot Apr 12, 2024
42c37fe
Merge pull request #908 from fronzbot/fix-codecov
fronzbot Apr 12, 2024
e44e6ca
Merge pull request #906 from mkmer/aiofiles-import-cleanup
fronzbot Apr 12, 2024
99cd15e
Merge pull request #895 from fronzbot/dependabot/pip/pytest-8.1.1
fronzbot Apr 12, 2024
04d58ac
Merge pull request #894 from fronzbot/dependabot/pip/pytest-timeout-2…
fronzbot Apr 12, 2024
e7c7aad
Bump ruff from 0.3.0 to 0.3.7
dependabot[bot] Apr 12, 2024
ffd7297
Bump coverage from 7.4.0 to 7.4.4
dependabot[bot] Apr 12, 2024
9a7d9fc
Bump build from 1.0.3 to 1.2.1
dependabot[bot] Apr 12, 2024
9de3f17
Merge pull request #909 from fronzbot/dependabot/pip/ruff-0.3.7
fronzbot Apr 12, 2024
560131b
Merge pull request #903 from fronzbot/dependabot/pip/build-1.2.1
fronzbot Apr 12, 2024
32e2cf0
Merge branch 'dev' into dependabot/pip/coverage-7.4.4
fronzbot Apr 12, 2024
aea5d77
Reformat to enable black 24.3.0
mkmer Apr 12, 2024
851cb03
Merge pull request #910 from mkmer/black-24.3.0-reformat
fronzbot Apr 12, 2024
9a7afce
Merge pull request #898 from fronzbot/dependabot/pip/coverage-7.4.4
fronzbot Apr 12, 2024
705c143
Update CHANGES.rst
fronzbot Apr 15, 2024
e9048d6
Version bump
fronzbot Apr 15, 2024
234e418
Merge pull request #913 from fronzbot/fronzbot-patch-1
fronzbot Apr 15, 2024
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
7 changes: 4 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -33,9 +33,10 @@ jobs:
run: |
tox -r -e cov
- name: Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
file: ./coverage.xml
name: blinkpy
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog

A list of changes between each release

0.22.7 (2024-04-15)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

See release notes: (`0.22.7 <https://github.com/fronzbot/blinkpy/releases/tag/v0.22.7>`__)


0.22.6 (2024-01-24)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ You can then run all of the tests with the following command:

**Tips**

If you only want to see if you can pass the local tests, you can run ``tox -e py37`` (or whatever python version you have installed. Only ``py36``, ``py37``, and ``py38`` will be accepted). If you just want to check for style violations, you can run ``tox -e lint``. Regardless, when you submit a pull request, your code MUST pass both the unit tests, and the linters.
If you only want to see if you can pass the local tests, you can run ``tox -e py39`` (or whatever python version you have installed. Only ``py39`` through ``py312`` will be accepted). If you just want to check for style violations, you can run ``tox -e lint``. Regardless, when you submit a pull request, your code MUST pass both the unit tests, and the linters.

If you need to change anything in ``requirements.txt`` for any reason, you'll want to regenerate the virtual envrionments used by ``tox`` by running with the ``-r`` flag: ``tox -r``

Expand All @@ -104,7 +104,7 @@ If your code is taking a while to develop, you may be behind the ``dev`` branch,

If rebase detects conflicts, repeat the following process until all changes have been resolved:

1. ``git status`` shows you the filw with a conflict. You will need to edit that file and resolve the lines between ``<<<< | >>>>``.
1. ``git status`` shows you the file with a conflict. You will need to edit that file and resolve the lines between ``<<<< | >>>>``.
2. Add the modified file: ``git add <file>`` or ``git add .``.
3. Continue rebase: ``git rebase --continue``.
4. Repeat until all conflicts resolved.
1 change: 1 addition & 0 deletions blinkapp/blinkapp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Script to run blinkpy as an blinkapp."""

from os import environ
import asyncio
from datetime import datetime, timedelta
Expand Down
9 changes: 5 additions & 4 deletions blinkpy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,9 @@ async def wait_for_command(blink, json_data: dict) -> bool:
_LOGGER.debug("Making GET request waiting for command")
status = await request_command_status(blink, network_id, command_id)
_LOGGER.debug("command status %s", status)
if status.get("status_code", 0) != 908:
return False
if status.get("complete"):
return True
if status:
if status.get("status_code", 0) != 908:
return False
if status.get("complete"):
return True
await sleep(COMMAND_POLL_TIME)
1 change: 1 addition & 0 deletions blinkpy/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Login handler for blink."""

import logging
from aiohttp import (
ClientSession,
Expand Down
4 changes: 1 addition & 3 deletions blinkpy/blinkpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import logging
import datetime
import aiofiles
from aiofiles import ospath

from requests.structures import CaseInsensitiveDict
from dateutil.parser import parse
from slugify import slugify
Expand Down Expand Up @@ -414,7 +412,7 @@ async def _parse_downloaded_items(self, result, camera, path, delay, debug):
filename = os.path.join(path, filename)

if not debug:
if await ospath.isfile(filename):
if await aiofiles.ospath.isfile(filename):
_LOGGER.info("%s already exists, skipping...", filename)
continue

Expand Down
12 changes: 10 additions & 2 deletions blinkpy/camera.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Defines Blink cameras."""

import copy
import string
import os
Expand Down Expand Up @@ -30,6 +31,7 @@ def __init__(self, sync):
self._version = None
self.motion_enabled = None
self.battery_level = None
self._battery_voltage = None
self.clip = None
# A clip remains in the recent clips list until is has
# been downloaded or has been expired.
Expand Down Expand Up @@ -59,6 +61,7 @@ def attributes(self):
"temperature_calibrated": self.temperature_calibrated,
"battery": self.battery,
"battery_level": self.battery_level,
"battery_voltage": self._battery_voltage,
"thumbnail": self.thumbnail,
"video": self.clip,
"recent_clips": self.recent_clips,
Expand All @@ -78,6 +81,11 @@ def battery(self):
"""Return battery as string."""
return self.battery_state

@property
def battery_voltage(self):
"""Return battery voltage as a number in 100ths of volts, so 165 = 1.65v."""
return self._battery_voltage

@property
def temperature_c(self):
"""Return temperature in celsius."""
Expand Down Expand Up @@ -246,14 +254,14 @@ def extract_config_info(self, config):
self.serial = config.get("serial")
self._version = config.get("fw_version")
self.motion_enabled = config.get("enabled", "unknown")
self._battery_voltage = config.get("battery_voltage", None)
self.battery_state = config.get("battery_state") or config.get("battery")
self.wifi_strength = config.get("wifi_strength")
if signals := config.get("signals"):
self.wifi_strength = signals.get("wifi")
self.battery_level = signals.get("battery")
self.sync_signal_strength = signals.get("lfr")
self.temperature = signals.get("temp")
else:
self.wifi_strength = config.get("wifi_strength")
self.temperature = config.get("temperature")
self.product_type = config.get("type")

Expand Down
2 changes: 1 addition & 1 deletion blinkpy/helpers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import time
import secrets
import re
import aiofiles
from asyncio import sleep
from calendar import timegm
from functools import wraps
from getpass import getpass
import aiofiles
import dateutil.parser
from blinkpy.helpers import constants as const

Expand Down
4 changes: 3 additions & 1 deletion blinkpy/sync_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Defines a sync module for Blink."""

import logging
import string
import datetime
Expand Down Expand Up @@ -49,10 +50,11 @@ def __init__(self, blink, network_name, network_id, camera_list):
self.last_records = {}
self.camera_list = camera_list
self.available = False
# type_key_map is only for the mini's and the doorbells.
# Outdoor cameras have their own URL API which must be queried.
self.type_key_map = {
"mini": "owls",
"doorbell": "doorbells",
"outdoor": "cameras",
}
self._names_table = {}
self._local_storage = {
Expand Down
19 changes: 11 additions & 8 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
codecov:
branch: dev
bot: codecov-io
max_report_age: 24
disable_default_path_fixes: no
require_ci_to_pass: yes
notify:
wait_for_ci: yes
coverage:
precision: 1
round: down
range: 85..100
status:
project:
default:
target: 80%
threshold: 2%
patch:
default:
target: 60%
target: auto
threshold: 5%

comment: true
require_ci_to_pass: yes

17 changes: 8 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "blinkpy"
version = "0.22.6"
version = "0.22.7"
license = {text = "MIT"}
description = "A Blink camera Python Library."
readme = "README.rst"
Expand Down Expand Up @@ -39,7 +39,7 @@ include-package-data = true
include = ["blinkpy*"]

[tool.ruff]
select = [
lint.select = [
"C", # complexity
"D", # docstrings
"E", # pydocstyle
Expand All @@ -54,11 +54,11 @@ select = [
"Q000", # Double quotes found but single quotes preferred
"SIM118", # Use {key} in {dict} instead of {key} in {dict}.keys()
"TRY004", # Prefer TypeError exception for invalid type
"TRY200", # Use raise from to specify exception cause
"B904", # Use raise from to specify exception cause
"UP", # pyupgrade
"W", # pycodestyle
]
ignore = [
lint.ignore = [
"D202", # No blank lines allowed after function docstring
"D203", # 1 blank line required before class docstring
"D212", # Multi-line docstring summary should start at the first line
Expand Down Expand Up @@ -86,10 +86,9 @@ ignore = [

line-length = 88

target-version = "py311"
target-version = "py312"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]


[tool.ruff.mccabe]
max-complexity = 25
[tool.ruff.lint.mccabe]
max-complexity = 25
16 changes: 8 additions & 8 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ruff==0.1.14
black==23.12.1
build==1.0.3
coverage==7.4.0
pytest==7.4.4
pytest-cov==4.1.0
pytest-sugar==0.9.7
pytest-timeout==2.2.0
ruff==0.3.7
black==24.3.0
build==1.2.1
coverage==7.4.4
pytest==8.1.1
pytest-cov==5.0.0
pytest-sugar==1.0.0
pytest-timeout==2.3.1
restructuredtext-lint==1.4.0
pygments==2.17.2
testtools>=2.4.0
Expand Down
1 change: 1 addition & 0 deletions tests/mock_responses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Simple mock responses definitions."""

from unittest import mock


Expand Down
6 changes: 3 additions & 3 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ async def test_wait_for_command(self, mock_resp):
response = await api.wait_for_command(self.blink, COMMAND_RESPONSE)
assert response

mock_resp.side_effect = (COMMAND_NOT_COMPLETE, {})
response = await api.wait_for_command(self.blink, COMMAND_RESPONSE)
self.assertFalse(response)
# mock_resp.side_effect = (COMMAND_NOT_COMPLETE, COMMAND_NOT_COMPLETE, None)
# response = await api.wait_for_command(self.blink, COMMAND_RESPONSE)
# self.assertFalse(response)

mock_resp.side_effect = (COMMAND_COMPLETE_BAD, {})
response = await api.wait_for_command(self.blink, COMMAND_RESPONSE)
Expand Down
1 change: 1 addition & 0 deletions tests/test_blink_functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests camera and system functions."""

from unittest import mock, IsolatedAsyncioTestCase
import time
import random
Expand Down
21 changes: 12 additions & 9 deletions tests/test_blinkpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ async def test_throttle(self, mock_time):
self.assertEqual(self.blink.last_refresh, None)
self.assertEqual(self.blink.check_if_ok_to_update(), True)
self.assertEqual(self.blink.last_refresh, None)
with mock.patch(
"blinkpy.sync_module.BlinkSyncModule.refresh", return_value=True
), mock.patch("blinkpy.blinkpy.Blink.get_homescreen", return_value=True):
with (
mock.patch(
"blinkpy.sync_module.BlinkSyncModule.refresh", return_value=True
),
mock.patch("blinkpy.blinkpy.Blink.get_homescreen", return_value=True),
):
await self.blink.refresh(force=True)

self.assertEqual(self.blink.last_refresh, now)
Expand All @@ -81,12 +84,12 @@ async def test_throttle(self, mock_time):
async def test_not_available_refresh(self):
"""Check that setup_post_verify executes on refresh when not avialable."""
self.blink.available = False
with mock.patch(
"blinkpy.sync_module.BlinkSyncModule.refresh", return_value=True
), mock.patch(
"blinkpy.blinkpy.Blink.get_homescreen", return_value=True
), mock.patch(
"blinkpy.blinkpy.Blink.setup_post_verify", return_value=True
with (
mock.patch(
"blinkpy.sync_module.BlinkSyncModule.refresh", return_value=True
),
mock.patch("blinkpy.blinkpy.Blink.get_homescreen", return_value=True),
mock.patch("blinkpy.blinkpy.Blink.setup_post_verify", return_value=True),
):
self.assertTrue(await self.blink.refresh(force=True))
with mock.patch("time.time", return_value=time.time() + 4):
Expand Down
6 changes: 4 additions & 2 deletions tests/test_camera_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"serial": "12345678",
"enabled": False,
"battery_state": "ok",
"battery_voltage": 163,
"wifi_strength": -38,
"signals": {"lfr": 5, "wifi": 4, "battery": 3, "temp": 68},
"thumbnail": "/thumb",
}
Expand Down Expand Up @@ -68,7 +70,8 @@ async def test_camera_update(self, mock_resp):
self.assertEqual(self.camera.temperature, 68)
self.assertEqual(self.camera.temperature_c, 20)
self.assertEqual(self.camera.temperature_calibrated, 71)
self.assertEqual(self.camera.wifi_strength, 4)
self.assertEqual(self.camera.battery_voltage, 163)
self.assertEqual(self.camera.wifi_strength, -38)
self.assertEqual(
self.camera.thumbnail, "https://rest-test.immedia-semi.com/thumb.jpg"
)
Expand Down Expand Up @@ -378,5 +381,4 @@ async def test_missing_keys(self, mock_resp):
mresp.MockResponse({"foobar": 200}, 200, raw_data="foobar"),
]
await self.camera.update(config, expire_clips=False, force=True)
self.assertEqual(self.camera.wifi_strength, None)
self.assertEqual(self.camera.battery_level, None)
1 change: 1 addition & 0 deletions tests/test_doorbell_as_sync.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests camera and system functions."""

from unittest import mock
from unittest import IsolatedAsyncioTestCase
import pytest
Expand Down
1 change: 1 addition & 0 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test blink Utils errors."""

import unittest
from blinkpy.helpers.errors import (
USERNAME,
Expand Down
1 change: 1 addition & 0 deletions tests/test_mini_as_sync.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests camera and system functions."""

from unittest import mock
from unittest import IsolatedAsyncioTestCase
import pytest
Expand Down
3 changes: 2 additions & 1 deletion tests/test_sync_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests camera and system functions."""

import datetime
import logging
from unittest import IsolatedAsyncioTestCase
Expand Down Expand Up @@ -31,7 +32,7 @@ def setUp(self):
self.blink: Blink = Blink(motion_interval=0, session=mock.AsyncMock())
self.blink.last_refresh = 0
self.blink.urls = BlinkURLHandler("test")
self.blink.sync["test"]: (BlinkSyncModule) = BlinkSyncModule(
self.blink.sync["test"]: BlinkSyncModule = BlinkSyncModule(
self.blink, "test", "1234", []
)
self.blink.sync["test"].network_info = {"network": {"armed": True}}
Expand Down
Loading