aiobmsble 0.3.0__tar.gz → 0.4.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.
Files changed (78) hide show
  1. {aiobmsble-0.3.0/aiobmsble.egg-info → aiobmsble-0.4.1}/PKG-INFO +48 -9
  2. aiobmsble-0.4.1/README.md +129 -0
  3. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/__main__.py +1 -1
  4. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/basebms.py +2 -2
  5. aiobmsble-0.4.1/aiobmsble/test_data/__init__.py +102 -0
  6. aiobmsble-0.4.1/aiobmsble/test_data/abc_bms.json +34 -0
  7. aiobmsble-0.4.1/aiobmsble/test_data/ant_bms.json +18 -0
  8. aiobmsble-0.4.1/aiobmsble/test_data/ant_leg_bms.json +19 -0
  9. aiobmsble-0.4.1/aiobmsble/test_data/braunpwr_bms.json +34 -0
  10. aiobmsble-0.4.1/aiobmsble/test_data/cbtpwr_bms.json +90 -0
  11. aiobmsble-0.4.1/aiobmsble/test_data/cbtpwr_vb_bms.json +20 -0
  12. aiobmsble-0.4.1/aiobmsble/test_data/daly_bms.json +100 -0
  13. aiobmsble-0.4.1/aiobmsble/test_data/dpwrcore_bms.json +18 -0
  14. aiobmsble-0.4.1/aiobmsble/test_data/ecoworthy_bms.json +100 -0
  15. aiobmsble-0.4.1/aiobmsble/test_data/ective_bms.json +104 -0
  16. aiobmsble-0.4.1/aiobmsble/test_data/ej_bms.json +107 -0
  17. aiobmsble-0.4.1/aiobmsble/test_data/felicity_bms.json +24 -0
  18. aiobmsble-0.4.1/aiobmsble/test_data/ignore.json +48 -0
  19. aiobmsble-0.4.1/aiobmsble/test_data/jbd_bms.json +440 -0
  20. aiobmsble-0.4.1/aiobmsble/test_data/jikong_bms.json +54 -0
  21. aiobmsble-0.4.1/aiobmsble/test_data/neey_bms.json +65 -0
  22. aiobmsble-0.4.1/aiobmsble/test_data/ogt_bms.json +16 -0
  23. aiobmsble-0.4.1/aiobmsble/test_data/pro_bms.json +15 -0
  24. aiobmsble-0.4.1/aiobmsble/test_data/redodo_bms.json +151 -0
  25. aiobmsble-0.4.1/aiobmsble/test_data/renogy_bms.json +19 -0
  26. aiobmsble-0.4.1/aiobmsble/test_data/renogy_pro_bms.json +16 -0
  27. aiobmsble-0.4.1/aiobmsble/test_data/roypow_bms.json +54 -0
  28. aiobmsble-0.4.1/aiobmsble/test_data/seplos_bms.json +96 -0
  29. aiobmsble-0.4.1/aiobmsble/test_data/seplos_v2_bms.json +41 -0
  30. aiobmsble-0.4.1/aiobmsble/test_data/tdt_bms.json +14 -0
  31. aiobmsble-0.4.1/aiobmsble/test_data/tianpwr_bms.json +13 -0
  32. {aiobmsble-0.3.0 → aiobmsble-0.4.1/aiobmsble.egg-info}/PKG-INFO +48 -9
  33. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble.egg-info/SOURCES.txt +28 -0
  34. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble.egg-info/requires.txt +1 -1
  35. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/pyproject.toml +6 -6
  36. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/tests/test_fuzzing.py +1 -1
  37. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/tests/test_main.py +1 -1
  38. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/tests/test_plugins.py +4 -5
  39. aiobmsble-0.4.1/tests/test_test_data.py +44 -0
  40. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/tests/test_utils.py +7 -6
  41. aiobmsble-0.3.0/README.md +0 -90
  42. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/LICENSE +0 -0
  43. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/MANIFEST.in +0 -0
  44. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/__init__.py +0 -0
  45. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/__init__.py +0 -0
  46. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/abc_bms.py +0 -0
  47. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/ant_bms.py +0 -0
  48. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/ant_leg_bms.py +0 -0
  49. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/braunpwr_bms.py +0 -0
  50. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/cbtpwr_bms.py +0 -0
  51. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/cbtpwr_vb_bms.py +0 -0
  52. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/daly_bms.py +0 -0
  53. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/dpwrcore_bms.py +0 -0
  54. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/dummy_bms.py +0 -0
  55. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/ecoworthy_bms.py +0 -0
  56. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/ective_bms.py +0 -0
  57. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/ej_bms.py +0 -0
  58. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/felicity_bms.py +0 -0
  59. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/jbd_bms.py +0 -0
  60. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/jikong_bms.py +0 -0
  61. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/neey_bms.py +0 -0
  62. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/ogt_bms.py +0 -0
  63. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/pro_bms.py +0 -0
  64. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/redodo_bms.py +0 -0
  65. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/renogy_bms.py +0 -0
  66. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/renogy_pro_bms.py +0 -0
  67. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/roypow_bms.py +0 -0
  68. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/seplos_bms.py +0 -0
  69. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/seplos_v2_bms.py +0 -0
  70. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/tdt_bms.py +0 -0
  71. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/bms/tianpwr_bms.py +0 -0
  72. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble/utils.py +0 -0
  73. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble.egg-info/dependency_links.txt +0 -0
  74. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble.egg-info/entry_points.txt +0 -0
  75. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/aiobmsble.egg-info/top_level.txt +0 -0
  76. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/setup.cfg +0 -0
  77. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/tests/test_basebms.py +0 -0
  78. {aiobmsble-0.3.0 → aiobmsble-0.4.1}/tests/test_examples.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiobmsble
