ruuvitag-sensor 2.3.1__tar.gz → 3.1.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.

Potentially problematic release.


This version of ruuvitag-sensor might be problematic. Click here for more details.

Files changed (37) hide show
  1. {ruuvitag_sensor-2.3.1/ruuvitag_sensor.egg-info → ruuvitag_sensor-3.1.0}/PKG-INFO +146 -75
  2. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/README.md +137 -61
  3. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/pyproject.toml +43 -41
  4. ruuvitag_sensor-3.1.0/ruuvitag_sensor/__init__.py +3 -0
  5. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/__main__.py +1 -1
  6. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/adapters/__init__.py +5 -14
  7. ruuvitag_sensor-3.1.0/ruuvitag_sensor/adapters/bleak_ble.py +262 -0
  8. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/adapters/bleson.py +2 -7
  9. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/adapters/development/dev_bleak_scanner.py +0 -2
  10. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/adapters/nix_hci.py +5 -8
  11. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/adapters/nix_hci_file.py +3 -1
  12. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/data_formats.py +2 -3
  13. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/decoder.py +133 -1
  14. ruuvitag_sensor-3.1.0/ruuvitag_sensor/log.py +44 -0
  15. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/ruuvi.py +131 -34
  16. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/ruuvi_rx.py +13 -9
  17. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/ruuvi_types.py +8 -6
  18. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0/ruuvitag_sensor.egg-info}/PKG-INFO +146 -75
  19. ruuvitag_sensor-3.1.0/ruuvitag_sensor.egg-info/requires.txt +11 -0
  20. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/tests/test_data_formats.py +0 -2
  21. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/tests/test_decoder.py +94 -1
  22. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/tests/test_ruuvitag_sensor.py +0 -2
  23. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/tests/test_ruuvitag_sensor_async.py +2 -10
  24. ruuvitag_sensor-2.3.1/ruuvitag_sensor/__init__.py +0 -8
  25. ruuvitag_sensor-2.3.1/ruuvitag_sensor/adapters/bleak_ble.py +0 -123
  26. ruuvitag_sensor-2.3.1/ruuvitag_sensor/log.py +0 -27
  27. ruuvitag_sensor-2.3.1/ruuvitag_sensor.egg-info/requires.txt +0 -20
  28. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/LICENSE +0 -0
  29. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/MANIFEST.in +0 -0
  30. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/adapters/development/__init__.py +0 -0
  31. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/adapters/dummy.py +0 -0
  32. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/adapters/utils.py +0 -0
  33. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor/ruuvitag.py +0 -0
  34. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor.egg-info/SOURCES.txt +0 -0
  35. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor.egg-info/dependency_links.txt +0 -0
  36. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/ruuvitag_sensor.egg-info/top_level.txt +0 -0
  37. {ruuvitag_sensor-2.3.1 → ruuvitag_sensor-3.1.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: ruuvitag_sensor
3
- Version: 2.3.1
3
+ Version: 3.1.0
4
4
  Summary: Find RuuviTag sensors and get decoded data from selected sensors
5
5
  Author-email: Tomi Tuhkanen <tomi.tuhkanen@iki.fi>
6
6
  License: MIT License
@@ -26,48 +26,43 @@ License: MIT License
26
26
  SOFTWARE.
27
27
 
28
28
  Project-URL: homepage, https://github.com/ttu/ruuvitag-sensor
29
+ Project-URL: documentation, https://ttu.github.io/ruuvitag-sensor/
29
30
  Project-URL: source, https://github.com/ttu/ruuvitag-sensor
30
31
  Project-URL: changelog, https://github.com/ttu/ruuvitag-sensor/blob/master/CHANGELOG.md
31
- Project-URL: Bug Tracker, https://github.com/ttu/ruuvitag-sensor/issues
32
- Keywords: RuuviTag BLE
32
+ Project-URL: issues, https://github.com/ttu/ruuvitag-sensor/issues
33
+ Keywords: RuuviTag,BLE,Bluetooth,IoT,Sensor
33
34
  Classifier: Programming Language :: Python
34
- Classifier: Programming Language :: Python :: 3.7
35
- Classifier: Programming Language :: Python :: 3.8
36
35
  Classifier: Programming Language :: Python :: 3.9
37
36
  Classifier: Programming Language :: Python :: 3.10
38
37
  Classifier: Programming Language :: Python :: 3.11
39
38
  Classifier: Programming Language :: Python :: 3.12
39
+ Classifier: Programming Language :: Python :: 3.13
40
40
  Classifier: License :: OSI Approved :: MIT License
41
41
  Classifier: Operating System :: OS Independent
42
42
  Classifier: Intended Audience :: Developers
43
43
  Classifier: Development Status :: 5 - Production/Stable
44
44
  Classifier: Framework :: AsyncIO
45
45
  Classifier: Framework :: Pytest
46
- Requires-Python: >=3.7
46
+ Requires-Python: >=3.9
47
47
  Description-Content-Type: text/markdown
48
48
  License-File: LICENSE
49
49
  Requires-Dist: reactivex
50
50
  Requires-Dist: ptyprocess; platform_system == "Linux"
51
- Requires-Dist: mypy-extensions; python_version < "3.8"
52
- Requires-Dist: importlib-metadata<4.3,>=1.1.0; python_version < "3.8"
53
- Requires-Dist: bleak; platform_system == "Windows" or platform_system == "Darwin"
51
+ Requires-Dist: bleak
54
52
  Provides-Extra: dev
55
53
  Requires-Dist: pytest; extra == "dev"
56
54
  Requires-Dist: pytest-asyncio; extra == "dev"
57
- Requires-Dist: flake8-pyproject; extra == "dev"
58
- Requires-Dist: pylint; extra == "dev"
55
+ Requires-Dist: ruff; extra == "dev"
59
56
  Requires-Dist: mypy; extra == "dev"
60
- Requires-Dist: isort; extra == "dev"
61
- Requires-Dist: black==23.3.0; extra == "dev"
62
57
 
63
58
  RuuviTag Sensor Python Package
64
59
  ---------------------------------
65
60
 
66
61
  [![Build Status](https://github.com/ttu/ruuvitag-sensor/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/ttu/ruuvitag-sensor/actions/workflows/build.yml)
67
62
  [![License](https://img.shields.io/pypi/l/ruuvitag-sensor.svg)](https://pypi.python.org/pypi/ruuvitag-sensor/)
68
- [![PyPI version](https://img.shields.io/pypi/v/ruuvitag-sensor.svg)](https://pypi.python.org/pypi/ruuvitag_-sensor)
63
+ [![PyPI version](https://img.shields.io/pypi/v/ruuvitag-sensor.svg)](https://pypi.python.org/pypi/ruuvitag-sensor)
69
64
  [![PyPI downloads](https://img.shields.io/pypi/dm/ruuvitag-sensor.svg)](https://pypistats.org/packages/ruuvitag-sensor)
70
- [![Python versions](https://img.shields.io/badge/python-3.7+-blue.svg)](https://pypi.python.org/pypi/ruuvitag-sensor/)
65
+ [![Python versions](https://img.shields.io/badge/python-3.9+-blue.svg)](https://pypi.python.org/pypi/ruuvitag-sensor/)
71
66
 
72
67
  `ruuvitag-sensor` is a Python package for communicating with [RuuviTag BLE Sensor](https://ruuvi.com/) and for decoding measurement data from broadcasted BLE data.
73
68
 
@@ -78,26 +73,30 @@ RuuviTag Sensor Python Package
78
73
  * RuuviTag sensor
79
74
  * Setup [guide](https://ruuvi.com/quick-start/)
80
75
  * Supports [Data Format 2, 3, 4 and 5](https://docs.ruuvi.com/)
81
- * __NOTE:__ Data Formats 2, 3 and 4 are _deprecated_ and should not be used
76
+ * __NOTE:__ Data Formats 2, 3 and 4 are _deprecated_ and should not be used.
82
77
  * [Bleak](https://github.com/hbldh/bleak) communication module (Windows, macOS and Linux)
83
- * Default adapter for Windows and macOS
78
+ * Default adapter for all supported operating systems.
84
79
  * Bleak supports
85
80
  * [Async-methods](#usage)
86
81
  * [Observable streams](#usage)
82
+ * [Fetch history data](#usage)
87
83
  * [Install guide](#Bleak)
88
84
  * Bluez (Linux-only)
89
- * Default adapter for Linux
90
85
  * Bluez supports
91
86
  * [Sync-methods](#usage)
92
87
  * [Observable streams](#usage)
93
88
  * [Install guide](#BlueZ)
94
89
  * __NOTE:__ The BlueZ-adapter implementation uses deprecated BlueZ tools that are no longer supported.
95
- * Even though BlueZ is still the default adapter, it is recommended to use the Bleak-communication adapter with Linux. Bleak will be the default adapter for Linux in the next major release.
96
90
  * Bleson-adapter supports sync-methods, but please be aware that it is not fully supported due to the alpha release status of the Bleson communication module. See [Bleson](#Bleson) for more information.
97
- * Python 3.7+
98
- * For Python 2.x or <3.7 support, check [installation instructions](#python-2x-and-36-and-below) for an older version
91
+ * Python 3.9+
92
+ * For Python 3.7 and 3.8 support, check installation [instructions](#python-37-and-38) for an older version.
93
+ * For Python 2.x or <3.7 support, check installation [instructions](#python-2x-and-36-and-below) for an older version.
94
+
95
+
96
+ __NOTE: Major version changes__
97
+ * Version 3.0 changed default BLE adapter for all platforms to Bleak with async-methods. To use `Bluez`and sync-methods, check the installation [instructions](#BlueZ).
98
+ * Version 2.0 contains method renames. When using a version prior to 2.0, check the documentation and examples from [documentation](https://ttu.github.io/ruuvitag-sensor/#/1.2.1/) or in GitHub, switch to the correct release tag from _switch branches/tags_.
99
99
 
100
- __NOTE:__ Version 2.0 contains method renames. When using a version prior to 2.0, check the documentation and examples from [PyPI](https://pypi.org/project/ruuvitag-sensor/) or in GitHub, switch to the correct release tag from _switch branches/tags_.
101
100
 
102
101
  ## Installation
103
102
 
@@ -120,18 +119,35 @@ Full installation guide for [Raspberry PI & Raspbian](https://github.com/ttu/ruu
120
119
 
121
120
  ## Usage
122
121
 
123
- The package provides 3 ways to fetch data from sensors:
122
+ ### Fetch broadcast data from RuuviTags
123
+
124
+ The package provides 3 ways to fetch broadcasted data from sensors:
124
125
 
125
126
  1. Asynchronously with async/await
126
127
  2. Synchronously with callback
127
128
  3. Observable streams with ReactiveX
128
129
 
129
- RuuviTag sensors can be identified using MAC addresses. Methods return a tuple with MAC and sensor data payload.
130
+ RuuviTag sensors can be identified using MAC addresses. Methods return a tuple containing MAC and sensor data payload.
130
131
 
131
132
  ```py
132
133
  ('D2:A3:6E:C8:E0:25', {'data_format': 5, 'humidity': 47.62, 'temperature': 23.58, 'pressure': 1023.68, 'acceleration': 993.2331045630729, 'acceleration_x': -48, 'acceleration_y': -12, 'acceleration_z': 992, 'tx_power': 4, 'battery': 2197, 'movement_counter': 0, 'measurement_sequence_number': 88, 'mac': 'd2a36ec8e025', 'rssi': -80})
133
134
  ```
134
135
 
136
+ ### Fetch stored history data from RuuviTags internal memory
137
+
138
+ 4. Fetch history data with async/await
139
+
140
+ Each history entry contains one measurement type (temperature, humidity, or pressure) with a Unix timestamp (integer). RuuviTag sends each measurement type as a separate entry.
141
+
142
+ ```py
143
+ [
144
+ {'temperature': 22.22, 'humidity': None, 'pressure': None, 'timestamp': 1738476581}
145
+ {'temperature': None, 'humidity': 38.8, 'pressure': None, 'timestamp': 1738476581},
146
+ {'temperature': None, 'humidity': None, 'pressure': 35755.0, 'timestamp': 1738476581},
147
+ ]
148
+ ```
149
+
150
+
135
151
  ### 1. Get sensor data asynchronously with async/await
136
152
 
137
153
  __NOTE:__ Asynchronous functionality works only with `Bleak`-adapter.
@@ -150,7 +166,7 @@ async def main():
150
166
 
151
167
 
152
168
  if __name__ == "__main__":
153
- asyncio.get_event_loop().run_until_complete(main())
169
+ asyncio.run(main())
154
170
  ```
155
171
 
156
172
  The optional list of MACs can be passed to the `get_data_async` function.
@@ -168,20 +184,22 @@ async def main():
168
184
  async for found_data in RuuviTagSensor.get_data_async(macs):
169
185
  print(f"MAC: {found_data[0]}")
170
186
  print(f"Data: {found_data[1]}")
171
- datas.push(found_data)
187
+ datas.append(found_data)
172
188
  if len(datas) > 10:
173
189
  break
174
190
 
175
191
 
176
192
  if __name__ == "__main__":
177
- asyncio.get_event_loop().run_until_complete(main())
193
+ asyncio.run(main())
178
194
  ```
179
195
 
180
- The line `if __name__ == "__main__":` is required on Windows and macOS due to the way the `multiprocessing` library works. It is not required on Linux, but it is recommended. It is omitted from the rest of the examples below.
196
+ The line `if __name__ == "__main__":` is required on Windows and macOS due to the way the `multiprocessing` library works. While not required on Linux, it is recommended. It is omitted from the rest of the examples below.
197
+
198
+ For Python 3.9, you must replace `asyncio.run(main())` with `asyncio.get_event_loop().run_until_complete(main())` due to limitations in the RuuviTag package's Bleak adapter. In Python 3.10 and later versions, you can use `asyncio.run(main())`.
181
199
 
182
200
  ### 2. Get sensor data synchronously with callback
183
201
 
184
- __NOTE:__ Asynchronous functionality works only with `BlueZ`-adapter.
202
+ __NOTE:__ Synchronous functionality works only with `BlueZ`-adapter.
185
203
 
186
204
  `get_data` calls the callback whenever a RuuviTag sensor broadcasts data. This method is the preferred way to use the library with _BlueZ_.
187
205
 
@@ -259,6 +277,54 @@ More [samples](https://github.com/ttu/ruuvitag-sensor/blob/master/examples/react
259
277
 
260
278
  Check the official documentation of [ReactiveX](https://rxpy.readthedocs.io/en/latest/index.html) and the [list of operators](https://rxpy.readthedocs.io/en/latest/operators.html).
261
279
 
280
+ ### 4. Fetch history data
281
+
282
+ __NOTE:__ History data functionality works only with `Bleak`-adapter.
283
+
284
+ RuuviTags with firmware version 3.30.0 or newer support retrieving historical measurements. The package provides two methods to access this data:
285
+
286
+ 1. `get_history_async`: Stream history entries as they arrive
287
+ 2. `download_history`: Download all history entries at once
288
+
289
+ Each history entry contains one measurement type (temperature, humidity, or pressure) with a Unix timestamp (integer). RuuviTag sends each measurement type as a separate entry.
290
+
291
+ Example history entry:
292
+ ```py
293
+ {
294
+ 'temperature': 22.22, # Only one measurement type per entry
295
+ 'humidity': None,
296
+ 'pressure': None,
297
+ 'timestamp': 1738476581 # Unix timestamp (integer)
298
+ }
299
+ ```
300
+
301
+ ```py
302
+ import asyncio
303
+ from datetime import datetime, timedelta
304
+
305
+ from ruuvitag_sensor.ruuvi import RuuviTagSensor
306
+
307
+
308
+ async def main():
309
+ # Get history from the last 10 minutes
310
+ start_time = datetime.now() - timedelta(minutes=10)
311
+
312
+ # Stream entries as they arrive
313
+ async for entry in RuuviTagSensor.get_history_async(mac="AA:BB:CC:DD:EE:FF", start_time=start_time):
314
+ print(f"Time: {entry['timestamp']} - {entry}")
315
+
316
+ # Or download all entries at once
317
+ history = await RuuviTagSensor.download_history(mac="AA:BB:CC:DD:EE:FF", start_time=start_time)
318
+ for entry in history:
319
+ print(f"Time: {entry['timestamp']} - {entry}")
320
+
321
+
322
+ if __name__ == "__main__":
323
+ asyncio.run(main())
324
+ ```
325
+
326
+ __NOTE:__ Due to the way macOS handles Bluetooth, methods uses UUIDs to identify RuuviTags instead of MAC addresses.
327
+
262
328
  ### Other helper methods
263
329
 
264
330
  #### Get data for specified sensors for a specific duration
@@ -317,7 +383,7 @@ RuuviTagSensor.find_ruuvitags()
317
383
 
318
384
  ### Using different Bluetooth device
319
385
 
320
- If you have multiple Bluetooth devices installed, a device to be used might not be the default (Linux: `hci0`). The device can be passed with a `bt_device`-parameter.
386
+ If you have multiple Bluetooth devices installed, the device to be used might not be the default (Linux: `hci0`). The device can be passed with a `bt_device` parameter.
321
387
 
322
388
  ```python
323
389
  from ruuvitag_sensor.ruuvi import RuuviTagSensor
@@ -371,41 +437,42 @@ Example data has data from 4 sensors with different firmware.
371
437
 
372
438
  There is no reason to use Data Format 2 or 4.
373
439
 
374
- The original reason to use the URL-encoded data was to use _Google's Nearby_ notifications to let users view tags without the need to install any app. Since _Google's Nearby_ has been discontinued, there isn't any benefit in using the Eddystone format anymore.
440
+ The original reason to use URL-encoded data was to use _Google's Nearby_ notifications to let users view tags without the need to install any app. Since _Google's Nearby_ has been discontinued, there isn't any benefit in using the Eddystone format anymore.
441
+
442
+ ## Logging
375
443
 
376
- ## Logging and printing to the console
444
+ The package uses Python's standard `logging` module. Each module in the package creates its own logger using `logging.getLogger(__name__)`.
377
445
 
378
- Logging can be enabled by importing `ruuvitag_sensor.log`. Console print can be enabled by calling `ruuvitag_sensor.log.enable_console()`. The command line application has console logging enabled by default.
446
+ ### Library usage
447
+
448
+ When using ruuvitag-sensor as a library in your application, you should configure logging according to your application's needs:
379
449
 
380
450
  ```py
451
+ import logging
381
452
  from ruuvitag_sensor.ruuvi import RuuviTagSensor
382
- import ruuvitag_sensor.log
383
453
 
384
- ruuvitag_sensor.log.enable_console()
454
+ # Configure logging at the application level
455
+ logging.basicConfig(level=logging.INFO)
456
+ # Or set up custom handlers, formatters, etc.
385
457
 
386
458
  data = RuuviTagSensor.get_data_for_sensors()
387
-
388
- print(data)
389
459
  ```
390
460
 
391
- To enable debug logging to console, set log-level to `DEBUG`.
461
+ ### Command-line and script usage
462
+
463
+ For command-line and script usage, the package provides convenience functions to enable console output:
392
464
 
393
465
  ```py
394
- import logging
395
- import ruuvitag_sensor.log
396
- from ruuvitag_sensor.log import log
397
466
  from ruuvitag_sensor.ruuvi import RuuviTagSensor
467
+ import ruuvitag_sensor.log
398
468
 
469
+ # Enable console logging (defaults to INFO level)
399
470
  ruuvitag_sensor.log.enable_console()
400
471
 
401
- log.setLevel(logging.DEBUG)
402
-
403
- for handler in log.handlers:
404
- handler.setLevel(logging.DEBUG)
472
+ # For debug logging
473
+ ruuvitag_sensor.log.enable_console(level=logging.DEBUG)
405
474
 
406
475
  data = RuuviTagSensor.get_data_for_sensors()
407
-
408
- print(data)
409
476
  ```
410
477
 
411
478
  ### Log all events to log-file
@@ -428,7 +495,7 @@ data = RuuviTagSensor.get_data_for_sensors()
428
495
 
429
496
  ### A custom event handler for a specific log event
430
497
 
431
- If custom functionality is required when a specific event happens, e.g. exit when a specific sensor is blacklisted, logging event handlers can be utilized for this functionality.
498
+ You can add custom handlers to respond to specific log events. For example, to exit when a specific sensor is blacklisted:
432
499
 
433
500
  ```py
434
501
  from logging import StreamHandler
@@ -439,7 +506,7 @@ from ruuvitag_sensor.ruuvi import RuuviTagSensor
439
506
  class ExitHandler(StreamHandler):
440
507
 
441
508
  def emit(self, record):
442
- if (record.levelname != "DEBUG"):
509
+ if record.levelname != "DEBUG":
443
510
  return
444
511
  msg = self.format(record)
445
512
  if "Blacklisting MAC F4:A5:74:89:16:57E" in msg:
@@ -487,12 +554,20 @@ $ sudo apt-get install bluez bluez-hcidump
487
554
 
488
555
  `ruuvitag-sensor` package uses internally _hciconfig_, _hcitool_ and _hcidump_. These tools are deprecated. In case tools are missing, an older version of BlueZ is required ([Issue](https://github.com/ttu/ruuvitag-sensor/issues/31))
489
556
 
490
- If you wish to test the library on Windows or macOS, enable it with `RUUVI_BLE_ADAPTER` environment variable.
557
+ Enable Bluez with the `RUUVI_BLE_ADAPTER` environment variable.
491
558
 
492
559
  ```sh
493
560
  $ export RUUVI_BLE_ADAPTER="bluez"
494
561
  ```
495
562
 
563
+ Or use `os.environ`. __NOTE:__ this must be set before importing `ruuvitag_sensor`.
564
+
565
+ ```py
566
+ import os
567
+
568
+ os.environ["RUUVI_BLE_ADAPTER"] = "bluez"
569
+ ```
570
+
496
571
  And install ptyprocess.
497
572
 
498
573
  ```sh
@@ -507,29 +582,10 @@ In case of errors, the application tries to exit immediately, so it can be autom
507
582
 
508
583
  ### Bleak
509
584
 
510
- On Windows and macOS Bleak is installed and used automatically with `ruuvitag-sensor` package.
585
+ Bleak is automatically installed with `ruuvitag-sensor` package on all platforms.
586
+ It is automatically used with `ruuvitag-sensor` package on all platforms.
511
587
 
512
- On Linux install it manually from PyPI and enable it with `RUUVI_BLE_ADAPTER` environment variable.
513
-
514
- ```sh
515
- $ python -m pip install bleak
516
- ```
517
-
518
- Add environment variable RUUVI_BLE_ADAPTER with value Bleak. E.g.
519
-
520
- ```sh
521
- $ export RUUVI_BLE_ADAPTER="bleak"
522
- ```
523
-
524
- Or use `os.environ`. __NOTE:__ this must be set before importing `ruuvitag_sensor`.
525
-
526
- ```py
527
- import os
528
-
529
- os.environ["RUUVI_BLE_ADAPTER"] = "bleak"
530
- ```
531
-
532
- Bleak supports only async methods.
588
+ Bleak only supports asynchronous methods.
533
589
 
534
590
  ```py
535
591
  import asyncio
@@ -542,14 +598,14 @@ async def main():
542
598
 
543
599
 
544
600
  if __name__ == "__main__":
545
- asyncio.get_event_loop().run_until_complete(main())
601
+ asyncio.run(main())
546
602
  ```
547
603
 
548
604
  Check [get_async_bleak](https://github.com/ttu/ruuvitag-sensor/blob/master/examples/get_async_bleak.py) and other async examples from [examples](https://github.com/ttu/ruuvitag-sensor/tree/master/examples) directory.
549
605
 
550
606
  #### Bleak dummy BLE data
551
607
 
552
- Bleak-adapter has a development-time generator for dummy data, which can be useful during the development, if no sensors are available. Set `RUUVI_BLE_ADAPTER` environment variable to `bleak_dev`.
608
+ Bleak-adapter has a development-time generator for dummy data, which can be useful during development if no sensors are available. Set the `RUUVI_BLE_ADAPTER` environment variable to `bleak_dev`.
553
609
 
554
610
  ### Bleson
555
611
 
@@ -574,6 +630,21 @@ __NOTE:__ On macOS, only Data Format 5 works, as macOS doesn't advertise MAC add
574
630
  __NOTE:__ On Windows, Bleson requires _Python 3.6_. Unfortunately on Windows, Bleson doesn't send any payload for the advertised package, so it is still unusable.
575
631
 
576
632
 
633
+ ## Python 3.7 and 3.8
634
+
635
+ Last version of `ruuvitag-sensor` with Python 3.7 and 3.8 support is [2.3.1](https://pypi.org/project/ruuvitag-sensor/2.3.1/).
636
+
637
+ [Branch](https://github.com/ttu/ruuvitag-sensor/tree/release/2.3.1) / [Tag / commit](https://github.com/ttu/ruuvitag-sensor/commit/b16c9580d75eafe5508d0551642eb3b022ae1325)
638
+
639
+ ```sh
640
+ $ git checkout release/2.3.1
641
+ ```
642
+
643
+ Install from PyPI
644
+ ```sh
645
+ $ python -m pip install ruuvitag-sensor==2.3.1
646
+ ```
647
+
577
648
  ## Python 2.x and 3.6 and below
578
649
 
579
650
  Last version of `ruuvitag-sensor` with Python 2.x and <3.7 support is [1.2.1](https://pypi.org/project/ruuvitag-sensor/1.2.1/).