Skip to content

Commit f68e20b

Browse files
authored
Merge pull request #869 from fronzbot/dev
v0.22.6
2 parents 5f929f0 + ceecb3c commit f68e20b

File tree

12 files changed

+90
-40
lines changed

12 files changed

+90
-40
lines changed

CHANGES.rst

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,50 @@ Changelog
44

55
A list of changes between each release
66

7+
8+
0.22.6 (2024-01-24)
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10+
11+
**Bugfixes**
12+
13+
- Test for None type in poll_local_storage_manifest (`@mkmer #859 <https://github.com/fronzbot/blinkpy/pull/859>`__)
14+
- Update image after snap by (`@mkmer #861 <https://github.com/fronzbot/blinkpy/pull/861>`__)
15+
- fix missing ':' before port number in rtsps adress (`@Rosi2143 #863 <https://github.com/fronzbot/blinkpy/pull/863>`__)
16+
- New temperature location (`@mkmer #867 <https://github.com/fronzbot/blinkpy/pull/867>`__)
17+
18+
**Other changes**
19+
20+
- Add properties for version information (`@mkmer #854 <https://github.com/fronzbot/blinkpy/pull/854>`__)
21+
- Complete header match (`@mkmer #856 <https://github.com/fronzbot/blinkpy/pull/856>`__)
22+
- Bump ruff from 0.1.11 to 0.1.13 (`@dependabot #858 <https://github.com/fronzbot/blinkpy/pull/858>`__)
23+
- Add option to change agent from Auth() init (`@mkmer #860 <https://github.com/fronzbot/blinkpy/pull/860>`__)
24+
- Add notification key to login (`@mkmer #862 <https://github.com/fronzbot/blinkpy/pull/862>`__)
25+
- Bump ruff from 0.1.13 to 0.1.14 (`@dependabot #868 <https://github.com/fronzbot/blinkpy/pull/868>`__)
26+
27+
728
0.22.5 (2024-01-07)
829
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
930

1031
Warning: This release removes support for Python 3.8 and adds Python 3.12 support.
1132

1233
**Bugfixes**
1334

14-
- Add new keys for wifi, lfr, and battery (`mkmer #835 <https://github.com/fronzbot/blinkpy/pull/835>`__)
15-
- Battery level (`mkmer #837 <https://github.com/fronzbot/blinkpy/pull/837>`__)
16-
- Address not awaited warning (`mkmer #838 <https://github.com/fronzbot/blinkpy/pull/838>`__)
17-
- Catch ContentTypeError in 2FA (`mkmer #843 <https://github.com/fronzbot/blinkpy/pull/843>`__)
18-
- Handle empty put response in wait_command (`mkmer #847 <https://github.com/fronzbot/blinkpy/pull/847>`__)
19-
- Change default user agent to fix API calls (`gingerm0nkey #848 <https://github.com/fronzbot/blinkpy/pull/848>`__)
20-
- Android for new user agent (`mkmer #850 <https://github.com/fronzbot/blinkpy/pull/850>`__)
35+
- Add new keys for wifi, lfr, and battery (`@mkmer #835 <https://github.com/fronzbot/blinkpy/pull/835>`__)
36+
- Battery level (`@mkmer #837 <https://github.com/fronzbot/blinkpy/pull/837>`__)
37+
- Address not awaited warning (`@mkmer #838 <https://github.com/fronzbot/blinkpy/pull/838>`__)
38+
- Catch ContentTypeError in 2FA (`@mkmer #843 <https://github.com/fronzbot/blinkpy/pull/843>`__)
39+
- Handle empty put response in wait_command (`@mkmer #847 <https://github.com/fronzbot/blinkpy/pull/847>`__)
40+
- Change default user agent to fix API calls (`@gingerm0nkey #848 <https://github.com/fronzbot/blinkpy/pull/848>`__)
41+
- Android for new user agent (`@mkmer #850 <https://github.com/fronzbot/blinkpy/pull/850>`__)
2142

2243
**Other changes**
2344

24-
- Remove Py3.8, add 3.12 (`fronzbot #839 <https://github.com/fronzbot/blinkpy/pull/839>`__)
25-
- Deprecate py38 (`fronzbot #840 <https://github.com/fronzbot/blinkpy/pull/840>`__)
26-
- Add/extract firmware version (`mkmer #842 <https://github.com/fronzbot/blinkpy/pull/842>`__)
27-
- Additional logging, fix blinksync json (`mkmer #844 <https://github.com/fronzbot/blinkpy/pull/844>`__)
28-
- Log text response (`mkmer #845 <https://github.com/fronzbot/blinkpy/pull/845>`__)
29-
- Add tests for logging (`mkmer #846 <https://github.com/fronzbot/blinkpy/pull/846>`__)
45+
- Remove Py3.8, add 3.12 (`@fronzbot #839 <https://github.com/fronzbot/blinkpy/pull/839>`__)
46+
- Deprecate py38 (`@fronzbot #840 <https://github.com/fronzbot/blinkpy/pull/840>`__)
47+
- Add/extract firmware version (`@mkmer #842 <https://github.com/fronzbot/blinkpy/pull/842>`__)
48+
- Additional logging, fix blinksync json (`@mkmer #844 <https://github.com/fronzbot/blinkpy/pull/844>`__)
49+
- Log text response (`@mkmer #845 <https://github.com/fronzbot/blinkpy/pull/845>`__)
50+
- Add tests for logging (`@mkmer #846 <https://github.com/fronzbot/blinkpy/pull/846>`__)
3051
- Bump ruff to 0.1.11
3152
- Bump black to 23.12.1
3253
- Bump coverage to 7.4.0
@@ -38,7 +59,7 @@ Warning: This release removes support for Python 3.8 and adds Python 3.12 suppor
3859

