python-openhab-rest-client 21.3.93__tar.gz → 21.4.0__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 (170) hide show
  1. python_openhab_rest_client-21.4.0/PKG-INFO +3069 -0
  2. python_openhab_rest_client-21.4.0/README.md +3042 -0
  3. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Actions.py +100 -100
  4. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Addons.py +395 -397
  5. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/AsyncActions.py +103 -91
  6. python_openhab_rest_client-21.4.0/openhab/AsyncAddons.py +398 -0
  7. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/AsyncAudio.py +155 -116
  8. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/AsyncAuth.py +245 -202
  9. python_openhab_rest_client-21.4.0/openhab/AsyncChannelTypes.py +131 -0
  10. python_openhab_rest_client-21.4.0/openhab/AsyncClient.py +245 -0
  11. python_openhab_rest_client-21.4.0/openhab/AsyncConfigDescriptions.py +97 -0
  12. python_openhab_rest_client-21.4.0/openhab/AsyncDiscovery.py +114 -0
  13. python_openhab_rest_client-21.4.0/openhab/AsyncEvents.py +356 -0
  14. python_openhab_rest_client-21.4.0/openhab/AsyncIconsets.py +48 -0
  15. python_openhab_rest_client-21.4.0/openhab/AsyncInbox.py +181 -0
  16. python_openhab_rest_client-21.4.0/openhab/AsyncItems.py +717 -0
  17. python_openhab_rest_client-21.4.0/openhab/AsyncLinks.py +261 -0
  18. python_openhab_rest_client-21.4.0/openhab/AsyncLogging.py +142 -0
  19. python_openhab_rest_client-21.4.0/openhab/AsyncModuleTypes.py +96 -0
  20. python_openhab_rest_client-21.4.0/openhab/AsyncPersistence.py +327 -0
  21. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/AsyncProfileTypes.py +57 -39
  22. python_openhab_rest_client-21.4.0/openhab/AsyncRules.py +619 -0
  23. python_openhab_rest_client-21.4.0/openhab/AsyncServices.py +236 -0
  24. python_openhab_rest_client-21.4.0/openhab/AsyncSitemaps.py +297 -0
  25. python_openhab_rest_client-21.4.0/openhab/AsyncSysteminfo.py +69 -0
  26. python_openhab_rest_client-21.4.0/openhab/AsyncTags.py +214 -0
  27. python_openhab_rest_client-21.4.0/openhab/AsyncTemplates.py +86 -0
  28. python_openhab_rest_client-21.4.0/openhab/AsyncThingTypes.py +89 -0
  29. python_openhab_rest_client-21.4.0/openhab/AsyncThings.py +508 -0
  30. python_openhab_rest_client-21.4.0/openhab/AsyncTransformations.py +180 -0
  31. python_openhab_rest_client-21.4.0/openhab/AsyncUI.py +211 -0
  32. python_openhab_rest_client-21.4.0/openhab/AsyncUUID.py +42 -0
  33. python_openhab_rest_client-21.4.0/openhab/AsyncVoice.py +397 -0
  34. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Audio.py +152 -152
  35. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Auth.py +241 -241
  36. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/ChannelTypes.py +128 -128
  37. python_openhab_rest_client-21.4.0/openhab/Client.py +269 -0
  38. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/ConfigDescriptions.py +94 -94
  39. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Discovery.py +111 -111
  40. python_openhab_rest_client-21.4.0/openhab/Events.py +353 -0
  41. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Iconsets.py +45 -45
  42. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Inbox.py +178 -178
  43. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Items.py +714 -708
  44. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Links.py +258 -258
  45. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Logging.py +139 -139
  46. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/ModuleTypes.py +93 -93
  47. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Persistence.py +324 -311
  48. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/ProfileTypes.py +54 -54
  49. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Rules.py +616 -613
  50. python_openhab_rest_client-21.4.0/openhab/SSE.py +85 -0
  51. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Services.py +233 -233
  52. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Sitemaps.py +294 -281
  53. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Systeminfo.py +66 -66
  54. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Tags.py +211 -211
  55. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Templates.py +83 -83
  56. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/ThingTypes.py +86 -86
  57. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Things.py +505 -505
  58. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Transformations.py +177 -177
  59. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/UI.py +208 -208
  60. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/UUID.py +39 -39
  61. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/Voice.py +394 -395
  62. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/__init__.py +137 -128
  63. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Actions.py +42 -42
  64. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Addons.py +111 -111
  65. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Audio.py +50 -50
  66. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Auth.py +68 -68
  67. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/ChannelEvents.py +30 -30
  68. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/ChannelTypes.py +42 -42
  69. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/ConfigDescriptions.py +32 -32
  70. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Discovery.py +41 -41
  71. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Events.py +49 -49
  72. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Iconsets.py +20 -20
  73. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Inbox.py +60 -60
  74. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/InboxEvents.py +37 -37
  75. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/ItemEvents.py +122 -122
  76. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Items.py +159 -159
  77. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/LinkEvents.py +30 -30
  78. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Links.py +84 -84
  79. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Logging.py +47 -47
  80. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/ModuleTypes.py +30 -30
  81. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Persistence.py +92 -92
  82. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/ProfileTypes.py +21 -21
  83. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Rules.py +83 -83
  84. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Services.py +72 -72
  85. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Sitemaps.py +81 -81
  86. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Systeminfo.py +33 -33
  87. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Tags.py +62 -62
  88. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Templates.py +34 -34
  89. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/ThingEvents.py +61 -61
  90. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/ThingTypes.py +35 -35
  91. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Things.py +81 -81
  92. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Transformations.py +62 -62
  93. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/UI.py +72 -72
  94. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/UUID.py +21 -21
  95. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/Voice.py +112 -112
  96. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/openhab/tests/__init__.py +68 -68
  97. python_openhab_rest_client-21.4.0/pyproject.toml +6 -0
  98. python_openhab_rest_client-21.4.0/python_openhab_rest_client.egg-info/PKG-INFO +3069 -0
  99. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/python_openhab_rest_client.egg-info/SOURCES.txt +2 -0
  100. python_openhab_rest_client-21.4.0/python_openhab_rest_client.egg-info/requires.txt +2 -0
  101. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/python_openhab_rest_client.egg-info/top_level.txt +0 -1
  102. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/setup.py +24 -23
  103. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Actions.py +38 -38
  104. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Addons.py +35 -35
  105. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Audio.py +18 -18
  106. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Auth.py +33 -33
  107. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/ChannelEvents.py +16 -16
  108. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/ChannelTypes.py +23 -23
  109. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/ConfigDescriptions.py +20 -20
  110. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Discovery.py +20 -20
  111. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Events.py +22 -22
  112. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Iconsets.py +17 -17
  113. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Inbox.py +26 -26
  114. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/InboxEvents.py +19 -19
  115. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/ItemEvents.py +28 -28
  116. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Items.py +46 -46
  117. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/LinkEvents.py +20 -20
  118. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Links.py +26 -26
  119. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Logging.py +23 -23
  120. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/ModuleTypes.py +20 -20
  121. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Persistence.py +31 -31
  122. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/ProfileTypes.py +16 -16
  123. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Rules.py +38 -38
  124. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Services.py +30 -30
  125. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Sitemaps.py +25 -25
  126. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Systeminfo.py +17 -17
  127. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Tags.py +33 -33
  128. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Templates.py +20 -20
  129. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/ThingEvents.py +23 -23
  130. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/ThingTypes.py +20 -20
  131. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Things.py +34 -34
  132. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Transformations.py +30 -30
  133. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/UI.py +45 -45
  134. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/UUID.py +16 -16
  135. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/Voice.py +45 -45
  136. python_openhab_rest_client-21.3.93/PKG-INFO +0 -2428
  137. python_openhab_rest_client-21.3.93/README.md +0 -2402
  138. python_openhab_rest_client-21.3.93/openhab/AsyncAddons.py +0 -306
  139. python_openhab_rest_client-21.3.93/openhab/AsyncChannelTypes.py +0 -82
  140. python_openhab_rest_client-21.3.93/openhab/AsyncClient.py +0 -175
  141. python_openhab_rest_client-21.3.93/openhab/AsyncConfigDescriptions.py +0 -61
  142. python_openhab_rest_client-21.3.93/openhab/AsyncDiscovery.py +0 -70
  143. python_openhab_rest_client-21.3.93/openhab/AsyncEvents.py +0 -144
  144. python_openhab_rest_client-21.3.93/openhab/AsyncIconsets.py +0 -32
  145. python_openhab_rest_client-21.3.93/openhab/AsyncInbox.py +0 -109
  146. python_openhab_rest_client-21.3.93/openhab/AsyncItems.py +0 -433
  147. python_openhab_rest_client-21.3.93/openhab/AsyncLinks.py +0 -120
  148. python_openhab_rest_client-21.3.93/openhab/AsyncLogging.py +0 -62
  149. python_openhab_rest_client-21.3.93/openhab/AsyncModuleTypes.py +0 -50
  150. python_openhab_rest_client-21.3.93/openhab/AsyncPersistence.py +0 -122
  151. python_openhab_rest_client-21.3.93/openhab/AsyncRules.py +0 -389
  152. python_openhab_rest_client-21.3.93/openhab/AsyncServices.py +0 -93
  153. python_openhab_rest_client-21.3.93/openhab/AsyncSitemaps.py +0 -105
  154. python_openhab_rest_client-21.3.93/openhab/AsyncSysteminfo.py +0 -38
  155. python_openhab_rest_client-21.3.93/openhab/AsyncTags.py +0 -87
  156. python_openhab_rest_client-21.3.93/openhab/AsyncTemplates.py +0 -36
  157. python_openhab_rest_client-21.3.93/openhab/AsyncThingTypes.py +0 -45
  158. python_openhab_rest_client-21.3.93/openhab/AsyncThings.py +0 -259
  159. python_openhab_rest_client-21.3.93/openhab/AsyncTransformations.py +0 -74
  160. python_openhab_rest_client-21.3.93/openhab/AsyncUI.py +0 -161
  161. python_openhab_rest_client-21.3.93/openhab/AsyncUUID.py +0 -42
  162. python_openhab_rest_client-21.3.93/openhab/AsyncVoice.py +0 -348
  163. python_openhab_rest_client-21.3.93/openhab/Client.py +0 -237
  164. python_openhab_rest_client-21.3.93/openhab/Events.py +0 -791
  165. python_openhab_rest_client-21.3.93/python_openhab_rest_client.egg-info/PKG-INFO +0 -2428
  166. python_openhab_rest_client-21.3.93/python_openhab_rest_client.egg-info/requires.txt +0 -2
  167. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/LICENSE +0 -0
  168. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/python_openhab_rest_client.egg-info/dependency_links.txt +0 -0
  169. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/setup.cfg +0 -0
  170. {python_openhab_rest_client-21.3.93 → python_openhab_rest_client-21.4.0}/tests/__init__.py +0 -0
