bluetooth-sensor-state-data 1.7.2__tar.gz → 1.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bluetooth_sensor_state_data-1.7.2 → bluetooth_sensor_state_data-1.8.0}/PKG-INFO +5 -6
- {bluetooth_sensor_state_data-1.7.2 → bluetooth_sensor_state_data-1.8.0}/pyproject.toml +10 -8
- {bluetooth_sensor_state_data-1.7.2 → bluetooth_sensor_state_data-1.8.0}/src/bluetooth_sensor_state_data/__init__.py +28 -6
- {bluetooth_sensor_state_data-1.7.2 → bluetooth_sensor_state_data-1.8.0}/LICENSE +0 -0
- {bluetooth_sensor_state_data-1.7.2 → bluetooth_sensor_state_data-1.8.0}/README.md +0 -0
- {bluetooth_sensor_state_data-1.7.2 → bluetooth_sensor_state_data-1.8.0}/src/bluetooth_sensor_state_data/py.typed +0 -0
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: bluetooth-sensor-state-data
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0
|
|
4
4
|
Summary: Models for storing and converting Bluetooth Sensor State Data
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: J. Nick Koston
|
|
7
7
|
Author-email: nick@koston.org
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
9
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
12
|
Classifier: Natural Language :: English
|
|
13
13
|
Classifier: Operating System :: OS Independent
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
18
|
Classifier: Topic :: Software Development :: Libraries
|
|
21
19
|
Provides-Extra: docs
|
|
22
|
-
Requires-Dist: Sphinx (>=5,<
|
|
23
|
-
Requires-Dist:
|
|
20
|
+
Requires-Dist: Sphinx (>=5,<8) ; extra == "docs"
|
|
21
|
+
Requires-Dist: bluetooth-data-tools (>=1.28.0)
|
|
22
|
+
Requires-Dist: habluetooth (>=3.42.0)
|
|
24
23
|
Requires-Dist: myst-parser (>=0.18,<3.1) ; extra == "docs"
|
|
25
24
|
Requires-Dist: sensor-state-data (>=2.0)
|
|
26
25
|
Requires-Dist: sphinx-rtd-theme (>=1,<4) ; extra == "docs"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "bluetooth-sensor-state-data"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.8.0"
|
|
4
4
|
license = "Apache-2.0"
|
|
5
5
|
description = "Models for storing and converting Bluetooth Sensor State Data"
|
|
6
6
|
authors = [{ name = "J. Nick Koston", email = "nick@koston.org" }]
|
|
7
7
|
readme = "README.md"
|
|
8
|
-
requires-python = ">=3.
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
9
|
dynamic = ["classifiers", "dependencies", "optional-dependencies"]
|
|
10
10
|
|
|
11
11
|
[project.urls]
|
|
@@ -27,14 +27,15 @@ packages = [
|
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
[tool.poetry.dependencies]
|
|
30
|
-
python = "
|
|
30
|
+
python = ">=3.11,<3.14"
|
|
31
31
|
|
|
32
32
|
# Documentation Dependencies
|
|
33
|
-
Sphinx = {version = ">=5,<
|
|
33
|
+
Sphinx = {version = ">=5,<8", optional = true}
|
|
34
34
|
sphinx-rtd-theme = {version = ">=1,<4", optional = true}
|
|
35
35
|
myst-parser = {version = ">=0.18,<3.1", optional = true}
|
|
36
|
-
home-assistant-bluetooth = ">=1.3.0"
|
|
37
36
|
sensor-state-data = ">=2.0"
|
|
37
|
+
bluetooth-data-tools = ">=1.28.0"
|
|
38
|
+
habluetooth = ">=3.42.0"
|
|
38
39
|
|
|
39
40
|
[tool.poetry.extras]
|
|
40
41
|
docs = [
|
|
@@ -45,12 +46,13 @@ docs = [
|
|
|
45
46
|
|
|
46
47
|
[tool.poetry.dev-dependencies]
|
|
47
48
|
pytest = "^8.3"
|
|
48
|
-
pytest-cov = "^6.
|
|
49
|
+
pytest-cov = "^6.1"
|
|
50
|
+
|
|
49
51
|
|
|
50
52
|
[tool.semantic_release]
|
|
51
53
|
branch = "main"
|
|
52
|
-
version_toml = "pyproject.toml:project.version"
|
|
53
|
-
|
|
54
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
55
|
+
version_variables = ["src/bluetooth_sensor_state_data/__init__.py:__version__"]
|
|
54
56
|
build_command = "pip install poetry && poetry build"
|
|
55
57
|
|
|
56
58
|
[tool.pytest.ini_options]
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
__version__ = "1.
|
|
3
|
+
__version__ = "1.8.0"
|
|
4
4
|
|
|
5
5
|
from abc import abstractmethod
|
|
6
6
|
|
|
7
|
-
from
|
|
7
|
+
from bluetooth_data_tools import parse_advertisement_data_bytes
|
|
8
|
+
from habluetooth import BluetoothServiceInfo, BluetoothServiceInfoBleak
|
|
8
9
|
from sensor_state_data import DeviceClass, SensorData, SensorUpdate, Units
|
|
9
10
|
|
|
10
11
|
SIGNAL_STRENGTH_KEY = DeviceClass.SIGNAL_STRENGTH.value
|
|
@@ -21,13 +22,30 @@ class BluetoothData(SensorData):
|
|
|
21
22
|
self._last_manufacturer_data_by_source: dict[str, dict[int, bytes]] = {}
|
|
22
23
|
|
|
23
24
|
def changed_manufacturer_data(
|
|
24
|
-
self,
|
|
25
|
+
self,
|
|
26
|
+
data: BluetoothServiceInfo | BluetoothServiceInfoBleak,
|
|
27
|
+
exclude_ids: set[int] | None = None,
|
|
25
28
|
) -> dict[int, bytes]:
|
|
26
29
|
"""Find changed manufacturer data.
|
|
27
30
|
|
|
28
31
|
This function is not re-entrant. It must only
|
|
29
32
|
be called once per update.
|
|
30
33
|
"""
|
|
34
|
+
if hasattr(data, "raw") and data.raw:
|
|
35
|
+
# If we have the raw data we don't need to work out
|
|
36
|
+
# which one is the newest.
|
|
37
|
+
_, _, _, changed_manufacturer_data, _ = parse_advertisement_data_bytes(
|
|
38
|
+
data.raw
|
|
39
|
+
)
|
|
40
|
+
if exclude_ids:
|
|
41
|
+
# If there are specific manufacturer data IDs to exclude,
|
|
42
|
+
# then remove them from the set of manufacturer data.
|
|
43
|
+
return {
|
|
44
|
+
k: v
|
|
45
|
+
for k, v in changed_manufacturer_data.items()
|
|
46
|
+
if k not in exclude_ids
|
|
47
|
+
}
|
|
48
|
+
return changed_manufacturer_data
|
|
31
49
|
manufacturer_data = data.manufacturer_data
|
|
32
50
|
source = data.source
|
|
33
51
|
last_manufacturer_data = self._last_manufacturer_data_by_source.get(source)
|
|
@@ -53,15 +71,19 @@ class BluetoothData(SensorData):
|
|
|
53
71
|
return dict(new_manufacturer_data.items() - last_manufacturer_data.items())
|
|
54
72
|
|
|
55
73
|
@abstractmethod
|
|
56
|
-
def _start_update(
|
|
74
|
+
def _start_update(
|
|
75
|
+
self, data: BluetoothServiceInfo | BluetoothServiceInfoBleak
|
|
76
|
+
) -> None:
|
|
57
77
|
"""Update the data."""
|
|
58
78
|
|
|
59
|
-
def supported(self, data: BluetoothServiceInfo) -> bool:
|
|
79
|
+
def supported(self, data: BluetoothServiceInfo | BluetoothServiceInfoBleak) -> bool:
|
|
60
80
|
"""Return True if the device is supported."""
|
|
61
81
|
self._start_update(data)
|
|
62
82
|
return bool(self._device_id_to_type)
|
|
63
83
|
|
|
64
|
-
def update(
|
|
84
|
+
def update(
|
|
85
|
+
self, data: BluetoothServiceInfo | BluetoothServiceInfoBleak
|
|
86
|
+
) -> SensorUpdate:
|
|
65
87
|
"""Update a device."""
|
|
66
88
|
# Ensure events from previous
|
|
67
89
|
# updates are not carried over
|
|
File without changes
|
|
File without changes
|
|
File without changes
|