aiohomematic 2025.11.3__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.

Potentially problematic release.


This version of aiohomematic might be problematic. Click here for more details.

Files changed (77) hide show
  1. aiohomematic/__init__.py +61 -0
  2. aiohomematic/async_support.py +212 -0
  3. aiohomematic/central/__init__.py +2309 -0
  4. aiohomematic/central/decorators.py +155 -0
  5. aiohomematic/central/rpc_server.py +295 -0
  6. aiohomematic/client/__init__.py +1848 -0
  7. aiohomematic/client/_rpc_errors.py +81 -0
  8. aiohomematic/client/json_rpc.py +1326 -0
  9. aiohomematic/client/rpc_proxy.py +311 -0
  10. aiohomematic/const.py +1127 -0
  11. aiohomematic/context.py +18 -0
  12. aiohomematic/converter.py +108 -0
  13. aiohomematic/decorators.py +302 -0
  14. aiohomematic/exceptions.py +164 -0
  15. aiohomematic/hmcli.py +186 -0
  16. aiohomematic/model/__init__.py +140 -0
  17. aiohomematic/model/calculated/__init__.py +84 -0
  18. aiohomematic/model/calculated/climate.py +290 -0
  19. aiohomematic/model/calculated/data_point.py +327 -0
  20. aiohomematic/model/calculated/operating_voltage_level.py +299 -0
  21. aiohomematic/model/calculated/support.py +234 -0
  22. aiohomematic/model/custom/__init__.py +177 -0
  23. aiohomematic/model/custom/climate.py +1532 -0
  24. aiohomematic/model/custom/cover.py +792 -0
  25. aiohomematic/model/custom/data_point.py +334 -0
  26. aiohomematic/model/custom/definition.py +871 -0
  27. aiohomematic/model/custom/light.py +1128 -0
  28. aiohomematic/model/custom/lock.py +394 -0
  29. aiohomematic/model/custom/siren.py +275 -0
  30. aiohomematic/model/custom/support.py +41 -0
  31. aiohomematic/model/custom/switch.py +175 -0
  32. aiohomematic/model/custom/valve.py +114 -0
  33. aiohomematic/model/data_point.py +1123 -0
  34. aiohomematic/model/device.py +1445 -0
  35. aiohomematic/model/event.py +208 -0
  36. aiohomematic/model/generic/__init__.py +217 -0
  37. aiohomematic/model/generic/action.py +34 -0
  38. aiohomematic/model/generic/binary_sensor.py +30 -0
  39. aiohomematic/model/generic/button.py +27 -0
  40. aiohomematic/model/generic/data_point.py +171 -0
  41. aiohomematic/model/generic/dummy.py +147 -0
  42. aiohomematic/model/generic/number.py +76 -0
  43. aiohomematic/model/generic/select.py +39 -0
  44. aiohomematic/model/generic/sensor.py +74 -0
  45. aiohomematic/model/generic/switch.py +54 -0
  46. aiohomematic/model/generic/text.py +29 -0
  47. aiohomematic/model/hub/__init__.py +333 -0
  48. aiohomematic/model/hub/binary_sensor.py +24 -0
  49. aiohomematic/model/hub/button.py +28 -0
  50. aiohomematic/model/hub/data_point.py +340 -0
  51. aiohomematic/model/hub/number.py +39 -0
  52. aiohomematic/model/hub/select.py +49 -0
  53. aiohomematic/model/hub/sensor.py +37 -0
  54. aiohomematic/model/hub/switch.py +44 -0
  55. aiohomematic/model/hub/text.py +30 -0
  56. aiohomematic/model/support.py +586 -0
  57. aiohomematic/model/update.py +143 -0
  58. aiohomematic/property_decorators.py +496 -0
  59. aiohomematic/py.typed +0 -0
  60. aiohomematic/rega_scripts/fetch_all_device_data.fn +92 -0
  61. aiohomematic/rega_scripts/get_program_descriptions.fn +30 -0
  62. aiohomematic/rega_scripts/get_serial.fn +44 -0
  63. aiohomematic/rega_scripts/get_system_variable_descriptions.fn +30 -0
  64. aiohomematic/rega_scripts/set_program_state.fn +12 -0
  65. aiohomematic/rega_scripts/set_system_variable.fn +15 -0
  66. aiohomematic/store/__init__.py +34 -0
  67. aiohomematic/store/dynamic.py +551 -0
  68. aiohomematic/store/persistent.py +988 -0
  69. aiohomematic/store/visibility.py +812 -0
  70. aiohomematic/support.py +664 -0
  71. aiohomematic/validator.py +112 -0
  72. aiohomematic-2025.11.3.dist-info/METADATA +144 -0
  73. aiohomematic-2025.11.3.dist-info/RECORD +77 -0
  74. aiohomematic-2025.11.3.dist-info/WHEEL +5 -0
  75. aiohomematic-2025.11.3.dist-info/entry_points.txt +2 -0
  76. aiohomematic-2025.11.3.dist-info/licenses/LICENSE +21 -0
  77. aiohomematic-2025.11.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,81 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2021-2025
