aioairzone-cloud 0.2.2__tar.gz → 0.2.3__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 (28) hide show
  1. {aioairzone-cloud-0.2.2/aioairzone_cloud.egg-info → aioairzone-cloud-0.2.3}/PKG-INFO +1 -1
  2. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/cloudapi.py +39 -0
  3. aioairzone-cloud-0.2.2/aioairzone_cloud/group.py → aioairzone-cloud-0.2.3/aioairzone_cloud/device_group.py +31 -40
  4. aioairzone-cloud-0.2.3/aioairzone_cloud/group.py +36 -0
  5. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/installation.py +15 -16
  6. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3/aioairzone_cloud.egg-info}/PKG-INFO +1 -1
  7. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud.egg-info/SOURCES.txt +1 -0
  8. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/pyproject.toml +2 -1
  9. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/LICENSE +0 -0
  10. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/MANIFEST.in +0 -0
  11. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/README.md +0 -0
  12. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/__init__.py +0 -0
  13. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/aidoo.py +0 -0
  14. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/common.py +0 -0
  15. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/const.py +0 -0
  16. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/device.py +0 -0
  17. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/exceptions.py +0 -0
  18. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/hvac.py +0 -0
  19. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/py.typed +0 -0
  20. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/system.py +0 -0
  21. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/webserver.py +0 -0
  22. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud/zone.py +0 -0
  23. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud.egg-info/dependency_links.txt +0 -0
  24. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud.egg-info/not-zip-safe +0 -0
  25. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud.egg-info/requires.txt +0 -0
  26. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/aioairzone_cloud.egg-info/top_level.txt +0 -0
  27. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/requirements.txt +0 -0
  28. {aioairzone-cloud-0.2.2 → aioairzone-cloud-0.2.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioairzone-cloud
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Library to control Airzone Cloud devices
5
5
  Author-email: Álvaro Fernández Rojas <noltari@gmail.com>
6
6
  License: Apache-2.0
@@ -261,6 +261,19 @@ class AirzoneCloudApi:
261
261
  json,
262
262
  )
263
263
 
264
+ async def api_put_installation(
265
+ self, inst: Installation, json: dict[str, Any]
266
+ ) -> dict[str, Any]:
267
+ """Perform a PUT request to update installation parameters."""
268
+ inst_id = inst.get_id()
269
+ inst_url = urllib.parse.quote(inst_id)
270
+
271
+ return await self.api_request(
272
+ "PUT",
273
+ f"{API_V1}/{API_INSTALLATIONS}/{inst_url}",
274
+ json,
275
+ )
276
+
264
277
  async def api_set_device_param(
265
278
  self, device: Device, param: str, data: dict[str, Any]
266
279
  ) -> None:
@@ -295,6 +308,14 @@ class AirzoneCloudApi:
295
308
 
296
309
  group.set_params(params)
297
310
 
311
+ async def api_set_installation_params(
312
+ self, inst: Installation, params: dict[str, Any]
313
+ ) -> None:
314
+ """Set installation parameters."""
315
+ await self.api_put_installation(inst, params)
316
+
317
+ inst.set_params(params)
318
+
298
319
  async def api_set_aidoo_id_params(
299
320
  self, aidoo_id: str, params: dict[str, Any]
300
321
  ) -> None:
@@ -323,6 +344,14 @@ class AirzoneCloudApi:
323
344
  if group is not None:
324
345
  await self.api_set_group_params(group, params)
325
346
 
347
+ async def api_set_installation_id_params(
348
+ self, inst_id: str, params: dict[str, Any]
349
+ ) -> None:
350
+ """Set installation parameters."""
351
+ inst = self.get_installation_id(inst_id)
352
+ if inst is not None:
353
+ await self.api_set_installation_params(inst, params)
354
+
326
355
  async def api_set_system_id_params(
327
356
  self, system_id: str, params: dict[str, Any]
328
357
  ) -> None:
@@ -523,6 +552,7 @@ class AirzoneCloudApi:
523
552
  if zone is not None:
524
553
  self.zones[zone.get_id()] = zone