3960
**Bugfixes**
4061

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

4465
** Other Changes **

blinkpy/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async def request_login(
3737
"Content-Type": "application/json",
3838
"user-agent": DEFAULT_USER_AGENT,
3939
}
40+
4041
data = dumps(
4142
{
4243
"email": login_data["username"],

blinkpy/auth.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from blinkpy.helpers import util
1111
from blinkpy.helpers.constants import (
1212
BLINK_URL,
13+
APP_BUILD,
1314
DEFAULT_USER_AGENT,
1415
LOGIN_ENDPOINT,
1516
TIMEOUT,
@@ -21,7 +22,14 @@
2122
class Auth:
2223
"""Class to handle login communication."""
2324

24-
def __init__(self, login_data=None, no_prompt=False, session=None):
25+
def __init__(
26+
self,
27+
login_data=None,
28+
no_prompt=False,
29+
session=None,
30+
agent=DEFAULT_USER_AGENT,
31+
app_build=APP_BUILD,
32+
):
2533
"""
2634
Initialize auth handler.
2735
@@ -43,10 +51,9 @@ def __init__(self, login_data=None, no_prompt=False, session=None):
4351
self.login_response = None
4452
self.is_errored = False
4553
self.no_prompt = no_prompt
46-
if session:
47-
self.session = session
48-
else:
49-
self.session = ClientSession()
54+
self._agent = agent
55+
self._app_build = app_build
56+
self.session = session if session else ClientSession()
5057

5158
@property
5259
def login_attributes(self):
@@ -64,9 +71,10 @@ def header(self):
6471
if self.token is None:
6572
return None
6673
return {
74+
"APP-BUILD": self._app_build,
6775
"TOKEN_AUTH": self.token,
68-
"user-agent": DEFAULT_USER_AGENT,
69-
"content-type": "application/json",
76+
"User-Agent": self._agent,
77+
"Content-Type": "application/json",
7078
}
7179

7280
def validate_login(self):

blinkpy/camera.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, sync):
2727
self.network_id = None
2828
self.thumbnail = None
2929
self.serial = None
30-
self.version = None
30+
self._version = None
3131
self.motion_enabled = None
3232
self.battery_level = None
3333
self.clip = None
@@ -53,7 +53,7 @@ def attributes(self):
5353
"name": self.name,
5454
"camera_id": self.camera_id,
5555
"serial": self.serial,
56-
"version": self.version,
56+
"version": self._version,
5757
"temperature": self.temperature,
5858
"temperature_c": self.temperature_c,
5959
"temperature_calibrated": self.temperature_calibrated,
@@ -100,6 +100,11 @@ def video_from_cache(self):
100100
return self._cached_video
101101
return None
102102

103+
@property
104+
def version(self):
105+
"""Return the camera Firmware version."""
106+
return self._version
107+
103108
@property
104109
def arm(self):
105110
"""Return arm status of camera."""
@@ -201,9 +206,14 @@ async def get_video_clip(self, url=None):
201206

202207
async def snap_picture(self):
203208
"""Take a picture with camera to create a new thumbnail."""
204-
return await api.request_new_image(
209+
ret_val = await api.request_new_image(
205210
self.sync.blink, self.network_id, self.camera_id
206211
)
212+
response = await self.get_media()
213+
if response and response.status == 200:
214+
self._cached_image = await response.read()
215+
216+
return ret_val
207217

208218
async def set_motion_detect(self, enable):
209219
"""Set motion detection."""
@@ -234,16 +244,17 @@ def extract_config_info(self, config):
234244
self.camera_id = str(config.get("id", "unknown"))
235245
self.network_id = str(config.get("network_id", "unknown"))
236246
self.serial = config.get("serial")
237-
self.version = config.get("fw_version")
247+
self._version = config.get("fw_version")
238248
self.motion_enabled = config.get("enabled", "unknown")
239249
self.battery_state = config.get("battery_state") or config.get("battery")
240-
self.temperature = config.get("temperature")
241250
if signals := config.get("signals"):
242251
self.wifi_strength = signals.get("wifi")
243252
self.battery_level = signals.get("battery")
244253
self.sync_signal_strength = signals.get("lfr")
254+
self.temperature = signals.get("temp")
245255
else:
246256
self.wifi_strength = config.get("wifi_strength")
257+
self.temperature = config.get("temperature")
247258
self.product_type = config.get("type")
248259

249260
async def get_sensor_info(self):
@@ -522,8 +533,8 @@ async def get_liveview(self):
522533
await api.wait_for_command(self.sync.blink, response)
523534
server = response["server"]
524535
server_split = server.split(":")
525-
server_split[0] = "rtsps:"
526-
link = "".join(server_split)
536+
server_split[0] = "rtsps"
537+
link = ":".join(server_split)
527538
return link
528539

529540

blinkpy/helpers/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"""
2121
OTHER
2222
"""
23-
23+
APP_BUILD = "ANDROID_28373244"
2424
DEFAULT_USER_AGENT = "27.0ANDROID_28373244"
2525
DEVICE_ID = "Blinkpy"
2626
TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%S%z"

blinkpy/sync_module.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, blink, network_name, network_id, camera_list):
3434
self.region_id = blink.auth.region_id
3535
self.name = network_name
3636
self.serial = None
37-
self.version = None
37+
self._version = None
3838
self.status = "offline"
3939
self.sync_id = None
4040
self.host = None
@@ -73,7 +73,7 @@ def attributes(self):
7373
"id": self.sync_id,
7474
"network_id": self.network_id,
7575
"serial": self.serial,
76-
"version": self.version,
76+
"version": self._version,
7777
"status": self.status,
7878
"region_id": self.region_id,
7979
"local_storage": self.local_storage,
@@ -95,6 +95,11 @@ def online(self):
9595
self.available = False
9696
return False
9797

98+
@property
99+
def version(self):
100+
"""Return the Syncmodule Firmware version."""
101+
return self._version
102+
98103
@property
99104
def arm(self):
100105
"""Return status of sync module: armed/disarmed."""
@@ -155,7 +160,7 @@ async def sync_initialize(self):
155160
"Could not retrieve sync module information with response: %s", response
156161
)
157162
return False
158-
self.version = self.summary.get("fw_version")
163+
self._version = self.summary.get("fw_version")
159164
return response
160165

161166
async def _init_local_storage(self, sync_id):
@@ -496,14 +501,14 @@ async def poll_local_storage_manifest(
496501
response = await api.request_local_storage_manifest(
497502
self.blink, self.network_id, self.sync_id
498503
)
499-
if "id" in response:
504+
if response and "id" in response:
500505
break
501506
# Get the manifest.
502507
else:
503508
response = await api.get_local_storage_manifest(
504509
self.blink, self.network_id, self.sync_id, manifest_request_id
505510
)
506-
if "clips" in response:
511+
if response and "clips" in response:
507512
break
508513
seconds = backoff_seconds(retry=retry, default_time=3)
509514
_LOGGER.debug("[retry=%d] Retrying in %d seconds", retry + 1, seconds)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "blinkpy"
7-
version = "0.22.5"
7+
version = "0.22.6"
88
license = {text = "MIT"}
99
description = "A Blink camera Python Library."
1010
readme = "README.rst"

requirements_test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ruff==0.1.11
1+
ruff==0.1.14
22
black==23.12.1
33
build==1.0.3
44
coverage==7.4.0

tests/test_auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,10 @@ def test_header(self):
132132
"""Test header data."""
133133
self.auth.token = "bar"
134134
expected_header = {
135+
"APP-BUILD": const.APP_BUILD,
135136
"TOKEN_AUTH": "bar",
136-
"user-agent": const.DEFAULT_USER_AGENT,
137-
"content-type": "application/json",
137+
"User-Agent": const.DEFAULT_USER_AGENT,
138+
"Content-Type": "application/json",
138139
}
139140
self.assertDictEqual(self.auth.header, expected_header)
140141

tests/test_camera_functions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"serial": "12345678",
2323
"enabled": False,
2424
"battery_state": "ok",
25-
"temperature": 68,
26-
"signals": {"lfr": 5, "wifi": 4, "battery": 3},
25+
"signals": {"lfr": 5, "wifi": 4, "battery": 3, "temp": 68},
2726
"thumbnail": "/thumb",
2827
}
2928

tests/test_cameras.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ def test_missing_attributes(self, mock_resp):
8989
"""Test that attributes return None if missing."""
9090
self.camera.temperature = None
9191
self.camera.serial = None
92+
self.camera._version = None
9293
attr = self.camera.attributes
9394
self.assertEqual(attr["serial"], None)
9495
self.assertEqual(attr["temperature"], None)
9596
self.assertEqual(attr["temperature_c"], None)
97+
self.assertEqual(attr["version"], None)
98+
self.assertEqual(self.camera.version, None)
9699

97100
def test_mini_missing_attributes(self, mock_resp):
98101
"""Test that attributes return None if missing."""

tests/test_sync_module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ async def test_get_camera_info(self, mock_resp) -> None:
128128
self.assertEqual(
129129
await self.blink.sync["test"].get_camera_info("1234"), "foobar"
130130
)
131+
self.assertEqual(self.blink.sync["test"].version, None)
131132

132133
async def test_get_camera_info_fail(self, mock_resp) -> None:
133134
"""Test handling of failed get camera info function."""

0 commit comments

Comments
 (0)