python-izone 1.3.3__py3-none-any.whl → 1.3.5__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.
pizone/__init__.py CHANGED
@@ -1,31 +1,79 @@
1
1
  """Interface to the iZone air conditioner controller.
2
2
 
3
- Interaction is mostly through the :class:`~pizone.controller.Controller` and
4
- :class:`~pizone.zone.Zone` classes.
3
+ Prefer :func:`~pizone.discovery.create_discovery` or
4
+ :func:`~pizone.discovery.discovery` to obtain a discovery service, then create
5
+ or discover :class:`~pizone.controller.Controller` instances through that
6
+ service. Zones and power monitors are owned by their controller.
5
7
 
6
8
  Synchronous property reads return cached device data and do not raise
7
9
  :exc:`ConnectionError`. Async command and refresh methods perform HTTP I/O and
8
10
  raise :exc:`ConnectionError` when the device cannot be reached. They raise
9
11
  :exc:`~pizone.exceptions.ControllerCommandError` when the device responds but
10
12
  rejects the request (``{ERROR...}`` body or HTTP 4xx).
13
+
14
+ Layered connection state on :class:`~pizone.controller.Controller`:
15
+
16
+ - :attr:`~pizone.controller.Controller.bridge_connected` — ASH bridge HTTP transport
17
+ - :attr:`~pizone.controller.Controller.connected` — bridge plus valid iZone AC data
18
+ - :attr:`~pizone.power.Power.connected` — power monitor I/O (when enabled)
19
+
20
+ Power support is off by default. Enable at runtime before create/refresh when
21
+ the consumer needs iPower (for example future Home Assistant power entities)::
22
+
23
+ import pizone
24
+ pizone.ENABLE_POWER = True
11
25
  """
12
26
 
27
+ import sys
28
+ from types import ModuleType
29
+ from typing import Any
30
+
31
+ from . import power as power_mod
32
+ from .const import PLACEHOLDER_DEVICE_UID
13
33
  from .controller import Controller
14
- from .discovery import DiscoveryService, Listener, discovery
15
- from .exceptions import ControllerCommandError
34
+ from .discovery import DiscoveryService, Listener, create_discovery, discovery
35
+ from .exceptions import ControllerCommandError, ResponseDecodeError, UnpairedBridgeError
16
36
  from .power import BatteryLevel, Power, PowerChannel, PowerDevice, PowerGroup
37
+ from .types import ControllerEndpoint
17
38
  from .zone import Zone
18
39
 
40
+
41
+ def __getattr__(name: str) -> Any:
42
+ if name == "ENABLE_POWER":
43
+ return power_mod.ENABLE_POWER
44
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
45
+
46
+
47
+ class _PizoneModule(ModuleType):
48
+ """Allow ``pizone.ENABLE_POWER = True`` to update :mod:`pizone.power`."""
49
+
50
+ @property
51
+ def ENABLE_POWER(self) -> bool:
52
+ return power_mod.ENABLE_POWER
53
+
54
+ @ENABLE_POWER.setter
55
+ def ENABLE_POWER(self, value: bool) -> None:
56
+ power_mod.ENABLE_POWER = bool(value)
57
+
58
+
59
+ sys.modules[__name__].__class__ = _PizoneModule
60
+
19
61
  __all__ = [
62
+ "ENABLE_POWER",
63
+ "PLACEHOLDER_DEVICE_UID",
64
+ "BatteryLevel",
20
65
  "Controller",
21
66
  "ControllerCommandError",
22
- "Zone",
67
+ "ControllerEndpoint",
23
68
  "DiscoveryService",
24
69
  "Listener",
25
- "discovery",
26
70
  "Power",
27
- "PowerGroup",
28
- "PowerDevice",
29
71
  "PowerChannel",
30
- "BatteryLevel",
72
+ "PowerDevice",
73
+ "PowerGroup",
74
+ "ResponseDecodeError",
75
+ "UnpairedBridgeError",
76
+ "Zone",
77
+ "create_discovery",
78
+ "discovery",
31
79
  ]
pizone/const.py ADDED
@@ -0,0 +1,4 @@
1
+ """Shared constants for pizone."""
2
+
3
+ # Exact AirStreamDeviceUId when an ASH bridge has no paired AC (desk evidence).
4
+ PLACEHOLDER_DEVICE_UID = "000000000"