blueair-api 1.20.0__tar.gz → 1.21.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.
Files changed (23) hide show
  1. {blueair_api-1.20.0 → blueair_api-1.21.0}/PKG-INFO +1 -1
  2. {blueair_api-1.20.0 → blueair_api-1.21.0}/pyproject.toml +1 -1
  3. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/device_aws.py +15 -0
  4. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/http_blueair.py +23 -0
  5. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/model_enum.py +0 -2
  6. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/stub.py +4 -4
  7. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/util_bootstrap.py +14 -16
  8. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api.egg-info/PKG-INFO +1 -1
  9. {blueair_api-1.20.0 → blueair_api-1.21.0}/LICENSE +0 -0
  10. {blueair_api-1.20.0 → blueair_api-1.21.0}/README.md +0 -0
  11. {blueair_api-1.20.0 → blueair_api-1.21.0}/setup.cfg +0 -0
  12. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/__init__.py +0 -0
  13. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/callbacks.py +0 -0
  14. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/const.py +0 -0
  15. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/device.py +0 -0
  16. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/errors.py +0 -0
  17. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/http_aws_blueair.py +0 -0
  18. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/util.py +0 -0
  19. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api/util_http.py +0 -0
  20. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api.egg-info/SOURCES.txt +0 -0
  21. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api.egg-info/dependency_links.txt +0 -0
  22. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api.egg-info/requires.txt +0 -0
  23. {blueair_api-1.20.0 → blueair_api-1.21.0}/src/blueair_api.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: blueair_api
3
- Version: 1.20.0
3
+ Version: 1.21.0
4
4
  Summary: Blueair Api Wrapper
5
5
  Author-email: Brendan Dahl <dahl.brendan@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/dahlb/blueair_api
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
8
8
 
9
9
  [project]
10
10
  name = "blueair_api"
11
- version = "1.20.0"
11
+ version = "1.21.0"
12
12
  authors = [
13
13
  { name="Brendan Dahl", email="dahl.brendan@gmail.com" },
14
14
  ]
@@ -11,6 +11,21 @@ _LOGGER = logging.getLogger(__name__)
11
11
 
12
12
  @dataclasses.dataclass(slots=True)
13
13
  class DeviceAws(CallbacksMixin):
14
+ @classmethod
15
+ async def create_device(cls, api, uuid, name, mac, type_name, refresh=False):
16
+ _LOGGER.debug("UUID:"+uuid)
17
+ device_aws = DeviceAws(
18
+ api=api,
19
+ uuid=uuid,
20
+ name_api=name,
21
+ mac=mac,
22
+ type_name=type_name,
23
+ )
24
+ if refresh:
25
+ await device_aws.refresh()
26
+ _LOGGER.debug(f"create_device blueair device_aws: {device_aws}")
27
+ return device_aws
28
+
14
29
  api: HttpAwsBlueair
15
30
  uuid: str = None
16
31
  name: str = None
@@ -201,6 +201,29 @@ class HttpBlueair:
201
201
  )
202
202
  return await response.json()
203
203
 
204
+ async def get_data_points_since(self, device_uuid: str, seconds_ago: int = 0, sample_period: int = 300) -> dict[str, any]:
205
+ """
206
+ Fetch the list of data points between a relative timestamp (in seconds) and the current time.
207
+
208
+ An optional sample period can be provided to group data points
209
+ together. The minimum sample period size is 300 (5 minutes).
210
+
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 respone
213
+ from the server and should be avoided to limit server load.
214
+ """
215
+ url = f"https://{await self.get_home_host()}/v2/device/{device_uuid}/datapoint/{seconds_ago}/last/{sample_period}/"
216
+ headers = {
217
+ "X-API-KEY-TOKEN": API_KEY,
218
+ "X-AUTH-TOKEN": await self.get_auth_token(),
219
+ }
220
+ response: ClientResponse = (
221
+ await self._get_request_with_logging_and_errors_raised(
222
+ url=url, headers=headers
223
+ )
224
+ )
225
+ return await response.json()
226
+
204
227
  async def set_fan_speed(self, device_uuid, new_speed: str):
205
228
  """
206
229
  Set the fan speed per @spikeyGG comment at https://community.home-assistant.io/t/blueair-purifier-addon/154456/14
@@ -63,8 +63,6 @@ class ModelEnum(Enum):
63
63
  FeatureEnum.CHILD_LOCK,
64
64
  ]
65
65
  MAX_311I = "Blueair Blue Pure 311i Max", [
66
- FeatureEnum.PM1,
67
- FeatureEnum.PM10,
68
66
  FeatureEnum.PM25,
69
67
  FeatureEnum.FILTER_EXPIRED,
70
68
  FeatureEnum.CHILD_LOCK,
@@ -28,16 +28,16 @@ async def testing():
28
28
  password = getpass()
29
29
  try:
30
30
  api, devices = await get_aws_devices(username=username, password=password)
31
- await devices[0].refresh()
32
- await devices[0].set_child_lock(True)
33
- logger.debug(devices[0])
31
+ for device in devices:
32
+ await device.refresh()
33
+ await device.set_child_lock(True)
34
+ logger.debug(device)
34
35
  finally:
35
36
  if api:
36
37
  await api.cleanup_client_session()
37
38
  try:
38
39
  api, devices = await get_devices(username=username, password=password)
39
40
  for device in devices:
40
- await device.post_init()
41
41
  await device.refresh()
42
42
  logger.debug(device)
43
43
  finally:
@@ -25,14 +25,13 @@ async def get_devices(
25
25
  auth_token=auth_token,
26
26
  )
27
27
  api_devices = await api.get_devices()
28
-
29
28
  devices = []
30
29
  for api_device in api_devices:
31
30
  devices.append(await Device.create_device(
32
- api,
33
- api_device["uuid"],
34
- api_device["name"],
35
- api_device["mac"]
31
+ api=api,
32
+ uuid=api_device["uuid"],
33
+ name=api_device["name"],
34
+ mac=api_device["mac"]
36
35
  ))
37
36
  return (
38
37
  api,
@@ -53,18 +52,17 @@ async def get_aws_devices(
53
52
  client_session=client_session,
54
53
  )
55
54
  api_devices = await api.devices()
56
-
57
- def create_device(device):
58
- return DeviceAws(
55
+ devices = []
56
+ for api_device in api_devices:
57
+ _LOGGER.debug("api_device: %s", api_device)
58
+ devices.append(await DeviceAws.create_device(
59
59
  api=api,
60
- uuid=device["uuid"],
61
- name_api=device["name"],
62
- mac=device["mac"],
63
- type_name=device["type"],
64
- )
65
-
66
- devices = map(create_device, api_devices)
60
+ uuid=api_device["uuid"],
61
+ name=api_device["name"],
62
+ mac=api_device["mac"],
63
+ type_name=api_device["type"]
64
+ ))
67
65
  return (
68
66
  api,
69
- list(devices)
67
+ devices
70
68
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: blueair_api
3
- Version: 1.20.0
3
+ Version: 1.21.0
4
4
  Summary: Blueair Api Wrapper
5
5
  Author-email: Brendan Dahl <dahl.brendan@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/dahlb/blueair_api
File without changes
File without changes
File without changes