aiohomematic 2025.12.7__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 (109) hide show
  1. aiohomematic-2025.12.7/LICENSE +21 -0
  2. aiohomematic-2025.12.7/MANIFEST.in +14 -0
  3. aiohomematic-2025.12.7/PKG-INFO +144 -0
  4. aiohomematic-2025.12.7/README.md +109 -0
  5. aiohomematic-2025.12.7/aiohomematic/__init__.py +110 -0
  6. aiohomematic-2025.12.7/aiohomematic/async_support.py +218 -0
  7. aiohomematic-2025.12.7/aiohomematic/backend_detection.py +430 -0
  8. aiohomematic-2025.12.7/aiohomematic/central/__init__.py +1740 -0
  9. aiohomematic-2025.12.7/aiohomematic/central/cache_coordinator.py +246 -0
  10. aiohomematic-2025.12.7/aiohomematic/central/client_coordinator.py +409 -0
  11. aiohomematic-2025.12.7/aiohomematic/central/decorators.py +171 -0
  12. aiohomematic-2025.12.7/aiohomematic/central/device_coordinator.py +789 -0
  13. aiohomematic-2025.12.7/aiohomematic/central/device_registry.py +211 -0
  14. aiohomematic-2025.12.7/aiohomematic/central/event_bus.py +561 -0
  15. aiohomematic-2025.12.7/aiohomematic/central/event_coordinator.py +326 -0
  16. aiohomematic-2025.12.7/aiohomematic/central/hub_coordinator.py +463 -0
  17. aiohomematic-2025.12.7/aiohomematic/central/rpc_server.py +300 -0
  18. aiohomematic-2025.12.7/aiohomematic/central/scheduler.py +433 -0
  19. aiohomematic-2025.12.7/aiohomematic/client/__init__.py +2274 -0
  20. aiohomematic-2025.12.7/aiohomematic/client/_rpc_errors.py +81 -0
  21. aiohomematic-2025.12.7/aiohomematic/client/json_rpc.py +1843 -0
  22. aiohomematic-2025.12.7/aiohomematic/client/rpc_proxy.py +327 -0
  23. aiohomematic-2025.12.7/aiohomematic/const.py +1475 -0
  24. aiohomematic-2025.12.7/aiohomematic/context.py +18 -0
  25. aiohomematic-2025.12.7/aiohomematic/converter.py +108 -0
  26. aiohomematic-2025.12.7/aiohomematic/decorators.py +303 -0
  27. aiohomematic-2025.12.7/aiohomematic/exceptions.py +163 -0
  28. aiohomematic-2025.12.7/aiohomematic/hmcli.py +186 -0
  29. aiohomematic-2025.12.7/aiohomematic/i18n.py +192 -0
  30. aiohomematic-2025.12.7/aiohomematic/interfaces.py +2566 -0
  31. aiohomematic-2025.12.7/aiohomematic/model/__init__.py +176 -0
  32. aiohomematic-2025.12.7/aiohomematic/model/calculated/__init__.py +84 -0
  33. aiohomematic-2025.12.7/aiohomematic/model/calculated/climate.py +291 -0
  34. aiohomematic-2025.12.7/aiohomematic/model/calculated/data_point.py +342 -0
  35. aiohomematic-2025.12.7/aiohomematic/model/calculated/operating_voltage_level.py +302 -0
  36. aiohomematic-2025.12.7/aiohomematic/model/calculated/support.py +232 -0
  37. aiohomematic-2025.12.7/aiohomematic/model/custom/__init__.py +164 -0
  38. aiohomematic-2025.12.7/aiohomematic/model/custom/climate.py +1185 -0
  39. aiohomematic-2025.12.7/aiohomematic/model/custom/cover.py +805 -0
  40. aiohomematic-2025.12.7/aiohomematic/model/custom/data_point.py +371 -0
  41. aiohomematic-2025.12.7/aiohomematic/model/custom/definition.py +886 -0
  42. aiohomematic-2025.12.7/aiohomematic/model/custom/light.py +1143 -0
  43. aiohomematic-2025.12.7/aiohomematic/model/custom/lock.py +401 -0
  44. aiohomematic-2025.12.7/aiohomematic/model/custom/siren.py +287 -0
  45. aiohomematic-2025.12.7/aiohomematic/model/custom/support.py +43 -0
  46. aiohomematic-2025.12.7/aiohomematic/model/custom/switch.py +181 -0
  47. aiohomematic-2025.12.7/aiohomematic/model/custom/valve.py +119 -0
  48. aiohomematic-2025.12.7/aiohomematic/model/data_point.py +1283 -0
  49. aiohomematic-2025.12.7/aiohomematic/model/device.py +1783 -0
  50. aiohomematic-2025.12.7/aiohomematic/model/event.py +213 -0
  51. aiohomematic-2025.12.7/aiohomematic/model/generic/__init__.py +222 -0
  52. aiohomematic-2025.12.7/aiohomematic/model/generic/action.py +36 -0
  53. aiohomematic-2025.12.7/aiohomematic/model/generic/binary_sensor.py +32 -0
  54. aiohomematic-2025.12.7/aiohomematic/model/generic/button.py +31 -0
  55. aiohomematic-2025.12.7/aiohomematic/model/generic/data_point.py +171 -0
  56. aiohomematic-2025.12.7/aiohomematic/model/generic/dummy.py +143 -0
  57. aiohomematic-2025.12.7/aiohomematic/model/generic/number.py +87 -0
  58. aiohomematic-2025.12.7/aiohomematic/model/generic/select.py +50 -0
  59. aiohomematic-2025.12.7/aiohomematic/model/generic/sensor.py +78 -0
  60. aiohomematic-2025.12.7/aiohomematic/model/generic/switch.py +56 -0
  61. aiohomematic-2025.12.7/aiohomematic/model/generic/text.py +35 -0
  62. aiohomematic-2025.12.7/aiohomematic/model/hub/__init__.py +676 -0
  63. aiohomematic-2025.12.7/aiohomematic/model/hub/binary_sensor.py +24 -0
  64. aiohomematic-2025.12.7/aiohomematic/model/hub/button.py +28 -0
  65. aiohomematic-2025.12.7/aiohomematic/model/hub/data_point.py +411 -0
  66. aiohomematic-2025.12.7/aiohomematic/model/hub/inbox.py +159 -0
  67. aiohomematic-2025.12.7/aiohomematic/model/hub/install_mode.py +372 -0
  68. aiohomematic-2025.12.7/aiohomematic/model/hub/number.py +42 -0
  69. aiohomematic-2025.12.7/aiohomematic/model/hub/select.py +52 -0
  70. aiohomematic-2025.12.7/aiohomematic/model/hub/sensor.py +37 -0
  71. aiohomematic-2025.12.7/aiohomematic/model/hub/switch.py +44 -0
  72. aiohomematic-2025.12.7/aiohomematic/model/hub/text.py +30 -0
  73. aiohomematic-2025.12.7/aiohomematic/model/hub/update.py +178 -0
  74. aiohomematic-2025.12.7/aiohomematic/model/support.py +614 -0
  75. aiohomematic-2025.12.7/aiohomematic/model/update.py +155 -0
  76. aiohomematic-2025.12.7/aiohomematic/model/week_profile.py +1835 -0
  77. aiohomematic-2025.12.7/aiohomematic/property_decorators.py +495 -0
  78. aiohomematic-2025.12.7/aiohomematic/py.typed +0 -0
  79. aiohomematic-2025.12.7/aiohomematic/rega_scripts/accept_device_in_inbox.fn +48 -0
  80. aiohomematic-2025.12.7/aiohomematic/rega_scripts/create_backup.fn +54 -0
  81. aiohomematic-2025.12.7/aiohomematic/rega_scripts/fetch_all_device_data.fn +92 -0
  82. aiohomematic-2025.12.7/aiohomematic/rega_scripts/get_backend_info.fn +55 -0
  83. aiohomematic-2025.12.7/aiohomematic/rega_scripts/get_inbox_devices.fn +61 -0
  84. aiohomematic-2025.12.7/aiohomematic/rega_scripts/get_program_descriptions.fn +30 -0
  85. aiohomematic-2025.12.7/aiohomematic/rega_scripts/get_serial.fn +44 -0
  86. aiohomematic-2025.12.7/aiohomematic/rega_scripts/get_service_messages.fn +82 -0
  87. aiohomematic-2025.12.7/aiohomematic/rega_scripts/get_system_update_info.fn +139 -0
  88. aiohomematic-2025.12.7/aiohomematic/rega_scripts/get_system_variable_descriptions.fn +30 -0
  89. aiohomematic-2025.12.7/aiohomematic/rega_scripts/set_program_state.fn +12 -0
  90. aiohomematic-2025.12.7/aiohomematic/rega_scripts/set_system_variable.fn +15 -0
  91. aiohomematic-2025.12.7/aiohomematic/rega_scripts/trigger_firmware_update.fn +50 -0
  92. aiohomematic-2025.12.7/aiohomematic/store/__init__.py +34 -0
  93. aiohomematic-2025.12.7/aiohomematic/store/dynamic.py +729 -0
  94. aiohomematic-2025.12.7/aiohomematic/store/persistent.py +1029 -0
  95. aiohomematic-2025.12.7/aiohomematic/store/visibility.py +817 -0
  96. aiohomematic-2025.12.7/aiohomematic/strings.json +172 -0
  97. aiohomematic-2025.12.7/aiohomematic/support.py +702 -0
  98. aiohomematic-2025.12.7/aiohomematic/translations/de.json +172 -0
  99. aiohomematic-2025.12.7/aiohomematic/translations/en.json +172 -0
  100. aiohomematic-2025.12.7/aiohomematic/type_aliases.py +51 -0
  101. aiohomematic-2025.12.7/aiohomematic/validator.py +118 -0
  102. aiohomematic-2025.12.7/aiohomematic.egg-info/PKG-INFO +144 -0
  103. aiohomematic-2025.12.7/aiohomematic.egg-info/SOURCES.txt +108 -0
  104. aiohomematic-2025.12.7/aiohomematic.egg-info/dependency_links.txt +1 -0
  105. aiohomematic-2025.12.7/aiohomematic.egg-info/entry_points.txt +2 -0
  106. aiohomematic-2025.12.7/aiohomematic.egg-info/requires.txt +4 -0
  107. aiohomematic-2025.12.7/aiohomematic.egg-info/top_level.txt +1 -0
  108. aiohomematic-2025.12.7/pyproject.toml +682 -0
  109. aiohomematic-2025.12.7/setup.cfg +7 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-2025 Daniel Perna, SukramJ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,14 @@
