bluetooth-sensor-state-data 1.6.2__tar.gz → 1.7.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.6.2 → bluetooth_sensor_state_data-1.7.0}/PKG-INFO +2 -1
- {bluetooth_sensor_state_data-1.6.2 → bluetooth_sensor_state_data-1.7.0}/pyproject.toml +1 -1
- {bluetooth_sensor_state_data-1.6.2 → bluetooth_sensor_state_data-1.7.0}/src/bluetooth_sensor_state_data/__init__.py +11 -16
- {bluetooth_sensor_state_data-1.6.2 → bluetooth_sensor_state_data-1.7.0}/LICENSE +0 -0
- {bluetooth_sensor_state_data-1.6.2 → bluetooth_sensor_state_data-1.7.0}/README.md +0 -0
- {bluetooth_sensor_state_data-1.6.2 → bluetooth_sensor_state_data-1.7.0}/src/bluetooth_sensor_state_data/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bluetooth-sensor-state-data
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
4
4
|
Summary: Models for storing and converting Bluetooth Sensor State Data
|
|
5
5
|
Home-page: https://github.com/bluetooth-devices/bluetooth-sensor-state-data
|
|
6
6
|
License: Apache Software License 2.0
|
|
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
20
|
Classifier: Topic :: Software Development :: Libraries
|
|
20
21
|
Provides-Extra: docs
|
|
21
22
|
Requires-Dist: Sphinx (>=5.0,<6.0) ; extra == "docs"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
__version__ = "1.
|
|
3
|
+
__version__ = "1.7.0"
|
|
4
4
|
|
|
5
5
|
from abc import abstractmethod
|
|
6
6
|
|
|
@@ -18,9 +18,7 @@ class BluetoothData(SensorData):
|
|
|
18
18
|
def __init__(self) -> None:
|
|
19
19
|
"""Initialize the class."""
|
|
20
20
|
super().__init__()
|
|
21
|
-
self.
|
|
22
|
-
str, set[tuple[int, bytes]]
|
|
23
|
-
] = {}
|
|
21
|
+
self._last_manufacturer_data_by_source: dict[str, dict[int, bytes]] = {}
|
|
24
22
|
|
|
25
23
|
def changed_manufacturer_data(
|
|
26
24
|
self, data: BluetoothServiceInfo, exclude_ids: set[int] | None = None
|
|
@@ -32,30 +30,27 @@ class BluetoothData(SensorData):
|
|
|
32
30
|
"""
|
|
33
31
|
manufacturer_data = data.manufacturer_data
|
|
34
32
|
source = data.source
|
|
33
|
+
last_manufacturer_data = self._last_manufacturer_data_by_source.get(source)
|
|
35
34
|
|
|
36
|
-
last_manufacturer_data_set = (
|
|
37
|
-
self._last_manufacturer_data_set_by_source.setdefault(source, set())
|
|
38
|
-
)
|
|
39
35
|
if exclude_ids:
|
|
40
36
|
# If there are specific manufacturer data IDs to exclude,
|
|
41
37
|
# then remove them from the set of manufacturer data.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
for key_val in manufacturer_data.items()
|
|
45
|
-
if key_val[0] not in exclude_ids
|
|
38
|
+
new_manufacturer_data = {
|
|
39
|
+
k: v for k, v in manufacturer_data.items() if k not in exclude_ids
|
|
46
40
|
}
|
|
47
41
|
else:
|
|
48
|
-
|
|
49
|
-
self._last_manufacturer_data_set_by_source[source] = manufacturer_data_set
|
|
42
|
+
new_manufacturer_data = manufacturer_data
|
|
50
43
|
|
|
51
|
-
|
|
44
|
+
self._last_manufacturer_data_by_source[source] = manufacturer_data
|
|
45
|
+
|
|
46
|
+
if not last_manufacturer_data:
|
|
52
47
|
# If there is no previous data and there is only one value
|
|
53
48
|
# return it
|
|
54
49
|
return (
|
|
55
|
-
|
|
50
|
+
new_manufacturer_data.copy() if len(new_manufacturer_data) == 1 else {}
|
|
56
51
|
)
|
|
57
52
|
|
|
58
|
-
return dict(
|
|
53
|
+
return dict(new_manufacturer_data.items() - last_manufacturer_data.items())
|
|
59
54
|
|
|
60
55
|
@abstractmethod
|
|
61
56
|
def _start_update(self, data: BluetoothServiceInfo) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|