@@ -0,0 +1,3069 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-openhab-rest-client
3
+ Version: 21.4.0
4
+ Summary: A Python client for the openHAB REST API. This library enables easy interaction with the openHAB REST API to control smart home devices, retrieve status information, and process events.
5
+ Home-page: https://github.com/Michdo93/python-openhab-rest-client
6
+ Author: Michael Christian Dörflinger
7
+ Author-email: michaeldoerflinger93@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Home Automation
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: requests>=2.28
16
+ Requires-Dist: aiohttp>=3.9
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: classifier
20
+ Dynamic: description
21
+ Dynamic: description-content-type
22
+ Dynamic: home-page
23
+ Dynamic: license-file
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+ Dynamic: summary
27
+
28
+ # python-openhab-rest-client
29
+
30
+ A Python client for the openHAB REST API. This library enables easy interaction with the openHAB REST API to control smart home devices, retrieve status information, and process events.
31
+
32
+ ## Features
33
+
34
+ Supports the following openHAB REST API endpoints:
35
+
36
+ - Actions
37
+ - Addons
38
+ - Audio
39
+ - Auth
40
+ - ChannelTypes
41
+ - ConfigDescriptions
42
+ - Discovery
43
+ - Events (ItemEvents, ThingEvents, InboxEvents, LinkEvents, ChannelEvents)
44
+ - Iconsets
45
+ - Inbox
46
+ - Items
47
+ - Links
48
+ - Logging
49
+ - ModuleTypes
50
+ - Persistence
51
+ - ProfileTypes
52
+ - Rules
53
+ - Services
54
+ - Sitemaps
55
+ - Systeminfo
56
+ - Tags
57
+ - Templates
58
+ - ThingTypes
59
+ - Things
60
+ - Transformations
61
+ - UI
62
+ - UUID
63
+ - Voice
64
+
65
+ All of the above are also available as asynchronous variants (e.g. `AsyncItems`, `AsyncThings`, etc.) using `AsyncOpenHABClient` based on `aiohttp`.
66
+
67
+ Supports both Server-Sent Events (SSE) and regular REST requests. SSE is used for the events of openHAB.
68
+
69
+ ## Requirements
70
+
71
+ - Python 3.8 or newer
72
+ - `requests`
73
+ - `aiohttp`
74
+
75
+ Tested against openHAB 5.2.3 (Java 21). The library also works with openHAB 4.x;
76
+ parameters that were added in later openHAB versions (e.g. `source`, `parents`,
77
+ `displayState`) are only sent if you pass them.
78
+
79
+ ## Installation
80
+
81
+ Install via pip:
82
+
83
+ ```sh
84
+ pip install python-openhab-rest-client
85
+ ```
86
+
87
+ ## Usage
88
+
89
+ Basically, you always need the `OpenHABClient` (or `AsyncOpenHABClient` for async usage). Regardless of whether you carry out a normal `REST request` or one via `SSE`.
90
+
91
+ ### Authentication
92
+
93
+ #### Basic Authentication
94
+
95
+ ```python
96
+ from openhab import OpenHABClient
97
+
98
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
99
+ ```
100
+
101
+ The `url`, the `username` and the `password` can also vary. In particular, it is possible that `url` could be a remote IP address or even the openHAB cloud.
102
+
103
+ #### Token-based Authentication
104
+
105
+ It is also conceivable that a `token` could be used instead of `basic authentication`, i.e. with a `username` and `password`. A `token` is used by default in openHAB. The `basic authentication` must actually be activated manually.
106
+
107
+ For token-based access, the initialization of the client is as follows:
108
+
109
+ ```python
110
+ client = OpenHABClient(url="http://127.0.0.1:8080", token="oh.openhab.U0doM1Lz4kJ6tPlVGjH17jjm4ZcTHIHi7sMwESzrIybKbCGySmBMtysPnObQLuLf7PgqnI7jWQ5LosySY8Q")
111
+ ```
112
+
113
+ Of course, your `token` will probably look different here too.
114
+
115
+ ### Requests
116
+
117
+ #### Normal REST requests
118
+
119
+ Depending on the `endpoint`, a corresponding class must be imported from the library. If you want to access endpoints of the REST API with which you want to access `items`, you import the `Items` class, for example. There are then different functions in this class for each endpoint for items. More details can be found in the documentation.
120
+
121
+ An easy example could be:
122
+
123
+ ```python
124
+ from openhab import OpenHABClient, Items
125
+
126
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
127
+ itemsAPI = Items(client)
128
+
129
+ allItems = itemsAPI.getItems()
130
+ print("All Items:", allItems)
131
+ ```
132
+
133
+ #### Async REST requests
134
+
135
+ All synchronous classes have an async counterpart that uses `AsyncOpenHABClient` and `aiohttp`. The `AsyncOpenHABClient` must be used as an async context manager with `async with`.
136
+
137
+ ```python
138
+ import asyncio
139
+ from openhab import AsyncOpenHABClient, AsyncItems
140
+
141
+ async def main():
142
+ async with AsyncOpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen") as client:
143
+ itemsAPI = AsyncItems(client)
144
+ allItems = await itemsAPI.getItems()
145
+ print("All Items:", allItems)
146
+
147
+ asyncio.run(main())
148
+ ```
149
+
150
+ #### Return values and errors
151
+
152
+ All methods follow the same conventions – in the synchronous and in the asynchronous classes:
153
+
154
+ | Situation | Return value |
155
+ |---|---|
156
+ | openHAB answers with JSON | the decoded JSON (`dict` or `list`) |
157
+ | openHAB answers with plain text (e.g. `getItemState`) | `str` |
158
+ | openHAB answers without a body (e.g. `sendCommand`) | `{"message": "..."}` |
159
+ | openHAB rejects the request (4xx/5xx) | `{"error": "..."}` – including openHAB's own error message if it sent one |
160
+ | network error, timeout | `{"error": "Request error: ..."}` |
161
+
162
+ So you can always check for errors like this:
163
+
164
+ ```python
165
+ result = itemsAPI.sendCommand("Livingroom_Light", "ON")
166
+ if isinstance(result, dict) and "error" in result:
167
+ print("openHAB rejected the command:", result["error"])
168
+ ```
169
+
170
+ The low-level methods `client.get/post/put/delete` return the JSON, the text or – for
171
+ responses without a body – a `StatusResponse` (a `dict` like `{"status": 202}`, with
172
+ `"location"` if openHAB sent a `Location` header). They raise
173
+ `requests.exceptions.HTTPError` (sync) or `aiohttp.ClientResponseError` (async) for
174
+ 4xx/5xx responses.
175
+
176
+ #### Server-sent Events (SSE) requests
177
+
178
+ All normal REST requests are static. This means that they do not react to status changes. You would therefore have to send several REST requests in succession (polling). Or you can use the various events from openHAB. This can be done using server-sent events (SSE) without polling. The server sends a message to the client exactly when it can make something available. With polling, on the other hand, you would have to constantly send requests to the server, which would significantly increase the network and server load.
179
+
180
+ There are various [events](https://www.openhab.org/docs/developer/utils/events.html) in openHAB. For `ItemEvents`, `ThingEvents`, `InboxEvents`, `LinkEvents` and `ChannelEvents` there are own classes. However, there is also the `Events` class. More information can be found in the documentation.
181
+
182
+ An example looks like this:
183
+
184
+ ```python
185
+ from openhab import OpenHABClient, ItemEvents
186
+
187
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
188
+ itemEvents = ItemEvents(client)
189
+
190
+ response = itemEvents.ItemStateChangedEvent()
191
+
192
+ with response as events:
193
+ for line in events.iter_lines():
194
+ line = line.decode()
195
+
196
+ if "data" in line:
197
+ line = line.replace("data: ", "")
198
+
199
+ try:
200
+ data = json.loads(line)
201
+ print(data)
202
+ except json.decoder.JSONDecodeError:
203
+ print("Event could not be converted to JSON")
204
+ ```
205
+
206
+ **Tip:** use the helpers `iterSSEEvents(response)` / `iterSSELines(response)` (and
207
+ `aiterSSEEvents` / `aiterSSELines` for the async client). `response.iter_lines()` with its
208
+ default arguments may hand out an event only when the *next* data arrives, i.e. seconds
209
+ late. `iterSSEEvents` also decodes the payload:
210
+
211
+ ```python
212
+ from openhab import OpenHABClient, ItemEvents, iterSSEEvents
213
+
214
+ client = OpenHABClient(url="http://127.0.0.1:8080", token="oh.openhab...")
215
+ with ItemEvents(client).ItemStateChangedEvent() as stream:
216
+ for event in iterSSEEvents(stream):
217
+ print(event["topic"], event["payload"]["value"])
218
+ ```
219
+
220
+ Remember that the `payload` of every event is itself a JSON string and has to be
221
+ decoded a second time. openHAB also sends `{"type": "ALIVE", ...}` messages every few
222
+ seconds – they have no `topic` and can be used as a heartbeat. The wildcard `*` in a
223
+ topic also matches slashes, so `openhab/items/*/statechanged` includes the state
224
+ changes of group items (`openhab/items/<group>/<member>/statechanged`).
225
+
226
+ The SSE stream uses the session of the client, i.e. token and Basic Authentication
227
+ are sent as well. If openHAB rejects the stream (e.g. `401`), the event methods return
228
+ `{"error": ...}` instead of a stream.
229
+
230
+ Asynchronous variant:
231
+
232
+ ```python
233
+ import asyncio, json
234
+ from openhab import AsyncOpenHABClient, AsyncItemEvents
235
+
236
+ async def main():
237
+ async with AsyncOpenHABClient(url="http://127.0.0.1:8080", token="oh.openhab...") as client:
238
+ response = await AsyncItemEvents(client).ItemStateChangedEvent("Livingroom_Light")
239
+ async for line in response.content:
240
+ line = line.decode().strip()
241
+ if line.startswith("data:"):
242
+ event = json.loads(line[5:])
243
+ if "topic" in event:
244
+ print(event["topic"], json.loads(event["payload"]))
245
+ response.close()
246
+
247
+ asyncio.run(main())
248
+ ```
249
+
250
+ ### Tests
251
+
252
+ There is also a test function for each function. This means that every class that you import also has a test class that you can import. These tests work with a try-catch, as well as with a print output. Neither the value of the REST API nor something like True or False is returned. Effectively, however, the actual function is called from this test function and also executed in full, unless an exception is thrown.
253
+
254
+ In other words... For example, if you use the following import,
255
+
256
+ ```python
257
+ from openhab import Items
258
+ ```
259
+
260
+ then the test class to be imported would be the following:
261
+
262
+ ```python
263
+ from openhab.tests import ItemsTest
264
+ ```
265
+
266
+ From e.g. the following function
267
+
268
+ ```python
269
+ itemsAPI = Items(client)
270
+ itemsAPI.sendCommand("testSwitch", "ON")
271
+ ```
272
+
273
+ then becomes the following function for the test:
274
+
275
+ ```python
276
+ itemsTest = ItemsTest(client)
277
+ itemsTest.testSendCommand("testSwitch", "ON")
278
+ ```
279
+
280
+ However, both would also really execute a sendCommand in openHAB. The test classes test whether a function can be executed. In the end, it can only not be executed if the endpoint does not exist or has been implemented incorrectly. However, a non-existent endpoint can also occur, for example, if the name of the item is incorrect.
281
+
282
+ ### Automated tests (pytest)
283
+
284
+ `tests_pytest/` contains automated tests:
285
+
286
+ - `test_offline.py` runs without openHAB (URL building, `StatusResponse`, parity between
287
+ the synchronous and the generated asynchronous classes).
288
+ - `test_integration.py` runs against a real openHAB instance. It is skipped unless
289
+ `OPENHAB_TEST_URL` and `OPENHAB_TEST_TOKEN` (an API token of an administrator) are set.
290
+ The tests create and delete their own items, rules, tags and things (all prefixed with
291
+ `PyTest`) and only send commands to these test items.
292
+
293
+ ```sh
294
+ pip install -e . pytest
295
+ pytest tests_pytest # offline tests only
296
+ OPENHAB_TEST_URL=http://127.0.0.1:8080 OPENHAB_TEST_TOKEN=oh.xxx pytest tests_pytest -v
297
+ ```
298
+
299
+ ### Development: synchronous and asynchronous classes
300
+
301
+ The synchronous classes in `openhab/*.py` are the single source of truth. The
302
+ asynchronous classes `openhab/Async*.py` are generated from them, so both always have
303
+ the same methods, parameters, return values and error messages:
304
+
305
+ ```sh
306
+ python tools/generate_async.py
307
+ ```
308
+
309
+ ## Full list of Methods
310
+
311
+ ---
312
+
313
+ ### OpenHABClient
314
+
315
+ `OpenHABClient` is a Python class that provides an interface to interact with the openHAB REST API. It allows users to send requests to openHAB to retrieve and manipulate smart home devices, events, and configurations. The get, put, post and delete methods are used in the other classes for the client. You therefore do not need to use them raw.
316
+
317
+ #### Initialization
318
+
319
+ ##### Constructor
320
+
321
+ ```python
322
+ from openhab import OpenHABClient
323
+
324
+ OpenHABClient(url: str, username: str = None, password: str = None, token: str = None, timeout: float = 10, verify=True)
325
+ ```
326
+
327
+ ###### Parameters:
328
+ - `url` (str): The base URL of the openHAB server (e.g., "http://127.0.0.1:8080").
329
+ - `username` (str, optional): Username for Basic Authentication (default is `None`).
330
+ - `password` (str, optional): Password for Basic Authentication (default is `None`).
331
+ - `token` (str, optional): Bearer Token for Token-based Authentication (default is `None`).
332
+
333
+ ###### Example:
334
+
335
+ ```python
336
+ client = OpenHABClient("http://127.0.0.1:8080", username="admin", password="password")
337
+ ```
338
+
339
+ #### Methods
340
+
341
+ ##### `get`
342
+
343
+ ```python
344
+ get(endpoint: str, headers: dict = None, params: dict = None)
345
+ ```
346
+
347
+ Sends a GET request to the openHAB server.
348
+
349
+ ###### Parameters:
350
+ - `endpoint` (str): The API endpoint (e.g., `"/items"`).
351
+ - `headers` (dict, optional): Headers to include in the request.
352
+ - `params` (dict, optional): Query parameters for the request.
353
+
354
+ ###### Example:
355
+
356
+ ```python
357
+ response = client.get("/items")
358
+ print(response)
359
+ ```
360
+
361
+ ##### `post`
362
+
363
+ ```python
364
+ post(endpoint: str, headers: dict = None, data=None, params: dict = None)
365
+ ```
366
+
367
+ Sends a POST request to the openHAB server.
368
+
369
+ ###### Parameters:
370
+ - `endpoint` (str): The API endpoint (e.g., `"/items"`).
371
+ - `headers` (dict, optional): Headers to include in the request.
372
+ - `data` (optional): Data to send in the request body.
373
+ - `params` (dict, optional): Query parameters for the request.
374
+
375
+ ###### Example:
376
+
377
+ ```python
378
+ data = {"type": "Switch", "state": "ON"}
379
+ response = client.post("/items/light", data=json.dumps(data))
380
+ print(response)
381
+ ```
382
+
383
+ ##### `put`
384
+
385
+ ```python
386
+ put(endpoint: str, headers: dict = None, data=None, params: dict = None)
387
+ ```
388
+
389
+ Sends a PUT request to update a resource in openHAB.
390
+
391
+ ###### Example:
392
+
393
+ ```python
394
+ data = {"state": "OFF"}
395
+ response = client.put("/items/light", data=json.dumps(data))
396
+ print(response)
397
+ ```
398
+
399
+ ##### `delete`
400
+
401
+ ```python
402
+ delete(endpoint: str, headers: dict = None, data=None, params: dict = None)
403
+ ```
404
+
405
+ Sends a DELETE request to remove a resource from openHAB.
406
+
407
+ ###### Example:
408
+
409
+ ```python
410
+ response = client.delete("/items/light")
411
+ print(response)
412
+ ```
413
+
414
+ #### Authentication
415
+
416
+ The client supports two types of authentication:
417
+
418
+ - **Basic Authentication** (Username & Password)
419
+ - **Bearer Token Authentication**
420
+
421
+ If a token is provided, it is used for authentication; otherwise, Basic Authentication is used if credentials are supplied.
422
+
423
+ #### Error Handling
424
+
425
+ Errors during requests are caught and logged, with appropriate exception handling for HTTP errors, connection issues, and timeouts.
426
+
427
+ ---
428
+
429
+ ### AsyncOpenHABClient
430
+
431
+ `AsyncOpenHABClient` is the asynchronous counterpart to `OpenHABClient`. It uses `aiohttp` and must be used as an async context manager with `async with`. All async API classes require an `AsyncOpenHABClient` instance.
432
+
433
+ #### Initialization
434
+
435
+ ##### Constructor
436
+
437
+ ```python
438
+ from openhab import AsyncOpenHABClient
439
+
440
+ AsyncOpenHABClient(url: str, username: str = None, password: str = None, token: str = None, timeout: float = 10, verify: bool = True)
441
+ ```
442
+
443
+ ###### Parameters:
444
+ - `url` (str): The base URL of the openHAB server.
445
+ - `username` (str, optional): Username for Basic Authentication.
446
+ - `password` (str, optional): Password for Basic Authentication.
447
+ - `token` (str, optional): Bearer Token for Token-based Authentication.
448
+
449
+ #### Usage
450
+
451
+ `AsyncOpenHABClient` must always be used as an async context manager. It opens and closes the underlying `aiohttp.ClientSession` automatically.
452
+
453
+ ```python
454
+ import asyncio
455
+ from openhab import AsyncOpenHABClient, AsyncItems
456
+
457
+ async def main():
458
+ async with AsyncOpenHABClient(url="http://127.0.0.1:8080", token="oh.openhab...") as client:
459
+ itemsAPI = AsyncItems(client)
460
+ items = await itemsAPI.getItems()
461
+ print(items)
462
+
463
+ asyncio.run(main())
464
+ ```
465
+
466
+ #### Methods
467
+
468
+ The async client exposes the same HTTP primitives as the sync client, but as coroutines:
469
+
470
+ - `async get(endpoint, headers, params)`
471
+ - `async post(endpoint, headers, data, params)`
472
+ - `async put(endpoint, headers, data, params)`
473
+ - `async delete(endpoint, headers, data, params)`
474
+
475
+ ---
476
+
477
+ ### Actions
478
+
479
+ The `Actions` class provides methods to interact with the openHAB actions API. It allows retrieving available actions for a specific `thingUID` and executing actions.
480
+
481
+ #### Initialization
482
+
483
+ ```python
484
+ from openhab import OpenHABClient, Actions
485
+
486
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
487
+ actions = Actions(client)
488
+ ```
489
+
490
+ #### Methods
491
+
492
+ ##### `getActions(thingUID: str, language: str = None) -> list`
493
+
494
+ Retrieves all available actions for a given thing UID.
495
+
496
+ **Parameters:**
497
+ - `thingUID` (str): The UID of the thing for which actions should be retrieved.
498
+ - `language` (str, optional): The language for the response (`Accept-Language` header).
499
+
500
+ **Returns:** A list of available actions.
501
+
502
+ ###### Example:
503
+
504
+ ```python
505
+ actions_list = actions.getActions("myThingUID")
506
+ print(actions_list)
507
+ ```
508
+
509
+ ##### `executeAction(thingUID: str, actionUID: str, actionInputs: dict, language: str = None) -> str`
510
+
511
+ Executes an action on a specific thing.
512
+
513
+ **Parameters:**
514
+ - `thingUID` (str): The UID of the thing on which the action is executed.
515
+ - `actionUID` (str): The UID of the action to be performed.
516
+ - `actionInputs` (dict): A dictionary containing input parameters for the action.
517
+ - `language` (str, optional): The language for the response.
518
+
519
+ **Returns:** The response from the openHAB server.
520
+
521
+ ###### Example:
522
+
523
+ ```python
524
+ response = actions.executeAction("myThingUID", "actionID", {"param1": "value1"})
525
+ print(response)
526
+ ```
527
+
528
+ ---
529
+
530
+ ### AsyncActions
531
+
532
+ The `AsyncActions` class is the asynchronous counterpart to `Actions`. It requires an `AsyncOpenHABClient`.
533
+
534
+ #### Methods
535
+
536
+ ##### `async getActions(thingUID: str, language: str = None) -> list`
537
+
538
+ Asynchronously retrieves all available actions for a given thing UID.
539
+
540
+ ##### `async executeAction(thingUID: str, actionUID: str, actionInputs: dict, language: str = None) -> str`
541
+
542
+ Asynchronously executes an action on a specific thing.
543
+
544
+ ###### Example:
545
+
546
+ ```python
547
+ async with AsyncOpenHABClient(url="http://127.0.0.1:8080", token="...") as client:
548
+ asyncActions = AsyncActions(client)
549
+ result = await asyncActions.executeAction("myThingUID", "actionID", {"param1": "value1"})
550
+ print(result)
551
+ ```
552
+
553
+ ---
554
+
555
+ ### Addons
556
+
557
+ The `Addons` class provides methods for interacting with the openHAB add-ons via the REST API.
558
+
559
+ #### Methods
560
+
561
+ ##### `getAddons(serviceID: str = None, language: str = None) -> dict`
562
+
563
+ Retrieves a list of all available add-ons.
564
+
565
+ **Parameters:**
566
+ - `serviceID` (str, optional): Filter by service ID.
567
+ - `language` (str, optional): Language preference for the response.
568
+
569
+ **Returns:** A dictionary containing add-ons data.
570
+
571
+ ##### `getAddon(addonID: str, serviceID: str = None, language: str = None) -> dict`
572
+
573
+ Retrieves details of a specific add-on by its ID.
574
+
575
+ **Parameters:**
576
+ - `addonID` (str): The unique identifier of the add-on.
577
+ - `serviceID` (str, optional): Filter by service ID.
578
+ - `language` (str, optional): Language preference for the response.
579
+
580
+ **Returns:** A dictionary containing details of the specified add-on.
581
+
582
+ ##### `getAddonConfig(addonID: str, serviceID: str = None) -> dict`
583
+
584
+ Retrieves the configuration of a specific add-on.
585
+
586
+ **Parameters:**
587
+ - `addonID` (str): The unique identifier of the add-on.
588
+ - `serviceID` (str, optional): Filter by service ID.
589
+
590
+ **Returns:** A dictionary containing the configuration of the add-on.
591
+
592
+ ##### `updateAddonConfig(addonID: str, configData: dict, serviceID: str = None) -> dict`
593
+
594
+ Updates the configuration of a specific add-on.
595
+
596
+ **Parameters:**
597
+ - `addonID` (str): The unique identifier of the add-on.
598
+ - `configData` (dict): Dictionary containing new configuration settings.
599
+ - `serviceID` (str, optional): Specify the target service.
600
+
601
+ **Returns:** A dictionary containing the updated configuration.
602
+
603
+ ##### `installAddon(addonID: str, serviceID: str = None) -> dict`
604
+
605
+ Installs an add-on by its ID.
606
+
607
+ **Parameters:**
608
+ - `addonID` (str): The unique identifier of the add-on.
609
+ - `serviceID` (str, optional): Specify the target service.
610
+
611
+ **Returns:** A dictionary containing the installation status.
612
+
613
+ ##### `uninstallAddon(addonID: str, serviceID: str = None) -> dict`
614
+
615
+ Uninstalls an add-on by its ID.
616
+
617
+ **Parameters:**
618
+ - `addonID` (str): The unique identifier of the add-on.
619
+ - `serviceID` (str, optional): Specify the target service.
620
+
621
+ **Returns:** A dictionary containing the uninstallation status.
622
+
623
+ ##### `getAddonServices(language: str = None) -> dict`
624
+
625
+ Retrieves a list of all available add-on services.
626
+
627
+ **Parameters:**
628
+ - `language` (str, optional): Language preference for the response.
629
+
630
+ **Returns:** A dictionary containing available add-on services.
631
+
632
+ ##### `getAddonSuggestions(language: str = None) -> dict`
633
+
634
+ Retrieves a list of suggested add-ons for installation.
635
+
636
+ **Parameters:**
637
+ - `language` (str, optional): Language preference for the response.
638
+
639
+ **Returns:** A dictionary containing suggested add-ons.
640
+
641
+ ##### `getAddonTypes(serviceID: str = None, language: str = None) -> dict`
642
+
643
+ Retrieves a list of all available add-on types.
644
+
645
+ **Parameters:**
646
+ - `serviceID` (str, optional): Filter by service ID.
647
+ - `language` (str, optional): Language preference for the response.
648
+
649
+ **Returns:** A dictionary containing available add-on types.
650
+
651
+ ##### `installAddonFromUrl(url: str) -> dict`
652
+
653
+ Installs an add-on from a given URL.
654
+
655
+ **Parameters:**
656
+ - `url` (str): The URL of the add-on to install.
657
+
658
+ **Returns:** A dictionary containing the installation status.
659
+
660
+ ---
661
+
662
+ ### AsyncAddons
663
+
664
+ The `AsyncAddons` class is the asynchronous counterpart to `Addons`. It provides the same methods as `Addons`, each as a coroutine prefixed with `async`:
665
+
666
+ - `async getAddons(serviceID, language)`
667
+ - `async getAddon(addonID, serviceID, language)`
668
+ - `async getAddonConfig(addonID, serviceID)`
669
+ - `async updateAddonConfig(addonID, configData, serviceID)`
670
+ - `async installAddon(addonID, serviceID)`
671
+ - `async uninstallAddon(addonID, serviceID)`
672
+ - `async getAddonServices(language)`
673
+ - `async getAddonSuggestions(language)`
674
+ - `async getAddonTypes(serviceID, language)`
675
+ - `async installAddonFromUrl(url)`
676
+
677
+ ---
678
+
679
+ ### Audio
680
+
681
+ The `Audio` class provides methods for interacting with the openHAB audio API. It allows retrieving default audio sinks and sources, as well as listing all available sinks and sources.
682
+
683
+ #### Initialization
684
+
685
+ ```python
686
+ from openhab import OpenHABClient, Audio
687
+
688
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
689
+ audio = Audio(client)
690
+ ```
691
+
692
+ #### Methods
693
+
694
+ ##### `getDefaultSink(language: str = None) -> dict`
695
+
696
+ Retrieves the default audio sink.
697
+
698
+ **Parameters:**
699
+ - `language` (str, optional): Language for the response.
700
+
701
+ **Returns:** Information about the default sink.
702
+
703
+ ##### `getDefaultSource(language: str = None) -> dict`
704
+
705
+ Retrieves the default audio source.
706
+
707
+ **Parameters:**
708
+ - `language` (str, optional): Language for the response.
709
+
710
+ **Returns:** Information about the default source.
711
+
712
+ ##### `getSinks(language: str = None) -> list`
713
+
714
+ Retrieves a list of all available audio sinks.
715
+
716
+ **Parameters:**
717
+ - `language` (str, optional): Language for the response.
718
+
719
+ **Returns:** A list of available audio sinks.
720
+
721
+ ##### `getSources(language: str = None) -> list`
722
+
723
+ Retrieves a list of all available audio sources.
724
+
725
+ **Parameters:**
726
+ - `language` (str, optional): Language for the response.
727
+
728
+ **Returns:** A list of available audio sources.
729
+
730
+ ---
731
+
732
+ ### AsyncAudio
733
+
734
+ The `AsyncAudio` class is the asynchronous counterpart to `Audio`. It provides the same methods as coroutines:
735
+
736
+ - `async getDefaultSink(language)`
737
+ - `async getDefaultSource(language)`
738
+ - `async getSinks(language)`
739
+ - `async getSources(language)`
740
+
741
+ ---
742
+
743
+ ### Auth
744
+
745
+ The `Auth` class provides methods for handling authentication in openHAB, including retrieving API tokens, revoking tokens, logging out, and managing authentication sessions.
746
+
747
+ #### Initialization
748
+
749
+ ```python
750
+ from openhab import OpenHABClient, Auth
751
+
752
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
753
+ auth = Auth(client)
754
+ ```
755
+
756
+ #### Methods
757
+
758
+ ##### `getAPITokens() -> dict`
759
+
760
+ Retrieves the API tokens associated with the authenticated user.
761
+
762
+ **Returns:** JSON response containing API tokens.
763
+
764
+ ##### `revokeAPIToken(tokenName: str) -> dict`
765
+
766
+ Revokes a specific API token.
767
+
768
+ **Parameters:**
769
+ - `tokenName` (str): The name of the API token to revoke.
770
+
771
+ **Returns:** JSON response confirming the revocation.
772
+
773
+ ##### `logout(refreshToken: str, sessionID: str) -> dict`
774
+
775
+ Terminates the session associated with a given refresh token.
776
+
777
+ **Parameters:**
778
+ - `refreshToken` (str): The refresh token used to delete the session.
779
+ - `sessionID` (str): The session ID associated with the refresh token.
780
+
781
+ **Returns:** JSON response confirming the logout.
782
+
783
+ ##### `getSessions() -> dict`
784
+
785
+ Retrieves the sessions associated with the authenticated user.
786
+
787
+ **Returns:** JSON response containing session details.
788
+
789
+ ##### `getToken(useCookie: bool = False, grantType: str = None, code: str = None, redirectURI: str = None, clientID: str = None, refreshToken: str = None, codeVerifier: str = None) -> dict`
790
+
791
+ Obtains access and refresh tokens.
792
+
793
+ **Parameters:**
794
+ - `useCookie` (bool, optional): Whether to use cookies for the session (default `False`).
795
+ - `grantType` (str, optional): The type of grant being requested.
796
+ - `code` (str, optional): Authorization code for authentication.
797
+ - `redirectURI` (str, optional): Redirect URI for OAuth authentication.
798
+ - `clientID` (str, optional): Client ID for authentication.
799
+ - `refreshToken` (str, optional): Refresh token for token renewal.
800
+ - `codeVerifier` (str, optional): Code verifier for PKCE authentication.
801
+
802
+ **Returns:** JSON response containing access and refresh tokens.
803
+
804
+ ---
805
+
806
+ ### AsyncAuth
807
+
808
+ The `AsyncAuth` class is the asynchronous counterpart to `Auth`. It provides the same methods as coroutines:
809
+
810
+ - `async getAPITokens()`
811
+ - `async revokeAPIToken(tokenName)`
812
+ - `async logout(refreshToken, sessionID)`
813
+ - `async getSessions()`
814
+ - `async getToken(useCookie, grantType, code, redirectURI, clientID, refreshToken, codeVerifier)`
815
+
816
+ ---
817
+
818
+ ### ChannelTypes
819
+
820
+ The `ChannelTypes` class provides methods to interact with openHAB's channel types.
821
+
822
+ #### Initialization
823
+
824
+ ```python
825
+ from openhab import OpenHABClient, ChannelTypes
826
+
827
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
828
+ channelTypes = ChannelTypes(client)
829
+ ```
830
+
831
+ #### Methods
832
+
833
+ ##### `getChannelTypes(prefixes: str = None, language: str = None) -> list`
834
+
835
+ Retrieves all available channel types.
836
+
837
+ **Parameters:**
838
+ - `prefixes` (str, optional): Filter channel types by prefix.
839
+ - `language` (str, optional): Language for the response.
840
+
841
+ **Returns:** A list of available channel types.
842
+
843
+ ##### `getChannelType(channelTypeUID: str, language: str = None) -> dict`
844
+
845
+ Retrieves details of a specific channel type by its UID.
846
+
847
+ **Parameters:**
848
+ - `channelTypeUID` (str): The unique identifier of the channel type.
849
+ - `language` (str, optional): Language for the response.
850
+
851
+ **Returns:** JSON response containing details of the specified channel type.
852
+
853
+ ##### `getLinkableItemTypes(channelTypeUID: str) -> list`
854
+
855
+ Retrieves the item types that can be linked to a specified trigger channel type.
856
+
857
+ **Parameters:**
858
+ - `channelTypeUID` (str): The unique identifier of the channel type.
859
+
860
+ **Returns:** A list of item types that can be linked to the given channel type.
861
+
862
+ ---
863
+
864
+ ### AsyncChannelTypes
865
+
866
+ The `AsyncChannelTypes` class is the asynchronous counterpart to `ChannelTypes`:
867
+
868
+ - `async getChannelTypes(prefixes, language)`
869
+ - `async getChannelType(channelTypeUID, language)`
870
+ - `async getLinkableItemTypes(channelTypeUID)`
871
+
872
+ ---
873
+
874
+ ### ConfigDescriptions
875
+
876
+ The `ConfigDescriptions` class provides methods to interact with openHAB's configuration descriptions.
877
+
878
+ #### Initialization
879
+
880
+ ```python
881
+ from openhab import OpenHABClient, ConfigDescriptions
882
+
883
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
884
+ configDescriptions = ConfigDescriptions(client)
885
+ ```
886
+
887
+ #### Methods
888
+
889
+ ##### `getConfigDescriptions(scheme: str = None, language: str = None) -> list`
890
+
891
+ Retrieves all available configuration descriptions.
892
+
893
+ **Parameters:**
894
+ - `scheme` (str, optional): Filter results by a specific scheme.
895
+ - `language` (str, optional): Language for the response.
896
+
897
+ **Returns:** A list of available configuration descriptions.
898
+
899
+ ##### `getConfigDescription(uri: str, language: str = None) -> dict`
900
+
901
+ Retrieves a specific configuration description by its URI.
902
+
903
+ **Parameters:**
904
+ - `uri` (str): The URI of the requested configuration description.
905
+ - `language` (str, optional): Language for the response.
906
+
907
+ **Returns:** JSON response containing details of the specified configuration description.
908
+
909
+ ---
910
+
911
+ ### AsyncConfigDescriptions
912
+
913
+ The `AsyncConfigDescriptions` class is the asynchronous counterpart to `ConfigDescriptions`:
914
+
915
+ - `async getConfigDescriptions(scheme, language)`
916
+ - `async getConfigDescription(uri, language)`
917
+
918
+ ---
919
+
920
+ ### Discovery
921
+
922
+ The `Discovery` class provides methods to interact with openHAB's discovery service.
923
+
924
+ #### Initialization
925
+
926
+ ```python
927
+ from openhab import OpenHABClient, Discovery
928
+
929
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
930
+ discovery = Discovery(client)
931
+ ```
932
+
933
+ #### Methods
934
+
935
+ ##### `getDiscoveryBindings() -> list`
936
+
937
+ Retrieves all bindings that support discovery.
938
+
939
+ **Returns:** A list of strings representing the bindings that support discovery.
940
+
941
+ ##### `getBindingInfo(bindingID: str, language: str = None) -> dict`
942
+
943
+ Retrieves information about a specific binding.
944
+
945
+ **Parameters:**
946
+ - `bindingID` (str): The ID of the binding.
947
+ - `language` (str, optional): Language for the response.
948
+
949
+ **Returns:** A dictionary containing the binding information.
950
+
951
+ ##### `startBindingScan(bindingID: str, input: str = None) -> int`
952
+
953
+ Starts the asynchronous discovery process for a binding and returns the timeout duration in seconds.
954
+
955
+ **Parameters:**
956
+ - `bindingID` (str): The ID of the binding for which discovery is to be started.
957
+ - `input` (str, optional): Optional input for the scan.
958
+
959
+ **Returns:** Timeout duration of the discovery operation in seconds.
960
+
961
+ ###### Example:
962
+
963
+ ```python
964
+ timeout = discovery.startBindingScan("zwave")
965
+ print(timeout)
966
+ ```
967
+
968
+ ---
969
+
970
+ ### AsyncDiscovery
971
+
972
+ The `AsyncDiscovery` class is the asynchronous counterpart to `Discovery`:
973
+
974
+ - `async getDiscoveryBindings()`
975
+ - `async getBindingInfo(bindingID, language)`
976
+ - `async startBindingScan(bindingID, input)`
977
+
978
+ ---
979
+
980
+ ### Events
981
+
982
+ The `Events` class provides methods to interact with openHAB's event service via SSE. It allows retrieving various event streams.
983
+
984
+ #### Initialization
985
+
986
+ ```python
987
+ from openhab import OpenHABClient, Events
988
+
989
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
990
+ events = Events(client)
991
+ ```
992
+
993
+ #### Methods
994
+
995
+ ##### `getEvents(topics: str = None) -> list`
996
+
997
+ Retrieves a stream of all openHAB events, optionally filtered by topic.
998
+
999
+ **Parameters:**
1000
+ - `topics` (str, optional): Comma-separated list of topics to filter events.
1001
+
1002
+ **Returns:** An SSE response stream.
1003
+
1004
+ ##### `initiateStateTracker() -> str`
1005
+
1006
+ Initiates a new state tracker connection and returns the connection ID.
1007
+
1008
+ **Returns:** A string containing the SSE connection ID.
1009
+
1010
+ ##### `updateSSEConnectionItems(connectionID: str, items: list) -> str`
1011
+
1012
+ Updates the items tracked by an existing SSE state tracker connection.
1013
+
1014
+ **Parameters:**
1015
+ - `connectionID` (str): The ID of the SSE connection to update.
1016
+ - `items` (list): A list of item names to track.
1017
+
1018
+ **Returns:** The response from the server.
1019
+
1020
+ ---
1021
+
1022
+ ### ItemEvents
1023
+
1024
+ The `ItemEvents` class provides SSE streams for item-related events.
1025
+
1026
+ #### Initialization
1027
+
1028
+ ```python
1029
+ from openhab import OpenHABClient, ItemEvents
1030
+
1031
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1032
+ itemEvents = ItemEvents(client)
1033
+ ```
1034
+
1035
+ #### Methods
1036
+
1037
+ ##### `ItemEvent()`
1038
+
1039
+ Subscribes to all item events.
1040
+
1041
+ ##### `ItemAddedEvent(itemName: str = "*")`
1042
+
1043
+ Subscribes to item added events.
1044
+
1045
+ **Parameters:**
1046
+ - `itemName` (str, optional): The name of the item to filter by (default `"*"` for all items).
1047
+
1048
+ ##### `ItemRemovedEvent(itemName: str = "*")`
1049
+
1050
+ Subscribes to item removed events.
1051
+
1052
+ ##### `ItemUpdatedEvent(itemName: str = "*")`
1053
+
1054
+ Subscribes to item updated events.
1055
+
1056
+ ##### `ItemCommandEvent(itemName: str = "*")`
1057
+
1058
+ Subscribes to item command events.
1059
+
1060
+ ##### `ItemStateEvent(itemName: str = "*")`
1061
+
1062
+ Subscribes to item state events.
1063
+
1064
+ ##### `ItemStatePredictedEvent(itemName: str = "*")`
1065
+
1066
+ Subscribes to item state predicted events.
1067
+
1068
+ ##### `ItemStateChangedEvent(itemName: str = "*")`
1069
+
1070
+ Subscribes to item state changed events.
1071
+
1072
+ **Parameters:**
1073
+ - `itemName` (str, optional): The name of the item to filter by (default `"*"` for all items).
1074
+
1075
+ **Returns:** An SSE response stream.
1076
+
1077
+ ###### Example:
1078
+
1079
+ ```python
1080
+ response = itemEvents.ItemStateChangedEvent()
1081
+
1082
+ with response as events:
1083
+ for line in events.iter_lines():
1084
+ line = line.decode()
1085
+ if "data" in line:
1086
+ line = line.replace("data: ", "")
1087
+ try:
1088
+ data = json.loads(line)
1089
+ print(data)
1090
+ except json.decoder.JSONDecodeError:
1091
+ print("Event could not be decoded as JSON")
1092
+ ```
1093
+
1094
+ ##### `GroupItemStateChangedEvent(itemName: str, memberName: str)`
1095
+
1096
+ Subscribes to group item state changed events for a specific member.
1097
+
1098
+ **Parameters:**
1099
+ - `itemName` (str): The name of the group item.
1100
+ - `memberName` (str): The name of the member item.
1101
+
1102
+ ---
1103
+
1104
+ ### ThingEvents
1105
+
1106
+ The `ThingEvents` class provides SSE streams for thing-related events.
1107
+
1108
+ #### Methods
1109
+
1110
+ ##### `ThingAddedEvent(thingUID: str = "*")`
1111
+
1112
+ Subscribes to thing added events.
1113
+
1114
+ ##### `ThingRemovedEvent(thingUID: str = "*")`
1115
+
1116
+ Subscribes to thing removed events.
1117
+
1118
+ ##### `ThingUpdatedEvent(thingUID: str = "*")`
1119
+
1120
+ Subscribes to thing updated events.
1121
+
1122
+ ##### `ThingStatusInfoEvent(thingUID: str = "*")`
1123
+
1124
+ Subscribes to thing status info events.
1125
+
1126
+ ##### `ThingStatusInfoChangedEvent(thingUID: str = "*")`
1127
+
1128
+ Subscribes to thing status info changed events.
1129
+
1130
+ ---
1131
+
1132
+ ### InboxEvents
1133
+
1134
+ The `InboxEvents` class provides SSE streams for inbox-related events.
1135
+
1136
+ #### Methods
1137
+
1138
+ ##### `InboxAddedEvent(thingUID: str = "*")`
1139
+
1140
+ Subscribes to inbox added events.
1141
+
1142
+ ##### `InboxRemovedEvent(thingUID: str = "*")`
1143
+
1144
+ Subscribes to inbox removed events.
1145
+
1146
+ ##### `InboxUpdatedEvent(thingUID: str = "*")`
1147
+
1148
+ Subscribes to inbox updated events.
1149
+
1150
+ ---
1151
+
1152
+ ### LinkEvents
1153
+
1154
+ The `LinkEvents` class provides SSE streams for link-related events.
1155
+
1156
+ #### Methods
1157
+
1158
+ ##### `ItemChannelLinkAddedEvent(itemName: str = "*", channelUID: str = "*")`
1159
+
1160
+ Subscribes to item-channel link added events.
1161
+
1162
+ **Parameters:**
1163
+ - `itemName` (str, optional): Filter by item name (default `"*"`).
1164
+ - `channelUID` (str, optional): Filter by channel UID (default `"*"`).
1165
+
1166
+ ##### `ItemChannelLinkRemovedEvent(itemName: str = "*", channelUID: str = "*")`
1167
+
1168
+ Subscribes to item-channel link removed events.
1169
+
1170
+ ---
1171
+
1172
+ ### ChannelEvents
1173
+
1174
+ The `ChannelEvents` class provides SSE streams for channel-related events.
1175
+
1176
+ #### Methods
1177
+
1178
+ ##### `ChannelDescriptionChangedEvent(channelUID: str = "*")`
1179
+
1180
+ Subscribes to channel description changed events.
1181
+
1182
+ **Parameters:**
1183
+ - `channelUID` (str, optional): Filter by channel UID (default `"*"`).
1184
+
1185
+ ##### `ChannelTriggeredEvent(channelUID: str = "*")`
1186
+
1187
+ Subscribes to channel triggered events.
1188
+
1189
+ ---
1190
+
1191
+ ### AsyncEvents
1192
+
1193
+ The `AsyncEvents` class is the asynchronous counterpart to `Events`:
1194
+
1195
+ - `async getEvents(topics)`
1196
+ - `async initiateStateTracker()`
1197
+ - `async updateSSEConnectionItems(connectionID, items)`
1198
+
1199
+ ### AsyncItemEvents
1200
+
1201
+ The `AsyncItemEvents` class is the asynchronous counterpart to `ItemEvents`:
1202
+
1203
+ - `async ItemEvent()`
1204
+ - `async ItemAddedEvent(itemName)`
1205
+ - `async ItemRemovedEvent(itemName)`
1206
+ - `async ItemUpdatedEvent(itemName)`
1207
+ - `async ItemCommandEvent(itemName)`
1208
+ - `async ItemStateEvent(itemName)`
1209
+ - `async ItemStatePredictedEvent(itemName)`
1210
+ - `async ItemStateChangedEvent(itemName)`
1211
+ - `async GroupItemStateChangedEvent(itemName, memberName)`
1212
+
1213
+ ### AsyncThingEvents
1214
+
1215
+ The `AsyncThingEvents` class is the asynchronous counterpart to `ThingEvents`:
1216
+
1217
+ - `async ThingAddedEvent(thingUID)`
1218
+ - `async ThingRemovedEvent(thingUID)`
1219
+ - `async ThingUpdatedEvent(thingUID)`
1220
+ - `async ThingStatusInfoEvent(thingUID)`
1221
+ - `async ThingStatusInfoChangedEvent(thingUID)`
1222
+
1223
+ ### AsyncInboxEvents
1224
+
1225
+ The `AsyncInboxEvents` class is the asynchronous counterpart to `InboxEvents`:
1226
+
1227
+ - `async InboxAddedEvent(thingUID)`
1228
+ - `async InboxRemovedEvent(thingUID)`
1229
+ - `async InboxUpdatedEvent(thingUID)`
1230
+
1231
+ ### AsyncLinkEvents
1232
+
1233
+ The `AsyncLinkEvents` class is the asynchronous counterpart to `LinkEvents`:
1234
+
1235
+ - `async ItemChannelLinkAddedEvent(itemName, channelUID)`
1236
+ - `async ItemChannelLinkRemovedEvent(itemName, channelUID)`
1237
+
1238
+ ### AsyncChannelEvents
1239
+
1240
+ The `AsyncChannelEvents` class is the asynchronous counterpart to `ChannelEvents`:
1241
+
1242
+ - `async ChannelDescriptionChangedEvent(channelUID)`
1243
+ - `async ChannelTriggeredEvent(channelUID)`
1244
+
1245
+ ---
1246
+
1247
+ ### Iconsets
1248
+
1249
+ The `Iconsets` class provides methods to interact with openHAB's iconsets.
1250
+
1251
+ #### Methods
1252
+
1253
+ ##### `getIconsets(language: str = None) -> list`
1254
+
1255
+ Retrieves all available iconsets.
1256
+
1257
+ **Parameters:**
1258
+ - `language` (str, optional): Language for the response.
1259
+
1260
+ **Returns:** A list of available iconsets.
1261
+
1262
+ ---
1263
+
1264
+ ### AsyncIconsets
1265
+
1266
+ The `AsyncIconsets` class is the asynchronous counterpart to `Iconsets`:
1267
+
1268
+ - `async getIconsets(language)`
1269
+
1270
+ ---
1271
+
1272
+ ### Inbox
1273
+
1274
+ The `Inbox` class provides methods to interact with the openHAB inbox, which contains discovery results.
1275
+
1276
+ #### Initialization
1277
+
1278
+ ```python
1279
+ from openhab import OpenHABClient, Inbox
1280
+
1281
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1282
+ inbox = Inbox(client)
1283
+ ```
1284
+
1285
+ #### Methods
1286
+
1287
+ ##### `getDiscoveredThings(includeIgnored: bool = True) -> list`
1288
+
1289
+ Retrieves all discovered things from the inbox.
1290
+
1291
+ **Parameters:**
1292
+ - `includeIgnored` (bool, optional): Whether to include ignored results (default `True`).
1293
+
1294
+ **Returns:** A list of discovered things.
1295
+
1296
+ ##### `removeDiscoveryResult(thingUID: str) -> dict`
1297
+
1298
+ Removes a discovery result from the inbox.
1299
+
1300
+ **Parameters:**
1301
+ - `thingUID` (str): The UID of the thing to remove.
1302
+
1303
+ **Returns:** The response from the server.
1304
+
1305
+ ##### `approveDiscoveryResult(thingUID: str, thingLabel: str, newThingID: str = None, language: str = None) -> dict`
1306
+
1307
+ Approves a discovery result and creates the corresponding thing.
1308
+
1309
+ **Parameters:**
1310
+ - `thingUID` (str): The UID of the thing to approve.
1311
+ - `thingLabel` (str): The label for the new thing.
1312
+ - `newThingID` (str, optional): An optional new thing ID.
1313
+ - `language` (str, optional): Language for the response.
1314
+
1315
+ **Returns:** The response from the server.
1316
+
1317
+ ##### `ignoreDiscoveryResult(thingUID: str) -> dict`
1318
+
1319
+ Flags a discovery result as ignored.
1320
+
1321
+ **Parameters:**
1322
+ - `thingUID` (str): The UID of the thing to ignore.
1323
+
1324
+ **Returns:** The response from the server.
1325
+
1326
+ ##### `unignoreDiscoveryResult(thingUID: str) -> dict`
1327
+
1328
+ Removes the ignore flag from a discovery result.
1329
+
1330
+ **Parameters:**
1331
+ - `thingUID` (str): The UID of the thing to unignore.
1332
+
1333
+ **Returns:** The response from the server.
1334
+
1335
+ ---
1336
+
1337
+ ### AsyncInbox
1338
+
1339
+ The `AsyncInbox` class is the asynchronous counterpart to `Inbox`:
1340
+
1341
+ - `async getDiscoveredThings(includeIgnored)`
1342
+ - `async removeDiscoveryResult(thingUID)`
1343
+ - `async approveDiscoveryResult(thingUID, thingLabel, newThingID, language)`
1344
+ - `async ignoreDiscoveryResult(thingUID)`
1345
+ - `async unignoreDiscoveryResult(thingUID)`
1346
+
1347
+ ---
1348
+
1349
+ ### Items
1350
+
1351
+ The `Items` class provides methods to interact with openHAB items via the REST API.
1352
+
1353
+ #### Initialization
1354
+
1355
+ ```python
1356
+ from openhab import OpenHABClient, Items
1357
+
1358
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1359
+ itemsAPI = Items(client)
1360
+ ```
1361
+
1362
+ #### Methods
1363
+
1364
+ ##### `getItems(type: str = None, tags: str = None, metadata: str = ".*", recursive: bool = False, fields: str = None, staticDataOnly: bool = False, language: str = None)`
1365
+
1366
+ Gets all available items.
1367
+
1368
+ **Parameters:**
1369
+ - `type` (str, optional): Item type filter.
1370
+ - `tags` (str, optional): Item tag filter.
1371
+ - `metadata` (str, optional): Metadata selector (default `".*"`).
1372
+ - `recursive` (bool, optional): Fetch group members recursively (default `False`).
1373
+ - `fields` (str, optional): Limit to specific fields (comma-separated).
1374
+ - `staticDataOnly` (bool, optional): Only return cached data (default `False`).
1375
+ - `language` (str, optional): Language for the response.
1376
+
1377
+ **Returns:** A list containing all item data.
1378
+
1379
+ ##### `addOrUpdateItems(items: list)`
1380
+
1381
+ Adds a list of items to the registry or updates existing items.
1382
+
1383
+ **Parameters:**
1384
+ - `items` (list): A list of item data dictionaries.
1385
+
1386
+ **Returns:** Confirmation that the items were successfully added or updated.
1387
+
1388
+ ##### `getItem(itemName: str, metadata: str = ".*", recursive: bool = True, language: str = None)`
1389
+
1390
+ Gets a single item.
1391
+
1392
+ **Parameters:**
1393
+ - `itemName` (str): The name of the item.
1394
+ - `metadata` (str, optional): Metadata selector (default `".*"`).
1395
+ - `recursive` (bool, optional): Fetch group members recursively (default `True`).
1396
+ - `language` (str, optional): Language for the response.
1397
+
1398
+ **Returns:** A dictionary containing the requested item data.
1399
+
1400
+ ##### `addOrUpdateItem(itemName: str, itemData: dict, language: str = None)`
1401
+
1402
+ Adds a new item to the registry or updates the existing item.
1403
+
1404
+ **Parameters:**
1405
+ - `itemName` (str): The name of the item.
1406
+ - `itemData` (dict): The data of the item.
1407
+ - `language` (str, optional): Language for the response.
1408
+
1409
+ **Returns:** Confirmation that the item was successfully added or updated.
1410
+
1411
+ ##### `sendCommand(itemName: str, command: str, source: str = None)`
1412
+
1413
+ Sends a command to an item.
1414
+
1415
+ **Parameters:**
1416
+ - `itemName` (str): The name of the item.
1417
+ - `command` (str): The command to send (e.g., `ON`, `OFF`).
1418
+ - `source` (str, optional): Source of the command, shown in the event (openHAB 4.1+).
1419
+
1420
+ **Returns:** Confirmation that the command was successfully sent.
1421
+
1422
+ ##### `postUpdate(itemName: str, state: str, source: str = None)`
1423
+
1424
+ Updates the state of an item. This is an alias for `updateItemState`.
1425
+
1426
+ **Parameters:**
1427
+ - `itemName` (str): The name of the item.
1428
+ - `state` (str): The state to be set.
1429
+
1430
+ ##### `deleteItem(itemName: str)`
1431
+
1432
+ Removes an item from the registry.
1433
+
1434
+ **Parameters:**
1435
+ - `itemName` (str): The name of the item.
1436
+
1437
+ **Returns:** Confirmation that the item was successfully deleted.
1438
+
1439
+ ##### `addGroupMember(itemName: str, memberItemName: str)`
1440
+
1441
+ Adds a new member to a group item.
1442
+
1443
+ **Parameters:**
1444
+ - `itemName` (str): The name of the group item.
1445
+ - `memberItemName` (str): The name of the member item to add.
1446
+
1447
+ **Returns:** Confirmation that the group member was successfully added.
1448
+
1449
+ ##### `removeGroupMember(itemName: str, memberItemName: str)`
1450
+
1451
+ Removes an existing member from a group item.
1452
+
1453
+ **Parameters:**
1454
+ - `itemName` (str): The name of the group item.
1455
+ - `memberItemName` (str): The name of the member item to remove.
1456
+
1457
+ **Returns:** Confirmation that the group member was successfully removed.
1458
+
1459
+ ##### `addMetadata(itemName: str, namespace: str, metadata: dict)`
1460
+
1461
+ Adds metadata to an item.
1462
+
1463
+ **Parameters:**
1464
+ - `itemName` (str): The name of the item.
1465
+ - `namespace` (str): The namespace of the metadata.
1466
+ - `metadata` (dict): A dictionary containing the metadata.
1467
+
1468
+ **Returns:** Confirmation that the metadata was successfully added.
1469
+
1470
+ ##### `removeMetadata(itemName: str, namespace: str)`
1471
+
1472
+ Removes metadata from an item.
1473
+
1474
+ **Parameters:**
1475
+ - `itemName` (str): The name of the item.
1476
+ - `namespace` (str): The namespace of the metadata to remove.
1477
+
1478
+ **Returns:** Confirmation that the metadata was successfully removed.
1479
+
1480
+ ##### `getMetadataNamespaces(itemName: str, language: str = None)`
1481
+
1482
+ Gets the namespaces of an item.
1483
+
1484
+ **Parameters:**
1485
+ - `itemName` (str): The name of the item.
1486
+ - `language` (str, optional): Language for the response.
1487
+
1488
+ **Returns:** A list of namespaces associated with the item.
1489
+
1490
+ ##### `getSemanticItem(itemName: str, semanticClass: str, language: str = None)`
1491
+
1492
+ Gets the item that defines the requested semantics of an item.
1493
+
1494
+ **Parameters:**
1495
+ - `itemName` (str): The name of the item.
1496
+ - `semanticClass` (str): The requested semantic class.
1497
+ - `language` (str, optional): Language for the response.
1498
+
1499
+ **Returns:** A dictionary containing the semantic item data.
1500
+
1501
+ ##### `getItemState(itemName: str)`
1502
+
1503
+ Gets the state of an item.
1504
+
1505
+ **Parameters:**
1506
+ - `itemName` (str): The name of the item.
1507
+
1508
+ **Returns:** The current state of the item as a string.
1509
+
1510
+ ##### `updateItemState(itemName: str, state: str, language: str = None)`
1511
+
1512
+ Updates the state of an item.
1513
+
1514
+ **Parameters:**
1515
+ - `itemName` (str): The name of the item.
1516
+ - `state` (str): The new state of the item.
1517
+ - `language` (str, optional): Language for the response.
1518
+
1519
+ **Returns:** Confirmation that the state was successfully updated.
1520
+
1521
+ ##### `addTag(itemName: str, tag: str)`
1522
+
1523
+ Adds a tag to an item.
1524
+
1525
+ **Parameters:**
1526
+ - `itemName` (str): The name of the item.
1527
+ - `tag` (str): The tag to add.
1528
+
1529
+ **Returns:** Confirmation that the tag was successfully added.
1530
+
1531
+ ##### `removeTag(itemName: str, tag: str)`
1532
+
1533
+ Removes a tag from an item.
1534
+
1535
+ **Parameters:**
1536
+ - `itemName` (str): The name of the item.
1537
+ - `tag` (str): The tag to remove.
1538
+
1539
+ **Returns:** Confirmation that the tag was successfully removed.
1540
+
1541
+ ##### `purgeOrphanedMetadata()`
1542
+
1543
+ Removes unused/orphaned metadata from all items.
1544
+
1545
+ **Returns:** Confirmation that orphaned metadata was successfully purged.
1546
+
1547
+ ---
1548
+
1549
+ ### AsyncItems
1550
+
1551
+ The `AsyncItems` class is the asynchronous counterpart to `Items`. It provides the same methods as coroutines:
1552
+
1553
+ - `async getItems(type, tags, metadata, recursive, fields, staticDataOnly, language)`
1554
+ - `async addOrUpdateItems(items)`
1555
+ - `async getItem(itemName, metadata, recursive, language)`
1556
+ - `async addOrUpdateItem(itemName, itemData, language)`
1557
+ - `async sendCommand(itemName, command, source)`
1558
+ - `async postUpdate(itemName, state, source)`
1559
+ - `async updateItemState(itemName, state, language, source)`
1560
+ - `async deleteItem(itemName)`
1561
+ - `async addGroupMember(itemName, memberItemName)`
1562
+ - `async removeGroupMember(itemName, memberItemName)`
1563
+ - `async addMetadata(itemName, namespace, metadata)`
1564
+ - `async removeMetadata(itemName, namespace)`
1565
+ - `async getMetadataNamespaces(itemName, language)`
1566
+ - `async getSemanticItem(itemName, semanticClass, language)`
1567
+ - `async getItemState(itemName)`
1568
+ - `async updateItemState(itemName, state, language)`
1569
+ - `async addTag(itemName, tag)`
1570
+ - `async removeTag(itemName, tag)`
1571
+ - `async purgeOrphanedMetadata()`
1572
+
1573
+ ---
1574
+
1575
+ ### Links
1576
+
1577
+ The `Links` class provides methods to interact with openHAB item-channel links.
1578
+
1579
+ #### Initialization
1580
+
1581
+ ```python
1582
+ from openhab import OpenHABClient, Links
1583
+
1584
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1585
+ links = Links(client)
1586
+ ```
1587
+
1588
+ #### Methods
1589
+
1590
+ ##### `getLinks(channelUID: str = None, itemName: str = None) -> list`
1591
+
1592
+ Gets all available links, optionally filtered by channel UID or item name.
1593
+
1594
+ **Parameters:**
1595
+ - `channelUID` (str, optional): Filter by channel UID.
1596
+ - `itemName` (str, optional): Filter by item name.
1597
+
1598
+ **Returns:** A list of links.
1599
+
1600
+ ##### `getLink(itemName: str, channelUID: str) -> dict`
1601
+
1602
+ Retrieves an individual link between an item and a channel.
1603
+
1604
+ **Parameters:**
1605
+ - `itemName` (str): The name of the item.
1606
+ - `channelUID` (str): The UID of the channel.
1607
+
1608
+ **Returns:** The link details.
1609
+
1610
+ ##### `linkItemToChannel(itemName: str, channelUID: str, configuration: dict) -> dict`
1611
+
1612
+ Links an item to a channel.
1613
+
1614
+ **Parameters:**
1615
+ - `itemName` (str): The name of the item.
1616
+ - `channelUID` (str): The UID of the channel.
1617
+ - `configuration` (dict): The configuration for the link.
1618
+
1619
+ **Returns:** The API response when the link is successfully created.
1620
+
1621
+ ##### `unlinkItemFromChannel(itemName: str, channelUID: str) -> dict`
1622
+
1623
+ Unlinks an item from a channel.
1624
+
1625
+ **Parameters:**
1626
+ - `itemName` (str): The name of the item.
1627
+ - `channelUID` (str): The UID of the channel.
1628
+
1629
+ **Returns:** The API response when the link is successfully removed.
1630
+
1631
+ ##### `deleteAllLinks(object: str) -> dict`
1632
+
1633
+ Deletes all links that refer to an item or thing.
1634
+
1635
+ **Parameters:**
1636
+ - `object` (str): The name of the item or the UID of the thing.
1637
+
1638
+ **Returns:** The API response when all links are successfully deleted.
1639
+
1640
+ ##### `getOrphanLinks() -> list`
1641
+
1642
+ Gets orphan links between items and broken/non-existent thing channels.
1643
+
1644
+ **Returns:** A list of orphan links.
1645
+
1646
+ ##### `purgeUnusedLinks() -> dict`
1647
+
1648
+ Removes all unused/orphaned links.
1649
+
1650
+ **Returns:** The API response when the links are successfully removed.
1651
+
1652
+ ---
1653
+
1654
+ ### AsyncLinks
1655
+
1656
+ The `AsyncLinks` class is the asynchronous counterpart to `Links`:
1657
+
1658
+ - `async getLinks(channelUID, itemName)`
1659
+ - `async getLink(itemName, channelUID)`
1660
+ - `async linkItemToChannel(itemName, channelUID, configuration)`
1661
+ - `async unlinkItemFromChannel(itemName, channelUID)`
1662
+ - `async deleteAllLinks(object)`
1663
+ - `async getOrphanLinks()`
1664
+ - `async purgeUnusedLinks()`
1665
+
1666
+ ---
1667
+
1668
+ ### Logging
1669
+
1670
+ The `Logging` class provides methods to interact with the openHAB logging system.
1671
+
1672
+ #### Initialization
1673
+
1674
+ ```python
1675
+ from openhab import OpenHABClient, Logging
1676
+
1677
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1678
+ logging_api = Logging(client)
1679
+ ```
1680
+
1681
+ #### Methods
1682
+
1683
+ ##### `getLoggers() -> dict`
1684
+
1685
+ Gets all current loggers and their levels.
1686
+
1687
+ **Returns:** A dictionary containing all loggers.
1688
+
1689
+ ##### `getLogger(loggerName: str) -> dict`
1690
+
1691
+ Gets a specific logger by name.
1692
+
1693
+ **Parameters:**
1694
+ - `loggerName` (str): The name of the logger.
1695
+
1696
+ **Returns:** A dictionary containing the logger details.
1697
+
1698
+ ##### `modifyOrAddLogger(loggerName: str, level: str) -> dict`
1699
+
1700
+ Modifies an existing logger or adds a new one.
1701
+
1702
+ **Parameters:**
1703
+ - `loggerName` (str): The name of the logger.
1704
+ - `level` (str): The log level (e.g., `DEBUG`, `INFO`, `WARN`, `ERROR`).
1705
+
1706
+ **Returns:** The response from the server.
1707
+
1708
+ ##### `removeLogger(loggerName: str) -> dict`
1709
+
1710
+ Removes a logger by name.
1711
+
1712
+ **Parameters:**
1713
+ - `loggerName` (str): The name of the logger to remove.
1714
+
1715
+ **Returns:** The response from the server.
1716
+
1717
+ ---
1718
+
1719
+ ### AsyncLogging
1720
+
1721
+ The `AsyncLogging` class is the asynchronous counterpart to `Logging`:
1722
+
1723
+ - `async getLoggers()`
1724
+ - `async getLogger(loggerName)`
1725
+ - `async modifyOrAddLogger(loggerName, level)`
1726
+ - `async removeLogger(loggerName)`
1727
+
1728
+ ---
1729
+
1730
+ ### ModuleTypes
1731
+
1732
+ The `ModuleTypes` class provides methods to retrieve openHAB rule module types.
1733
+
1734
+ #### Methods
1735
+
1736
+ ##### `getModuleTypes(tags=None, typeFilter=None, language: str = None)`
1737
+
1738
+ Gets all available module types.
1739
+
1740
+ **Parameters:**
1741
+ - `tags` (optional): Filter by tags.
1742
+ - `typeFilter` (optional): Filter by type (e.g., `trigger`, `condition`, `action`).
1743
+ - `language` (str, optional): Language for the response.
1744
+
1745
+ **Returns:** A list of module types.
1746
+
1747
+ ##### `getModuleType(moduleTypeUID, language: str = None)`
1748
+
1749
+ Gets a specific module type by its UID.
1750
+
1751
+ **Parameters:**
1752
+ - `moduleTypeUID`: The UID of the module type.
1753
+ - `language` (str, optional): Language for the response.
1754
+
1755
+ **Returns:** The module type details.
1756
+
1757
+ ---
1758
+
1759
+ ### AsyncModuleTypes
1760
+
1761
+ The `AsyncModuleTypes` class is the asynchronous counterpart to `ModuleTypes`:
1762
+
1763
+ - `async getModuleTypes(tags, typeFilter, language)`
1764
+ - `async getModuleType(moduleTypeUID, language)`
1765
+
1766
+ ---
1767
+
1768
+ ### Persistence
1769
+
1770
+ The `Persistence` class provides methods to interact with openHAB's persistence services.
1771
+
1772
+ #### Initialization
1773
+
1774
+ ```python
1775
+ from openhab import OpenHABClient, Persistence
1776
+
1777
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1778
+ persistence = Persistence(client)
1779
+ ```
1780
+
1781
+ #### Methods
1782
+
1783
+ ##### `getServices(language: str = None) -> dict`
1784
+
1785
+ Gets a list of persistence services.
1786
+
1787
+ **Parameters:**
1788
+ - `language` (str, optional): Language for the response.
1789
+
1790
+ **Returns:** A list of persistence services with IDs, labels, and types.
1791
+
1792
+ ##### `getServiceConfiguration(serviceID: str) -> dict`
1793
+
1794
+ Gets the configuration of a specific persistence service.
1795
+
1796
+ **Parameters:**
1797
+ - `serviceID` (str): The ID of the persistence service.
1798
+
1799
+ **Returns:** The configuration of the service.
1800
+
1801
+ ##### `setServiceConfiguration(serviceID: str, config: dict) -> dict`
1802
+
1803
+ Sets the configuration of a persistence service.
1804
+
1805
+ **Parameters:**
1806
+ - `serviceID` (str): The ID of the persistence service.
1807
+ - `config` (dict): The configuration data.
1808
+
1809
+ **Returns:** The response from the API after modification.
1810
+
1811
+ ##### `deleteServiceConfiguration(serviceID: str) -> dict`
1812
+
1813
+ Deletes the configuration of a persistence service.
1814
+
1815
+ **Parameters:**
1816
+ - `serviceID` (str): The ID of the persistence service.
1817
+
1818
+ **Returns:** The response from the API after deleting the configuration.
1819
+
1820
+ ##### `getItemsFromService(serviceID: str = None, itemName: str = None) -> list`
1821
+
1822
+ Gets a list of items available via a specific persistence service. Not every
1823
+ service provides this information (rrd4j does not, inmemory and JDBC do).
1824
+
1825
+ **Parameters:**
1826
+ - `serviceID` (str, optional): The ID of the persistence service.
1827
+ - `itemName` (str, optional): Only return information for this item.
1828
+
1829
+ **Returns:** A list of items with their last and earliest timestamps.
1830
+
1831
+ ##### `getItemPersistenceData(itemName: str, serviceID: str = None, startTime: str = None, endTime: str = None, page: int = None, pageLength: int = None, boundary: bool = False, itemState: bool = False, displayState: bool = None, language: str = None) -> dict`
1832
+
1833
+ Gets item persistence data from a persistence service.
1834
+
1835
+ **Parameters:**
1836
+ - `itemName` (str): The name of the item.
1837
+ - `serviceID` (str, optional): The ID of the persistence service (default service if omitted).
1838
+ - `startTime` (str, optional): Start time in ISO 8601, e.g. `2026-10-30T00:00:00.000Z` (default: one day before `endTime`).
1839
+ - `endTime` (str, optional): End time in ISO 8601 (default: now).
1840
+ - `page` (int, optional): Page number, **starting at 0**. Only used together with `pageLength`.
1841
+ - `pageLength` (int, optional): Data points per page. Without it, all data points of the time range are returned.
1842
+ - `boundary` (bool, optional): Also return the values just outside the time range (default `False`).
1843
+ - `itemState` (bool, optional): Append the current item state (default `False`).
1844
+ - `displayState` (bool, optional): Add a formatted display state to every data point (openHAB 5.0+).
1845
+ - `language` (str, optional): `Accept-Language` header.
1846
+
1847
+ **Returns:** The retrieved data points of the item.
1848
+
1849
+ ##### `storeItemData(itemName: str, time: str, state: str, serviceID: str = None) -> dict`
1850
+
1851
+ Stores item persistence data into a persistence service.
1852
+
1853
+ **Parameters:**
1854
+ - `itemName` (str): The name of the item.
1855
+ - `time` (str): The timestamp for the data point.
1856
+ - `state` (str): The state value to store.
1857
+ - `serviceID` (str, optional): The ID of the persistence service.
1858
+
1859
+ **Returns:** The response from the API after storing the data.
1860
+
1861
+ ##### `deleteItemData(itemName: str, startTime: str, endTime: str, serviceID: str) -> dict`
1862
+
1863
+ Deletes item persistence data from a persistence service within a given time range.
1864
+
1865
+ **Parameters:**
1866
+ - `itemName` (str): The name of the item.
1867
+ - `startTime` (str): The start time of the data to delete.
1868
+ - `endTime` (str): The end time of the data to delete.
1869
+ - `serviceID` (str): The ID of the persistence service.
1870
+
1871
+ **Returns:** The response from the API after deleting the data.
1872
+
1873
+ ---
1874
+
1875
+ ### AsyncPersistence
1876
+
1877
+ The `AsyncPersistence` class is the asynchronous counterpart to `Persistence`:
1878
+
1879
+ - `async getServices(language)`
1880
+ - `async getServiceConfiguration(serviceID)`
1881
+ - `async setServiceConfiguration(serviceID, config)`
1882
+ - `async deleteServiceConfiguration(serviceID)`
1883
+ - `async getItemsFromService(serviceID, itemName)`
1884
+ - `async getItemPersistenceData(itemName, serviceID, startTime, endTime, page, pageLength, boundary, itemState, displayState, language)`
1885
+ - `async storeItemData(itemName, time, state, serviceID)`
1886
+ - `async deleteItemData(itemName, startTime, endTime, serviceID)`
1887
+
1888
+ ---
1889
+
1890
+ ### ProfileTypes
1891
+
1892
+ The `ProfileTypes` class provides methods to retrieve openHAB profile types.
1893
+
1894
+ #### Methods
1895
+
1896
+ ##### `getProfileTypes(channelTypeUID=None, itemType=None, language: str = None)`
1897
+
1898
+ Gets all available profile types.
1899
+
1900
+ **Parameters:**
1901
+ - `channelTypeUID` (optional): Filter by channel type UID.
1902
+ - `itemType` (optional): Filter by item type.
1903
+ - `language` (str, optional): Language for the response.
1904
+
1905
+ **Returns:** A list of profile types.
1906
+
1907
+ ---
1908
+
1909
+ ### AsyncProfileTypes
1910
+
1911
+ The `AsyncProfileTypes` class is the asynchronous counterpart to `ProfileTypes`:
1912
+
1913
+ - `async getProfileTypes(channelTypeUID, itemType, language)`
1914
+
1915
+ ---
1916
+
1917
+ ### Rules
1918
+
1919
+ The `Rules` class provides methods to interact with openHAB's rule engine.
1920
+
1921
+ #### Initialization
1922
+
1923
+ ```python
1924
+ from openhab import OpenHABClient, Rules
1925
+
1926
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1927
+ rules = Rules(client)
1928
+ ```
1929
+
1930
+ #### Methods
1931
+
1932
+ ##### `getRules(prefix=None, tags=None, summary=False, staticDataOnly=False)`
1933
+
1934
+ Gets all available rules.
1935
+
1936
+ **Parameters:**
1937
+ - `prefix` (optional): Filter by rule UID prefix.
1938
+ - `tags` (optional): Filter by tags.
1939
+ - `summary` (bool, optional): Return summary only (default `False`).
1940
+ - `staticDataOnly` (bool, optional): Return only cached data (default `False`).
1941
+
1942
+ **Returns:** A list of rules.
1943
+
1944
+ ##### `createRule(ruleData: dict)`
1945
+
1946
+ Creates a new rule.
1947
+
1948
+ **Parameters:**
1949
+ - `ruleData` (dict): The rule data.
1950
+
1951
+ **Returns:** The response from the server.
1952
+
1953
+ ##### `getRule(ruleUID: str)`
1954
+
1955
+ Gets a specific rule by its UID.
1956
+
1957
+ **Parameters:**
1958
+ - `ruleUID` (str): The UID of the rule.
1959
+
1960
+ **Returns:** The rule details.
1961
+
1962
+ ##### `updateRule(ruleUID: str, ruleData: dict)`
1963
+
1964
+ Updates an existing rule.
1965
+
1966
+ **Parameters:**
1967
+ - `ruleUID` (str): The UID of the rule to update.
1968
+ - `ruleData` (dict): The new rule data.
1969
+
1970
+ **Returns:** The response from the server.
1971
+
1972
+ ##### `deleteRule(ruleUID: str)`
1973
+
1974
+ Deletes a rule.
1975
+
1976
+ **Parameters:**
1977
+ - `ruleUID` (str): The UID of the rule to delete.
1978
+
1979
+ **Returns:** The response from the server.
1980
+
1981
+ ##### `getModule(ruleUID: str, moduleCategory: str, moduleID: str)`
1982
+
1983
+ Gets a specific module of a rule.
1984
+
1985
+ **Parameters:**
1986
+ - `ruleUID` (str): The UID of the rule.
1987
+ - `moduleCategory` (str): The category of the module (e.g., `triggers`, `conditions`, `actions`).
1988
+ - `moduleID` (str): The ID of the module.
1989
+
1990
+ **Returns:** The module details.
1991
+
1992
+ ##### `getModuleConfig(ruleUID: str, moduleCategory: str, moduleID: str)`
1993
+
1994
+ Gets the configuration of a specific module.
1995
+
1996
+ **Parameters:**
1997
+ - `ruleUID` (str): The UID of the rule.
1998
+ - `moduleCategory` (str): The module category.
1999
+ - `moduleID` (str): The module ID.
2000
+
2001
+ **Returns:** The module configuration.
2002
+
2003
+ ##### `getModuleConfigParam(ruleUID: str, moduleCategory: str, moduleID: str, param: str)`
2004
+
2005
+ Gets a specific configuration parameter of a module.
2006
+
2007
+ **Parameters:**
2008
+ - `ruleUID` (str): The UID of the rule.
2009
+ - `moduleCategory` (str): The module category.
2010
+ - `moduleID` (str): The module ID.
2011
+ - `param` (str): The name of the parameter.
2012
+
2013
+ **Returns:** The parameter value.
2014
+
2015
+ ##### `setModuleConfigParam(ruleUID: str, moduleCategory: str, moduleID: str, param: str, value: str)`
2016
+
2017
+ Sets a specific configuration parameter of a module.
2018
+
2019
+ **Parameters:**
2020
+ - `ruleUID` (str): The UID of the rule.
2021
+ - `moduleCategory` (str): The module category.
2022
+ - `moduleID` (str): The module ID.
2023
+ - `param` (str): The name of the parameter.
2024
+ - `value` (str): The value to set.
2025
+
2026
+ **Returns:** The response from the server.
2027
+
2028
+ ##### `getActions(ruleUID: str)`
2029
+
2030
+ Gets the actions of a rule.
2031
+
2032
+ **Parameters:**
2033
+ - `ruleUID` (str): The UID of the rule.
2034
+
2035
+ **Returns:** A list of action modules.
2036
+
2037
+ ##### `getConditions(ruleUID: str)`
2038
+
2039
+ Gets the conditions of a rule.
2040
+
2041
+ **Parameters:**
2042
+ - `ruleUID` (str): The UID of the rule.
2043
+
2044
+ **Returns:** A list of condition modules.
2045
+
2046
+ ##### `getTriggers(ruleUID: str)`
2047
+
2048
+ Gets the triggers of a rule.
2049
+
2050
+ **Parameters:**
2051
+ - `ruleUID` (str): The UID of the rule.
2052
+
2053
+ **Returns:** A list of trigger modules.
2054
+
2055
+ ##### `getConfiguration(ruleUID: str)`
2056
+
2057
+ Gets the configuration of a rule.
2058
+
2059
+ **Parameters:**
2060
+ - `ruleUID` (str): The UID of the rule.
2061
+
2062
+ **Returns:** The rule configuration.
2063
+
2064
+ ##### `updateConfiguration(ruleUID: str, configData: dict)`
2065
+
2066
+ Updates the configuration of a rule.
2067
+
2068
+ **Parameters:**
2069
+ - `ruleUID` (str): The UID of the rule.
2070
+ - `configData` (dict): The new configuration data.
2071
+
2072
+ **Returns:** The response from the server.
2073
+
2074
+ ##### `setRuleState(ruleUID: str, enable: bool)`
2075
+
2076
+ Enables or disables a rule.
2077
+
2078
+ **Parameters:**
2079
+ - `ruleUID` (str): The UID of the rule.
2080
+ - `enable` (bool): `True` to enable, `False` to disable.
2081
+
2082
+ **Returns:** The response from the server.
2083
+
2084
+ ##### `enable(ruleUID: str)`
2085
+
2086
+ Enables a rule. Convenience wrapper for `setRuleState(ruleUID, True)`.
2087
+
2088
+ ##### `disable(ruleUID: str)`
2089
+
2090
+ Disables a rule. Convenience wrapper for `setRuleState(ruleUID, False)`.
2091
+
2092
+ ##### `runNow(ruleUID: str, contextData: dict = None)`
2093
+
2094
+ Executes a rule immediately.
2095
+
2096
+ **Parameters:**
2097
+ - `ruleUID` (str): The UID of the rule to run.
2098
+ - `contextData` (dict, optional): Optional context data for the rule execution.
2099
+
2100
+ **Returns:** The response from the server.
2101
+
2102
+ ##### `simulateSchedule(fromTime: str, untilTime: str)`
2103
+
2104
+ Simulates the rule schedule between two timestamps.
2105
+
2106
+ **Parameters:**
2107
+ - `fromTime` (str): The start timestamp.
2108
+ - `untilTime` (str): The end timestamp.
2109
+
2110
+ **Returns:** The simulated schedule.
2111
+
2112
+ ---
2113
+
2114
+ ### AsyncRules
2115
+
2116
+ The `AsyncRules` class is the asynchronous counterpart to `Rules`:
2117
+
2118
+ - `async getRules(prefix, tags, summary, staticDataOnly)`
2119
+ - `async createRule(ruleData)`
2120
+ - `async getRule(ruleUID)`
2121
+ - `async updateRule(ruleUID, ruleData)`
2122
+ - `async deleteRule(ruleUID)`
2123
+ - `async runNow(ruleUID, contextData)`
2124
+ - `async enable(ruleUID)`
2125
+ - `async disable(ruleUID)`
2126
+ - `async setRuleState(ruleUID, enable)`
2127
+ - `async getModule(ruleUID, moduleCategory, moduleID)`
2128
+ - `async getModuleConfig(ruleUID, moduleCategory, moduleID)`
2129
+ - `async getModuleConfigParam(ruleUID, moduleCategory, moduleID, param)`
2130
+ - `async setModuleConfigParam(ruleUID, moduleCategory, moduleID, param, value)`
2131
+ - `async getActions(ruleUID)`
2132
+ - `async getConditions(ruleUID)`
2133
+ - `async getConfiguration(ruleUID)`
2134
+ - `async updateConfiguration(ruleUID, configData)`
2135
+ - `async getTriggers(ruleUID)`
2136
+ - `async simulateSchedule(fromTime, untilTime)`
2137
+
2138
+ ---
2139
+
2140
+ ### Services
2141
+
2142
+ The `Services` class provides methods to interact with openHAB's configurable services.
2143
+
2144
+ #### Initialization
2145
+
2146
+ ```python
2147
+ from openhab import OpenHABClient, Services
2148
+
2149
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
2150
+ services = Services(client)
2151
+ ```
2152
+
2153
+ #### Methods
2154
+
2155
+ ##### `getServices(language=None)`
2156
+
2157
+ Gets all configurable services.
2158
+
2159
+ **Parameters:**
2160
+ - `language` (optional): Language for the response.
2161
+
2162
+ **Returns:** A list of services.
2163
+
2164
+ ##### `getService(serviceID: str, language=None)`
2165
+
2166
+ Gets a specific service by ID.
2167
+
2168
+ **Parameters:**
2169
+ - `serviceID` (str): The ID of the service.
2170
+ - `language` (optional): Language for the response.
2171
+
2172
+ **Returns:** The service details.
2173
+
2174
+ ##### `getServiceConfig(serviceID: str)`
2175
+
2176
+ Gets the configuration of a service.
2177
+
2178
+ **Parameters:**
2179
+ - `serviceID` (str): The ID of the service.
2180
+
2181
+ **Returns:** The service configuration.
2182
+
2183
+ ##### `updateServiceConfig(serviceID: str, configData: dict, language: str = None)`
2184
+
2185
+ Updates the configuration of a service.
2186
+
2187
+ **Parameters:**
2188
+ - `serviceID` (str): The ID of the service.
2189
+ - `configData` (dict): The new configuration data.
2190
+ - `language` (str, optional): Language for the response.
2191
+
2192
+ **Returns:** The response from the server.
2193
+
2194
+ ##### `deleteServiceConfig(serviceID: str)`
2195
+
2196
+ Deletes the configuration of a service.
2197
+
2198
+ **Parameters:**
2199
+ - `serviceID` (str): The ID of the service.
2200
+
2201
+ **Returns:** The response from the server.
2202
+
2203
+ ##### `getServiceContexts(serviceID: str, language=None)`
2204
+
2205
+ Gets all contexts of a multi-context service.
2206
+
2207
+ **Parameters:**
2208
+ - `serviceID` (str): The ID of the service.
2209
+ - `language` (optional): Language for the response.
2210
+
2211
+ **Returns:** A list of service contexts.
2212
+
2213
+ ---
2214
+
2215
+ ### AsyncServices
2216
+
2217
+ The `AsyncServices` class is the asynchronous counterpart to `Services`:
2218
+
2219
+ - `async getServices(language)`
2220
+ - `async getService(serviceID, language)`
2221
+ - `async getServiceConfig(serviceID)`
2222
+ - `async updateServiceConfig(serviceID, configData, language)`
2223
+ - `async deleteServiceConfig(serviceID)`
2224
+ - `async getServiceContexts(serviceID, language)`
2225
+
2226
+ ---
2227
+
2228
+ ### Sitemaps
2229
+
2230
+ The `Sitemaps` class provides methods to interact with openHAB sitemaps.
2231
+
2232
+ #### Initialization
2233
+
2234
+ ```python
2235
+ from openhab import OpenHABClient, Sitemaps
2236
+
2237
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
2238
+ sitemaps = Sitemaps(client)
2239
+ ```
2240
+
2241
+ #### Methods
2242
+
2243
+ ##### `getSitemaps()`
2244
+
2245
+ Gets all available sitemaps.
2246
+
2247
+ **Returns:** A list of sitemaps.
2248
+
2249
+ ##### `getSitemap(sitemapName: str, type: str = None, jsonCallback: str = None, includeHidden: bool = False, language: str = None)`
2250
+
2251
+ Gets a specific sitemap.
2252
+
2253
+ **Parameters:**
2254
+ - `sitemapName` (str): The name of the sitemap.
2255
+ - `type` (str, optional): The type of subscription.
2256
+ - `jsonCallback` (str, optional): JSONP callback name.
2257
+ - `includeHidden` (bool, optional): Include hidden widgets (default `False`).
2258
+ - `language` (str, optional): Language for the response.
2259
+
2260
+ **Returns:** The sitemap data.
2261
+
2262
+ ##### `getSitemapPage(sitemapName: str, pageID: str, subscriptionID: str = None, includeHidden: bool = False, language: str = None)`
2263
+
2264
+ Gets a specific page of a sitemap.
2265
+
2266
+ **Parameters:**
2267
+ - `sitemapName` (str): The name of the sitemap.
2268
+ - `pageID` (str): The ID of the page.
2269
+ - `subscriptionID` (str, optional): The subscription ID for real-time updates.
2270
+ - `includeHidden` (bool, optional): Include hidden widgets (default `False`).
2271
+ - `language` (str, optional): Language for the response.
2272
+
2273
+ **Returns:** The sitemap page data.
2274
+
2275
+ ##### `getFullSitemap(sitemapName: str, subscriptionID: str = None, includeHidden: bool = False, language: str = None)`
2276
+
2277
+ Gets the full sitemap including all pages.
2278
+
2279
+ **Parameters:**
2280
+ - `sitemapName` (str): The name of the sitemap.
2281
+ - `subscriptionID` (str, optional): The subscription ID for real-time updates.
2282
+ - `includeHidden` (bool, optional): Include hidden widgets (default `False`).
2283
+ - `language` (str, optional): Language for the response.
2284
+
2285
+ **Returns:** The full sitemap data.
2286
+
2287
+ ##### `getSitemapEvents(subscriptionID: str, sitemapName: str = None, pageID: str = None)`
2288
+
2289
+ Gets sitemap events for a given subscription, optionally filtered by sitemap and page.
2290
+
2291
+ **Parameters:**
2292
+ - `subscriptionID` (str): The ID of the subscription.
2293
+ - `sitemapName` (str, optional): The name of the sitemap to filter by.
2294
+ - `pageID` (str, optional): The ID of the page to filter by.
2295
+
2296
+ **Returns:** An SSE event stream for sitemap updates.
2297
+
2298
+ ##### `getFullSitemapEvents(subscriptionID: str, sitemapName: str = None)`
2299
+
2300
+ Gets full sitemap events for a given subscription.
2301
+
2302
+ **Parameters:**
2303
+ - `subscriptionID` (str): The ID of the subscription.
2304
+ - `sitemapName` (str, optional): The name of the sitemap to filter by.
2305
+
2306
+ **Returns:** An SSE event stream for full sitemap updates.
2307
+
2308
+ ##### `subscribeToSitemapEvents()`
2309
+
2310
+ Creates a new subscription for sitemap events.
2311
+
2312
+ **Returns:** `{"message": "Subscription created.", "location": "<url>", "subscriptionID": "<id>"}`.
2313
+
2314
+ ---
2315
+
2316
+ ### AsyncSitemaps
2317
+
2318
+ The `AsyncSitemaps` class is the asynchronous counterpart to `Sitemaps`:
2319
+
2320
+ - `async getSitemaps()`
2321
+ - `async getSitemap(sitemapName, type, jsonCallback, includeHidden, language)`
2322
+ - `async getSitemapPage(sitemapName, pageID, subscriptionID, includeHidden, language)`
2323
+ - `async getFullSitemap(sitemapName, subscriptionID, includeHidden, language)`
2324
+ - `async getSitemapEvents(subscriptionID, sitemapName, pageID)`
2325
+ - `async getFullSitemapEvents(subscriptionID, sitemapName)`
2326
+ - `async subscribeToSitemapEvents()`
2327
+
2328
+ ---
2329
+
2330
+ ### Systeminfo
2331
+
2332
+ The `Systeminfo` class provides methods to retrieve openHAB system information.
2333
+
2334
+ #### Methods
2335
+
2336
+ ##### `getSystemInfo()`
2337
+
2338
+ Gets general system information.
2339
+
2340
+ **Returns:** A dictionary containing system information.
2341
+
2342
+ ##### `getUoMInfo()`
2343
+
2344
+ Gets units of measurement information.
2345
+
2346
+ **Returns:** A dictionary containing UoM information.
2347
+
2348
+ ---
2349
+
2350
+ ### AsyncSysteminfo
2351
+
2352
+ The `AsyncSysteminfo` class is the asynchronous counterpart to `Systeminfo`:
2353
+
2354
+ - `async getSystemInfo()`
2355
+ - `async getUoMInfo()`
2356
+
2357
+ ---
2358
+
2359
+ ### Tags
2360
+
2361
+ The `Tags` class provides methods to interact with openHAB semantic tags.
2362
+
2363
+ #### Initialization
2364
+
2365
+ ```python
2366
+ from openhab import OpenHABClient, Tags
2367
+
2368
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
2369
+ tags = Tags(client)
2370
+ ```
2371
+
2372
+ #### Methods
2373
+
2374
+ ##### `getTags(language: str = None)`
2375
+
2376
+ Gets all available semantic tags.
2377
+
2378
+ **Parameters:**
2379
+ - `language` (str, optional): Language for the response.
2380
+
2381
+ **Returns:** A list of semantic tags.
2382
+
2383
+ ##### `createTag(tagData, language: str = None)`
2384
+
2385
+ Creates a new semantic tag.
2386
+
2387
+ **Parameters:**
2388
+ - `tagData`: The tag data.
2389
+ - `language` (str, optional): Language for the response.
2390
+
2391
+ **Returns:** The response from the server.
2392
+
2393
+ ##### `getTag(tagID: str, language: str = None)`
2394
+
2395
+ Gets a specific semantic tag by ID.
2396
+
2397
+ **Parameters:**
2398
+ - `tagID` (str): The ID of the tag.
2399
+ - `language` (str, optional): Language for the response.
2400
+
2401
+ **Returns:** The tag details.
2402
+
2403
+ ##### `updateTag(tagID: str, tagData, language: str = None)`
2404
+
2405
+ Updates an existing semantic tag.
2406
+
2407
+ **Parameters:**
2408
+ - `tagID` (str): The ID of the tag to update.
2409
+ - `tagData`: The new tag data.
2410
+ - `language` (str, optional): Language for the response.
2411
+
2412
+ **Returns:** The response from the server.
2413
+
2414
+ ##### `deleteTag(tagID: str, language: str = None)`
2415
+
2416
+ Deletes a semantic tag.
2417
+
2418
+ **Parameters:**
2419
+ - `tagID` (str): The ID of the tag to delete.
2420
+ - `language` (str, optional): Language for the response.
2421
+
2422
+ **Returns:** The response from the server.
2423
+
2424
+ ---
2425
+
2426
+ ### AsyncTags
2427
+
2428
+ The `AsyncTags` class is the asynchronous counterpart to `Tags`:
2429
+
2430
+ - `async getTags(language)`
2431
+ - `async createTag(tagData, language)`
2432
+ - `async getTag(tagID, language)`
2433
+ - `async updateTag(tagID, tagData, language)`
2434
+ - `async deleteTag(tagID, language)`
2435
+
2436
+ ---
2437
+
2438
+ ### Templates
2439
+
2440
+ The `Templates` class provides methods to retrieve openHAB rule templates.
2441
+
2442
+ #### Methods
2443
+
2444
+ ##### `getTemplates(language: str = None) -> list`
2445
+
2446
+ Gets all available templates.
2447
+
2448
+ **Parameters:**
2449
+ - `language` (str, optional): Language for the response.
2450
+
2451
+ **Returns:** A list of templates.
2452
+
2453
+ ##### `getTemplate(templateUID: str, language: str = None) -> dict`
2454
+
2455
+ Gets a specific template by its UID.
2456
+
2457
+ **Parameters:**
2458
+ - `templateUID` (str): The UID of the template.
2459
+ - `language` (str, optional): Language for the response.
2460
+
2461
+ **Returns:** The template details.
2462
+
2463
+ ---
2464
+
2465
+ ### AsyncTemplates
2466
+
2467
+ The `AsyncTemplates` class is the asynchronous counterpart to `Templates`:
2468
+
2469
+ - `async getTemplates(language)`
2470
+ - `async getTemplate(templateUID, language)`
2471
+
2472
+ ---
2473
+
2474
+ ### ThingTypes
2475
+
2476
+ The `ThingTypes` class provides methods to retrieve openHAB thing types.
2477
+
2478
+ #### Methods
2479
+
2480
+ ##### `getThingTypes(bindingID: str = None, language: str = None) -> list`
2481
+
2482
+ Gets all available thing types.
2483
+
2484
+ **Parameters:**
2485
+ - `bindingID` (str, optional): Filter by binding ID.
2486
+ - `language` (str, optional): Language for the response.
2487
+
2488
+ **Returns:** A list of thing types.
2489
+
2490
+ ##### `getThingType(thingTypeUID: str, language: str = None) -> dict`
2491
+
2492
+ Gets a specific thing type by its UID.
2493
+
2494
+ **Parameters:**
2495
+ - `thingTypeUID` (str): The UID of the thing type.
2496
+ - `language` (str, optional): Language for the response.
2497
+
2498
+ **Returns:** The thing type details.
2499
+
2500
+ ---
2501
+
2502
+ ### AsyncThingTypes
2503
+
2504
+ The `AsyncThingTypes` class is the asynchronous counterpart to `ThingTypes`:
2505
+
2506
+ - `async getThingTypes(bindingID, language)`
2507
+ - `async getThingType(thingTypeUID, language)`
2508
+
2509
+ ---
2510
+
2511
+ ### Things
2512
+
2513
+ The `Things` class provides methods to interact with openHAB things.
2514
+
2515
+ #### Initialization
2516
+
2517
+ ```python
2518
+ from openhab import OpenHABClient, Things
2519
+
2520
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
2521
+ things = Things(client)
2522
+ ```
2523
+
2524
+ #### Methods
2525
+
2526
+ ##### `getThings(summary: bool = False, staticDataOnly: bool = False, language: str = None)`
2527
+
2528
+ Gets all available things.
2529
+
2530
+ **Parameters:**
2531
+ - `summary` (bool, optional): Return summary only (default `False`).
2532
+ - `staticDataOnly` (bool, optional): Return only cached data (default `False`).
2533
+ - `language` (str, optional): Language for the response.
2534
+
2535
+ **Returns:** A list of things.
2536
+
2537
+ ##### `createThing(thingData: dict, language: str = None)`
2538
+
2539
+ Creates a new thing.
2540
+
2541
+ **Parameters:**
2542
+ - `thingData` (dict): The thing data.
2543
+ - `language` (str, optional): Language for the response.
2544
+
2545
+ **Returns:** The response from the server.
2546
+
2547
+ ##### `getThing(thingUID: str, language: str = None)`
2548
+
2549
+ Gets a specific thing by its UID.
2550
+
2551
+ **Parameters:**
2552
+ - `thingUID` (str): The UID of the thing.
2553
+ - `language` (str, optional): Language for the response.
2554
+
2555
+ **Returns:** The thing details.
2556
+
2557
+ ##### `updateThing(thingUID: str, thingData: dict, language: str = None)`
2558
+
2559
+ Updates an existing thing.
2560
+
2561
+ **Parameters:**
2562
+ - `thingUID` (str): The UID of the thing to update.
2563
+ - `thingData` (dict): The new thing data.
2564
+ - `language` (str, optional): Language for the response.
2565
+
2566
+ **Returns:** The response from the server.
2567
+
2568
+ ##### `deleteThing(thingUID: str, force: bool = False, language: str = None)`
2569
+
2570
+ Deletes a thing.
2571
+
2572
+ **Parameters:**
2573
+ - `thingUID` (str): The UID of the thing to delete.
2574
+ - `force` (bool, optional): Force deletion even if the thing is linked (default `False`).
2575
+ - `language` (str, optional): Language for the response.
2576
+
2577
+ **Returns:** The response from the server.
2578
+
2579
+ ##### `updateThingConfiguration(thingUID: str, configurationData: dict, language: str = None)`
2580
+
2581
+ Updates the configuration of a thing.
2582
+
2583
+ **Parameters:**
2584
+ - `thingUID` (str): The UID of the thing.
2585
+ - `configurationData` (dict): The new configuration data.
2586
+ - `language` (str, optional): Language for the response.
2587
+
2588
+ **Returns:** The response from the server.
2589
+
2590
+ ##### `getThingConfigStatus(thingUID: str, language: str = None)`
2591
+
2592
+ Gets the configuration status of a thing.
2593
+
2594
+ **Parameters:**
2595
+ - `thingUID` (str): The UID of the thing.
2596
+ - `language` (str, optional): Language for the response.
2597
+
2598
+ **Returns:** The configuration status.
2599
+
2600
+ ##### `setThingStatus(thingUID: str, enabled: bool, language: str = None)`
2601
+
2602
+ Enables or disables a thing.
2603
+
2604
+ **Parameters:**
2605
+ - `thingUID` (str): The UID of the thing.
2606
+ - `enabled` (bool): `True` to enable, `False` to disable.
2607
+ - `language` (str, optional): Language for the response.
2608
+
2609
+ **Returns:** The response from the server.
2610
+
2611
+ ##### `enableThing(thingUID: str)`
2612
+
2613
+ Enables a thing. Convenience wrapper for `setThingStatus(thingUID, True)`.
2614
+
2615
+ ##### `disableThing(thingUID: str)`
2616
+
2617
+ Disables a thing. Convenience wrapper for `setThingStatus(thingUID, False)`.
2618
+
2619
+ ##### `updateThingFirmware(thingUID: str, firmwareVersion: str, language: str = None)`
2620
+
2621
+ Updates the firmware of a thing.
2622
+
2623
+ **Parameters:**
2624
+ - `thingUID` (str): The UID of the thing.
2625
+ - `firmwareVersion` (str): The firmware version to install.
2626
+ - `language` (str, optional): Language for the response.
2627
+
2628
+ **Returns:** The response from the server.
2629
+
2630
+ ##### `getThingFirmwareStatus(thingUID: str, language: str = None)`
2631
+
2632
+ Gets the firmware status of a thing.
2633
+
2634
+ **Parameters:**
2635
+ - `thingUID` (str): The UID of the thing.
2636
+ - `language` (str, optional): Language for the response.
2637
+
2638
+ **Returns:** The firmware status.
2639
+
2640
+ ##### `getThingFirmwares(thingUID: str, language: str = None)`
2641
+
2642
+ Gets all available firmware versions for a thing.
2643
+
2644
+ **Parameters:**
2645
+ - `thingUID` (str): The UID of the thing.
2646
+ - `language` (str, optional): Language for the response.
2647
+
2648
+ **Returns:** A list of available firmware versions.
2649
+
2650
+ ##### `getThingStatus(thingUID: str, language: str = None)`
2651
+
2652
+ Gets the status of a thing.
2653
+
2654
+ **Parameters:**
2655
+ - `thingUID` (str): The UID of the thing.
2656
+ - `language` (str, optional): Language for the response.
2657
+
2658
+ **Returns:** The thing status.
2659
+
2660
+ ---
2661
+
2662
+ ### AsyncThings
2663
+
2664
+ The `AsyncThings` class is the asynchronous counterpart to `Things`:
2665
+
2666
+ - `async getThings(summary, staticDataOnly, language)`
2667
+ - `async createThing(thingData, language)`
2668
+ - `async getThing(thingUID, language)`
2669
+ - `async updateThing(thingUID, thingData, language)`
2670
+ - `async deleteThing(thingUID, force, language)`
2671
+ - `async updateThingConfiguration(thingUID, configurationData, language)`
2672
+ - `async getThingConfigStatus(thingUID, language)`
2673
+ - `async setThingStatus(thingUID, enabled, language)`
2674
+ - `async enableThing(thingUID)`
2675
+ - `async disableThing(thingUID)`
2676
+ - `async updateThingFirmware(thingUID, firmwareVersion, language)`
2677
+ - `async getThingFirmwareStatus(thingUID, language)`
2678
+ - `async getThingFirmwares(thingUID, language)`
2679
+ - `async getThingStatus(thingUID, language)`
2680
+
2681
+ ---
2682
+
2683
+ ### Transformations
2684
+
2685
+ The `Transformations` class provides methods to interact with transformations in the openHAB system.
2686
+
2687
+ #### Methods
2688
+
2689
+ ##### `getTransformations()`
2690
+
2691
+ Retrieves a list of all transformations.
2692
+
2693
+ **Returns:** A list of transformations (JSON).
2694
+
2695
+ ##### `getTransformation(transformationUID: str)`
2696
+
2697
+ Gets a single transformation by its UID.
2698
+
2699
+ **Parameters:**
2700
+ - `transformationUID` (str): The UID of the transformation to retrieve.
2701
+
2702
+ **Returns:** The transformation (JSON).
2703
+
2704
+ ##### `updateTransformation(transformationUID: str, transformationData)`
2705
+
2706
+ Updates a single transformation.
2707
+
2708
+ **Parameters:**
2709
+ - `transformationUID` (str): The UID of the transformation to update.
2710
+ - `transformationData`: The new data for the transformation.
2711
+
2712
+ **Returns:** The response to the transformation update request.
2713
+
2714
+ ##### `deleteTransformation(transformationUID: str)`
2715
+
2716
+ Deletes a single transformation by its UID.
2717
+
2718
+ **Parameters:**
2719
+ - `transformationUID` (str): The UID of the transformation to delete.
2720
+
2721
+ **Returns:** The response to the transformation delete request.
2722
+
2723
+ ##### `getTransformationServices()`
2724
+
2725
+ Gets all transformation services available.
2726
+
2727
+ **Returns:** A list of transformation services (JSON).
2728
+
2729
+ ---
2730
+
2731
+ ### AsyncTransformations
2732
+
2733
+ The `AsyncTransformations` class is the asynchronous counterpart to `Transformations`:
2734
+
2735
+ - `async getTransformations()`
2736
+ - `async getTransformation(transformationUID)`
2737
+ - `async updateTransformation(transformationUID, transformationData)`
2738
+ - `async deleteTransformation(transformationUID)`
2739
+ - `async getTransformationServices()`
2740
+
2741
+ ---
2742
+
2743
+ ### UI
2744
+
2745
+ The `UI` class provides methods to interact with UI components and tiles in the openHAB system.
2746
+
2747
+ #### Methods
2748
+
2749
+ ##### `getUIComponents(namespace: str, summary: bool = False)`
2750
+
2751
+ Retrieves all registered UI components within the specified namespace.
2752
+
2753
+ **Parameters:**
2754
+ - `namespace` (str): The namespace for which UI components should be retrieved.
2755
+ - `summary` (bool, optional): If `True`, only summary fields will be returned (default `False`).
2756
+
2757
+ **Returns:** A list of UI components (JSON).
2758
+
2759
+ ##### `addUIComponent(namespace: str, componentData)`
2760
+
2761
+ Adds a UI component to the specified namespace.
2762
+
2763
+ **Parameters:**
2764
+ - `namespace` (str): The namespace where the UI component should be added.
2765
+ - `componentData`: The data of the UI component to be added (JSON).
2766
+
2767
+ **Returns:** The response to the request (JSON).
2768
+
2769
+ ##### `getUIComponent(namespace: str, componentUID: str)`
2770
+
2771
+ Retrieves a specific UI component in the specified namespace.
2772
+
2773
+ **Parameters:**
2774
+ - `namespace` (str): The namespace where the UI component is located.
2775
+ - `componentUID` (str): The UID of the UI component to retrieve.
2776
+
2777
+ **Returns:** The UI component (JSON).
2778
+
2779
+ ##### `updateUIComponent(namespace: str, componentUID: str, componentData)`
2780
+
2781
+ Updates a specific UI component in the specified namespace.
2782
+
2783
+ **Parameters:**
2784
+ - `namespace` (str): The namespace where the UI component should be updated.
2785
+ - `componentUID` (str): The UID of the UI component to update.
2786
+ - `componentData`: The new data for the UI component (JSON).
2787
+
2788
+ **Returns:** The response to the request (JSON).
2789
+
2790
+ ##### `deleteUIComponent(namespace: str, componentUID: str)`
2791
+
2792
+ Removes a specific UI component from the specified namespace.
2793
+
2794
+ **Parameters:**
2795
+ - `namespace` (str): The namespace where the UI component should be removed.
2796
+ - `componentUID` (str): The UID of the UI component to delete.
2797
+
2798
+ **Returns:** The response to the request (JSON).
2799
+
2800
+ ##### `getUITiles()`
2801
+
2802
+ Retrieves all registered UI tiles.
2803
+
2804
+ **Returns:** A list of UI tiles (JSON).
2805
+
2806
+ ---
2807
+
2808
+ ### AsyncUI
2809
+
2810
+ The `AsyncUI` class is the asynchronous counterpart to `UI`:
2811
+
2812
+ - `async getUIComponents(namespace, summary)`
2813
+ - `async addUIComponent(namespace, componentData)`
2814
+ - `async getUIComponent(namespace, componentUID)`
2815
+ - `async updateUIComponent(namespace, componentUID, componentData)`
2816
+ - `async deleteUIComponent(namespace, componentUID)`
2817
+ - `async getUITiles()`
2818
+
2819
+ ---
2820
+
2821
+ ### UUID
2822
+
2823
+ The `UUID` class provides a method to retrieve a unified unique identifier from the openHAB system.
2824
+
2825
+ #### Methods
2826
+
2827
+ ##### `getUUID() -> str`
2828
+
2829
+ Retrieves the UUID of the openHAB instance.
2830
+
2831
+ **Returns:** A string containing the UUID.
2832
+
2833
+ ---
2834
+
2835
+ ### AsyncUUID
2836
+
2837
+ The `AsyncUUID` class is the asynchronous counterpart to `UUID`:
2838
+
2839
+ - `async getUUID()`
2840
+
2841
+ ---
2842
+
2843
+ ### Voice
2844
+
2845
+ The `Voice` class provides methods to interact with the voice processing system, including starting and stopping dialogs, interpreting text, and speaking text aloud.
2846
+
2847
+ #### Initialization
2848
+
2849
+ ```python
2850
+ from openhab import OpenHABClient, Voice
2851
+
2852
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
2853
+ voice = Voice(client)
2854
+ ```
2855
+
2856
+ #### Methods
2857
+
2858
+ ##### `getDefaultVoice(language: str = None)`
2859
+
2860
+ Gets the default voice used by the system.
2861
+
2862
+ **Returns:** A dictionary with details of the default voice.
2863
+
2864
+ ##### `getVoices(language: str = None)`
2865
+
2866
+ Gets the list of all voices.
2867
+
2868
+ **Returns:** A list of voices.
2869
+
2870
+ ##### `getInterpreters(language: str = None)`
2871
+
2872
+ Gets the list of all interpreters.
2873
+
2874
+ **Parameters:**
2875
+ - `language` (str, optional): The language for the request.
2876
+
2877
+ **Returns:** A list of interpreters.
2878
+
2879
+ ##### `getInterpreter(interpreterID: str, language: str = None)`
2880
+
2881
+ Gets a single interpreter.
2882
+
2883
+ **Parameters:**
2884
+ - `interpreterID` (str): The ID of the interpreter.
2885
+ - `language` (str, optional): The language for the request.
2886
+
2887
+ **Returns:** The details of the interpreter.
2888
+
2889
+ ##### `interpretText(text: str, language: str = None)`
2890
+
2891
+ Sends a text to the default human language interpreter.
2892
+
2893
+ **Parameters:**
2894
+ - `text` (str): The text to be interpreted.
2895
+ - `language` (str, optional): The language of the text.
2896
+
2897
+ **Returns:** The response from the server.
2898
+
2899
+ ##### `interpretTextBatch(text: str, IDs: list, language: str = None)`
2900
+
2901
+ Sends a text to given human language interpreter(s).
2902
+
2903
+ **Parameters:**
2904
+ - `text` (str): The text to be interpreted.
2905
+ - `IDs` (list): A list of interpreter IDs.
2906
+ - `language` (str, optional): The language of the text.
2907
+
2908
+ **Returns:** The response from the server.
2909
+
2910
+ ##### `startDialog(sourceID: str, ksID: str = None, sttID: str = None, ttsID: str = None, voiceID: str = None, hliIDs: str = None, sinkID: str = None, keyword: str = None, listeningItem: str = None)`
2911
+
2912
+ Starts dialog processing for a given audio source.
2913
+
2914
+ **Parameters:**
2915
+ - `sourceID` (str): The ID of the audio source.
2916
+ - `ksID` (str, optional): The ID of the keyword spotter.
2917
+ - `sttID` (str, optional): The ID of the speech-to-text system.
2918
+ - `ttsID` (str, optional): The ID of the text-to-speech system.
2919
+ - `voiceID` (str, optional): The ID of the voice.
2920
+ - `hliIDs` (str, optional): A comma-separated list of interpreter IDs.
2921
+ - `sinkID` (str, optional): The ID of the audio output.
2922
+ - `keyword` (str, optional): The keyword used to start the dialog.
2923
+ - `listeningItem` (str, optional): The name of the item to listen to.
2924
+
2925
+ **Returns:** The response from the server.
2926
+
2927
+ ##### `stopDialog(sourceID: str)`
2928
+
2929
+ Stops dialog processing for a given audio source.
2930
+
2931
+ **Parameters:**
2932
+ - `sourceID` (str): The ID of the audio source.
2933
+
2934
+ **Returns:** The response from the server.
2935
+
2936
+ ##### `listenAndAnswer(sourceID: str, sttID: str, ttsID: str, voiceID: str, hliIDs: list = None, sinkID: str = None, listeningItem: str = None)`
2937
+
2938
+ Executes a simple dialog sequence without keyword spotting for a given audio source.
2939
+
2940
+ **Parameters:**
2941
+ - `sourceID` (str): The ID of the audio source.
2942
+ - `sttID` (str): The ID of the speech-to-text system.
2943
+ - `ttsID` (str): The ID of the text-to-speech system.
2944
+ - `voiceID` (str): The ID of the voice.
2945
+ - `hliIDs` (list, optional): A list of interpreter IDs.
2946
+ - `sinkID` (str, optional): The ID of the audio output.
2947
+ - `listeningItem` (str, optional): The name of the item to listen to.
2948
+
2949
+ **Returns:** The response from the server.
2950
+
2951
+ ##### `sayText(text: str, voiceID: str, sinkID: str, volume: str = '100')`
2952
+
2953
+ Speaks a given text with a given voice through the given audio sink.
2954
+
2955
+ **Parameters:**
2956
+ - `text` (str): The text to be spoken.
2957
+ - `voiceID` (str): The ID of the voice.
2958
+ - `sinkID` (str): The ID of the audio output.
2959
+ - `volume` (str, optional): The volume level (default: `100`).
2960
+
2961
+ **Returns:** The response from the server.
2962
+
2963
+ ---
2964
+
2965
+ ### AsyncVoice
2966
+
2967
+ The `AsyncVoice` class is the asynchronous counterpart to `Voice`. It provides the same methods as coroutines:
2968
+
2969
+ - `async getDefaultVoice(language)`
2970
+ - `async getVoices(language)`
2971
+ - `async getInterpreters(language)`
2972
+ - `async getInterpreter(interpreterID, language)`
2973
+ - `async interpretText(text, language)`
2974
+ - `async interpretTextBatch(text, IDs, language)`
2975
+ - `async startDialog(sourceID, ksID, sttID, ttsID, voiceID, hliIDs, sinkID, keyword, listeningItem)`
2976
+ - `async stopDialog(sourceID)`
2977
+ - `async listenAndAnswer(sourceID, sttID, ttsID, voiceID, hliIDs, sinkID, listeningItem)`
2978
+ - `async sayText(text, voiceID, sinkID, volume)`
2979
+
2980
+ ---
2981
+
2982
+ ## Contributing
2983
+
2984
+ Contributions are welcome! Please create an issue or pull request to suggest changes.
2985
+
2986
+ We welcome contributions to improve **python-openhab-rest-client**!
2987
+
2988
+ ### How to contribute:
2989
+ 1. Fork the repository.
2990
+ 2. Create a new branch:
2991
+ ```bash
2992
+ git checkout -b feature/your-feature-name
2993
+ ```
2994
+ 3. Commit your changes:
2995
+ ```bash
2996
+ git commit -m "Add your feature description"
2997
+ ```
2998
+ 4. Push to the branch:
2999
+ ```bash
3000
+ git push origin feature/your-feature-name
3001
+ ```
3002
+ 5. Open a pull request.
3003
+
3004
+ Please ensure your code adheres to PEP 8 guidelines and includes relevant documentation and tests.
3005
+
3006
+ ## License
3007
+
3008
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
3009
+
3010
+ ## Changelog
3011
+
3012
+ ### 21.4.0
3013
+
3014
+ Bug fixes (all found against openHAB 5.2.3):
3015
+
3016
+ - **Async events:** `AsyncEvents`, `AsyncItemEvents`, … called the non-existent
3017
+ `AsyncOpenHABClient.executeSSE()`. The method now exists (public) and returns the open
3018
+ `aiohttp` response. SSE streams are no longer cut after the aiohttp default timeout of 5 minutes.
3019
+ - **SSE and token authentication:** the synchronous SSE request did not use the client
3020
+ session, so the `Authorization: Bearer` header was missing (`401`). It now uses the
3021
+ session (token and Basic Authentication) and reports errors properly.
3022
+ - **Responses with a `status` field:** the internal marker `{"status": <code>}` for empty
3023
+ responses collided with JSON that contains a `status` field. `Things.getThingStatus()`
3024
+ and `Rules.getRule()`/`getRules()` returned `"Unexpected response"` instead of the data.
3025
+ Empty responses are now represented by the dedicated type `StatusResponse`.
3026
+ - **`ItemEvents.ItemEvent()`** subscribed to `openhab/items` (no events at all); now `openhab/items/*`.
3027
+ - **Persistence:** the query parameter was sent as `serviceID` instead of `serviceId`, so
3028
+ openHAB silently used the default service. `getItemPersistenceData()` used `page=1`,
3029
+ which skipped the first page (pages start at 0) – paging is now off by default and all
3030
+ data points of the time range are returned. `getItemsFromService()` builds its query
3031
+ correctly and explains `405`.
3032
+ - **`Items.addOrUpdateItem()`** sent `Accept: */` and always failed with `406`.
3033
+ - **`Rules.createRule()`** crashed with `AttributeError` (`response.status_code`).
3034
+ - **`Rules.runNow()`** sent its body without content type (`415` in the async variant).
3035
+ - **`Links`:** `linkItemToChannel()` put the URL-encoded channel UID into the JSON body
3036
+ (`400 Content does not match the path`); `getLink()` reported a missing link as
3037
+ "Content does not match the path".
3038
+ - **UIDs containing `#`** (action and channel UIDs such as `astro.getElevation#…`) were cut
3039
+ off as URL fragment, e.g. `Actions.executeAction()` always returned "Action not found".
3040
+ - **`Inbox.approveDiscoveryResult()`:** `newThingID` → `newThingId`.
3041
+ - **`Sitemaps`:** `subscriptionID`/`pageId` → `subscriptionid`/`pageid`;
3042
+ `subscribeToSitemapEvents()` now returns the subscription ID and URL.
3043
+ - **`Voice`:** `sayText()` sent `voiceId`/`sinkId` instead of `voiceid`/`sinkid`;
3044
+ `interpretTextBatch()` used the wrong endpoint.
3045
+ - **`Addons`:** `serviceId` for install/uninstall/config is sent as query parameter.
3046
+ - **`Services.updateServiceConfig()`** reported `204` (no previous configuration) as error.
3047
+ - The client no longer changes the session headers permanently with every request
3048
+ (a `Content-Type` of one request leaked into all following requests).
3049
+
3050
+ Improvements:
3051
+
3052
+ - The asynchronous classes are generated from the synchronous ones
3053
+ (`tools/generate_async.py`) and now return exactly the same values and messages –
3054
+ previously many async methods returned the raw `{"status": 200}`.
3055
+ - Error messages contain openHAB's own explanation, e.g.
3056
+ `... (Persistence service not modifiable: rrd4j)`.
3057
+ - Clearer messages for rejected commands/states (`Invalid command for this item.`).
3058
+ - New optional parameters: `timeout` and `verify` for both clients;
3059
+ `source` for `sendCommand`/`postUpdate`/`updateItemState`; `parents` for `getItems`/`getItem`;
3060
+ `displayState`/`language` for `getItemPersistenceData`; `itemName` for `getItemsFromService`;
3061
+ `language` for `Voice.getVoices`/`getDefaultVoice`.
3062
+ - `OpenHABClient` can be used as context manager (`with OpenHABClient(...) as client:`),
3063
+ `AsyncOpenHABClient` creates its session lazily and has `close()`.
3064
+ - **Events arrived late:** SSE streams are now requested uncompressed (`Accept-Encoding: identity`);
3065
+ a gzip-compressed stream was flushed by openHAB only with the next message.
3066
+ New helpers `iterSSELines`, `iterSSEEvents`, `aiterSSELines`, `aiterSSEEvents` and `parseSSEData`
3067
+ deliver every event immediately – `requests`' `iter_lines()` keeps the last line of a chunk back.
3068
+ - Text responses are decoded as UTF-8 (`getItemState` returned `21.5 °C` instead of `21.5 °C`).
3069
+ - `StatusResponse` is exported. Automated tests (`tests_pytest/`), `pyproject.toml`.