1
+ # MANIFEST.in
2
+
3
+ # Include the main package and important files
4
+ graft aiohomematic
5
+ include README.md
6
+ include LICENSE
7
+
8
+ # Exclude tests and build artifacts
9
+ prune tests
10
+ prune build
11
+ prune dist
12
+
13
+ # IMPORTANT: exclude support package from the sdist tarball
14
+ prune aiohomematic_test_support
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: aiohomematic
3
+ Version: 2025.12.7
4
+ Summary: Homematic interface for Home Assistant running on Python 3.
5
+ Home-page: https://github.com/sukramj/aiohomematic
6
+ Author-email: SukramJ <sukramj@icloud.com>, Daniel Perna <danielperna84@gmail.com>
7
+ License: MIT License
8
+ Project-URL: Source Code, https://github.com/sukramj/aiohomematic
9
+ Project-URL: Bug Reports, https://github.com/sukramj/aiohomematic/issues
10
+ Project-URL: Docs: Dev, https://github.com/sukramj/aiohomematic
11
+ Project-URL: Forum, https://github.com/sukramj/aiohomematic/discussions
12
+ Keywords: home,automation,homematic,openccu,homegear
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: End Users/Desktop
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Programming Language :: Python :: Implementation :: CPython
24
+ Classifier: Framework :: AsyncIO
25
+ Classifier: Typing :: Typed
26
+ Classifier: Topic :: Home Automation
27
+ Requires-Python: >=3.13
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: aiohttp>=3.12.0
31
+ Requires-Dist: orjson>=3.11.0
32
+ Requires-Dist: python-slugify>=8.0.0
33
+ Requires-Dist: voluptuous>=0.15.0
34
+ Dynamic: license-file
35
+
36
+ [![releasebadge]][release]
37
+ [![License][license-shield]](LICENSE.md)
38
+ [![GitHub Sponsors][sponsorsbadge]][sponsors]
39
+
40
+ # AIO Homematic
41
+
42
+ A lightweight Python 3 library that powers Home Assistant integrations for controlling and monitoring [Homematic](https://www.eq-3.com/products/homematic.html) and [HomematicIP](https://www.homematic-ip.com/en/start.html) devices. Some third‑party devices/gateways (e.g., Bosch, Intertechno) may be supported as well.
43
+
44
+ This project is the modern successor to [pyhomematic](https://github.com/danielperna84/pyhomematic), focusing on automatic entity creation, fewer manual device definitions, and faster startups.
45
+
46
+ ## How it works
47
+
48
+ Unlike pyhomematic, which required manual device mappings, aiohomematic automatically creates entities for each relevant parameter on every device channel (unless blacklisted). To achieve this it:
49
+
50
+ - Fetches and caches device paramsets (VALUES) for fast successive startups.
51
+ - Provides hooks for custom entity classes where complex behavior is needed (e.g., thermostats, lights, covers, climate, locks, sirens).
52
+ - Includes helpers for robust operation, such as automatic reconnection after CCU restarts.
53
+
54
+ ## Key features
55
+
56
+ - Automatic entity discovery from device/channel parameters.
57
+ - Extensible via custom entity classes for complex devices.
58
+ - Caching of paramsets to speed up restarts.
59
+ - Designed to integrate with Home Assistant.
60
+
61
+ ## Quickstart for Home Assistant
62
+
63
+ Use the Home Assistant custom integration "Homematic(IP) Local", which is powered by aiohomematic.
64
+
65
+ 1. Prerequisites
66
+ - Use latest version of Home Assistant.
67
+ - A CCU3, OpenCCU, or Homegear instance reachable from Home Assistant.
68
+ - For HomematicIP devices, ensure CCU firmware meets the minimum versions listed below.
69
+ 2. Install the integration
70
+ - Add the custom repository and install: https://github.com/sukramj/homematicip_local
71
+ - Follow the installation guide: https://github.com/sukramj/homematicip_local/wiki/Installation
72
+ 3. Configure via Home Assistant UI
73
+ - In Home Assistant: Settings → Devices & Services → Add Integration → search for "Homematic(IP) Local".
74
+ - Enter the CCU/Homegear host (IP or hostname). If you use HTTPS on the CCU, enable TLS and don't use verify if self‑signed.
75
+ - Always enter credentials.
76
+ - Choose which interfaces to enable (HM, HmIP, Virtual). Default ports are typically 2001 (HM), 2010 (HmIP), 9292 (Virtual).
77
+ 4. Network callbacks
78
+ - The integration needs to receive XML‑RPC callbacks from the CCU. Make sure Home Assistant is reachable from the CCU (no NAT/firewall blocking). Callbacks are only required for special network setups.
79
+ 5. Verify
80
+ - After setup, devices should appear under Devices & Services → Homematic(IP) Local. Discovery may take a few seconds after the first connection while paramsets are fetched and cached for faster restarts.
81
+
82
+ If you need to use aiohomematic directly in Python, see the Public API and example below.
83
+
84
+ ## Requirements
85
+
86
+ Due to a bug in earlier CCU2/CCU3 firmware, aiohomematic requires at least the following versions when used with HomematicIP devices:
87
+
88
+ - CCU2: 2.53.27
89
+ - CCU3: 3.53.26
90
+
91
+ See details here: https://github.com/OpenCCU/OpenCCU/issues/843. Other CCU‑like platforms using the buggy HmIPServer version are not supported.
92
+
93
+ ## Public API and imports
94
+
95
+ - The public API of aiohomematic is explicitly defined via **all** in each module and subpackage.
96
+ - Backwards‑compatible imports should target these modules:
97
+ - aiohomematic.central: CentralUnit, CentralConfig and related schemas
98
+ - aiohomematic.central.event: display received events from the backend
99
+ - aiohomematic.client: Client, InterfaceConfig, create_client, get_client
100
+ - aiohomematic.model: device/data point abstractions (see subpackages for details)
101
+ - aiohomematic.exceptions: library exception types intended for consumers
102
+ - aiohomematic.const: constants and enums (stable subset; see module **all**)
103
+ - aiohomematic.performance: display some performance metrics (enabled when DEBUG is enabled)
104
+ - The top‑level package only exposes **version** to avoid import cycles and keep startup lean. Prefer importing from the specific submodules listed above.
105
+
106
+ Example:
107
+
108
+ from aiohomematic.central import CentralConfig
109
+ from aiohomematic import client as hmcl
110
+
111
+ cfg = CentralConfig(
112
+ central_id="ccu-main",
113
+ host="ccu.local",
114
+ username="admin",
115
+ password="secret",
116
+ default_callback_port=43439,
117
+ interface_configs={hmcl.InterfaceConfig(interface=hmcl.Interface.HMIP, port=2010, enabled=True)},
118
+ )
119
+ central = cfg.create_central()
120
+
121
+ ## Useful links
122
+
123
+ - Changelog: [see](changelog.md) for release history and latest changes.
124
+ - Definition of calculated data points: [see](docs/calculated_data_points.md)
125
+ - Naming: [see](docs/naming.md) for how device, channel and data point names are created.
126
+ - Homematic(IP) Local integration: https://github.com/sukramj/homematicip_local
127
+ - Input select helper: [see](docs/input_select_helper.md) for an overview of how to use the input select helper.
128
+ - Troubleshooting with Home Assistant: [see](docs/homeassistant_troubleshooting.md) for common issues and how to debug them.
129
+ - Unignore mechanism: [see](docs/unignore.md) for how to unignore devices that are ignored by default.
130
+
131
+ ## Useful developer links
132
+
133
+ - Architecture overview: [see](docs/architecture.md) for an overview of the architecture of the library.
134
+ - Data flow: [see](docs/data_flow.md) for an overview of how data flows through the library.
135
+ - Extending the model: [see](docs/extension_points.md) for adding custom device profiles and calculated data points.
136
+ - Home Assistant lifecycle (discovery, updates, teardown): [see](docs/homeassistant_lifecycle.md) for details on how the integration works and how to debug issues.
137
+ - RSSI fix: [see](docs/rssi_fix.md) for how RSSI values are fixed for Home Assistant.
138
+ - Sequence diagrams: [see](docs/sequence_diagrams.md) for a sequence diagram of how the library works.
139
+
140
+ [license-shield]: https://img.shields.io/github/license/SukramJ/aiohomematic.svg?style=for-the-badge
141
+ [release]: https://github.com/SukramJ/aiohomematic/releases
142
+ [releasebadge]: https://img.shields.io/github/v/release/SukramJ/aiohomematic?style=for-the-badge
143
+ [sponsorsbadge]: https://img.shields.io/github/sponsors/SukramJ?style=for-the-badge&label=GitHub%20Sponsors&color=green
144
+ [sponsors]: https://github.com/sponsors/SukramJ
@@ -0,0 +1,109 @@
1
+ [![releasebadge]][release]
2
+ [![License][license-shield]](LICENSE.md)
3
+ [![GitHub Sponsors][sponsorsbadge]][sponsors]
4
+
5
+ # AIO Homematic
6
+
7
+ A lightweight Python 3 library that powers Home Assistant integrations for controlling and monitoring [Homematic](https://www.eq-3.com/products/homematic.html) and [HomematicIP](https://www.homematic-ip.com/en/start.html) devices. Some third‑party devices/gateways (e.g., Bosch, Intertechno) may be supported as well.
8
+
9
+ This project is the modern successor to [pyhomematic](https://github.com/danielperna84/pyhomematic), focusing on automatic entity creation, fewer manual device definitions, and faster startups.
10
+
11
+ ## How it works
12
+
13
+ Unlike pyhomematic, which required manual device mappings, aiohomematic automatically creates entities for each relevant parameter on every device channel (unless blacklisted). To achieve this it:
14
+
15
+ - Fetches and caches device paramsets (VALUES) for fast successive startups.
16
+ - Provides hooks for custom entity classes where complex behavior is needed (e.g., thermostats, lights, covers, climate, locks, sirens).
17
+ - Includes helpers for robust operation, such as automatic reconnection after CCU restarts.
18
+
19
+ ## Key features
20
+
21
+ - Automatic entity discovery from device/channel parameters.
22
+ - Extensible via custom entity classes for complex devices.
23
+ - Caching of paramsets to speed up restarts.
24
+ - Designed to integrate with Home Assistant.
25
+
26
+ ## Quickstart for Home Assistant
27
+
28
+ Use the Home Assistant custom integration "Homematic(IP) Local", which is powered by aiohomematic.
29
+
30
+ 1. Prerequisites
31
+ - Use latest version of Home Assistant.
32
+ - A CCU3, OpenCCU, or Homegear instance reachable from Home Assistant.
33
+ - For HomematicIP devices, ensure CCU firmware meets the minimum versions listed below.
34
+ 2. Install the integration
35
+ - Add the custom repository and install: https://github.com/sukramj/homematicip_local
36
+ - Follow the installation guide: https://github.com/sukramj/homematicip_local/wiki/Installation
37
+ 3. Configure via Home Assistant UI
38
+ - In Home Assistant: Settings → Devices & Services → Add Integration → search for "Homematic(IP) Local".
39
+ - Enter the CCU/Homegear host (IP or hostname). If you use HTTPS on the CCU, enable TLS and don't use verify if self‑signed.
40
+ - Always enter credentials.
41
+ - Choose which interfaces to enable (HM, HmIP, Virtual). Default ports are typically 2001 (HM), 2010 (HmIP), 9292 (Virtual).
42
+ 4. Network callbacks
43
+ - The integration needs to receive XML‑RPC callbacks from the CCU. Make sure Home Assistant is reachable from the CCU (no NAT/firewall blocking). Callbacks are only required for special network setups.
44
+ 5. Verify
45
+ - After setup, devices should appear under Devices & Services → Homematic(IP) Local. Discovery may take a few seconds after the first connection while paramsets are fetched and cached for faster restarts.
46
+
47
+ If you need to use aiohomematic directly in Python, see the Public API and example below.
48
+
49
+ ## Requirements
50
+
51
+ Due to a bug in earlier CCU2/CCU3 firmware, aiohomematic requires at least the following versions when used with HomematicIP devices:
52
+
53
+ - CCU2: 2.53.27
54
+ - CCU3: 3.53.26
55
+
56
+ See details here: https://github.com/OpenCCU/OpenCCU/issues/843. Other CCU‑like platforms using the buggy HmIPServer version are not supported.
57
+
58
+ ## Public API and imports
59
+
60
+ - The public API of aiohomematic is explicitly defined via **all** in each module and subpackage.
61
+ - Backwards‑compatible imports should target these modules:
62
+ - aiohomematic.central: CentralUnit, CentralConfig and related schemas
63
+ - aiohomematic.central.event: display received events from the backend
64
+ - aiohomematic.client: Client, InterfaceConfig, create_client, get_client
65
+ - aiohomematic.model: device/data point abstractions (see subpackages for details)
66
+ - aiohomematic.exceptions: library exception types intended for consumers
67
+ - aiohomematic.const: constants and enums (stable subset; see module **all**)
68
+ - aiohomematic.performance: display some performance metrics (enabled when DEBUG is enabled)
69
+ - The top‑level package only exposes **version** to avoid import cycles and keep startup lean. Prefer importing from the specific submodules listed above.
70
+
71
+ Example:
72
+
73
+ from aiohomematic.central import CentralConfig
74
+ from aiohomematic import client as hmcl
75
+
76
+ cfg = CentralConfig(
77
+ central_id="ccu-main",
78
+ host="ccu.local",
79
+ username="admin",
80
+ password="secret",
81
+ default_callback_port=43439,
82
+ interface_configs={hmcl.InterfaceConfig(interface=hmcl.Interface.HMIP, port=2010, enabled=True)},
83
+ )
84
+ central = cfg.create_central()
85
+
86
+ ## Useful links
87
+
88
+ - Changelog: [see](changelog.md) for release history and latest changes.
89
+ - Definition of calculated data points: [see](docs/calculated_data_points.md)
90
+ - Naming: [see](docs/naming.md) for how device, channel and data point names are created.
91
+ - Homematic(IP) Local integration: https://github.com/sukramj/homematicip_local
92
+ - Input select helper: [see](docs/input_select_helper.md) for an overview of how to use the input select helper.
93
+ - Troubleshooting with Home Assistant: [see](docs/homeassistant_troubleshooting.md) for common issues and how to debug them.
94
+ - Unignore mechanism: [see](docs/unignore.md) for how to unignore devices that are ignored by default.
95
+
96
+ ## Useful developer links
97
+
98
+ - Architecture overview: [see](docs/architecture.md) for an overview of the architecture of the library.
99
+ - Data flow: [see](docs/data_flow.md) for an overview of how data flows through the library.
100
+ - Extending the model: [see](docs/extension_points.md) for adding custom device profiles and calculated data points.
101
+ - Home Assistant lifecycle (discovery, updates, teardown): [see](docs/homeassistant_lifecycle.md) for details on how the integration works and how to debug issues.
102
+ - RSSI fix: [see](docs/rssi_fix.md) for how RSSI values are fixed for Home Assistant.
103
+ - Sequence diagrams: [see](docs/sequence_diagrams.md) for a sequence diagram of how the library works.
104
+
105
+ [license-shield]: https://img.shields.io/github/license/SukramJ/aiohomematic.svg?style=for-the-badge
106
+ [release]: https://github.com/SukramJ/aiohomematic/releases
107
+ [releasebadge]: https://img.shields.io/github/v/release/SukramJ/aiohomematic?style=for-the-badge
108
+ [sponsorsbadge]: https://img.shields.io/github/sponsors/SukramJ?style=for-the-badge&label=GitHub%20Sponsors&color=green
109
+ [sponsors]: https://github.com/sponsors/SukramJ
@@ -0,0 +1,110 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2021-2025
3
+ """
4
+ AioHomematic: async Python library for Homematic and HomematicIP backends.
5
+
6
+ Overview
7
+ --------
8
+ This package provides a comprehensive async library for interacting with Homematic CCU
9
+ and HomematicIP systems. It enables device discovery, data point manipulation, event
10
+ handling, and management of programs and system variables.
11
+
12
+ The library is designed for integration with Home Assistant but can be used standalone.
13
+ It features automatic entity discovery, flexible customization through device-specific
14
+ implementations, and fast startup through intelligent caching.
15
+
16
+ Architecture
17
+ ------------
18
+ The library is organized into four main layers:
19
+
20
+ - **aiohomematic.central**: Central orchestration managing client lifecycles, device
21
+ creation, event handling, and background tasks.
22
+ - **aiohomematic.client**: Protocol adapters (JSON-RPC/XML-RPC) for backend communication.
23
+ - **aiohomematic.model**: Runtime representation of devices, channels, and data points
24
+ with generic, custom, calculated, and hub entity types.
25
+ - **aiohomematic.store**: Persistence layer for device descriptions, paramsets, and
26
+ runtime caches.
27
+
28
+ Public API
29
+ ----------
30
+ - `__version__`: Library version string.
31
+
32
+ The primary entry point is `CentralConfig` and `CentralUnit` from `aiohomematic.central`.
33
+
34
+ Quick start
35
+ -----------
36
+ Typical usage pattern:
37
+
38
+ from aiohomematic.central import CentralConfig
39
+ from aiohomematic.client import InterfaceConfig, Interface
40
+
41
+ config = CentralConfig(
42
+ name="ccu-main",
43
+ host="192.168.1.100",
44
+ username="admin",
45
+ password="secret",
46
+ central_id="unique-id",
47
+ interface_configs={
48
+ InterfaceConfig(
49
+ central_name="ccu-main",
50
+ interface=Interface.HMIP_RF,
51
+ port=2010,
52
+ ),
53
+ },
54
+ )
55
+
56
+ central = config.create_central()
57
+ await central.start()
58
+
59
+ # Access devices and data points
60
+ device = central.get_device_by_address("VCU0000001")
61
+
62
+ await central.stop()
63
+
64
+ Notes
65
+ -----
66
+ Public API at the top-level package is defined by `__all__`.
67
+
68
+ """
69
+
70
+ from __future__ import annotations
71
+
72
+ import asyncio
73
+ import logging
74
+ import signal
75
+ import sys
76
+ import threading
77
+ from typing import Final
78
+
79
+ from aiohomematic import central as hmcu, i18n, validator as _ahm_validator
80
+ from aiohomematic.const import VERSION
81
+
82
+ if sys.stdout.isatty():
83
+ logging.basicConfig(level=logging.INFO)
84
+
85
+ __version__: Final = VERSION
86
+ _LOGGER: Final = logging.getLogger(__name__)
87
+
88
+
89
+ # pylint: disable=unused-argument
90
+ # noinspection PyUnusedLocal
91
+ def signal_handler(sig, frame): # type: ignore[no-untyped-def]
92
+ """Handle signal to shut down central."""
93
+ _LOGGER.info(i18n.tr("log.core.signal.shutdown", sig=str(sig)))
94
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
95
+ for central in hmcu.CENTRAL_INSTANCES.values():
96
+ asyncio.run_coroutine_threadsafe(central.stop(), asyncio.get_running_loop())
97
+
98
+
99
+ # Perform lightweight startup validation once on import
100
+ try:
101
+ _ahm_validator.validate_startup()
102
+ except Exception as _exc: # pragma: no cover
103
+ # Fail-fast with a clear message if validation fails during import
104
+ raise RuntimeError(i18n.tr("exception.startup.validation_failed", reason=_exc)) from _exc
105
+
106
+ if threading.current_thread() is threading.main_thread() and sys.stdout.isatty():
107
+ signal.signal(signal.SIGINT, signal_handler)
108
+
109
+ # Define public API for the top-level package
110
+ __all__ = ["__version__"]
@@ -0,0 +1,218 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2021-2025
3
+ """
4
+ Async event loop utilities and task management.
5
+
6
+ Public API of this module is defined by __all__.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import asyncio
12
+ from collections.abc import Callable, Collection
13
+ from concurrent.futures import ThreadPoolExecutor
14
+ from concurrent.futures._base import CancelledError
15
+ import contextlib
16
+ from functools import wraps
17
+ import logging
18
+ from time import monotonic
19
+ from typing import Any, Final, cast
20
+
21
+ from aiohomematic.const import BLOCK_LOG_TIMEOUT
22
+ from aiohomematic.exceptions import AioHomematicException
23
+ from aiohomematic.interfaces import TaskScheduler
24
+ import aiohomematic.support as hms
25
+ from aiohomematic.support import extract_exc_args
26
+ from aiohomematic.type_aliases import AsyncTaskFactoryAny, CallableAny, CoroutineAny
27
+
28
+ _LOGGER: Final = logging.getLogger(__name__)
29
+
30
+
31
+ class Looper(TaskScheduler):
32
+ """Helper class for event loop support."""
33
+
34
+ def __init__(self) -> None:
35
+ """Initialize the loop helper."""
36
+ self._tasks: Final[set[asyncio.Future[Any]]] = set()
37
+ self._loop = asyncio.get_event_loop()
38
+
39
+ def async_add_executor_job[T](
40
+ self,
41
+ target: Callable[..., T],
42
+ *args: Any,
43
+ name: str,
44
+ executor: ThreadPoolExecutor | None = None,
45
+ ) -> asyncio.Future[T]:
46
+ """Add an executor job from within the event_loop."""
47
+ try:
48
+ task = self._loop.run_in_executor(executor, target, *args)
49
+ self._tasks.add(task)
50
+ task.add_done_callback(self._tasks.remove)
51
+ except (TimeoutError, CancelledError) as err: # pragma: no cover
52
+ message = f"async_add_executor_job: task cancelled for {name} [{extract_exc_args(exc=err)}]"
53
+ _LOGGER.debug(message)
54
+ raise AioHomematicException(message) from err
55
+ return task
56
+
57
+ async def block_till_done(self, *, wait_time: float | None = None) -> None:
58
+ """
59
+ Block until all pending work is done.
60
+
61
+ If wait_time is set, stop waiting after the given number of seconds and log remaining tasks.
62
+ """
63
+ # To flush out any call_soon_threadsafe
64
+ await asyncio.sleep(0)
65
+ start_time: float | None = None
66
+ deadline: float | None = (monotonic() + wait_time) if wait_time is not None else None
67
+ current_task = asyncio.current_task()
68
+ while tasks := [task for task in self._tasks if task is not current_task and not cancelling(task=task)]:
69
+ # If we have a deadline and have exceeded it, log remaining tasks and break
70
+ if deadline is not None and monotonic() >= deadline:
71
+ for task in tasks:
72
+ _LOGGER.warning( # i18n-log: ignore
73
+ "Shutdown timeout reached; task still pending: %s", task
74
+ )
75
+ break
76
+
77
+ pending_after_wait = await self._await_and_log_pending(pending=tasks, deadline=deadline)
78
+
79
+ # If deadline has been reached and tasks are still pending, log and break
80
+ if deadline is not None and monotonic() >= deadline and pending_after_wait:
81
+ for task in pending_after_wait:
82
+ _LOGGER.warning( # i18n-log: ignore
83
+ "Shutdown timeout reached; task still pending: %s", task
84
+ )
85
+ break
86
+
87
+ if start_time is None:
88
+ # Avoid calling monotonic() until we know
89
+ # we may need to start logging blocked tasks.
90
+ start_time = 0
91
+ elif start_time == 0:
92
+ # If we have waited twice then we set the start
93
+ # time
94
+ start_time = monotonic()
95
+ elif monotonic() - start_time > BLOCK_LOG_TIMEOUT:
96
+ # We have waited at least three loops and new tasks
97
+ # continue to block. At this point we start
98
+ # logging all waiting tasks.
99
+ for task in tasks:
100
+ _LOGGER.debug("Waiting for task: %s", task)
101
+
102
+ def cancel_tasks(self) -> None:
103
+ """Cancel running tasks."""
104
+ for task in self._tasks.copy():
105
+ if not task.cancelled():
106
+ task.cancel()
107
+
108
+ def create_task(self, *, target: CoroutineAny | AsyncTaskFactoryAny, name: str) -> None:
109
+ """
110
+ Schedule a coroutine to run in the loop.
111
+
112
+ Accepts either an already-created coroutine object or a zero-argument
113
+ callable that returns a coroutine. The callable form defers coroutine
114
+ creation until inside the event loop, which avoids "was never awaited"
115
+ warnings if callers only inspect the parameters (e.g. in tests).
116
+ """
117
+ try:
118
+ self._loop.call_soon_threadsafe(self._async_create_task, target, name)
119
+ except CancelledError:
120
+ # Scheduling failed; if a coroutine object was provided, close it to
121
+ # avoid 'was never awaited' warnings.
122
+ if asyncio.iscoroutine(target):
123
+ with contextlib.suppress(Exception):
124
+ getattr(target, "close", lambda: None)()
125
+ _LOGGER.debug("create_task: task cancelled for %s", name)
126
+ return
127
+
128
+ def run_coroutine(self, *, coro: CoroutineAny, name: str) -> Any:
129
+ """Call coroutine from sync."""
130
+ try:
131
+ return asyncio.run_coroutine_threadsafe(coro, self._loop).result()
132
+ except CancelledError: # pragma: no cover
133
+ _LOGGER.debug(
134
+ "run_coroutine: coroutine interrupted for %s",
135
+ name,
136
+ )
137
+ return None
138
+
139
+ def _async_create_task( # kwonly: disable
140
+ self, target: CoroutineAny | AsyncTaskFactoryAny, name: str
141
+ ) -> asyncio.Task[Any]:
142
+ """Create a task from within the event loop. Must be run in the event loop."""
143
+ # If target is a callable, call it here to create the coroutine inside the loop
144
+ coro: CoroutineAny = target if asyncio.iscoroutine(target) else target()
145
+ task = self._loop.create_task(coro, name=name)
146
+ self._tasks.add(task)
147
+ task.add_done_callback(self._tasks.remove)
148
+ return task
149
+
150
+ async def _await_and_log_pending(
151
+ self, *, pending: Collection[asyncio.Future[Any]], deadline: float | None
152
+ ) -> set[asyncio.Future[Any]]:
153
+ """
154
+ Await and log tasks that take a long time, respecting an optional deadline.
155
+
156
+ Returns the set of pending tasks if the deadline has been reached (or zero timeout),
157
+ allowing the caller to decide about timeout logging. Returns an empty set if no tasks are pending.
158
+ """
159
+ wait_time = 0.0
160
+ pending_set: set[asyncio.Future[Any]] = set(pending)
161
+ while pending_set:
162
+ if deadline is None:
163
+ timeout = BLOCK_LOG_TIMEOUT
164
+ else:
165
+ remaining = int(max(0.0, deadline - monotonic()))
166
+ if (timeout := min(BLOCK_LOG_TIMEOUT, remaining)) == 0.0:
167
+ # Deadline reached; return current pending to caller for warning log
168
+ return pending_set
169
+ done, still_pending = await asyncio.wait(pending_set, timeout=timeout)
170
+ if not (pending_set := set(still_pending)):
171
+ return set()
172
+ wait_time += timeout
173
+ for task in pending_set:
174
+ _LOGGER.debug("Waited %s seconds for task: %s", wait_time, task)
175
+ # If the deadline was reached during the wait, let caller handle warning
176
+ if deadline is not None and monotonic() >= deadline:
177
+ return pending_set
178
+ return set()
179
+
180
+
181
+ def cancelling(*, task: asyncio.Future[Any]) -> bool:
182
+ """Return True if task is cancelling."""
183
+ return bool((cancelling_ := getattr(task, "cancelling", None)) and cancelling_())
184
+
185
+
186
+ def loop_check[**P, R](func: Callable[P, R]) -> Callable[P, R]:
187
+ """
188
+ Annotation to mark method that must be run within the event loop.
189
+
190
+ Always wraps the function, but only performs loop checks when debug is enabled.
191
+ This allows tests to monkeypatch aiohomematic.support.debug_enabled at runtime.
192
+ """
193
+ _with_loop: set[CallableAny] = set()
194
+
195
+ @wraps(func)
196
+ def wrapper_loop_check(*args: P.args, **kwargs: P.kwargs) -> R:
197
+ """Wrap loop check."""
198
+ return_value = func(*args, **kwargs)
199
+
200
+ # Only perform the (potentially expensive) loop check when debug is enabled.
201
+ if hms.debug_enabled():
202
+ try:
203
+ asyncio.get_running_loop()
204
+ loop_running = True
205
+ except Exception:
206
+ loop_running = False
207
+
208
+ if not loop_running and func not in _with_loop:
209
+ _with_loop.add(func)
210
+ _LOGGER.error( # i18n-log: ignore
211
+ "Method %s must run in the event_loop. No loop detected.",
212
+ func.__name__,
213
+ )
214
+
215
+ return return_value
216
+
217
+ setattr(func, "_loop_check", True)
218
+ return cast(Callable[P, R], wrapper_loop_check)