blueair-api 1.22.0__py3-none-any.whl → 1.23.0__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/device.py +20 -2
- blueair_api/http_blueair.py +2 -2
- blueair_api/util.py +19 -0
- {blueair_api-1.22.0.dist-info → blueair_api-1.23.0.dist-info}/METADATA +1 -1
- {blueair_api-1.22.0.dist-info → blueair_api-1.23.0.dist-info}/RECORD +8 -8
- {blueair_api-1.22.0.dist-info → blueair_api-1.23.0.dist-info}/LICENSE +0 -0
- {blueair_api-1.22.0.dist-info → blueair_api-1.23.0.dist-info}/WHEEL +0 -0
- {blueair_api-1.22.0.dist-info → blueair_api-1.23.0.dist-info}/top_level.txt +0 -0
blueair_api/device.py
CHANGED
@@ -3,6 +3,7 @@ import logging
|
|
3
3
|
|
4
4
|
from .callbacks import CallbacksMixin
|
5
5
|
from .http_blueair import HttpBlueair
|
6
|
+
from .util import transform_data_points, safely_get_json_value
|
6
7
|
|
7
8
|
_LOGGER = logging.getLogger(__name__)
|
8
9
|
|
@@ -51,11 +52,18 @@ class Device(CallbacksMixin):
|
|
51
52
|
filter_expired: bool | None = None
|
52
53
|
wifi_working: bool | None = None
|
53
54
|
|
55
|
+
pm1: int | None = None
|
56
|
+
pm10: int | None = None
|
57
|
+
pm25: int | None = None
|
58
|
+
voc: int | None = None
|
59
|
+
co2: int | None = None
|
60
|
+
temperature: float | None = None
|
61
|
+
humidity: float | None = None
|
62
|
+
all_pollution: float | None = None
|
63
|
+
|
54
64
|
async def refresh(self):
|
55
65
|
_LOGGER.debug("Requesting current attributes...")
|
56
66
|
attributes = await self.api.get_attributes(self.uuid)
|
57
|
-
_data_points = await self.api.get_current_data_point(self.uuid)
|
58
|
-
_data_points2 = await self.api.get_data_points_since(self.uuid)
|
59
67
|
_LOGGER.debug(f"result: {attributes}")
|
60
68
|
if "brightness" in attributes:
|
61
69
|
self.brightness = int(attributes["brightness"])
|
@@ -73,6 +81,16 @@ class Device(CallbacksMixin):
|
|
73
81
|
self.wifi_working = attributes["wifi_status"] == "1"
|
74
82
|
else:
|
75
83
|
self.wifi_working = False
|
84
|
+
for data_point in transform_data_points(await self.api.get_data_points_since(self.uuid)):
|
85
|
+
_LOGGER.debug(data_point)
|
86
|
+
self.pm25 = safely_get_json_value(data_point, "pm25", int)
|
87
|
+
self.pm10 = safely_get_json_value(data_point, "pm10", int)
|
88
|
+
self.pm1 = safely_get_json_value(data_point, "pm1", int)
|
89
|
+
self.voc = safely_get_json_value(data_point, "voc", int)
|
90
|
+
self.co2 = safely_get_json_value(data_point, "co2", int)
|
91
|
+
self.temperature = safely_get_json_value(data_point, "temperature", int)
|
92
|
+
self.humidity = safely_get_json_value(data_point, "humidity", int)
|
93
|
+
self.all_pollution = safely_get_json_value(data_point, "all_pollution", int)
|
76
94
|
_LOGGER.debug(f"refreshed blueair device: {self}")
|
77
95
|
self.publish_updates()
|
78
96
|
|
blueair_api/http_blueair.py
CHANGED
@@ -186,7 +186,7 @@ class HttpBlueair:
|
|
186
186
|
available device information.
|
187
187
|
|
188
188
|
Note: the data for this API call is only updated once every 5 minutes.
|
189
|
-
Calling it more often will return the same
|
189
|
+
Calling it more often will return the same response from the server and
|
190
190
|
should be avoided to limit server load.
|
191
191
|
"""
|
192
192
|
url = f"https://{await self.get_home_host()}/v2/device/{device_uuid}/datapoint/0/last/0/"
|
@@ -209,7 +209,7 @@ class HttpBlueair:
|
|
209
209
|
together. The minimum sample period size is 300 (5 minutes).
|
210
210
|
|
211
211
|
Note: the data for the most recent data point is only updated once
|
212
|
-
every 5 minutes. Calling it more often will return the same
|
212
|
+
every 5 minutes. Calling it more often will return the same response
|
213
213
|
from the server and should be avoided to limit server load.
|
214
214
|
"""
|
215
215
|
url = f"https://{await self.get_home_host()}/v2/device/{device_uuid}/datapoint/{seconds_ago}/last/{sample_period}/"
|
blueair_api/util.py
CHANGED
@@ -51,3 +51,22 @@ def safely_get_json_value(json, key, callable_to_cast=None):
|
|
51
51
|
if callable_to_cast is not None and value is not None:
|
52
52
|
value = callable_to_cast(value)
|
53
53
|
return value
|
54
|
+
|
55
|
+
|
56
|
+
def transform_data_points(data):
|
57
|
+
"""Transform a measurement list response from the Blueair API to a more pythonic data structure."""
|
58
|
+
key_mapping = {
|
59
|
+
"time": "timestamp",
|
60
|
+
"pm": "pm25",
|
61
|
+
"pm1": "pm1",
|
62
|
+
"pm10": "pm10",
|
63
|
+
"tmp": "temperature",
|
64
|
+
"hum": "humidity",
|
65
|
+
"co2": "co2",
|
66
|
+
"voc": "voc",
|
67
|
+
"allpollu": "all_pollution",
|
68
|
+
}
|
69
|
+
|
70
|
+
keys = [key_mapping[key] for key in data["sensors"]]
|
71
|
+
|
72
|
+
return [dict(zip(keys, values)) for values in data["datapoints"]]
|
@@ -1,18 +1,18 @@
|
|
1
1
|
blueair_api/__init__.py,sha256=GucsIENhTF4AVxPn4Xyr4imUxJJ8RO8RYt1opHCF2hQ,326
|
2
2
|
blueair_api/callbacks.py,sha256=eqgfe1qN_NNWOp2qNSP123zQJxh_Ie6vZXp5EHp6ePc,757
|
3
3
|
blueair_api/const.py,sha256=fRth29dQT1dguM7L4ij8pDefB_vBrevAHqTdfNvSugs,1048
|
4
|
-
blueair_api/device.py,sha256=
|
4
|
+
blueair_api/device.py,sha256=XhEfo2qb3WHN_6c67ZSXMnzToZesh6pyGnCGa2uTncU,3685
|
5
5
|
blueair_api/device_aws.py,sha256=tqrpUyrgsuTa6eu_Q9ycqJj41HH2NgDuq6T5amU25V0,5871
|
6
6
|
blueair_api/errors.py,sha256=lJ_iFU_W6zQfGRi_wsMhWDw-fAVPFeCkCbT1erIlYQQ,233
|
7
7
|
blueair_api/http_aws_blueair.py,sha256=m_qoCFOYICCu_U_maBvkmOha3YmNtxxtPYyapVBGKNc,17821
|
8
|
-
blueair_api/http_blueair.py,sha256=
|
8
|
+
blueair_api/http_blueair.py,sha256=n9F5fvEROIyAkqDMM22l84PB7ZoeEkWbj2YuCZpeDNg,9411
|
9
9
|
blueair_api/model_enum.py,sha256=C42DpLsHO2QLez-qfrFHZnr9QaNPPcnsISm4SoRnvoY,2194
|
10
10
|
blueair_api/stub.py,sha256=sTWyRSDObzrXpZToAgDmZhCk3q8SsGN35h-kzMOqSOc,1272
|
11
|
-
blueair_api/util.py,sha256=
|
11
|
+
blueair_api/util.py,sha256=4g8dTlxawBYKslOJS7WCWss0670mtUc53c3L8NiPTsM,2201
|
12
12
|
blueair_api/util_bootstrap.py,sha256=Vewg7mT1qSRgzOOJDrpXrVhGwcFPRnMrqhJVSIB-0AA,1688
|
13
13
|
blueair_api/util_http.py,sha256=45AJG3Vb6LMVzI0WV22AoSyt64f_Jj3KpOAwF5M6EFE,1327
|
14
|
-
blueair_api-1.
|
15
|
-
blueair_api-1.
|
16
|
-
blueair_api-1.
|
17
|
-
blueair_api-1.
|
18
|
-
blueair_api-1.
|
14
|
+
blueair_api-1.23.0.dist-info/LICENSE,sha256=W6UV41yCe1R_Avet8VtsxwdJar18n40b3MRnbEMHZmI,1066
|
15
|
+
blueair_api-1.23.0.dist-info/METADATA,sha256=hr1z37I41YsNcIw4IhoW1KDj9_CSmVRN-iPjKT5fHW0,1995
|
16
|
+
blueair_api-1.23.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
17
|
+
blueair_api-1.23.0.dist-info/top_level.txt,sha256=-gn0jNtmE83qEu70uMW5F4JrXnHGRfuFup1EPWF70oc,12
|
18
|
+
blueair_api-1.23.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|