bluetooth-sensor-state-data 1.6.2__tar.gz → 1.7.1__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.
@@ -1,21 +1,21 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bluetooth-sensor-state-data
3
- Version: 1.6.2
3
+ Version: 1.7.1
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
- License: Apache Software License 2.0
7
6
  Author: J. Nick Koston
8
7
  Author-email: nick@koston.org
9
8
  Requires-Python: >=3.9,<4.0
10
9
  Classifier: Development Status :: 2 - Pre-Alpha
11
10
  Classifier: Intended Audience :: Developers
12
- Classifier: License :: Other/Proprietary License
11
+ Classifier: License :: OSI Approved :: Apache Software License
13
12
  Classifier: Natural Language :: English
14
13
  Classifier: Operating System :: OS Independent
15
14
  Classifier: Programming Language :: Python :: 3
16
15
  Classifier: Programming Language :: Python :: 3.9
17
16
  Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
19
  Classifier: Topic :: Software Development :: Libraries
20
20
  Provides-Extra: docs
21
21
  Requires-Dist: Sphinx (>=5.0,<6.0) ; extra == "docs"
@@ -1,9 +1,8 @@
1
1
  [tool.poetry]
2
2
  name = "bluetooth-sensor-state-data"
3
- version = "1.6.2"
3
+ version = "1.7.1"
4
4
  description = "Models for storing and converting Bluetooth Sensor State Data"
5
5
  authors = ["J. Nick Koston <nick@koston.org>"]
6
- license = "Apache Software License 2.0"
7
6
  readme = "README.md"
8
7
  repository = "https://github.com/bluetooth-devices/bluetooth-sensor-state-data"
9
8
  documentation = "https://bluetooth-sensor-state-data.readthedocs.io"
@@ -13,6 +12,7 @@ classifiers = [
13
12
  "Natural Language :: English",
14
13
  "Operating System :: OS Independent",
15
14
  "Topic :: Software Development :: Libraries",
15
+ "License :: OSI Approved :: Apache Software License",
16
16
  ]
17
17
  packages = [
18
18
  { include = "bluetooth_sensor_state_data", from = "src" },
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "1.6.2"
3
+ __version__ = "1.7.1"
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._last_manufacturer_data_set_by_source: dict[
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
- manufacturer_data_set = {
43
- key_val
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
- manufacturer_data_set = set(manufacturer_data.items())
49
- self._last_manufacturer_data_set_by_source[source] = manufacturer_data_set
42
+ new_manufacturer_data = manufacturer_data
50
43
 
51
- if not last_manufacturer_data_set:
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
- dict(manufacturer_data_set) if len(manufacturer_data_set) == 1 else {}
50
+ new_manufacturer_data.copy() if len(new_manufacturer_data) == 1 else {}
56
51
  )
57
52
 
58
- return dict(manufacturer_data_set - last_manufacturer_data_set)
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: