bluetooth-sensor-state-data 1.6.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bluetooth-sensor-state-data
3
- Version: 1.6.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
  [tool.poetry]
2
2
  name = "bluetooth-sensor-state-data"
3
- version = "1.6.1"
3
+ version = "1.7.0"
4
4
  description = "Models for storing and converting Bluetooth Sensor State Data"
5
5
  authors = ["J. Nick Koston <nick@koston.org>"]
6
6
  license = "Apache Software License 2.0"
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "1.6.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._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:
@@ -68,6 +63,10 @@ class BluetoothData(SensorData):
68
63
 
69
64
  def update(self, data: BluetoothServiceInfo) -> SensorUpdate:
70
65
  """Update a device."""
66
+ # Ensure events from previous
67
+ # updates are not carried over
68
+ # as events are transient.
69
+ self._events_updates.clear()
71
70
  self._start_update(data)
72
71
  self.update_signal_strength(data.rssi)
73
72
  return self._finish_update()
@@ -1,40 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from setuptools import setup
3
-
4
- package_dir = \
5
- {'': 'src'}
6
-
7
- packages = \
8
- ['bluetooth_sensor_state_data']
9
-
10
- package_data = \
11
- {'': ['*']}
12
-
13
- install_requires = \
14
- ['home-assistant-bluetooth>=1.3.0', 'sensor-state-data>=2.0']
15
-
16
- extras_require = \
17
- {'docs': ['Sphinx>=5.0,<6.0',
18
- 'sphinx-rtd-theme>=1.0,<2.0',
19
- 'myst-parser>=0.18,<0.19']}
20
-
21
- setup_kwargs = {
22
- 'name': 'bluetooth-sensor-state-data',
23
- 'version': '1.6.1',
24
- 'description': 'Models for storing and converting Bluetooth Sensor State Data',
25
- 'long_description': '# bluetooth-sensor-state-data\n\n<p align="center">\n <a href="https://github.com/bluetooth-devices/bluetooth-sensor-state-data/actions?query=workflow%3ACI">\n <img src="https://img.shields.io/github/workflow/status/bluetooth-devices/bluetooth-sensor-state-data/CI/main?label=CI&logo=github&style=flat-square" alt="CI Status" >\n </a>\n <a href="https://bluetooth-sensor-state-data.readthedocs.io">\n <img src="https://img.shields.io/readthedocs/bluetooth-sensor-state-data.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">\n </a>\n <a href="https://codecov.io/gh/bluetooth-devices/bluetooth-sensor-state-data">\n <img src="https://img.shields.io/codecov/c/github/bluetooth-devices/bluetooth-sensor-state-data.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">\n </a>\n</p>\n<p align="center">\n <a href="https://python-poetry.org/">\n <img src="https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJJSURBVHgBfZLPa1NBEMe/s7tNXoxW1KJQKaUHkXhQvHgW6UHQQ09CBS/6V3hKc/AP8CqCrUcpmop3Cx48eDB4yEECjVQrlZb80CRN8t6OM/teagVxYZi38+Yz853dJbzoMV3MM8cJUcLMSUKIE8AzQ2PieZzFxEJOHMOgMQQ+dUgSAckNXhapU/NMhDSWLs1B24A8sO1xrN4NECkcAC9ASkiIJc6k5TRiUDPhnyMMdhKc+Zx19l6SgyeW76BEONY9exVQMzKExGKwwPsCzza7KGSSWRWEQhyEaDXp6ZHEr416ygbiKYOd7TEWvvcQIeusHYMJGhTwF9y7sGnSwaWyFAiyoxzqW0PM/RjghPxF2pWReAowTEXnDh0xgcLs8l2YQmOrj3N7ByiqEoH0cARs4u78WgAVkoEDIDoOi3AkcLOHU60RIg5wC4ZuTC7FaHKQm8Hq1fQuSOBvX/sodmNJSB5geaF5CPIkUeecdMxieoRO5jz9bheL6/tXjrwCyX/UYBUcjCaWHljx1xiX6z9xEjkYAzbGVnB8pvLmyXm9ep+W8CmsSHQQY77Zx1zboxAV0w7ybMhQmfqdmmw3nEp1I0Z+FGO6M8LZdoyZnuzzBdjISicKRnpxzI9fPb+0oYXsNdyi+d3h9bm9MWYHFtPeIZfLwzmFDKy1ai3p+PDls1Llz4yyFpferxjnyjJDSEy9CaCx5m2cJPerq6Xm34eTrZt3PqxYO1XOwDYZrFlH1fWnpU38Y9HRze3lj0vOujZcXKuuXm3jP+s3KbZVra7y2EAAAAAASUVORK5CYII=" alt="Poetry">\n </a>\n <a href="https://github.com/ambv/black">\n <img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square" alt="black">\n </a>\n <a href="https://github.com/pre-commit/pre-commit">\n <img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">\n </a>\n</p>\n<p align="center">\n <a href="https://pypi.org/project/bluetooth-sensor-state-data/">\n <img src="https://img.shields.io/pypi/v/bluetooth-sensor-state-data.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">\n </a>\n <img src="https://img.shields.io/pypi/pyversions/bluetooth-sensor-state-data.svg?style=flat-square&logo=python&amp;logoColor=fff" alt="Supported Python versions">\n <img src="https://img.shields.io/pypi/l/bluetooth-sensor-state-data.svg?style=flat-square" alt="License">\n</p>\n\nModels for storing and converting Bluetooth Sensor State Data\n\n## Installation\n\nInstall this via pip (or your favourite package manager):\n\n`pip install bluetooth-sensor-state-data`\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- prettier-ignore-start -->\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- markdownlint-disable -->\n<!-- markdownlint-enable -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n<!-- prettier-ignore-end -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## Credits\n\nThis package was created with\n[Cookiecutter](https://github.com/audreyr/cookiecutter) and the\n[browniebroke/cookiecutter-pypackage](https://github.com/browniebroke/cookiecutter-pypackage)\nproject template.\n',
26
- 'author': 'J. Nick Koston',
27
- 'author_email': 'nick@koston.org',
28
- 'maintainer': 'None',
29
- 'maintainer_email': 'None',
30
- 'url': 'https://github.com/bluetooth-devices/bluetooth-sensor-state-data',
31
- 'package_dir': package_dir,
32
- 'packages': packages,
33
- 'package_data': package_data,
34
- 'install_requires': install_requires,
35
- 'extras_require': extras_require,
36
- 'python_requires': '>=3.9,<4.0',
37
- }
38
-
39
-
40
- setup(**setup_kwargs)