blueair-api 1.9.1__py3-none-any.whl → 1.33.2__py3-none-any.whl

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.
blueair_api/util.py CHANGED
@@ -1,3 +1,4 @@
1
+ from typing import Any
1
2
  import logging
2
3
 
3
4
  from .const import SENSITIVE_FIELD_NAMES
@@ -5,7 +6,7 @@ from .const import SENSITIVE_FIELD_NAMES
5
6
  _LOGGER = logging.getLogger(__name__)
6
7
 
7
8
 
8
- def clean_dictionary_for_logging(dictionary: dict[str, any]) -> dict[str, any]:
9
+ def clean_dictionary_for_logging(dictionary: dict[str, Any]) -> dict[str, Any]:
9
10
  mutable_dictionary = dictionary.copy()
10
11
  for key in dictionary:
11
12
  if key.lower() in SENSITIVE_FIELD_NAMES:
@@ -26,17 +27,6 @@ def clean_dictionary_for_logging(dictionary: dict[str, any]) -> dict[str, any]:
26
27
  return mutable_dictionary
27
28
 
28
29
 
29
- def convert_api_array_to_dict(array):
30
- dictionary = {}
31
- for obj in array:
32
- if "v" in obj:
33
- dictionary[obj["n"]] = obj["v"]
34
- else:
35
- if "vb" in obj:
36
- dictionary[obj["n"]] = obj["vb"]
37
- return dictionary
38
-
39
-
40
30
  def safely_get_json_value(json, key, callable_to_cast=None):
41
31
  value = json
42
32
  for x in key.split("."):
@@ -51,3 +41,27 @@ def safely_get_json_value(json, key, callable_to_cast=None):
51
41
  if callable_to_cast is not None and value is not None:
52
42
  value = callable_to_cast(value)
53
43
  return value
44
+
45
+ def convert_none_to_not_implemented(value):
46
+ if value is None:
47
+ return NotImplemented
48
+ else:
49
+ return value
50
+
51
+ def transform_data_points(data):
52
+ """Transform a measurement list response from the Blueair API to a more pythonic data structure."""
53
+ key_mapping = {
54
+ "time": "timestamp",
55
+ "pm": "pm25",
56
+ "pm1": "pm1",
57
+ "pm10": "pm10",
58
+ "tmp": "temperature",
59
+ "hum": "humidity",
60
+ "co2": "co2",
61
+ "voc": "voc",
62
+ "allpollu": "all_pollution",
63
+ }
64
+
65
+ keys = [key_mapping[key] for key in data["sensors"]]
66
+
67
+ return [dict(zip(keys, values)) for values in data["datapoints"]]
@@ -6,6 +6,7 @@ from .http_blueair import HttpBlueair
6
6
  from .http_aws_blueair import HttpAwsBlueair
7
7
  from .device import Device
8
8
  from .device_aws import DeviceAws
9
+ from typing import Optional
9
10
 
10
11
  _LOGGER = logging.getLogger(__name__)
11
12
 