525
554
  group.add_zone(zone)
555
+ inst.add_zone(zone)
526
556
  elif API_AZ_SYSTEM == device_data[API_TYPE]:
527
557
  if self.get_system_id(device_data[API_DEVICE_ID]) is None:
528
558
  system = System(
@@ -531,6 +561,7 @@ class AirzoneCloudApi:
531
561
  if system is not None:
532
562
  self.systems[system.get_id()] = system
533
563
  group.add_system(system)
564
+ inst.add_system(system)
534
565
  elif API_AZ_AIDOO == device_data[API_TYPE]:
535
566
  if self.get_aidoo_id(device_data[API_DEVICE_ID]) is None:
536
567
  aidoo = Aidoo(
@@ -539,6 +570,7 @@ class AirzoneCloudApi:
539
570
  if aidoo is not None:
540
571
  self.aidoos[aidoo.get_id()] = aidoo
541
572
  group.add_aidoo(aidoo)
573
+ inst.add_aidoo(aidoo)
542
574
 
543
575
  async def update_installations(self) -> None:
544
576
  """Update Airzone Cloud installations from API."""
@@ -578,22 +610,29 @@ class AirzoneCloudApi:
578
610
  ws_data = await self.api_get_webserver(ws, devices)
579
611
  ws.update(ws_data)
580
612
  if devices:
613
+ inst = self.get_installation_id(ws.get_installation())
581
614
  for device_data in ws_data[API_DEVICES]:
582
615
  if API_AZ_ZONE == device_data[API_DEVICE_TYPE]:
583
616
  if self.get_zone_id(device_data[API_DEVICE_ID]) is None:
584
617
  zone = Zone(ws.get_installation(), ws.get_id(), device_data)
585
618
  if zone is not None:
586
619
  self.zones[zone.get_id()] = zone
620
+ if inst is not None:
621
+ inst.add_zone(zone)
587
622
  elif API_AZ_SYSTEM == device_data[API_DEVICE_TYPE]:
588
623
  if self.get_system_id(device_data[API_DEVICE_ID]) is None:
589
624
  system = System(ws.get_installation(), ws.get_id(), device_data)
590
625
  if system is not None:
591
626
  self.systems[system.get_id()] = system
627
+ if inst is not None:
628
+ inst.add_system(system)
592
629
  elif API_AZ_AIDOO == device_data[API_DEVICE_TYPE]:
593
630
  if self.get_aidoo_id(device_data[API_DEVICE_ID]) is None:
594
631
  aidoo = Aidoo(ws.get_installation(), ws.get_id(), device_data)
595
632
  if aidoo is not None:
596
633
  self.aidoos[aidoo.get_id()] = aidoo
634
+ if inst is not None:
635
+ inst.add_aidoo(aidoo)
597
636
 
598
637
  async def update_webserver_id(self, ws_id: str, devices: bool) -> None:
599
638
  """Update Airzone Cloud WebServer by ID."""
@@ -1,6 +1,7 @@
1
- """Airzone Cloud API Group."""
1
+ """Airzone Cloud API Device."""
2
2
  from __future__ import annotations
3
3
 
4
+ from abc import ABC
4
5
  from collections import Counter
5
6
  from typing import Any
6
7
 
@@ -8,8 +9,6 @@ from .aidoo import Aidoo
8
9
  from .common import OperationAction, OperationMode
9
10
  from .const import (
10
11
  API_DEFAULT_TEMP_STEP,
11
- API_GROUP_ID,
12
- API_NAME,
13
12
  API_PARAMS,
14
13
  API_VALUE,
15
14
  AZD_ACTION,
@@ -17,7 +16,7 @@ from .const import (
17
16
  AZD_AIDOOS,
18
17
  AZD_AVAILABLE,
19
18
  AZD_HUMIDITY,
20
- AZD_INSTALLATION,
19
+ AZD_ID,
21
20
  AZD_MODE,
22
21
  AZD_MODES,
23
22
  AZD_NAME,
@@ -35,25 +34,21 @@ from .system import System
35
34
  from .zone import Zone
36
35
 
37
36
 
38
- class Group:
39
- """Airzone Cloud Group."""
37
+ class DeviceGroup(ABC):
38
+ """Airzone Cloud DeviceGroup."""
40
39
 
41
- def __init__(self, inst_id: str, group_data: dict[str, Any]):
42
- """Airzone Cloud Group init."""
40
+ id: str
41
+ name: str
42
+
43
+ def __init__(self) -> None:
44
+ """Airzone Cloud DeviceGroup init."""
43
45
 
44
46
  self.aidoos: dict[str, Aidoo] = {}
45
- self.id = str(group_data[API_GROUP_ID])
46
- self.installation_id = inst_id
47
47
  self.systems: dict[str, System] = {}
48
48
  self.zones: dict[str, Zone] = {}
49
49
 
50
- if API_NAME in group_data:
51
- self.name = str(group_data[API_NAME])
52
- else:
53
- self.name = "Group"
54
-
55
50
  def data(self) -> dict[str, Any]:
56
- """Return Group data."""
51
+ """Return DeviceGroup data."""
57
52
  data: dict[str, Any] = {}
58
53
 
59
54
  if len(self.aidoos) > 0:
@@ -66,7 +61,7 @@ class Group:
66
61
  data[AZD_ACTION] = self.get_action()
67
62
  data[AZD_ACTIVE] = self.get_active()
68
63
  data[AZD_AVAILABLE] = self.get_available()
69
- data[AZD_INSTALLATION] = self.get_installation()
64
+ data[AZD_ID] = self.get_id()
70
65
  data[AZD_MODE] = self.get_mode()
71
66
  data[AZD_NAME] = self.get_name()
72
67
  data[AZD_NUM_DEVICES] = self.get_devices_num()
@@ -97,7 +92,7 @@ class Group:
97
92
  return data
98
93
 
99
94
  def get_action(self) -> OperationAction:
100
- """Return Group action."""
95
+ """Return DeviceGroup action."""
101
96
  action_values: list[OperationAction] = []
102
97
  for aidoo in self.aidoos.values():
103
98
  action_values += [aidoo.get_action()]
@@ -116,7 +111,7 @@ class Group:
116
111
  return OperationAction.OFF
117
112
 
118
113
  def get_active(self) -> bool | None:
119
- """Return Group active status."""
114
+ """Return DeviceGroup active status."""
120
115
  active_values: list[bool] = []
121
116
  for aidoo in self.aidoos.values():
122
117
  active = aidoo.get_active()
@@ -134,25 +129,25 @@ class Group:
134
129
  return None
135
130
 
136
131
  def add_aidoo(self, aidoo: Aidoo) -> None:
137
- """Add Aidoo to Group."""
132
+ """Add Aidoo to DeviceGroup."""
138
133
  aidoo_id = aidoo.get_id()
139
134
  if aidoo_id not in self.aidoos:
140
135
  self.aidoos[aidoo_id] = aidoo
141
136
 
142
137
  def add_system(self, system: System) -> None:
143
- """Add System to Group."""
138
+ """Add System to DeviceGroup."""
144
139
  system_id = system.get_id()
145
140
  if system_id not in self.systems:
146
141
  self.systems[system_id] = system
147
142
 
148
143
  def add_zone(self, zone: Zone) -> None:
149
- """Add Zone to Group."""
144
+ """Add Zone to DeviceGroup."""
150
145
  zone_id = zone.get_id()
151
146
  if zone_id not in self.zones:
152
147
  self.zones[zone_id] = zone
153
148
 
154
149
  def get_available(self) -> bool:
155
- """Return Group availability status."""
150
+ """Return DeviceGroup availability status."""
156
151
  for aidoo in self.aidoos.values():
157
152
  if aidoo.get_available():
158
153
  return True
@@ -162,11 +157,11 @@ class Group:
162
157
  return False
163
158
 
164
159
  def get_devices_num(self) -> int:
165
- """Return Group devices count."""
160
+ """Return DeviceGroup devices count."""
166
161
  return len(self.aidoos) + len(self.zones)
167
162
 
168
163
  def get_humidity(self) -> int | None:
169
- """Return Group humidity."""
164
+ """Return DeviceGroup humidity."""
170
165
  humidity: int | float | None
171
166
  humidity_values: list[int] = []
172
167
  for aidoo in self.aidoos.values():
@@ -183,15 +178,11 @@ class Group:
183
178
  return None
184
179
 
185
180
  def get_id(self) -> str:
186
- """Return Group ID."""
181
+ """Return DeviceGroup ID."""
187
182
  return self.id
188
183
 
189
- def get_installation(self) -> str:
190
- """Return Installation ID."""
191
- return self.installation_id
192
-
193
184
  def get_mode(self) -> OperationMode | None:
194
- """Return Group mode."""
185
+ """Return DeviceGroup mode."""
195
186
  mode_values: list[OperationMode] = []
196
187
  for aidoo in self.aidoos.values():
197
188
  mode = aidoo.get_mode()
@@ -210,7 +201,7 @@ class Group:
210
201
  return OperationMode.STOP
211
202
 
212
203
  def get_modes(self) -> list[OperationMode] | None:
213
- """Return Group modes."""
204
+ """Return DeviceGroup modes."""
214
205
  mode_values: list[OperationMode] = []
215
206
  for aidoo in self.aidoos.values():
216
207
  modes = aidoo.get_modes() or []
@@ -227,11 +218,11 @@ class Group:
227
218
  return None
228
219
 
229
220
  def get_name(self) -> str:
230
- """Return Group name."""
221
+ """Return DeviceGroup name."""
231
222
  return self.name
232
223
 
233
224
  def get_power(self) -> bool | None:
234
- """Return Group power status."""
225
+ """Return DeviceGroup power status."""
235
226
  power_values: list[bool] = []
236
227
  for aidoo in self.aidoos.values():
237
228
  power = aidoo.get_power()
@@ -249,7 +240,7 @@ class Group:
249
240
  return None
250
241
 
251
242
  def get_temperature(self) -> float | None:
252
- """Return Group temperature."""
243
+ """Return DeviceGroup temperature."""
253
244
  temp_values: list[float] = []
254
245
  for aidoo in self.aidoos.values():
255
246
  temp = aidoo.get_temperature()
@@ -265,7 +256,7 @@ class Group:
265
256
  return None
266
257
 
267
258
  def get_temp_set(self) -> float | None:
268
- """Return Group setpoint."""
259
+ """Return DeviceGroup setpoint."""
269
260
  temp_set_values: list[float] = []
270
261
  for aidoo in self.aidoos.values():
271
262
  temp_set = aidoo.get_temp_set()
@@ -281,7 +272,7 @@ class Group:
281
272
  return None
282
273
 
283
274
  def get_temp_set_max(self) -> float | None:
284
- """Return Group max setpoint."""
275
+ """Return DeviceGroup max setpoint."""
285
276
  temp_set_max_values: list[float] = []
286
277
  for aidoo in self.aidoos.values():
287
278
  temp_set_max = aidoo.get_temp_set_max()
@@ -297,7 +288,7 @@ class Group:
297
288
  return None
298
289
 
299
290
  def get_temp_set_min(self) -> float | None:
300
- """Return Group min setpoint."""
291
+ """Return DeviceGroup min setpoint."""
301
292
  temp_set_min_values: list[float] = []
302
293
  for aidoo in self.aidoos.values():
303
294
  temp_set_min = aidoo.get_temp_set_min()
@@ -313,11 +304,11 @@ class Group:
313
304
  return None
314
305
 
315
306
  def get_temp_step(self) -> float | None:
316
- """Return Group temperature step."""
307
+ """Return DeviceGroup temperature step."""
317
308
  return API_DEFAULT_TEMP_STEP
318
309
 
319
310
  def set_params(self, params: dict[str, Any]) -> None:
320
- """Update Group parameters from API request."""
311
+ """Update DeviceGroup parameters from API request."""
321
312
 
322
313
  _params: dict[str, Any] = params[API_PARAMS]
323
314
  for param, value in _params.items():
@@ -0,0 +1,36 @@
1
+ """Airzone Cloud API Group."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Any
5
+
6
+ from .const import API_GROUP_ID, API_NAME, AZD_INSTALLATION
7
+ from .device_group import DeviceGroup
8
+
9
+
10
+ class Group(DeviceGroup):
11
+ """Airzone Cloud Group."""
12
+
13
+ def __init__(self, inst_id: str, group_data: dict[str, Any]) -> None:
14
+ """Airzone Cloud Group init."""
15
+ super().__init__()
16
+
17
+ self.id = str(group_data[API_GROUP_ID])
18
+ self.installation_id = inst_id
19
+
20
+ name: str = group_data.get(API_NAME, "")
21
+ if len(name) > 0:
22
+ self.name = name
23
+ else:
24
+ self.name = "Group"
25
+
26
+ def data(self) -> dict[str, Any]:
27
+ """Return Group data."""
28
+ data = super().data()
29
+
30
+ data[AZD_INSTALLATION] = self.get_installation()
31
+
32
+ return data
33
+
34
+ def get_installation(self) -> str:
35
+ """Return Installation ID."""
36
+ return self.installation_id
@@ -3,35 +3,34 @@ from __future__ import annotations
3
3
 
4
4
  from typing import Any
5
5
 
6
- from .const import (
7
- API_INSTALLATION_ID,
8
- API_NAME,
9
- API_WS_IDS,
10
- AZD_ID,
11
- AZD_NAME,
12
- AZD_WEBSERVERS,
13
- )
6
+ from .const import API_INSTALLATION_ID, API_NAME, API_WS_IDS, AZD_WEBSERVERS
7
+ from .device_group import DeviceGroup
14
8
 
15
9
 
16
- class Installation:
10
+ class Installation(DeviceGroup):
17
11
  """Airzone Cloud Installation."""
18
12
 
19
- def __init__(self, inst_data: dict[str, Any]):
13
+ def __init__(self, inst_data: dict[str, Any]) -> None:
20
14
  """Airzone Cloud Installation init."""
15
+ super().__init__()
16
+
21
17
  self.id = str(inst_data[API_INSTALLATION_ID])
22
- self.name = str(inst_data[API_NAME])
23
18
  self.webservers: list[str] = []
24
19
 
20
+ name: str = inst_data.get(API_NAME, "")
21
+ if len(name) > 0:
22
+ self.name = name
23
+ else:
24
+ self.name = "Installation"
25
+
25
26
  for ws_id in inst_data[API_WS_IDS]:
26
27
  self.webservers += [ws_id]
27
28
 
28
29
  def data(self) -> dict[str, Any]:
29
30
  """Return Installation data."""
30
- data: dict[str, Any] = {
31
- AZD_ID: self.get_id(),
32
- AZD_NAME: self.get_name(),
33
- AZD_WEBSERVERS: self.get_webservers(),
34
- }
31
+ data = super().data()
32
+
33
+ data[AZD_WEBSERVERS] = self.get_webservers()
35
34
 
36
35
  return data
37
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aioairzone-cloud
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Library to control Airzone Cloud devices
5
5
  Author-email: Álvaro Fernández Rojas <noltari@gmail.com>
6
6
  License: Apache-2.0
@@ -9,6 +9,7 @@ aioairzone_cloud/cloudapi.py
9
9
  aioairzone_cloud/common.py
10
10
  aioairzone_cloud/const.py
11
11
  aioairzone_cloud/device.py
12
+ aioairzone_cloud/device_group.py
12
13
  aioairzone_cloud/exceptions.py
13
14
  aioairzone_cloud/group.py
14
15
  aioairzone_cloud/hvac.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aioairzone-cloud"
3
- version = "0.2.2"
3
+ version = "0.2.3"
4
4
  description = "Library to control Airzone Cloud devices"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -48,6 +48,7 @@ disable = [
48
48
  "too-many-branches",
49
49
  "too-many-instance-attributes",
50
50
  "too-many-locals",
51
+ "too-many-nested-blocks",
51
52
  "too-many-public-methods",
52
53
  "too-many-statements",
53
54
  ]