3
+ """
4
+ Error mapping helpers for RPC transports.
5
+
6
+ This module centralizes small, transport-agnostic utilities to turn the backend
7
+ errors into domain-specific exceptions with useful context. It is used by both
8
+ JSON-RPC and XML-RPC clients.
9
+
10
+ Key types and functions
11
+ - RpcContext: Lightweight context container that formats protocol/method/host
12
+ for readable error messages and logs.
13
+ - map_jsonrpc_error: Maps a JSON-RPC error object to an appropriate exception
14
+ (AuthFailure, InternalBackendException, ClientException).
15
+ - map_transport_error: Maps generic transport-level exceptions like OSError to
16
+ domain exceptions (NoConnectionException/ClientException).
17
+ - map_xmlrpc_fault: Maps XML-RPC faults to domain exceptions with context.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ from collections.abc import Mapping
23
+ from dataclasses import dataclass
24
+ from typing import Any
25
+
26
+ from aiohomematic.exceptions import AuthFailure, ClientException, InternalBackendException, NoConnectionException
27
+
28
+
29
+ @dataclass(slots=True)
30
+ class RpcContext:
31
+ protocol: str
32
+ method: str
33
+ host: str | None = None
34
+ interface: str | None = None
35
+ params: Mapping[str, Any] | None = None
36
+
37
+ def fmt(self) -> str:
38
+ """Format context for error messages."""
39
+ parts: list[str] = [f"protocol={self.protocol}", f"method={self.method}"]
40
+ if self.interface:
41
+ parts.append(f"interface={self.interface}")
42
+ if self.host:
43
+ parts.append(f"host={self.host}")
44
+ return ", ".join(parts)
45
+
46
+
47
+ def map_jsonrpc_error(*, error: Mapping[str, Any], ctx: RpcContext) -> Exception:
48
+ """Map JSON-RPC error to exception."""
49
+ # JSON-RPC 2.0 like error: {code, message, data?}
50
+ code = int(error.get("code", 0))
51
+ message = str(error.get("message", ""))
52
+ # Enrich message with context
53
+ base_msg = f"{message} ({ctx.fmt()})"
54
+
55
+ # Map common codes
56
+ if message.startswith("access denied") or code in (401, -32001):
57
+ return AuthFailure(base_msg)
58
+ if "internal error" in message.lower() or code in (-32603, 500):
59
+ return InternalBackendException(base_msg)
60
+ # Generic client exception for others
61
+ return ClientException(base_msg)
62
+
63
+
64
+ def map_transport_error(*, exc: BaseException, ctx: RpcContext) -> Exception:
65
+ """Map transport error to exception."""
66
+ msg = f"{exc} ({ctx.fmt()})"
67
+ if isinstance(exc, OSError):
68
+ return NoConnectionException(msg)
69
+ return ClientException(msg)
70
+
71
+
72
+ def map_xmlrpc_fault(*, code: int, fault_string: str, ctx: RpcContext) -> Exception:
73
+ """Map XML-RPC fault to exception."""
74
+ # Enrich message with context
75
+ fault_msg = f"XMLRPC Fault {code}: {fault_string} ({ctx.fmt()})"
76
+ # Simple mappings
77
+ if "unauthorized" in fault_string.lower():
78
+ return AuthFailure(fault_msg)
79
+ if "internal" in fault_string.lower():
80
+ return InternalBackendException(fault_msg)
81
+ return ClientException(fault_msg)