python-izone 1.3.6__py3-none-any.whl → 1.3.8__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
@@ -31,7 +31,12 @@ from typing import Any
31
31
  from . import power as power_mod
32
32
  from .controller import Controller
33
33
  from .discovery import DiscoveryService, Listener, create_discovery, discovery
34
- from .exceptions import ControllerCommandError, ResponseDecodeError, UnpairedBridgeError
34
+ from .exceptions import (
35
+ ControllerAlreadyClaimedError,
36
+ ControllerCommandError,
37
+ ResponseDecodeError,
38
+ UnpairedBridgeError,
39
+ )
35
40
  from .power import BatteryLevel, Power, PowerChannel, PowerDevice, PowerGroup
36
41
  from .types import ControllerEndpoint
37
42
  from .zone import Zone
@@ -61,6 +66,7 @@ __all__ = [
61
66
  "ENABLE_POWER",
62
67
  "BatteryLevel",
63
68
  "Controller",
69
+ "ControllerAlreadyClaimedError",
64
70
  "ControllerCommandError",
65
71
  "ControllerEndpoint",
66
72
  "DiscoveryService",
pizone/discovery.py CHANGED
@@ -24,7 +24,7 @@ import ifaddr
24
24
 
25
25
  from .const import PLACEHOLDER_DEVICE_UID
26
26
  from .controller import Controller
27
- from .exceptions import raise_if_placeholder_uid
27
+ from .exceptions import ControllerAlreadyClaimedError, raise_if_placeholder_uid
28
28
  from .types import ControllerEndpoint
29
29
  from .zone import Zone
30
30
 
@@ -405,7 +405,9 @@ class DiscoveryService:
405
405
  def _ensure_endpoint_available(self, endpoint: ControllerEndpoint) -> None:
406
406
  """Raise if *endpoint* is already claimed."""
407
407
  if endpoint.uid in self._claimed_endpoints:
408
- raise RuntimeError(f"Controller {endpoint.uid} already created")
408
+ raise ControllerAlreadyClaimedError(
409
+ f"Controller {endpoint.uid} already created"
410
+ )
409
411
 
410
412
  # disposition: 1.4
411
413
  def _claim_endpoint(self, endpoint: ControllerEndpoint) -> None:
@@ -451,7 +453,9 @@ class DiscoveryService:
451
453
  """
452
454
  claimed = self._endpoint_by_host(self._claimed_endpoints, host)
453
455
  if claimed is not None:
454
- raise RuntimeError(f"Controller {claimed.uid} already created")
456
+ raise ControllerAlreadyClaimedError(
457
+ f"Controller {claimed.uid} already created"
458
+ )
455
459
  known = self._endpoint_by_host(self._known_endpoints, host)
456
460
  if known is not None:
457
461
  return known
@@ -476,7 +480,7 @@ class DiscoveryService:
476
480
  """
477
481
  raise_if_placeholder_uid(uid)
478
482
  if uid in self._claimed_endpoints:
479
- raise RuntimeError(f"Controller {uid} already created")
483
+ raise ControllerAlreadyClaimedError(f"Controller {uid} already created")
480
484
  endpoint = self._known_endpoints.get(uid)
481
485
  if endpoint is not None:
482
486
  return endpoint
@@ -545,7 +549,7 @@ class DiscoveryService:
545
549
  continue
546
550
  try:
547
551
  self._cache_endpoint(endpoint)
548
- except RuntimeError:
552
+ except ControllerAlreadyClaimedError:
549
553
  continue
550
554
  verified.append(endpoint)
551
555
  if endpoint.uid not in notified:
@@ -569,7 +573,7 @@ class DiscoveryService:
569
573
 
570
574
  Raises:
571
575
  UnpairedBridgeError: If *uid* is the unpaired placeholder (no I/O).
572
- RuntimeError: If a controller with *uid* already exists.
576
+ ControllerAlreadyClaimedError: If a controller with *uid* already exists.
573
577
  ConnectionError: If the controller cannot be reached after
574
578
  address fallback.
575
579
  ControllerCommandError: If the device rejects the protocol request.
@@ -579,7 +583,7 @@ class DiscoveryService:
579
583
  """
580
584
  raise_if_placeholder_uid(uid)
581
585
  if uid in self._claimed_endpoints:
582
- raise RuntimeError(f"Controller {uid} already created")
586
+ raise ControllerAlreadyClaimedError(f"Controller {uid} already created")
583
587
  pending_address_changed: ControllerEndpoint | None = None
584
588
 
585
589
  try:
@@ -795,8 +799,13 @@ class DiscoveryService:
795
799
  """Return the aiohttp session used for HTTP requests."""
796
800
  return self._session
797
801
 
798
- def _on_error_received(self, _: Exception) -> None:
799
- _LOG.warning("Error passed and ignored to error_received", exc_info=True)
802
+ def _on_error_received(self, exc: Exception) -> None:
803
+ # Expected when broadcast is blocked (firewall / no permission) or the
804
+ # interface is down; scan just finds nothing. Keep unexpected errors loud.
805
+ if isinstance(exc, OSError):
806
+ _LOG.debug("UDP error ignored: %s", exc)
807
+ return
808
+ _LOG.warning("Error passed and ignored to error_received: %s", exc)
800
809
 
801
810
  def _find_by_addr(self, addr: tuple[str, int]) -> Controller | None:
802
811
  for ctrl in self._controllers.values():
@@ -919,8 +928,7 @@ class DiscoveryService:
919
928
  previous = self._known_endpoints.get(endpoint.uid)
920
929
  newly_seen = previous is None
921
930
  host_changed = previous is not None and previous.host != endpoint.host
922
- with suppress(RuntimeError):
923
- self._cache_endpoint(endpoint)
931
+ self._cache_endpoint(endpoint)
924
932
  if newly_seen or host_changed:
925
933
  self._emit_endpoint_discovered(endpoint)
926
934
 
pizone/exceptions.py CHANGED
@@ -28,6 +28,14 @@ class UnpairedBridgeError(ValueError):
28
28
  """
29
29
 
30
30
 
31
+ class ControllerAlreadyClaimedError(Exception):
32
+ """A controller UID or host is already claimed on this discovery service.
33
+
34
+ Raised when ``discover_by_host``, ``discover_by_uid``, or ``create_controller``
35
+ would duplicate an active controller registration.
36
+ """
37
+
38
+
31
39
  def raise_if_placeholder_uid(uid: str) -> None:
32
40
  """Raise :exc:`UnpairedBridgeError` if *uid* is the unpaired placeholder."""
33
41
  if uid == PLACEHOLDER_DEVICE_UID:
pizone/version.py CHANGED
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '1.3.6'
22
- __version_tuple__ = version_tuple = (1, 3, 6)
21
+ __version__ = version = '1.3.8'
22
+ __version_tuple__ = version_tuple = (1, 3, 8)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-izone
3
- Version: 1.3.6
3
+ Version: 1.3.8
4
4
  Summary: A python interface to the iZone airconditioner controller
5
5
  Project-URL: Homepage, https://github.com/Swamp-Ig/pizone
6
6
  Author-email: Penny Wood <pypl@ninjateaparty.com>
@@ -0,0 +1,14 @@
1
+ pizone/__init__.py,sha256=9EbQzqD1XfS5fSE-zgFieuzxAfZcQb9a3wNXsMp0JKc,2644
2
+ pizone/const.py,sha256=0skTh6zBe61AJ_57fqdBrxz3aVBM3T4Ak_cPSkOx2Bo,153
3
+ pizone/controller.py,sha256=nctzAF8Y75T0_Ue9Hxxv9OfEex4zoNseOMjGfI6wHFE,41109
4
+ pizone/discovery.py,sha256=ZEXlzMgEcK2qYCU7UXCdgOrgv6vChOCgN_ddq5rACg0,37685
5
+ pizone/exceptions.py,sha256=qzYNHzQBMDcuvLfxlvOsk6J2Lp0gtzlHqJWpzyEunvU,1603
6
+ pizone/power.py,sha256=bXoDRVD6gCfq0kJv132sjfy13DHGd6p2uBg9HcxRSxA,10343
7
+ pizone/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ pizone/types.py,sha256=fZrnec0Q815HyG2sFciLqNX0QDbTq1_0wTF92GXQh78,200
9
+ pizone/version.py,sha256=FXUTXirc7-JCTXzXG9H84JqQTySUJIh6ktR1ZkEoISc,520
10
+ pizone/zone.py,sha256=tqiLJAJCmp1cehCtVPjawUNY9qyYypC4x3igI5jtDNo,7446
11
+ python_izone-1.3.8.dist-info/METADATA,sha256=S5q-Hty056t4AYv8gUgXUhvRbfgpuUButQxLBXAxpi0,2703
12
+ python_izone-1.3.8.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
13
+ python_izone-1.3.8.dist-info/licenses/licence.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
+ python_izone-1.3.8.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- pizone/__init__.py,sha256=yJMEJCKBU0mYOuvvBZFG5NTkpMpMWBAg9MvmzP3npK8,2555
2
- pizone/const.py,sha256=0skTh6zBe61AJ_57fqdBrxz3aVBM3T4Ak_cPSkOx2Bo,153
3
- pizone/controller.py,sha256=nctzAF8Y75T0_Ue9Hxxv9OfEex4zoNseOMjGfI6wHFE,41109
4
- pizone/discovery.py,sha256=C9AEK6nMyo2xU-jZ3BWyADnTMM-X1EkgNh9LaECkpBc,37266
5
- pizone/exceptions.py,sha256=wRO-COpyNyKL6P1vG0MlAVwbwo2iOvH0kRO7O75PUlo,1327
6
- pizone/power.py,sha256=bXoDRVD6gCfq0kJv132sjfy13DHGd6p2uBg9HcxRSxA,10343
7
- pizone/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- pizone/types.py,sha256=fZrnec0Q815HyG2sFciLqNX0QDbTq1_0wTF92GXQh78,200
9
- pizone/version.py,sha256=_FUKw5XE-1Iz4eIZxskUWzdnDjBxzXHPurN7TvxgxV8,520
10
- pizone/zone.py,sha256=tqiLJAJCmp1cehCtVPjawUNY9qyYypC4x3igI5jtDNo,7446
11
- python_izone-1.3.6.dist-info/METADATA,sha256=nv6-HMl-Py3IKlUPtstcKfpEz1LbsmOZGF1P0oOy8ao,2703
12
- python_izone-1.3.6.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
13
- python_izone-1.3.6.dist-info/licenses/licence.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
14
- python_izone-1.3.6.dist-info/RECORD,,