3
- Version: 0.3.0
3
+ Version: 0.4.1
4
4
  Summary: Asynchronous Python library to query battery management systems via Bluetooth Low Energy.
5
5
  Author: Patrick Loschmidt
6
6
  Maintainer: Patrick Loschmidt
@@ -12,7 +12,7 @@ Project-URL: Bug Reports, https://github.com/patman15/aiobmsble/issues
12
12
  Keywords: BMS,BLE,battery,bluetooth
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Operating System :: OS Independent
15
- Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Development Status :: 4 - Beta
16
16
  Classifier: Intended Audience :: Developers
17
17
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
18
  Requires-Python: >=3.12
@@ -27,26 +27,42 @@ Requires-Dist: pytest-cov; extra == "dev"
27
27
  Requires-Dist: pytest-xdist; extra == "dev"
28
28
  Requires-Dist: hypothesis; extra == "dev"
29
29
  Requires-Dist: mypy; extra == "dev"
30
- Requires-Dist: ruff~=0.12.1; extra == "dev"
30
+ Requires-Dist: ruff<0.14.0,>=0.12.1; extra == "dev"
31
31
  Dynamic: license-file
32
32
 
33
+ [![GitHub Release][releases-shield]](https://pypi.org/p/aiobmsble/)
33
34
  [![License][license-shield]](LICENSE)
34
35
 
35
36
  # Aiobmsble
36
37
  Requires Python 3 and uses [asyncio](https://pypi.org/project/asyncio/) and [bleak](https://pypi.org/project/bleak/)
37
- > [!IMPORTANT]
38
- > At the moment the library is under development and there might be missing functionality compared to the [BMS_BLE-HA integration](https://github.com/patman15/BMS_BLE-HA/)!
39
- > Please do not (yet) report missing BMS support or bugs here. Instead please raise an issue at the integration till the library reached at least development status *beta*.
40
38
 
41
39
  ## Asynchronous Library to Query Battery Management Systems via Bluetooth LE
42
- This library is intended to query data from battery management systems that use Bluetooth LE. It is developed to support [BMS_BLE-HA integration](https://github.com/patman15/BMS_BLE-HA/) that was written to make BMS data available to Home Assistant. While the integration depends on Home Assistant, this library can be used stand-alone in any Python environment (with necessary dependencies installed).
40
+ This library is intended to query data from battery management systems that use Bluetooth LE. This library can be used stand-alone in any Python environment (with necessary dependencies installed). It is developed to support [BMS_BLE-HA integration](https://github.com/patman15/BMS_BLE-HA/) that was written to make BMS data available to Home Assistant, but can be hopefully usefull for other use-cases as well.
41
+
42
+ * [Features](#features)
43
+ * [Usage](#usage)
44
+ * [Installation](#installation)
45
+ * [Troubleshooting](#troubleshooting)
46
+
47
+ ## Features
48
+ - Support for autodetecting compatible BLE BMSs
49
+ - Automatic detection of compatible BLE write mode
50
+ - Asynchronous operation using [asyncio](https://pypi.org/project/asyncio/)
51
+ - Any number of batteries in parallel
52
+ - 100% test coverage plus fuzz tests for BLE data
53
+
54
+ ### Supported Devices
55
+ The [list of supported devices](https://github.com/patman15/BMS_BLE-HA/blob/feature-aiobmsble/README.md#supported-devices) is maintained in the repository of the related [Home Assistant integration](https://github.com/patman15/BMS_BLE-HA).
43
56
 
44
57
  ## Usage
45
58
  In order to identify all devices that are reachable and supported by the library, simply run
46
59
  ```bash
47
60
  aiobmsble
48
61
  ```
49
- from the command line after [installation](#installation). In case you need the code as reference, please see [\_\_main\_\_.py](/aiobmsble/__main__.py).
62
+ from the command line after [installation](#installation).
63
+
64
+ ### From your Python code
65
+ In case you need a reference to include the code into your library, please see [\_\_main\_\_.py](/aiobmsble/__main__.py).
50
66
 
51
67
  ### From a Script
52
68
  This example can also be found as an [example](/examples/minimal.py) in the respective [folder](/main/examples).
@@ -97,6 +113,18 @@ if __name__ == "__main__":
97
113
  asyncio.run(main(NAME)) # pragma: no cover
98
114
  ```
99
115
 
116
+ ### Testing
117
+ For integrations tests (using pytest) the library provides advertisement data that can be used to verify detection of BMSs. For your tests you can use
118
+
119
+ ```python
120
+ from aiobmsble.test_data import bms_advertisements
121
+
122
+ def test_advertisements() -> None:
123
+ """Run some tests with the advertisements"""
124
+ for advertisement, bms_type, _comments in bms_advertisements():
125
+ ...
126
+ ```
127
+
100
128
  ## Installation
101
129
  Install python and pip if you have not already, then run:
102
130
  ```bash
@@ -119,4 +147,15 @@ pip3 install -e .[dev]
119
147
  ```
120
148
  This gives you the latest library code from the main branch.
121
149
 
122
- [license-shield]: https://img.shields.io/github/license/patman15/aiobmsble.svg?style=for-the-badge&cacheSeconds=86400
150
+ ## Troubleshooting
151
+ In case you have problems with the library, please enable debug logging. You can also run `aiobmsble -v` from the command line in order to query all known BMS that are reachable.
152
+
153
+ ### In case you have troubles you'd like to have help with
154
+
155
+ - please record a debug log using `aiobmsble -v -l debug.log`,
156
+ - [open an issue](https://github.com/patman15/aiobmsble/issues/new?assignees=&labels=question&projects=&template=support.yml) with a good description of what your question/issue is and attach the log, or
157
+ - [open a bug](https://github.com/patman15/aiobmsble/issues/new?assignees=&labels=Bug&projects=&template=bug.yml) if you think the behaviour you see is misbehaviour of the library, including a good description of what happened, your expectations,
158
+ - and put the `debug.log` **as attachement** to the issue.
159
+
160
+ [license-shield]: https://img.shields.io/github/license/patman15/aiobmsble?style=for-the-badge&cacheSeconds=86400
161
+ [releases-shield]: https://img.shields.io/pypi/v/aiobmsble?style=for-the-badge
@@ -0,0 +1,129 @@
1
+ [![GitHub Release][releases-shield]](https://pypi.org/p/aiobmsble/)
2
+ [![License][license-shield]](LICENSE)
3
+
4
+ # Aiobmsble
5
+ Requires Python 3 and uses [asyncio](https://pypi.org/project/asyncio/) and [bleak](https://pypi.org/project/bleak/)
6
+
7
+ ## Asynchronous Library to Query Battery Management Systems via Bluetooth LE
8
+ This library is intended to query data from battery management systems that use Bluetooth LE. This library can be used stand-alone in any Python environment (with necessary dependencies installed). It is developed to support [BMS_BLE-HA integration](https://github.com/patman15/BMS_BLE-HA/) that was written to make BMS data available to Home Assistant, but can be hopefully usefull for other use-cases as well.
9
+
10
+ * [Features](#features)
11
+ * [Usage](#usage)
12
+ * [Installation](#installation)
13
+ * [Troubleshooting](#troubleshooting)
14
+
15
+ ## Features
16
+ - Support for autodetecting compatible BLE BMSs
17
+ - Automatic detection of compatible BLE write mode
18
+ - Asynchronous operation using [asyncio](https://pypi.org/project/asyncio/)
19
+ - Any number of batteries in parallel
20
+ - 100% test coverage plus fuzz tests for BLE data
21
+
22
+ ### Supported Devices
23
+ The [list of supported devices](https://github.com/patman15/BMS_BLE-HA/blob/feature-aiobmsble/README.md#supported-devices) is maintained in the repository of the related [Home Assistant integration](https://github.com/patman15/BMS_BLE-HA).
24
+
25
+ ## Usage
26
+ In order to identify all devices that are reachable and supported by the library, simply run
27
+ ```bash
28
+ aiobmsble
29
+ ```
30
+ from the command line after [installation](#installation).
31
+
32
+ ### From your Python code
33
+ In case you need a reference to include the code into your library, please see [\_\_main\_\_.py](/aiobmsble/__main__.py).
34
+
35
+ ### From a Script
36
+ This example can also be found as an [example](/examples/minimal.py) in the respective [folder](/main/examples).
37
+ ```python
38
+ """Example of using the aiobmsble library to find a BLE device by name and print its sensor data.
39
+
40
+ Project: aiobmsble, https://pypi.org/p/aiobmsble/
41
+ License: Apache-2.0, http://www.apache.org/licenses/
42
+ """
43
+
44
+ import asyncio
45
+ import logging
46
+ from typing import Final
47
+
48
+ from bleak import BleakScanner
49
+ from bleak.backends.device import BLEDevice
50
+ from bleak.exc import BleakError
51
+
52
+ from aiobmsble import BMSsample
53
+ from aiobmsble.bms.dummy_bms import BMS # TODO: use the right BMS class for your device
54
+
55
+ NAME: Final[str] = "BT Device Name" # TODO: replace with the name of your BLE device
56
+
57
+ # Configure logging
58
+ logging.basicConfig(level=logging.INFO)
59
+ logger: logging.Logger = logging.getLogger(__name__)
60
+
61
+
62
+ async def main(dev_name) -> None:
63
+ """Find a BLE device by name and update its sensor data."""
64
+
65
+ device: BLEDevice | None = await BleakScanner.find_device_by_name(dev_name)
66
+ if device is None:
67
+ logger.error("Device '%s' not found.", dev_name)
68
+ return
69
+
70
+ logger.info("Found device: %s (%s)", device.name, device.address)
71
+ try:
72
+ async with BMS(ble_device=device) as bms:
73
+ logger.info("Updating BMS data...")
74
+ data: BMSsample = await bms.async_update()
75
+ logger.info("BMS data: %s", repr(data).replace(", ", ",\n\t"))
76
+ except BleakError as ex:
77
+ logger.error("Failed to update BMS: %s", type(ex).__name__)
78
+
79
+
80
+ if __name__ == "__main__":
81
+ asyncio.run(main(NAME)) # pragma: no cover
82
+ ```
83
+
84
+ ### Testing
85
+ For integrations tests (using pytest) the library provides advertisement data that can be used to verify detection of BMSs. For your tests you can use
86
+
87
+ ```python
88
+ from aiobmsble.test_data import bms_advertisements
89
+
90
+ def test_advertisements() -> None:
91
+ """Run some tests with the advertisements"""
92
+ for advertisement, bms_type, _comments in bms_advertisements():
93
+ ...
94
+ ```
95
+
96
+ ## Installation
97
+ Install python and pip if you have not already, then run:
98
+ ```bash
99
+ pip3 install pip --upgrade
100
+ pip3 install wheel
101
+ ```
102
+
103
+ ### For Production:
104
+
105
+ ```bash
106
+ pip3 install aiobmsble
107
+ ```
108
+ This will install the latest library release and all of it's python dependencies.
109
+
110
+ ### For Development:
111
+ ```bash
112
+ git clone https://github.com/patman15/aiobmsble.git
113
+ cd aiobmsble
114
+ pip3 install -e .[dev]
115
+ ```
116
+ This gives you the latest library code from the main branch.
117
+
118
+ ## Troubleshooting
119
+ In case you have problems with the library, please enable debug logging. You can also run `aiobmsble -v` from the command line in order to query all known BMS that are reachable.
120
+
121
+ ### In case you have troubles you'd like to have help with
122
+
123
+ - please record a debug log using `aiobmsble -v -l debug.log`,
124
+ - [open an issue](https://github.com/patman15/aiobmsble/issues/new?assignees=&labels=question&projects=&template=support.yml) with a good description of what your question/issue is and attach the log, or
125
+ - [open a bug](https://github.com/patman15/aiobmsble/issues/new?assignees=&labels=Bug&projects=&template=bug.yml) if you think the behaviour you see is misbehaviour of the library, including a good description of what happened, your expectations,
126
+ - and put the `debug.log` **as attachement** to the issue.
127
+
128
+ [license-shield]: https://img.shields.io/github/license/patman15/aiobmsble?style=for-the-badge&cacheSeconds=86400
129
+ [releases-shield]: https://img.shields.io/pypi/v/aiobmsble?style=for-the-badge
@@ -31,7 +31,7 @@ async def scan_devices() -> dict[str, tuple[BLEDevice, AdvertisementData]]:
31
31
  scan_result: dict[str, tuple[BLEDevice, AdvertisementData]] = (
32
32
  await BleakScanner.discover(return_adv=True)
33
33
  )
34
- logger.info(scan_result)
34
+ logger.debug(scan_result)
35
35
  logger.info("%i BT devices in range.", len(scan_result))
36
36
  return scan_result
37
37
 
@@ -379,8 +379,8 @@ class BaseBMS(ABC):
379
379
  if reset:
380
380
  self._inv_wr_mode = None # reset write mode
381
381
  await self._client.disconnect()
382
- except BleakError:
383
- self._log.warning("disconnect failed!")
382
+ except (BleakError, TimeoutError) as exc:
383
+ self._log.error("disconnect failed! (%s)", type(exc).__name__)
384
384
 
385
385
  async def _wait_event(self) -> None:
386
386
  """Wait for data event and clear it."""
@@ -0,0 +1,102 @@
1
+ """Test advertisements for aiobmsble package."""
2
+
3
+ from importlib import resources
4
+ import json
5
+ from typing import Any
6
+
7
+ from bleak.backends.scanner import AdvertisementData
8
+
9
+ from tests.bluetooth import generate_advertisement_data
10
+
11
+ type BmsAdvList = list[tuple[AdvertisementData, str, list[str]]]
12
+
13
+
14
+ def _json_dict_to_advdata(json_dict: dict[str, Any]) -> AdvertisementData:
15
+ """Generate an AdvertisementData instance from a JSON dictionary."""
16
+
17
+ if "manufacturer_data" in json_dict:
18
+ json_dict["manufacturer_data"] = {
19
+ int(k): bytes.fromhex(v) for k, v in json_dict["manufacturer_data"].items()
20
+ }
21
+ if "service_data" in json_dict:
22
+ json_dict["service_data"] = {
23
+ k: bytes.fromhex(v) for k, v in json_dict["service_data"].items()
24
+ }
25
+ if "platform_data" in json_dict:
26
+ json_dict["platform_data"] = tuple(json_dict.get("platform_data", []))
27
+
28
+ return generate_advertisement_data(**json_dict)
29
+
30
+
31
+ def bms_advertisements() -> BmsAdvList:
32
+ """Provide all available BMS advertisements from test data directory.
33
+
34
+ Load all *_bms.json files from the packaged test data directory.
35
+
36
+ Returns:
37
+ BmsAdvList: List of tuples containing advertisement, bms type,
38
+ and a list of comments, i.e. list[tuple[AdvertisementData, str, list[str]]]
39
+
40
+ """
41
+ all_data: BmsAdvList = []
42
+
43
+ for resource in resources.files(__package__).iterdir():
44
+ if resource.name.endswith("_bms.json"):
45
+ with resource.open("r", encoding="UTF-8") as f:
46
+ raw_data: Any = json.load(f)
47
+ assert isinstance(raw_data, list)
48
+
49
+ for entry in raw_data:
50
+ assert isinstance(entry, dict)
51
+ assert {"advertisement", "type"}.issubset(set(entry.keys()))
52
+ adv: AdvertisementData = _json_dict_to_advdata(
53
+ entry["advertisement"]
54
+ )
55
+ bms_type: str = entry["type"]
56
+ comments: list[str] = entry["_comments"]
57
+
58
+ assert isinstance(adv, AdvertisementData)
59
+ assert isinstance(bms_type, str)
60
+ assert isinstance(comments, list)
61
+ assert all(isinstance(c, str) for c in comments)
62
+ assert resource.name == f"{bms_type}.json"
63
+
64
+ all_data.append((adv, bms_type, comments))
65
+ return all_data
66
+
67
+
68
+ def ignore_advertisements() -> BmsAdvList:
69
+ """Provide a list of advertisements that shall not be identified as a valid BMS.
70
+
71
+ Load ignore.json files from the packaged test data directory.
72
+
73
+ Returns:
74
+ BmsAdvList: List of tuples containing advertisement, reason why not to detect,
75
+ and a list of comments, i.e. list[tuple[AdvertisementData, str, list[str]]]
76
+
77
+ """
78
+ data: BmsAdvList = []
79
+
80
+ with (
81
+ resources.files(__package__)
82
+ .joinpath("ignore.json")
83
+ .open("r", encoding="UTF-8") as f
84
+ ):
85
+ raw_data: Any = json.load(f)
86
+ assert isinstance(raw_data, list)
87
+
88
+ for entry in raw_data:
89
+ assert isinstance(entry, dict)
90
+ assert {"advertisement", "reason"}.issubset(set(entry.keys()))
91
+ adv: AdvertisementData = _json_dict_to_advdata(entry["advertisement"])
92
+ reason: str = entry["reason"]
93
+ comments: list[str] = entry["_comments"]
94
+
95
+ assert isinstance(adv, AdvertisementData)
96
+ assert isinstance(reason, str)
97
+ assert isinstance(comments, list)
98
+ assert all(isinstance(c, str) for c in comments)
99
+
100
+ data.append((adv, reason, comments))
101
+
102
+ return data
@@ -0,0 +1,34 @@
1
+ [
2
+ {
3
+ "advertisement": {
4
+ "local_name": "SOK-24V1127",
5
+ "service_uuids": [
6
+ "0000fff0-0000-1000-8000-00805f9b34fb"
7
+ ],
8
+ "rssi": -94
9
+ },
10
+ "type": "abc_bms",
11
+ "_comments": [
12
+ "source pcap (https://github.com/patman15/BMS_BLE-HA/issues/168)"
13
+ ]
14
+ },
15
+ {
16
+ "advertisement": {
17
+ "local_name": "SOK-AA02120",
18
+ "service_uuids": [
19
+ "00001800-0000-1000-8000-00805f9b34fb",
20
+ "00001801-0000-1000-8000-00805f9b34fb",
21
+ "0000180a-0000-1000-8000-00805f9b34fb",
22
+ "0000180f-0000-1000-8000-00805f9b34fb",
23
+ "0000ffe0-0000-1000-8000-00805f9b34fb",
24
+ "0000fff0-0000-1000-8000-00805f9b34fb",
25
+ "f000ffc0-0451-4000-b000-000000000000"
26
+ ],
27
+ "rssi": -62
28
+ },
29
+ "type": "abc_bms",
30
+ "_comments": [
31
+ "source log (https://github.com/patman15/BMS_BLE-HA/issues/394)"
32
+ ]
33
+ }
34
+ ]
@@ -0,0 +1,18 @@
1
+ [
2
+ {
3
+ "advertisement": {
4
+ "local_name": "ANT-BLE24C-001",
5
+ "manufacturer_data": {
6
+ "8979": "88a0aabbcc900001"
7
+ },
8
+ "service_uuids": [
9
+ "0000ffe0-0000-1000-8000-00805f9b34fb"
10
+ ],
11
+ "rssi": -70
12
+ },
13
+ "type": "ant_bms",
14
+ "_comments": [
15
+ "source advmon (https://github.com/patman15/BMS_BLE-HA/issues/366)"
16
+ ]
17
+ }
18
+ ]
@@ -0,0 +1,19 @@
1
+ [
2
+ {
3
+ "advertisement": {
4
+ "local_name": "ANT-BLE16S",
5
+ "manufacturer_data": {
6
+ "1623": "88a0aabbcca12345"
7
+ },
8
+ "service_uuids": [
9
+ "0000ffe0-0000-1000-8000-00805f9b34fb",
10
+ "0000fee7-0000-1000-8000-00805f9b34fb"
11
+ ],
12
+ "rssi": -31
13
+ },
14
+ "type": "ant_leg_bms",
15
+ "_comments": [
16
+ "source HA Bluetooth"
17
+ ]
18
+ }
19
+ ]
@@ -0,0 +1,34 @@
1
+ [
2
+ {
3
+ "advertisement": {
4
+ "local_name": "HSKS-25A-118",
5
+ "manufacturer_data": {
6
+ "123": "02ffff7b"
7
+ },
8
+ "service_uuids": [
9
+ "0000ff00-0000-1000-8000-00805f9b34fb"
10
+ ],
11
+ "rssi": -70
12
+ },
13
+ "type": "braunpwr_bms",
14
+ "_comments": [
15
+ "source pcap (https://github.com/patman15/BMS_BLE-HA/issues/303)"
16
+ ]
17
+ },
18
+ {
19
+ "advertisement": {
20
+ "local_name": "BL-25F-170-118",
21
+ "manufacturer_data": {
22
+ "123": "02ffff7d"
23
+ },
24
+ "service_uuids": [
25
+ "0000ff00-0000-1000-8000-00805f9b34fb"
26
+ ],
27
+ "rssi": -76
28
+ },
29
+ "type": "braunpwr_bms",
30
+ "_comments": [
31
+ "source LOG (https://github.com/patman15/BMS_BLE-HA/issues/303)"
32
+ ]
33
+ }
34
+ ]
@@ -0,0 +1,90 @@
1
+ [
2
+ {
3
+ "advertisement": {
4
+ "local_name": "170R000121",
5
+ "manufacturer_data": {
6
+ "21330": "2134ba03ec110cb4010500010000"
7
+ },
8
+ "service_uuids": [
9
+ "00001800-0000-1000-8000-00805f9b34fb",
10
+ "00001801-0000-1000-8000-00805f9b34fb",
11
+ "0000180a-0000-1000-8000-00805f9b34fb",
12
+ "0000fd00-0000-1000-8000-00805f9b34fb",
13
+ "0000ff90-0000-1000-8000-00805f9b34fb",
14
+ "0000ffb0-0000-1000-8000-00805f9b34fb",
15
+ "0000ffc0-0000-1000-8000-00805f9b34fb",
16
+ "0000ffd0-0000-1000-8000-00805f9b34fb",
17
+ "0000ffe0-0000-1000-8000-00805f9b34fb",
18
+ "0000ffe5-0000-1000-8000-00805f9b34fb",
19
+ "0000fff0-0000-1000-8000-00805f9b34fb"
20
+ ],
21
+ "tx_power": 0,
22
+ "rssi": -75
23
+ },
24
+ "type": "cbtpwr_bms",
25
+ "_comments": [
26
+ "source LOG, https://github.com/patman15/BMS_BLE-HA/issues/59"
27
+ ]
28
+ },
29
+ {
30
+ "advertisement": {
31
+ "local_name": "170R000086",
32
+ "manufacturer_data": {
33
+ "21330": "2134ba03ec110cf8010500010000"
34
+ },
35
+ "service_uuids": [
36
+ "00001800-0000-1000-8000-00805f9b34fb",
37
+ "00001801-0000-1000-8000-00805f9b34fb",
38
+ "0000180a-0000-1000-8000-00805f9b34fb",
39
+ "0000fd00-0000-1000-8000-00805f9b34fb",
40
+ "0000ff90-0000-1000-8000-00805f9b34fb",
41
+ "0000ffb0-0000-1000-8000-00805f9b34fb",
42
+ "0000ffc0-0000-1000-8000-00805f9b34fb",
43
+ "0000ffd0-0000-1000-8000-00805f9b34fb",
44
+ "0000ffe0-0000-1000-8000-00805f9b34fb",
45
+ "0000ffe5-0000-1000-8000-00805f9b34fb",
46
+ "0000fff0-0000-1000-8000-00805f9b34fb"
47
+ ],
48
+ "tx_power": 0,
49
+ "rssi": -73
50
+ },
51
+ "type": "cbtpwr_bms",
52
+ "_comments": [
53
+ "source LOG"
54
+ ]
55
+ },
56
+ {
57
+ "advertisement": {
58
+ "local_name": "140R000288",
59
+ "manufacturer_data": {
60
+ "0": "ffffffff6400ff000000000000000000"
61
+ },
62
+ "service_uuids": [
63
+ "0000fff0-0000-1000-8000-00805f9b34fb"
64
+ ],
65
+ "rssi": -82
66
+ },
67
+ "type": "cbtpwr_bms",
68
+ "_comments": [
69
+ "source BT monitor (https://github.com/patman15/BMS_BLE-HA/issues/176)"
70
+ ]
71
+ },
72
+ {
73
+ "advertisement": {
74
+ "local_name": "100R0002E3",
75
+ "manufacturer_data": {
76
+ "21330": "2134ba03ec110909010500010000"
77
+ },
78
+ "service_uuids": [
79
+ "000003c1-0000-1000-8000-00805f9b34fb"
80
+ ],
81
+ "tx_power": 0,
82
+ "rssi": -76
83
+ },
84
+ "type": "cbtpwr_bms",
85
+ "_comments": [
86
+ "source advmon (https://github.com/patman15/BMS_BLE-HA/issues/197)",
87
+ "Creabest"
88
+ ]
89
+ }
90
+ ]
@@ -0,0 +1,20 @@
1
+ [
2
+ {
3
+ "advertisement": {
4
+ "local_name": "VB024000390",
5
+ "manufacturer_data": {
6
+ "16963": "545e0211f82e0ca88942"
7
+ },
8
+ "service_uuids": [
9
+ "0000fff0-0000-1000-8000-00805f9b34fb",
10
+ "0000ffb0-0000-1000-8000-00805f9b34fb"
11
+ ],
12
+ "rssi": -73
13
+ },
14
+ "type": "cbtpwr_vb_bms",
15
+ "_comments": [
16
+ "source advmon (https://github.com/patman15/BMS_BLE-HA/issues/240)",
17
+ "Creabest"
18
+ ]
19
+ }
20
+ ]
@@ -0,0 +1,100 @@
1
+ [
2
+ {
3
+ "advertisement": {
4
+ "local_name": "DL-46640102XXXX",
5
+ "manufacturer_data": {
6
+ "25670": "010209ac"
7
+ },
8
+ "service_uuids": [
9
+ "0000fff0-0000-1000-8000-00805f9b34fb"
10
+ ],
11
+ "rssi": -58
12
+ },
13
+ "type": "daly_bms",
14
+ "_comments": [
15
+ "source LOG (https://github.com/patman15/BMS_BLE-HA/issues/89)"
16
+ ]
17
+ },
18
+ {
19
+ "advertisement": {
20
+ "local_name": "DL-401710015C9B",
21
+ "manufacturer_data": {
22
+ "770": "16401710015c9b444c"
23
+ },
24
+ "rssi": -36
25
+ },
26
+ "type": "daly_bms",
27
+ "_comments": [
28
+ "source LOG, proxy (https://github.com/patman15/BMS_BLE-HA/issues/160)"
29
+ ]
30
+ },
31
+ {
32
+ "advertisement": {
33
+ "local_name": "JHB-501812XXXXXX",
34
+ "manufacturer_data": {
35
+ "260": "0150181201a3b34a4842"
36
+ },
37
+ "rssi": -46
38
+ },
39
+ "type": "daly_bms",
40
+ "_comments": [
41
+ "source BTctl (https://github.com/patman15/BMS_BLE-HA/issues/145)"
42
+ ]
43
+ },
44
+ {
45
+ "advertisement": {
46
+ "local_name": "Randomname",
47
+ "manufacturer_data": {
48
+ "260": "0150181201a4944a4842"
49
+ },
50
+ "rssi": -36
51
+ },
52
+ "type": "daly_bms",
53
+ "_comments": [
54
+ "source LOG (https://github.com/patman15/BMS_BLE-HA/issues/160#issuecomment-2629318416)",
55
+ "JHB-50181201A494"
56
+ ]
57
+ },
58
+ {
59
+ "advertisement": {
60
+ "local_name": "BT270-2",
61
+ "manufacturer_data": {
62
+ "770": "16401712011197444c"
63
+ },
64
+ "rssi": -60
65
+ },
66
+ "type": "daly_bms",
67
+ "_comments": [
68
+ "source BTctl (https://github.com/patman15/BMS_BLE-HA/issues/174#issuecomment-2637936795)"
69
+ ]
70
+ },
71
+ {
72
+ "advertisement": {
73
+ "local_name": "DL-40160901534C",
74
+ "manufacturer_data": {
75
+ "258": "04"
76
+ },
77
+ "rssi": -87
78
+ },
79
+ "type": "daly_bms",
80
+ "_comments": [
81
+ "source advmon (https://github.com/patman15/BMS_BLE-HA/issues/204)",
82
+ "16S LiFePo 250A BMS"
83
+ ]
84
+ },
85
+ {
86
+ "advertisement": {
87
+ "local_name": "DL-FB4C2E0000000",
88
+ "manufacturer_data": {
89
+ "771": "00b4c2e0000000444c00"
90
+ },
91
+ "rssi": -81
92
+ },
93
+ "type": "daly_bms",
94
+ "_comments": [
95
+ "proxy LOG (https://github.com/patman15/BMS_BLE-HA/issues/85)",
96
+ "Bulltron battery",
97
+ "MAC address (Bouffalo Lab)"
98
+ ]
99
+ }
100
+ ]