@@ -13,10 +14,10 @@ _LOGGER = logging.getLogger(__name__)
13
14
  async def get_devices(
14
15
  username: str,
15
16
  password: str,
16
- home_host: str = None,
17
- auth_token: str = None,
18
- client_session: ClientSession = None,
19
- ) -> (HttpBlueair, list[Device]):
17
+ home_host: str | None = None,
18
+ auth_token: str | None = None,
19
+ client_session: ClientSession | None = None,
20
+ ) -> tuple[HttpBlueair, list[Device]]:
20
21
  api = HttpBlueair(
21
22
  client_session=client_session,
22
23
  username=username,
@@ -25,19 +26,17 @@ async def get_devices(
25
26
  auth_token=auth_token,
26
27
  )
27
28
  api_devices = await api.get_devices()
28
-
29
- def create_device(device):
30
- return Device(
29
+ devices = []
30
+ for api_device in api_devices:
31
+ devices.append(await Device.create_device(
31
32
  api=api,
32
- uuid=device["uuid"],
33
- name=device["name"],
34
- mac=device["mac"],
35
- )
36
-
37
- devices = map(create_device, api_devices)
33
+ uuid=api_device["uuid"],
34
+ name=api_device["name"],
35
+ mac=api_device["mac"]
36
+ ))
38
37
  return (
39
38
  api,
40
- list(devices),
39
+ devices,
41
40
  )
42
41
 
43
42
 
@@ -45,8 +44,8 @@ async def get_aws_devices(
45
44
  username: str,
46
45
  password: str,
47
46
  region: str = "us",
48
- client_session: ClientSession = None,
49
- ) -> (HttpAwsBlueair, list[Device]):
47
+ client_session: ClientSession | None = None,
48
+ ) -> tuple[HttpAwsBlueair, list[DeviceAws]]:
50
49
  api = HttpAwsBlueair(
51
50
  username=username,
52
51
  password=password,
@@ -54,14 +53,17 @@ async def get_aws_devices(
54
53
  client_session=client_session,
55
54
  )
56
55
  api_devices = await api.devices()
57
-
58
- def create_device(device):
59
- return DeviceAws(
56
+ devices = []
57
+ for api_device in api_devices:
58
+ _LOGGER.debug("api_device: %s", api_device)
59
+ devices.append(await DeviceAws.create_device(
60
60
  api=api,
61
- uuid=device["uuid"],
62
- name_api=device["name"],
63
- mac=device["mac"],
64
- )
65
-
66
- devices = map(create_device, api_devices)
67
- return (api, list(devices))
61
+ uuid=api_device["uuid"],
62
+ name=api_device["name"],
63
+ mac=api_device["mac"],
64
+ type_name=api_device["type"]
65
+ ))
66
+ return (
67
+ api,
68
+ devices
69
+ )
@@ -1,24 +1,22 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: blueair_api
3
- Version: 1.9.1
3
+ Version: 1.33.2
4
4
  Summary: Blueair Api Wrapper
5
- Home-page: https://github.com/dahlb/blueair_api
6
- Author: Brendan Dahl
7
- Author-email: dahl.brendan@gmail.com
8
- Project-URL: Bug Reports, https://github.com/dahlb/blueair_api/issues
9
- Project-URL: Source, https://github.com/dahlb/blueair_api
10
- Keywords: blueair,api
5
+ Author-email: Brendan Dahl <dahl.brendan@gmail.com>
6
+ Project-URL: Homepage, https://github.com/dahlb/blueair_api
7
+ Project-URL: Bug Tracker, https://github.com/dahlb/blueair_api/issues
8
+ Keywords: hatch,rest-mini,api
11
9
  Classifier: Development Status :: 4 - Beta
12
- Classifier: Framework :: AsyncIO
13
10
  Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Framework :: AsyncIO
14
12
  Classifier: Natural Language :: English
15
13
  Classifier: Intended Audience :: Developers
16
- Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
17
15
  Classifier: Operating System :: MacOS :: MacOS X
18
- Requires-Python: >=3.9, <4
16
+ Requires-Python: <4,>=3.12.0
19
17
  Description-Content-Type: text/markdown
20
18
  License-File: LICENSE
21
- Requires-Dist: aiohttp >=3.8.1
19
+ Requires-Dist: aiohttp>=3.8.1
22
20
 
23
21
  [![GitHub Release][releases-shield]][releases]
24
22
  [![GitHub Activity][commits-shield]][commits]
@@ -42,5 +40,3 @@ a lot of this is based on [hass-blueair](https://github.com/aijayadams/hass-blue
42
40
  [releases]: https://github.com/dahlb/blueair_api/releases
43
41
  [buymecoffee]: https://www.buymeacoffee.com/dahlb
44
42
  [buymecoffeebadge]: https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?style=for-the-badge
45
-
46
-
@@ -0,0 +1,19 @@
1
+ blueair_api/__init__.py,sha256=GucsIENhTF4AVxPn4Xyr4imUxJJ8RO8RYt1opHCF2hQ,326
2
+ blueair_api/callbacks.py,sha256=fvrJsqH5eDRxWOGWiZkF2uLU4n2ve0zzU17ERqWbHP8,756
3
+ blueair_api/const.py,sha256=q1smSEhwyYvuQiR867lToFm-mGV-d3dNJvN0NJgscbU,1037
4
+ blueair_api/device.py,sha256=qD4kiYjhJdRsY9d6CZSDKqJLO_dSum3sumYLgZW8v2s,5474
5
+ blueair_api/device_aws.py,sha256=cWpMrMzWH9hI-gkZb_Tvp2DMJPFZm3p5kt01ZHTUtGc,10008
6
+ blueair_api/errors.py,sha256=lJ_iFU_W6zQfGRi_wsMhWDw-fAVPFeCkCbT1erIlYQQ,233
7
+ blueair_api/http_aws_blueair.py,sha256=jztGyoH0iC7aCJ2oGf9hnEeHFOie3YikFvwtWo3W2w4,8536
8
+ blueair_api/http_blueair.py,sha256=IMnKXs9S0Z-t1GVshSItjNr9tTdtXjh7-T-tHpsbzhE,11752
9
+ blueair_api/intermediate_representation_aws.py,sha256=DJWxHFP9yVll0O6kxHWjKscIlu-7genc3f7ZvwV5YdA,6137
10
+ blueair_api/model_enum.py,sha256=Z9Ne4icNEjbGNwdHJZSDibcKJKwv-W1BRpZx01RGFuY,2480
11
+ blueair_api/stub.py,sha256=tWJJLIhKf39P1gRAXfJk6L8cBJI9fVK3Uk9pj2_Teaw,1187
12
+ blueair_api/util.py,sha256=uWO_rSSXWO-SDzIUHrQP4JR0PlARVV2IlQAJyWiGAlE,2089
13
+ blueair_api/util_bootstrap.py,sha256=oo6qqEYUxWb4wLLivk7ofB0YFrKsTZo5tW0U2wc3-D0,1757
14
+ blueair_api/util_http.py,sha256=45AJG3Vb6LMVzI0WV22AoSyt64f_Jj3KpOAwF5M6EFE,1327
15
+ blueair_api-1.33.2.dist-info/LICENSE,sha256=W6UV41yCe1R_Avet8VtsxwdJar18n40b3MRnbEMHZmI,1066
16
+ blueair_api-1.33.2.dist-info/METADATA,sha256=UMWO4mwQTJNLW3vg3p0s6fWvtMjB7_XnuP4cE9Q3CyE,1995
17
+ blueair_api-1.33.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
18
+ blueair_api-1.33.2.dist-info/top_level.txt,sha256=-gn0jNtmE83qEu70uMW5F4JrXnHGRfuFup1EPWF70oc,12
19
+ blueair_api-1.33.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,17 +0,0 @@
1
- blueair_api/__init__.py,sha256=TSAR2ntyFQWyGdKNR1iEsJJmQbNMOvnw-xdVONMHdA8,279
2
- blueair_api/callbacks.py,sha256=6hzAAbdq-FQYTgc5RVBQCiqJz3PaBHkIgAkg0P2NZ8U,725
3
- blueair_api/const.py,sha256=4c_BWF1YzFZ3lpCtywxrBVY7g7lryNxzBkYnIOK09CA,1110
4
- blueair_api/device.py,sha256=wYPK7EqzwdJ_Qm3o6uzt_rc9KSWoTjiy81vNXmCzTMs,3065
5
- blueair_api/device_aws.py,sha256=EEk38JdKPF18Tq_Gt3Qofmhe6zujoG_1Pfl8Y1LFhdY,4910
6
- blueair_api/errors.py,sha256=lJ_iFU_W6zQfGRi_wsMhWDw-fAVPFeCkCbT1erIlYQQ,233
7
- blueair_api/http_aws_blueair.py,sha256=39pQDQLxElMhvNppzHLcB3N8iejwrQKbeeHKIzdHBus,17989
8
- blueair_api/http_blueair.py,sha256=ieDvjs0_DHSJzseO_qdvLIxdrUUHuTgSHjWb6u-_gRs,7350
9
- blueair_api/stub.py,sha256=04RBMbv3ZdfJzmZISj3grf43AYU7ia0parL0UKDfeXI,1273
10
- blueair_api/util.py,sha256=3L9-vfHfN1vUBYU0BA9ruYyNPUTmS21D-uI-Jyo5x6U,1672
11
- blueair_api/util_bootstrap.py,sha256=A_0wj92QpowoKy8tJgKgQMKScC_c8uyfhZlCXZup5mY,1562
12
- blueair_api/util_http.py,sha256=45AJG3Vb6LMVzI0WV22AoSyt64f_Jj3KpOAwF5M6EFE,1327
13
- blueair_api-1.9.1.dist-info/LICENSE,sha256=W6UV41yCe1R_Avet8VtsxwdJar18n40b3MRnbEMHZmI,1066
14
- blueair_api-1.9.1.dist-info/METADATA,sha256=S-1-G_T4qq8TX5iW24Em2HJriPE6pxXOnm3x3nrEpMw,2036
15
- blueair_api-1.9.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
16
- blueair_api-1.9.1.dist-info/top_level.txt,sha256=-gn0jNtmE83qEu70uMW5F4JrXnHGRfuFup1EPWF70oc,12
17
- blueair_api-1.9.1.dist-info/RECORD,,