python-openhab-rest-client 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. openhab/Actions.py +43 -0
  2. openhab/Addons.py +163 -0
  3. openhab/Audio.py +66 -0
  4. openhab/Auth.py +105 -0
  5. openhab/ChannelTypes.py +54 -0
  6. openhab/Client.py +197 -0
  7. openhab/ConfigDescriptions.py +44 -0
  8. openhab/Discovery.py +28 -0
  9. openhab/Events.py +302 -0
  10. openhab/Iconsets.py +21 -0
  11. openhab/Inbox.py +64 -0
  12. openhab/Items.py +264 -0
  13. openhab/Links.py +98 -0
  14. openhab/Logging.py +55 -0
  15. openhab/ModuleTypes.py +47 -0
  16. openhab/Persistence.py +103 -0
  17. openhab/ProfileTypes.py +32 -0
  18. openhab/Rules.py +206 -0
  19. openhab/Services.py +78 -0
  20. openhab/Sitemaps.py +88 -0
  21. openhab/Systeminfo.py +34 -0
  22. openhab/Tags.py +82 -0
  23. openhab/Templates.py +38 -0
  24. openhab/ThingTypes.py +42 -0
  25. openhab/Things.py +199 -0
  26. openhab/Transformations.py +58 -0
  27. openhab/UI.py +75 -0
  28. openhab/UUID.py +18 -0
  29. openhab/Voice.py +147 -0
  30. openhab/__init__.py +66 -0
  31. python_openhab_rest_client-0.1.0.dist-info/LICENSE +21 -0
  32. python_openhab_rest_client-0.1.0.dist-info/METADATA +2391 -0
  33. python_openhab_rest_client-0.1.0.dist-info/RECORD +70 -0
  34. python_openhab_rest_client-0.1.0.dist-info/WHEEL +5 -0
  35. python_openhab_rest_client-0.1.0.dist-info/top_level.txt +2 -0
  36. tests/__init__.py +0 -0
  37. tests/actions.py +55 -0
  38. tests/addons.py +96 -0
  39. tests/audio.py +16 -0
  40. tests/auth.py +45 -0
  41. tests/channel_events.py +14 -0
  42. tests/channel_types.py +29 -0
  43. tests/config_descriptions.py +23 -0
  44. tests/discovery.py +23 -0
  45. tests/events.py +41 -0
  46. tests/iconsets.py +19 -0
  47. tests/inbox.py +53 -0
  48. tests/inbox_events.py +15 -0
  49. tests/item_events.py +38 -0
  50. tests/items.py +120 -0
  51. tests/link_events.py +14 -0
  52. tests/links.py +74 -0
  53. tests/logging_test.py +43 -0
  54. tests/module_types.py +14 -0
  55. tests/persistence.py +78 -0
  56. tests/profile_types.py +13 -0
  57. tests/rules.py +151 -0
  58. tests/services.py +52 -0
  59. tests/sitemaps.py +65 -0
  60. tests/systeminfo.py +14 -0
  61. tests/tags.py +53 -0
  62. tests/templates.py +28 -0
  63. tests/test.py +11 -0
  64. tests/thing_events.py +17 -0
  65. tests/thing_types.py +28 -0
  66. tests/things.py +75 -0
  67. tests/transformations.py +38 -0
  68. tests/ui.py +70 -0
  69. tests/uuid.py +18 -0
  70. tests/voice.py +119 -0
@@ -0,0 +1,2391 @@
1
+ Metadata-Version: 2.1
2
+ Name: python-openhab-rest-client
3
+ Version: 0.1.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
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: requests
15
+
16
+ # python-openhab-rest-client
17
+
18
+ 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.
19
+
20
+ ## Features
21
+
22
+ Supports the following openHAB REST API endpoints:
23
+
24
+ - Actions
25
+ - Addons
26
+ - Audio
27
+ - Auth
28
+ - ChannelTypes
29
+ - ConfigDescriptions
30
+ - Discovery
31
+ - Events (ItemEvents, ThingEvents, InboxEvents, LinkEvents, ChannelEvents)
32
+ - Iconsets
33
+ - Inbox
34
+ - Items
35
+ - Links
36
+ - Logging
37
+ - ModuleTypes
38
+ - Persistence
39
+ - ProfileTypes
40
+ - Rules
41
+ - Services
42
+ - Sitemaps
43
+ - Systeminfo
44
+ - Tags
45
+ - Templates
46
+ - ThingTypes
47
+ - Things
48
+ - Transformations
49
+ - UI
50
+ - UUID
51
+ - Voice
52
+
53
+ Supports both Server-Sent Events (SSE) and regular REST requests. SSE is used for the events of openHAB.
54
+
55
+ ## Requirements
56
+
57
+ - Python 3.x
58
+ - `requests`
59
+ - `json`
60
+
61
+ ## Installation
62
+
63
+ Install via pip:
64
+
65
+ ```sh
66
+ pip install python-openhab-rest-client
67
+ ```
68
+
69
+ ## Usage
70
+
71
+ Basically, you always need the `OpenHABClient`. Regardless of whether you carry out a normal `REST request` or one via `SSE`. This looks as follows:
72
+
73
+ ### Authentication
74
+
75
+ #### Basic Authentication
76
+
77
+ ```python
78
+ from openhab import OpenHABClient
79
+
80
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
81
+ ```
82
+
83
+ 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.
84
+
85
+ #### Token-based Authentication
86
+
87
+ 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.
88
+
89
+ For token-based access, the initialization of the client is as follows:
90
+
91
+ ```python
92
+ client = OpenHABClient(url="http://127.0.0.1:8080", token="oh.openhab.U0doM1Lz4kJ6tPlVGjH17jjm4ZcTHIHi7sMwESzrIybKbCGySmBMtysPnObQLuLf7PgqnI7jWQ5LosySY8Q")
93
+ ```
94
+
95
+ Of course, your `token` will probably look different here too.
96
+
97
+ ### Requests
98
+
99
+ #### Normal REST requests
100
+
101
+ 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.
102
+
103
+ An easy example could be:
104
+
105
+ ```python
106
+ from openhab import OpenHABClient, Items
107
+
108
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
109
+ itemsAPI = Items(client)
110
+
111
+ allItems = itemsAPI.getAllItems()
112
+ print("All Items:", allItems)
113
+ ```
114
+
115
+ #### Server-sent Events (SSE) requests
116
+
117
+ 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 evetnts 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.
118
+
119
+ 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.
120
+
121
+ An example looks like this:
122
+
123
+ ```python
124
+ from openhab import OpenHABClient, ItemEvents
125
+
126
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
127
+ itemEvents = ItemEvents(client)
128
+
129
+ response = itemEvents.ItemStateChangedEvent()
130
+
131
+ with response as events:
132
+ for line in events.iter_lines():
133
+ line = line.decode()
134
+
135
+ if "data" in line:
136
+ line = line.replace("data: ", "")
137
+
138
+ try:
139
+ data = json.loads(line)
140
+ print(data)
141
+ except json.decoder.JSONDecodeError:
142
+ print("Event could not be converted to JSON")
143
+ ```
144
+
145
+ ## Full list of Methods
146
+
147
+ ### OpenHABClient
148
+
149
+ `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.
150
+
151
+ #### Initialization
152
+
153
+ ##### Constructor
154
+
155
+ ```python
156
+ OpenHABClient(url: str, username: str = None, password: str = None, token: str = None)
157
+ ```
158
+ ###### Parameters:
159
+ - `url` (str): The base URL of the openHAB server (e.g., "http://127.0.0.1:8080").
160
+ - `username` (str, optional): Username for Basic Authentication (default is `None`).
161
+ - `password` (str, optional): Password for Basic Authentication (default is `None`).
162
+ - `token` (str, optional): Bearer Token for Token-based Authentication (default is `None`).
163
+
164
+ ###### Example:
165
+
166
+ ```python
167
+ client = OpenHABClient("http://127.0.0.1:8080", username="admin", password="password")
168
+ ```
169
+
170
+ #### Methods
171
+
172
+ ##### `get`
173
+
174
+ ```python
175
+ get(endpoint: str, header: dict = None, params: dict = None)
176
+ ```
177
+
178
+ Sends a GET request to the openHAB server.
179
+
180
+ ###### Parameters:
181
+ - `endpoint` (str): The API endpoint (e.g., `"/items"`).
182
+ - `header` (dict, optional): Headers to include in the request.
183
+ - `params` (dict, optional): Query parameters for the request.
184
+
185
+ ###### Example:
186
+
187
+ ```python
188
+ response = client.get("/items")
189
+ print(response)
190
+ ```
191
+
192
+ ##### `post`
193
+
194
+ ```python
195
+ post(endpoint: str, header: dict = None, data=None, params: dict = None)
196
+ ```
197
+
198
+ Sends a POST request to the openHAB server.
199
+
200
+ ###### Parameters:
201
+ - `endpoint` (str): The API endpoint (e.g., `"/items"`).
202
+ - `header` (dict, optional): Headers to include in the request.
203
+ - `data` (optional): Data to send in the request body.
204
+ - `params` (dict, optional): Query parameters for the request.
205
+
206
+ ###### Example:
207
+
208
+ ```python
209
+ data = {"type": "Switch", "state": "ON"}
210
+ response = client.post("/items/light", data=json.dumps(data))
211
+ print(response)
212
+ ```
213
+
214
+ ##### `put`
215
+
216
+ ```python
217
+ put(endpoint: str, header: dict = None, data=None, params: dict = None)
218
+ ```
219
+
220
+ Sends a PUT request to update a resource in openHAB.
221
+
222
+ ###### Example:
223
+
224
+ ```python
225
+ data = {"state": "OFF"}
226
+ response = client.put("/items/light", data=json.dumps(data))
227
+ print(response)
228
+ ```
229
+
230
+ ##### `delete`
231
+
232
+ ```python
233
+ delete(endpoint: str, header: dict = None, data=None, params: dict = None)
234
+ ```
235
+
236
+ Sends a DELETE request to remove a resource from openHAB.
237
+
238
+ ###### Example:
239
+
240
+ ```python
241
+ response = client.delete("/items/light")
242
+ print(response)
243
+ ```
244
+
245
+ #### Authentication
246
+
247
+ The client supports two types of authentication:
248
+ - **Basic Authentication** (Username & Password)
249
+ - **Bearer Token Authentication**
250
+
251
+ If a token is provided, it is used for authentication; otherwise, Basic Authentication is used if credentials are supplied.
252
+
253
+ #### Error Handling
254
+
255
+ Errors during requests are caught and logged, with appropriate exception handling for HTTP errors, connection issues, and timeouts.
256
+
257
+
258
+ ### Actions
259
+
260
+ The `Actions` class provides methods to interact with the OpenHAB actions API. It allows retrieving available actions for a specific `thingUID` and executing actions.
261
+
262
+ #### Initialization
263
+
264
+ ```python
265
+ from .client import OpenHABClient
266
+ from actions import Actions
267
+
268
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
269
+ actions = Actions(client)
270
+ ```
271
+
272
+ #### Methods
273
+
274
+ ##### `getAllActions(thingUID: str, language: str = None) -> list`
275
+
276
+ Retrieves all available actions for a given thing UID.
277
+
278
+ **Parameters:**
279
+ - `thingUID` (str): The UID of the thing for which actions should be retrieved.
280
+ - `language` (str, optional): The language for the response (sets the `Accept-Language` header).
281
+
282
+ **Returns:**
283
+ - `list`: A list of available actions.
284
+
285
+ ###### Example:
286
+ ```python
287
+ actions_list = actions.getAllActions("myThingUID")
288
+ print(actions_list)
289
+ ```
290
+
291
+ ##### `execute_action(thingUID: str, actionUID: str, actionInputs: dict, language: str = None) -> str`
292
+
293
+ Executes an action on a specific thing.
294
+
295
+ **Parameters:**
296
+ - `thingUID` (str): The UID of the thing on which the action is executed.
297
+ - `actionUID` (str): The UID of the action to be performed.
298
+ - `actionInputs` (dict): A dictionary containing input parameters for the action.
299
+ - `language` (str, optional): The language for the response (sets the `Accept-Language` header).
300
+
301
+ **Returns:**
302
+ - `str`: The response from the OpenHAB server.
303
+
304
+ ###### Example:
305
+
306
+ ```python
307
+ response = actions.execute_action("myThingUID", "actionID", {"param1": "value1"})
308
+ print(response)
309
+ ```
310
+
311
+ ### Addons
312
+
313
+ The `Addons` class provides methods for interacting with the openHAB add-ons via the REST API.
314
+
315
+ #### Methods
316
+
317
+ ##### `getAddons(serviceID: str = None, language: str = None) -> dict`
318
+
319
+ Retrieves a list of all available add-ons.
320
+
321
+ **Parameters:**
322
+ - `serviceID` (optional): Filter by service ID.
323
+ - `language` (optional): Language preference for the response.
324
+
325
+ **Returns:**
326
+ A dictionary containing add-ons data.
327
+
328
+ ##### `getAddon(addonID: str, serviceID: str = None, language: str = None) -> dict`
329
+
330
+ Retrieves details of a specific add-on by its ID.
331
+
332
+ **Parameters:**
333
+ - `addonID`: The unique identifier of the add-on.
334
+ - `serviceID` (optional): Filter by service ID.
335
+ - `language` (optional): Language preference for the response.
336
+
337
+ **Returns:**
338
+ A dictionary containing details of the specified add-on.
339
+
340
+ ##### `getAddonConfig(addonID: str, serviceID: str = None) -> dict`
341
+
342
+ Retrieves the configuration of a specific add-on.
343
+
344
+ **Parameters:**
345
+ - `addonID`: The unique identifier of the add-on.
346
+ - `serviceID` (optional): Filter by service ID.
347
+
348
+ **Returns:**
349
+ A dictionary containing the configuration of the add-on.
350
+
351
+ ##### `updateAddonConfig(addonID: str, configData: dict, serviceID: str = None) -> dict`
352
+
353
+ Updates the configuration of a specific add-on.
354
+
355
+ **Parameters:**
356
+ - `addonID`: The unique identifier of the add-on.
357
+ - `configData`: Dictionary containing new configuration settings.
358
+ - `serviceID` (optional): Specify the target service.
359
+
360
+ **Returns:**
361
+ A dictionary containing the updated configuration.
362
+
363
+ ##### `installAddon(addonID: str, serviceID: str = None, language: str = None) -> dict`
364
+
365
+ Installs an add-on by its ID.
366
+
367
+ **Parameters:**
368
+ - `addonID`: The unique identifier of the add-on.
369
+ - `serviceID` (optional): Specify the target service.
370
+ - `language` (optional): Language preference for the response.
371
+
372
+ **Returns:**
373
+ A dictionary containing the installation status.
374
+
375
+ ##### `uninstallAddon(addonID: str, serviceID: str = None, language: str = None) -> dict`
376
+
377
+ Uninstalls an add-on by its ID.
378
+
379
+ **Parameters:**
380
+ - `addonID`: The unique identifier of the add-on.
381
+ - `serviceID` (optional): Specify the target service.
382
+ - `language` (optional): Language preference for the response.
383
+
384
+ **Returns:**
385
+ A dictionary containing the uninstallation status.
386
+
387
+ ##### `getAddonServices(language: str = None) -> dict`
388
+
389
+ Retrieves a list of all available add-on services.
390
+
391
+ **Parameters:**
392
+ - `language` (optional): Language preference for the response.
393
+
394
+ **Returns:**
395
+ A dictionary containing available add-on services.
396
+
397
+ ##### `getAddonSuggestions(language: str = None) -> dict`
398
+
399
+ Retrieves a list of suggested add-ons for installation.
400
+
401
+ **Parameters:**
402
+ - `language` (optional): Language preference for the response.
403
+
404
+ **Returns:**
405
+ A dictionary containing suggested add-ons.
406
+
407
+ ##### `getAddonTypes(language: str = None) -> dict`
408
+
409
+ Retrieves a list of all available add-on types.
410
+
411
+ **Parameters:**
412
+ - `language` (optional): Language preference for the response.
413
+
414
+ **Returns:**
415
+ A dictionary containing available add-on types.
416
+
417
+ ##### `installAddonFromUrl(url: str) -> dict`
418
+
419
+ Installs an add-on from a given URL.
420
+
421
+ **Parameters:**
422
+ - `url`: The URL of the add-on to install.
423
+
424
+ **Returns:**
425
+ A dictionary containing the installation status.
426
+
427
+ ### Audio
428
+
429
+ The `Audio` class provides methods for interacting with the OpenHAB audio API. It allows retrieving default audio sinks and sources, as well as listing available sinks and sources.
430
+
431
+ #### Initialization
432
+
433
+ ```python
434
+ from .client import OpenHABClient
435
+ from audio import Audio
436
+
437
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
438
+ audio = Audio(client)
439
+ ```
440
+
441
+ #### Methods
442
+
443
+ ##### `getDefaultSink(language: str = None) -> dict`
444
+
445
+ Retrieves the default audio sink if defined, or the first available sink.
446
+
447
+ **Parameters:**
448
+ - `language` (str, optional): The language for the response (sets the `Accept-Language` header).
449
+
450
+ **Returns:**
451
+ - `dict`: Information about the default sink.
452
+
453
+ ###### Example:
454
+
455
+ ```python
456
+ default_sink = audio.getDefaultSink()
457
+ print(default_sink)
458
+ ```
459
+
460
+ ##### `getDefaultSource(language: str = None) -> dict`
461
+
462
+ Retrieves the default audio source if defined, or the first available source.
463
+
464
+ **Parameters:**
465
+ - `language` (str, optional): The language for the response (sets the `Accept-Language` header).
466
+
467
+ **Returns:**
468
+ - `dict`: Information about the default source.
469
+
470
+ ###### Example:
471
+
472
+ ```python
473
+ default_source = audio.getDefaultSource()
474
+ print(default_source)
475
+ ```
476
+
477
+ ##### `getSinks(language: str = None) -> list`
478
+
479
+ Retrieves a list of all available audio sinks.
480
+
481
+ **Parameters:**
482
+ - `language` (str, optional): The language for the response (sets the `Accept-Language` header).
483
+
484
+ **Returns:**
485
+ - `list`: A list of available audio sinks.
486
+
487
+ ###### Example:
488
+
489
+ ```python
490
+ sinks = audio.getSinks()
491
+ print(sinks)
492
+ ```
493
+
494
+ ##### `getSources(language: str = None) -> list`
495
+
496
+ Retrieves a list of all available audio sources.
497
+
498
+ **Parameters:**
499
+ - `language` (str, optional): The language for the response (sets the `Accept-Language` header).
500
+
501
+ **Returns:**
502
+ - `list`: A list of available audio sources.
503
+
504
+ ###### Example:
505
+
506
+ ```python
507
+ sources = audio.getSources()
508
+ print(sources)
509
+ ```
510
+
511
+ ### Auth
512
+
513
+ The `Auth` class provides methods for handling authentication in OpenHAB, including retrieving API tokens, revoking tokens, logging out, and managing authentication sessions.
514
+
515
+ #### Initialization
516
+
517
+ ```python
518
+ from .client import OpenHABClient
519
+ from auth import Auth
520
+
521
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
522
+ auth = Auth(client)
523
+ ```
524
+
525
+ #### Methods
526
+
527
+ ##### `getApiTokens(language: str = None) -> dict`
528
+
529
+ Retrieves the API tokens associated with the authenticated user.
530
+
531
+ **Parameters:**
532
+ - `language` (str, optional): The language for the request (sets the `Accept-Language` header).
533
+
534
+ **Returns:**
535
+ - `dict`: JSON response containing API tokens.
536
+
537
+ ###### Example:
538
+
539
+ ```python
540
+ tokens = auth.getApiTokens()
541
+ print(tokens)
542
+ ```
543
+
544
+ ##### `revokeApiToken(tokenName: str, language: str = None) -> dict`
545
+
546
+ Revokes a specific API token associated with the authenticated user.
547
+
548
+ **Parameters:**
549
+ - `tokenName` (str): The name of the API token to revoke.
550
+ - `language` (str, optional): The language for the request.
551
+
552
+ **Returns:**
553
+ - `dict`: JSON response confirming the revocation.
554
+
555
+ ###### Example:
556
+
557
+ ```python
558
+ response = auth.revokeApiToken("my_token")
559
+ print(response)
560
+ ```
561
+
562
+ ##### `logout(refreshToken: str, language: str = None) -> dict`
563
+
564
+ Terminates the session associated with a given refresh token.
565
+
566
+ **Parameters:**
567
+ - `refreshToken` (str): The refresh token used to delete the session.
568
+ - `language` (str, optional): The language for the request.
569
+
570
+ **Returns:**
571
+ - `dict`: JSON response confirming the logout.
572
+
573
+ ###### Example:
574
+
575
+ ```python
576
+ response = auth.logout("my_refresh_token")
577
+ print(response)
578
+ ```
579
+
580
+ ##### `getSessions(language: str = None) -> dict`
581
+
582
+ Retrieves the sessions associated with the authenticated user.
583
+
584
+ **Parameters:**
585
+ - `language` (str, optional): The language for the request.
586
+
587
+ **Returns:**
588
+ - `dict`: JSON response containing session details.
589
+
590
+ ###### Example:
591
+
592
+ ```python
593
+ sessions = auth.getSessions()
594
+ print(sessions)
595
+ ```
596
+
597
+ ##### `getToken(grantType: str, code: str = None, redirectUri: str = None, clientID: str = None, refreshToken: str = None, codeVerifier: str = None, language: str = None) -> dict`
598
+
599
+ Obtains access and refresh tokens.
600
+
601
+ **Parameters:**
602
+ - `grantType` (str): The type of grant being requested.
603
+ - `code` (str, optional): Authorization code for authentication.
604
+ - `redirectUri` (str, optional): Redirect URI for OAuth authentication.
605
+ - `clientID` (str, optional): Client ID for authentication.
606
+ - `refreshToken` (str, optional): Refresh token for token renewal.
607
+ - `codeVerifier` (str, optional): Code verifier for PKCE authentication.
608
+ - `language` (str, optional): The language for the request.
609
+
610
+ **Returns:**
611
+ - `dict`: JSON response containing access and refresh tokens.
612
+
613
+ ###### Example:
614
+
615
+ ```python
616
+ token_response = auth.getToken(
617
+ grantType="authorization_code",
618
+ code="auth_code",
619
+ redirectUri="http://localhost/callback",
620
+ clientID="client123",
621
+ codeVerifier="verifier123"
622
+ )
623
+ print(token_response)
624
+ ```
625
+
626
+ ### ChannelTypes
627
+
628
+ The `ChannelTypes` class provides methods to interact with OpenHAB's channel types, allowing retrieval of all available channel types, specific channel types by UID, and linkable item types.
629
+
630
+ #### Initialization
631
+
632
+ ```python
633
+ from .client import OpenHABClient
634
+ from channel_types import ChannelTypes
635
+
636
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
637
+ channel_types = ChannelTypes(client)
638
+ ```
639
+
640
+ #### Methods
641
+
642
+ ##### `getAllChannelTypes(language: str = None, prefixes: str = None) -> list`
643
+
644
+ Retrieves all available channel types.
645
+
646
+ **Parameters:**
647
+ - `language` (str, optional): The preferred language for the response (`Accept-Language` header).
648
+ - `prefixes` (str, optional): A query parameter to filter channel types by prefix.
649
+
650
+ **Returns:**
651
+ - `list`: A list of available channel types.
652
+
653
+ ###### Example:
654
+
655
+ ```python
656
+ channels = channel_types.getAllChannelTypes(language="en", prefixes="zwave")
657
+ print(channels)
658
+ ```
659
+
660
+ ##### `getChannelTypeByUid(channelTypeUid: str, language: str = None) -> dict`
661
+
662
+ Retrieves details of a specific channel type by its UID.
663
+
664
+ **Parameters:**
665
+ - `channelTypeUid` (str): The unique identifier of the channel type.
666
+ - `language` (str, optional): The preferred language for the response.
667
+
668
+ **Returns:**
669
+ - `dict`: JSON response containing details of the specified channel type.
670
+
671
+ ###### Example:
672
+
673
+ ```python
674
+ channel_details = channel_types.getChannelTypeByUid("zwave:switch_binary", language="en")
675
+ print(channel_details)
676
+ ```
677
+
678
+ ##### `getLinkableItemTypes(channelTypeUid: str) -> list`
679
+
680
+ Retrieves the item types that can be linked to a specified trigger channel type.
681
+
682
+ **Parameters:**
683
+ - `channelTypeUid` (str): The unique identifier of the channel type.
684
+
685
+ **Returns:**
686
+ - `list`: A list of item types that can be linked to the given channel type.
687
+
688
+ ###### Example:
689
+
690
+ ```python
691
+ linkable_items = channel_types.getLinkableItemTypes("zwave:switch_binary")
692
+ print(linkable_items)
693
+ ```
694
+
695
+ ### ConfigDescriptions
696
+
697
+ The `ConfigDescriptions` class provides methods to interact with OpenHAB's configuration descriptions, allowing retrieval of all available descriptions and specific descriptions by URI.
698
+
699
+ #### Initialization
700
+
701
+ ```python
702
+ from .client import OpenHABClient
703
+ from config_descriptions import ConfigDescriptions
704
+
705
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
706
+ config_descriptions = ConfigDescriptions(client)
707
+ ```
708
+
709
+ #### Methods
710
+
711
+ ##### `getAllConfigDescriptions(language: str = None, scheme: str = None) -> list`
712
+
713
+ Retrieves all available configuration descriptions.
714
+
715
+ **Parameters:**
716
+ - `language` (str, optional): The preferred language for the response (`Accept-Language` header).
717
+ - `scheme` (str, optional): A query parameter to filter results by a specific scheme.
718
+
719
+ **Returns:**
720
+ - `list`: A list of available configuration descriptions.
721
+
722
+ ###### Example:
723
+
724
+ ```python
725
+ configs = config_descriptions.getAllConfigDescriptions(language="en", scheme="thing")
726
+ print(configs)
727
+ ```
728
+
729
+ ##### `getConfigDescriptionByUri(uri: str, language: str = None) -> dict`
730
+
731
+ Retrieves a specific configuration description by its URI.
732
+
733
+ **Parameters:**
734
+ - `uri` (str): The URI of the requested configuration description.
735
+ - `language` (str, optional): The preferred language for the response.
736
+
737
+ **Returns:**
738
+ - `dict`: JSON response containing details of the specified configuration description.
739
+
740
+ ###### Example:
741
+
742
+ ```python
743
+ config_details = config_descriptions.getConfigDescriptionByUri("thing-type:zwave:device", language="en")
744
+ print(config_details)
745
+ ```
746
+
747
+ ### Discovery
748
+
749
+ The `Discovery` class provides methods to interact with OpenHAB's discovery service, allowing retrieval of all available bindings that support discovery and starting a discovery scan for specific bindings.
750
+
751
+ #### Initialization
752
+
753
+ ```python
754
+ from .client import OpenHABClient
755
+ from discovery import Discovery
756
+
757
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
758
+ discovery = Discovery(client)
759
+ ```
760
+
761
+ #### Methods
762
+
763
+ ##### `getAllDiscoveryBindings() -> list`
764
+
765
+ Retrieves all bindings that support discovery.
766
+
767
+ **Returns:**
768
+ - `list`: A list of strings representing the bindings that support discovery.
769
+
770
+ ###### Example:
771
+
772
+ ```python
773
+ bindings = discovery.getAllDiscoveryBindings()
774
+ print(bindings)
775
+ ```
776
+
777
+ ##### `startBindingScan(bindingID: str) -> int`
778
+ Starts the asynchronous discovery process for a binding and returns the timeout duration in seconds.
779
+
780
+ **Parameters:**
781
+ - `bindingID` (str): The ID of the binding for which the discovery process is to be started.
782
+
783
+ **Returns:**
784
+ - `int`: Timeout duration of the discovery operation in seconds.
785
+
786
+ ###### Example:
787
+
788
+ ```python
789
+ timeout = discovery.startBindingScan("zwave")
790
+ print(timeout)
791
+ ```
792
+
793
+ ### Events
794
+
795
+ The `Events` class provides methods to interact with OpenHAB's event service. It allows you to retrieve various event streams, including item-related events, thing-related events, inbox events, and more.
796
+
797
+ #### Initialization
798
+
799
+ ```python
800
+ from .client import OpenHABClient
801
+ from events import Events
802
+
803
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
804
+ events = Events(client)
805
+ ```
806
+
807
+ #### Methods
808
+
809
+ ##### `getAllEvents(topics: str = None) -> list`
810
+
811
+ Retrieves all available events, optionally filtered by topic.
812
+
813
+ **Parameters:**
814
+ - `topics` (str, optional): A comma-separated list of topics to filter the events by.
815
+
816
+ **Returns:**
817
+ - `list`: A SSE stream of events.
818
+
819
+ ###### Example:
820
+
821
+ ```python
822
+ events = events.getAllEvents(topics="openhab/items")
823
+ print(events)
824
+ ```
825
+
826
+ ##### `initiateStateTracker() -> str`
827
+
828
+ Initiates a new item state tracker connection.
829
+
830
+ **Returns:**
831
+ - `str`: The connection ID as a string.
832
+
833
+ ###### Example:
834
+
835
+ ```python
836
+ connection_id = events.initiateStateTracker()
837
+ print(connection_id)
838
+ ```
839
+
840
+ ##### `updateSseConnectionItems(connectionId: str, items: list) -> str`
841
+
842
+ Changes the list of items an SSE connection will receive state updates for.
843
+
844
+ **Parameters:**
845
+ - `connectionId` (str): The ID of the existing connection.
846
+ - `items` (list): A list of item names to subscribe to for state updates.
847
+
848
+ **Returns:**
849
+ - `str`: A success message when the update is completed.
850
+
851
+ ###### Example:
852
+
853
+ ```python
854
+ success_message = events.updateSseConnectionItems("connection-id", ["item1", "item2"])
855
+ print(success_message)
856
+ ```
857
+
858
+ #### `ItemEvents` Class
859
+
860
+ The `ItemEvents` class allows you to retrieve events related to items.
861
+
862
+ ##### `ItemEvent()`
863
+
864
+ Get all item-related events.
865
+
866
+ **Returns:**
867
+ - `list`: A SSE stream of item events.
868
+
869
+ ##### `ItemAddedEvent(itemName: str = "*")`
870
+
871
+ Get events for added items.
872
+
873
+ **Parameters:**
874
+ - `itemName` (str, optional): The name of the item (default is "*").
875
+
876
+ **Returns:**
877
+ - `list`: A SSE stream of added item events.
878
+
879
+ ##### `ItemRemovedEvent(itemName: str = "*")`
880
+
881
+ Get events for removed items.
882
+
883
+ **Parameters:**
884
+ - `itemName` (str, optional): The name of the item (default is "*").
885
+
886
+ **Returns:**
887
+ - `list`: A SSE stream of removed item events.
888
+
889
+ ##### `ItemUpdatedEvent(itemName: str = "*")`
890
+
891
+ Get events for updated items.
892
+
893
+ **Parameters:**
894
+ - `itemName` (str, optional): The name of the item (default is "*").
895
+
896
+ **Returns:**
897
+ - `list`: A SSE stream of updated item events.
898
+
899
+ ##### `ItemCommandEvent(itemName: str = "*")`
900
+
901
+ Get events for item commands.
902
+
903
+ **Parameters:**
904
+ - `itemName` (str, optional): The name of the item (default is "*").
905
+
906
+ **Returns:**
907
+ - `list`: A SSE stream of item command events.
908
+
909
+ ##### `ItemStateEvent(itemName: str = "*")`
910
+
911
+ Get events for item state changes.
912
+
913
+ **Parameters:**
914
+ - `itemName` (str, optional): The name of the item (default is "*").
915
+
916
+ **Returns:**
917
+ - `list`: A SSE stream of item state events.
918
+
919
+ ##### `ItemStatePredictedEvent(itemName: str = "*")`
920
+
921
+ Get events for predicted item state changes.
922
+
923
+ **Parameters:**
924
+ - `itemName` (str, optional): The name of the item (default is "*").
925
+
926
+ **Returns:**
927
+ - `list`: A SSE stream of predicted item state events.
928
+
929
+ ##### `ItemStateChangedEvent(itemName: str = "*")`
930
+
931
+ Get events for item state changes.
932
+
933
+ **Parameters:**
934
+ - `itemName` (str, optional): The name of the item (default is "*").
935
+
936
+ **Returns:**
937
+ - `list`: A SSE stream of state changed events.
938
+
939
+ #### `ThingEvents` Class
940
+
941
+ The `ThingEvents` class allows you to retrieve events related to things.
942
+
943
+ ##### `ThingAddedEvent(thingUID: str = "*")`
944
+
945
+ Get events for added things.
946
+
947
+ **Parameters:**
948
+ - `thingUID` (str, optional): The UID of the thing (default is "*").
949
+
950
+ **Returns:**
951
+ - `list`: A SSE stream of added thing events.
952
+
953
+ ##### `ThingRemovedEvent(thingUID: str = "*")`
954
+
955
+ Get events for removed things.
956
+
957
+ **Parameters:**
958
+ - `thingUID` (str, optional): The UID of the thing (default is "*").
959
+
960
+ **Returns:**
961
+ - `list`: A SSE stream of removed thing events.
962
+
963
+ ##### `ThingUpdatedEvent(thingUID: str = "*")`
964
+
965
+ Get events for updated things.
966
+
967
+ **Parameters:**
968
+ - `thingUID` (str, optional): The UID of the thing (default is "*").
969
+
970
+ **Returns:**
971
+ - `list`: A SSE stream of updated thing events.
972
+
973
+ ##### `ThingStatusInfoEvent(thingUID: str = "*")`
974
+
975
+ Get events for thing status information.
976
+
977
+ **Parameters:**
978
+ - `thingUID` (str, optional): The UID of the thing (default is "*").
979
+
980
+ **Returns:**
981
+ - `list`: A SSE stream of status information events.
982
+
983
+ ##### `ThingStatusInfoChangedEvent(thingUID: str = "*")`
984
+
985
+ Get events for thing status information changes.
986
+
987
+ **Parameters:**
988
+ - `thingUID` (str, optional): The UID of the thing (default is "*").
989
+
990
+ **Returns:**
991
+ - `list`: A SSE stream of status changed events.
992
+
993
+ #### `InboxEvents` Class
994
+
995
+ The `InboxEvents` class allows you to retrieve events related to things in the inbox.
996
+
997
+ ##### `InboxAddedEvent(thingUID: str = "*")`
998
+
999
+ Get events for added things in the inbox.
1000
+
1001
+ **Parameters:**
1002
+ - `thingUID` (str, optional): The UID of the thing (default is "*").
1003
+
1004
+ **Returns:**
1005
+ - `list`: A SSE stream of added inbox events.
1006
+
1007
+ ##### `InboxRemovedEvent(thingUID: str = "*")`
1008
+
1009
+ Get events for removed things in the inbox.
1010
+
1011
+ **Parameters:**
1012
+ - `thingUID` (str, optional): The UID of the thing (default is "*").
1013
+
1014
+ **Returns:**
1015
+ - `list`: A SSE stream of removed inbox events.
1016
+
1017
+ ##### `InboxUpdatedEvent(thingUID: str = "*")`
1018
+
1019
+ Get events for updated things in the inbox.
1020
+
1021
+ **Parameters:**
1022
+ - `thingUID` (str, optional): The UID of the thing (default is "*").
1023
+
1024
+ **Returns:**
1025
+ - `list`: A SSE stream of updated inbox events.
1026
+
1027
+ #### `LinkEvents` Class
1028
+
1029
+ The `LinkEvents` class allows you to retrieve events related to item-channel links.
1030
+
1031
+ ##### `ItemChannelLinkAddedEvent(itemName: str = "*", channelUID: str = "*")`
1032
+
1033
+ Get events for added item-channel links.
1034
+
1035
+ **Parameters:**
1036
+ - `itemName` (str, optional): The name of the item (default is "*").
1037
+ - `channelUID` (str, optional): The UID of the channel (default is "*").
1038
+
1039
+ **Returns:**
1040
+ - `list`: A SSE stream of added item-channel link events.
1041
+
1042
+ ##### `ItemChannelLinkRemovedEvent(itemName: str = "*", channelUID: str = "*")`
1043
+
1044
+ Get events for removed item-channel links.
1045
+
1046
+ **Parameters:**
1047
+ - `itemName` (str, optional): The name of the item (default is "*").
1048
+ - `channelUID` (str, optional): The UID of the channel (default is "*").
1049
+
1050
+ **Returns:**
1051
+ - `list`: A SSE stream of removed item-channel link events.
1052
+
1053
+ #### `ChannelEvents` Class
1054
+
1055
+ The `ChannelEvents` class allows you to retrieve events related to channel descriptions and triggers.
1056
+
1057
+ ##### `ChannelDescriptionChangedEvent(channelUID: str = "*")`
1058
+
1059
+ Get events for changes in channel descriptions.
1060
+
1061
+ **Parameters:**
1062
+ - `channelUID` (str, optional): The UID of the channel (default is "*").
1063
+
1064
+ **Returns:**
1065
+ - `list`: A SSE stream of channel description changed events.
1066
+
1067
+ ##### `ChannelTriggeredEvent(channelUID: str = "*")`
1068
+
1069
+ Get events for triggered channels.
1070
+
1071
+ **Parameters:**
1072
+ - `channelUID` (str, optional): The UID of the channel (default is "*").
1073
+
1074
+ **Returns:**
1075
+ - `list`: A SSE stream of triggered channel events.
1076
+
1077
+ ### Iconsets
1078
+
1079
+ The `Iconsets` class provides methods to interact with OpenHAB's icon sets. It allows you to retrieve all available icon sets, optionally filtered by language.
1080
+
1081
+ #### Initialization
1082
+
1083
+ ```python
1084
+ from .client import OpenHABClient
1085
+ from iconsets import Iconsets
1086
+
1087
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1088
+ iconsets = Iconsets(client)
1089
+ ```
1090
+
1091
+ #### Methods
1092
+
1093
+ ##### `getAllIconsets(language: str = None) -> list`
1094
+
1095
+ Gets all icon sets, optionally filtered by language.
1096
+
1097
+ **Parameters:**
1098
+ - `language` (str, optional): An optional language preference for the response (e.g., 'en', 'de').
1099
+
1100
+ **Returns:**
1101
+ - `list`: A list of icon sets with details such as ID, label, description, and supported formats.
1102
+
1103
+ ###### Example:
1104
+
1105
+ ```python
1106
+ iconsets = iconsets.getAllIconsets(language="en")
1107
+ print(iconsets)
1108
+ ```
1109
+
1110
+ ### Inbox
1111
+
1112
+ The `Inbox` class provides methods to interact with the inbox of discovered things in OpenHAB. It allows you to retrieve all discovered things, approve or ignore discovery results, and remove entries from the inbox.
1113
+
1114
+ #### Initialization
1115
+
1116
+ ```python
1117
+ from .client import OpenHABClient
1118
+ from inbox import Inbox
1119
+
1120
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1121
+ inbox = Inbox(client)
1122
+ ```
1123
+
1124
+ #### Methods
1125
+
1126
+ ##### `getAllDiscoveredThings(includeIgnored: bool = True) -> list`
1127
+
1128
+ Gets all discovered things, optionally including ignored ones.
1129
+
1130
+ **Parameters:**
1131
+ - `includeIgnored` (bool, optional): Whether ignored entries should also be included. Defaults to `True`.
1132
+
1133
+ **Returns:**
1134
+ - `list`: A list of discovered things with details such as UID, flag, label, and properties.
1135
+
1136
+ ###### Example:
1137
+
1138
+ ```python
1139
+ discovered_things = inbox.getAllDiscoveredThings()
1140
+ print(discovered_things)
1141
+ ```
1142
+
1143
+ ##### `removeDiscoveryResult(thingUID: str) -> dict`
1144
+
1145
+ Removes a discovery result from the inbox.
1146
+
1147
+ **Parameters:**
1148
+ - `thingUID` (str): The UID of the discovered thing to be removed.
1149
+
1150
+ **Returns:**
1151
+ - `dict`: The API response to the delete request.
1152
+
1153
+ ###### Example:
1154
+
1155
+ ```python
1156
+ response = inbox.removeDiscoveryResult("someThingUID")
1157
+ print(response)
1158
+ ```
1159
+
1160
+ ##### `approveDiscoveryResult(thingUID: str, thingLabel: str, newThingID: str = None, language: str = None) -> dict`
1161
+
1162
+ Approves the discovery result by adding the thing to the registry.
1163
+
1164
+ **Parameters:**
1165
+ - `thingUID` (str): The UID of the discovered thing.
1166
+ - `thingLabel` (str): The new name of the thing.
1167
+ - `newThingID` (str, optional): The new thing ID.
1168
+ - `language` (str, optional): The language preference for the response.
1169
+
1170
+ **Returns:**
1171
+ - `dict`: The API response to the approval request.
1172
+
1173
+ ###### Example:
1174
+ ```python
1175
+ response = inbox.approveDiscoveryResult("someThingUID", "NewThingLabel")
1176
+ print(response)
1177
+ ```
1178
+
1179
+ ##### `ignoreDiscoveryResult(thingUID: str) -> dict`
1180
+
1181
+ Flags a discovery result as ignored for further processing.
1182
+
1183
+ **Parameters:**
1184
+ - `thingUID` (str): The UID of the discovered thing.
1185
+
1186
+ **Returns:**
1187
+ - `dict`: The API response to the ignore request.
1188
+
1189
+ ###### Example:
1190
+
1191
+ ```python
1192
+ response = inbox.ignoreDiscoveryResult("someThingUID")
1193
+ print(response)
1194
+ ```
1195
+
1196
+ ##### `unignoreDiscoveryResult(thingUID: str) -> dict`
1197
+
1198
+ Removes the ignore flag from a discovery result.
1199
+
1200
+ **Parameters:**
1201
+ - `thingUID` (str): The UID of the discovered thing.
1202
+
1203
+ **Returns:**
1204
+ - `dict`: The API response to the unignore request.
1205
+
1206
+ ###### Example:
1207
+
1208
+ ```python
1209
+ response = inbox.unignoreDiscoveryResult("someThingUID")
1210
+ print(response)
1211
+ ```
1212
+
1213
+ ### Items
1214
+
1215
+ The `Items` class provides methods for managing OpenHAB items via the REST API. It enables the retrieval, addition, updating and deletion of items as well as the management of tags, metadata and statuses.
1216
+
1217
+ #### **Initilization**
1218
+
1219
+ ```python
1220
+ from .client import OpenHABClient
1221
+ from items import Items
1222
+
1223
+ client = OpenHABClient("http://openhab-server:8080", username="user", password="pass")
1224
+ items = Items(client)
1225
+ ```
1226
+
1227
+ #### **Methoden**
1228
+
1229
+ ##### `getAllItems(...) -> list`
1230
+
1231
+ Retrieves all available items.
1232
+
1233
+ **Parameter:**
1234
+ - `language` (str, optional): Language filter for the header `Accept-Language`.
1235
+ - `type` (str, optional): Item type filter.
1236
+ - `tags` (str, optional): Item tag filter.
1237
+ - `metadata` (str, optional): Metadata selector (default: `.*`).
1238
+ - `recursive` (bool, optional): Should group members be retrieved recursively? (Default: `False`).
1239
+ - `fields` (str, optional): Limitation to certain fields (comma-separated).
1240
+ - `staticDataOnly` (bool, optional): Only return cached data? (Default: `False`).
1241
+
1242
+ **Example:**
1243
+
1244
+ ```python
1245
+ all_items = items.getAllItems(language="de", type="Switch")
1246
+ print(all_items)
1247
+ ```
1248
+
1249
+ ##### `addOrUpdateItems(items: list) -> dict`
1250
+
1251
+ Adds a list of items or updates existing ones.
1252
+
1253
+ **Parameter:**
1254
+ - `items` (list): List of items as a dictionary.
1255
+
1256
+ **Example:**
1257
+
1258
+ ```python
1259
+ new_items = [{"name": "NewLight", "type": "Switch"}]
1260
+ response = items.addOrUpdateItems(new_items)
1261
+ print(response)
1262
+ ```
1263
+
1264
+ ##### `getItem(itemName: str, ...) -> dict`
1265
+
1266
+ Gets the details of a single item.
1267
+
1268
+ **Parameter:**
1269
+ - `itemName` (str): Name of the item.
1270
+ - `language`, `metadata`, `recursive` (see `getAllItems`).
1271
+
1272
+ **Example:**
1273
+
1274
+ ```python
1275
+ item_data = items.getItem("LivingRoomLight")
1276
+ print(item_data)
1277
+ ```
1278
+
1279
+ ##### `addOrUpdateItem(itemName: str, itemData: dict, ...) -> dict`
1280
+
1281
+ Adds or updates an item.
1282
+
1283
+ **Parameter:**
1284
+ - `itemName` (str): Name of the item.
1285
+ - `itemData` (dict): Data of the item.
1286
+ - `language` (str, optional).
1287
+
1288
+ **Example:**
1289
+
1290
+ ```python
1291
+ new_item = {"type": "Switch", "label": "New Light"}
1292
+ response = items.addOrUpdateItem("NewLight", new_item)
1293
+ print(response)
1294
+ ```
1295
+
1296
+ ##### `sendCommand(itemName: str, command: str) -> dict`
1297
+
1298
+ Sends a command to an item.
1299
+
1300
+ **Example:**
1301
+
1302
+ ```python
1303
+ response = items.sendCommand("LivingRoomLight", "ON")
1304
+ print(response)
1305
+ ```
1306
+
1307
+ ##### `postUpdate(itemName: str, state: str) -> dict`
1308
+
1309
+ Updates the status of an item.
1310
+
1311
+ **Example:**
1312
+
1313
+ ```python
1314
+ response = items.postUpdate("LivingRoomLight", "OFF")
1315
+ print(response)
1316
+ ```
1317
+
1318
+ ##### `deleteItem(itemName: str) -> dict`
1319
+
1320
+ Deletes an item from the registry.
1321
+
1322
+ **Example:**
1323
+
1324
+ ```python
1325
+ response = items.deleteItem("OldItem")
1326
+ print(response)
1327
+ ```
1328
+
1329
+ ##### `addGroupMember(itemName: str, memberItemName: str) -> dict`
1330
+
1331
+ Adds an item to a group.
1332
+
1333
+ **Example:**
1334
+
1335
+ ```python
1336
+ response = items.addGroupMember("LivingRoomGroup", "NewLight")
1337
+ print(response)
1338
+ ```
1339
+
1340
+ ##### `removeGroupMember(itemName: str, memberItemName: str) -> dict`
1341
+
1342
+ Removes an item from a group.
1343
+
1344
+ **Example:**
1345
+ ```python
1346
+ response = items.removeGroupMember("LivingRoomGroup", "OldLight")
1347
+ print(response)
1348
+ ```
1349
+
1350
+ ##### `addMetadata(itemName: str, namespace: str, metadata: dict) -> dict`
1351
+
1352
+ Adds metadata to an item.
1353
+
1354
+ **Example:**
1355
+
1356
+ ```python
1357
+ metadata = {"value": "20", "config": {"unit": "°C"}}
1358
+ response = items.addMetadata("Thermostat", "temperature", metadata)
1359
+ print(response)
1360
+ ```
1361
+
1362
+ ##### `removeMetadata(itemName: str, namespace: str) -> dict`
1363
+
1364
+ Removes metadata from an item.
1365
+
1366
+ **Example:**
1367
+
1368
+ ```python
1369
+ response = items.removeMetadata("Thermostat", "temperature")
1370
+ print(response)
1371
+ ```
1372
+
1373
+ ##### `getMetadataNamespaces(itemName: str, ...) -> list`
1374
+
1375
+ Returns the metadata namespace of an item.
1376
+
1377
+ **Example:**
1378
+
1379
+ ```python
1380
+ namespaces = items.getMetadataNamespaces("Thermostat")
1381
+ print(namespaces)
1382
+ ```
1383
+
1384
+ ##### `getSemanticItem(itemName: str, semanticClass: str, ...) -> dict`
1385
+
1386
+ Returns the item of a specific semantic class.
1387
+
1388
+ **Example:**
1389
+
1390
+ ```python
1391
+ semantic_item = items.getSemanticItem("Thermostat", "Point")
1392
+ print(semantic_item)
1393
+ ```
1394
+
1395
+ ##### `getItemState(itemName: str) -> dict`
1396
+
1397
+ Gets the current status of an item.
1398
+
1399
+ **Example:**
1400
+
1401
+ ```python
1402
+ state = items.getItemState("LivingRoomLight")
1403
+ print(state)
1404
+ ```
1405
+
1406
+ ##### `updateItemState(itemName: str, state: str, ...) -> dict`
1407
+
1408
+ Updates the status of an item.
1409
+
1410
+ **Example:**
1411
+
1412
+ ```python
1413
+ response = items.updateItemState("LivingRoomLight", "ON")
1414
+ print(response)
1415
+ ```
1416
+
1417
+ ##### `addTag(itemName: str, tag: str) -> dict`
1418
+
1419
+ Adds a tag to an item.
1420
+
1421
+ **Example:**
1422
+ ```python
1423
+ response = items.addTag("LivingRoomLight", "Lighting")
1424
+ print(response)
1425
+ ```
1426
+
1427
+ ##### `removeTag(itemName: str, tag: str) -> dict`
1428
+
1429
+ Removes a tag from an item.
1430
+
1431
+ **Example:**
1432
+
1433
+ ```python
1434
+ response = items.removeTag("LivingRoomLight", "Lighting")
1435
+ print(response)
1436
+ ```
1437
+
1438
+ ##### `purgeOrphanedMetadata() -> dict`
1439
+
1440
+ Deletes unused metadata.
1441
+
1442
+ **Example:**
1443
+
1444
+ ```python
1445
+ response = items.purgeOrphanedMetadata()
1446
+ print(response)
1447
+ ```
1448
+
1449
+ ### Links
1450
+
1451
+ The `Links` class provides methods to manage links between items and channels in OpenHAB via the REST API.
1452
+
1453
+ #### Methods
1454
+
1455
+ ##### `getAllLinks(channelUID: str = None, itemName: str = None) -> list`
1456
+
1457
+ Retrieves all available links.
1458
+
1459
+ - `channelUID` *(optional, str)* – Filters by the Channel UID.
1460
+ - `itemName` *(optional, str)* – Filters by the Item Name.
1461
+
1462
+ **Returns:** A list of links containing details such as `itemName`, `channelUID`, and configuration.
1463
+
1464
+ ##### `getIndividualLink(itemName: str, channelUID: str) -> dict`
1465
+
1466
+ Retrieves a specific link between an item and a channel.
1467
+
1468
+ - `itemName` *(str)* – The name of the item.
1469
+ - `channelUID` *(str)* – The UID of the channel.
1470
+
1471
+ **Returns:** A dictionary containing details of the link, including the item, channel UID, and configuration.
1472
+
1473
+ ##### `linkItemToChannel(itemName: str, channelUID: str, configuration: dict) -> dict`
1474
+
1475
+ Creates a link between an item and a channel.
1476
+
1477
+ - `itemName` *(str)* – The name of the item.
1478
+ - `channelUID` *(str)* – The UID of the channel.
1479
+ - `configuration` *(dict)* – The configuration parameters for the link.
1480
+
1481
+ **Returns:** The API response confirming the link creation.
1482
+
1483
+ ##### `unlinkItemFromChannel(itemName: str, channelUID: str) -> dict`
1484
+
1485
+ Removes a link between an item and a channel.
1486
+
1487
+ - `itemName` *(str)* – The name of the item.
1488
+ - `channelUID` *(str)* – The UID of the channel.
1489
+
1490
+ **Returns:** The API response confirming the link removal.
1491
+
1492
+ ##### `deleteAllLinks(object: str) -> dict`
1493
+
1494
+ Deletes all links that refer to a specific item or thing.
1495
+
1496
+ - `object` *(str)* – The name of the item or the UID of the thing.
1497
+
1498
+ **Returns:** The API response confirming the deletion.
1499
+
1500
+ ##### `getOrphanLinks() -> list`
1501
+
1502
+ Retrieves orphaned links, which refer to items connected to non-existent or broken channels.
1503
+
1504
+ **Returns:** A list of orphaned links.
1505
+
1506
+ ##### `purgeUnusedLinks() -> dict`
1507
+
1508
+ Removes all unused or orphaned links.
1509
+
1510
+ **Returns:** The API response confirming the removal.
1511
+
1512
+ ### Logging
1513
+
1514
+ The `Logging` class provides methods to manage loggers in OpenHAB via the REST API.
1515
+
1516
+ #### Methods
1517
+
1518
+ ##### `getAllLoggers() -> dict`
1519
+
1520
+ Retrieves all available loggers.
1521
+
1522
+ **Returns:** A dictionary containing all loggers with their names and logging levels.
1523
+
1524
+ ##### `getSingleLogger(loggerName: str) -> dict`
1525
+
1526
+ Retrieves a specific logger.
1527
+
1528
+ - `loggerName` *(str)* – The name of the logger.
1529
+
1530
+ **Returns:** A dictionary containing the logger name and its current logging level.
1531
+
1532
+ ##### `modifyOrAddLogger(loggerName: str, level: str) -> dict`
1533
+
1534
+ Modifies an existing logger or creates a new one with a specified logging level.
1535
+
1536
+ - `loggerName` *(str)* – The name of the logger.
1537
+ - `level` *(str)* – The logging level (e.g., `DEBUG`, `INFO`, `WARN`, `ERROR`).
1538
+
1539
+ **Returns:** The API response confirming the modification or addition.
1540
+
1541
+ ##### `removeLogger(loggerName: str) -> dict`
1542
+
1543
+ Removes a specific logger.
1544
+
1545
+ - `loggerName` *(str)* – The name of the logger.
1546
+
1547
+ **Returns:** The API response confirming the removal.
1548
+
1549
+ ### ModuleTypes
1550
+
1551
+ The `ModuleTypes` class provides methods to retrieve module types in OpenHAB via the REST API.
1552
+
1553
+ #### Methods
1554
+
1555
+ ##### `getModuleTypes(tags=None, typeFilter=None, language: str = None) -> list`
1556
+
1557
+ Retrieves all available module types.
1558
+
1559
+ - `tags` *(Optional, str)* – Filter for specific tags.
1560
+ - `typeFilter` *(Optional, str)* – Filter by module type (`action`, `condition`, `trigger`).
1561
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1562
+
1563
+ **Returns:** A list of available module types.
1564
+
1565
+ ##### `getModuleType(moduleTypeUID: str, language: str = None) -> dict`
1566
+
1567
+ Retrieves a specific module type based on its UID.
1568
+
1569
+ - `moduleTypeUID` *(str)* – The UID of the module type.
1570
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1571
+
1572
+ **Returns:** A dictionary containing the module type information.
1573
+
1574
+ ### Persistence
1575
+
1576
+ The `Persistence` class provides methods to interact with OpenHAB's persistence services via the REST API.
1577
+
1578
+ #### Methods
1579
+
1580
+ ##### `getAllServices() -> dict`
1581
+
1582
+ Retrieves a list of available persistence services.
1583
+
1584
+ **Returns:** A list of persistence services with their IDs, labels, and types.
1585
+
1586
+ ##### `getServiceConfiguration(serviceId: str) -> dict`
1587
+
1588
+ Retrieves the configuration of a specific persistence service.
1589
+
1590
+ - `serviceId` *(str)* – The ID of the persistence service.
1591
+
1592
+ **Returns:** A dictionary containing the service configuration.
1593
+
1594
+ ##### `setServiceConfiguration(serviceId: str, config: dict) -> dict`
1595
+
1596
+ Sets the configuration of a persistence service.
1597
+
1598
+ - `serviceId` *(str)* – The ID of the persistence service.
1599
+ - `config` *(dict)* – The configuration data for the service.
1600
+
1601
+ **Returns:** The API response after modifying the configuration.
1602
+
1603
+ ##### `deleteServiceConfiguration(serviceId: str) -> dict`
1604
+
1605
+ Deletes the configuration of a persistence service.
1606
+
1607
+ - `serviceId` *(str)* – The ID of the persistence service.
1608
+
1609
+ **Returns:** The API response after deleting the configuration.
1610
+
1611
+ ##### `getItemsForService(serviceId: str) -> dict`
1612
+
1613
+ Retrieves a list of items available in a specific persistence service.
1614
+
1615
+ - `serviceId` *(str)* – The ID of the persistence service.
1616
+
1617
+ **Returns:** A list of items with their last and earliest timestamps.
1618
+
1619
+ ##### `getItemPersistenceData(serviceId: str, itemName: str, startTime: str = None, endTime: str = None, page: int = 1, pageLength: int = 50) -> dict`
1620
+
1621
+ Retrieves persistence data for a specific item from a persistence service.
1622
+
1623
+ - `serviceId` *(str)* – The ID of the persistence service.
1624
+ - `itemName` *(str)* – The name of the item.
1625
+ - `startTime` *(Optional, str)* – The start time for the data. Defaults to one day before `endTime`.
1626
+ - `endTime` *(Optional, str)* – The end time for the data. Defaults to the current time.
1627
+ - `page` *(Optional, int)* – The page number for paginated results. Defaults to `1`.
1628
+ - `pageLength` *(Optional, int)* – The number of data points per page. Defaults to `50`.
1629
+
1630
+ **Returns:** The retrieved data points of the item.
1631
+
1632
+ ##### `storeItemData(serviceId: str, itemName: str, time: str, state: str) -> dict`
1633
+
1634
+ Stores persistence data for a specific item.
1635
+
1636
+ - `serviceId` *(str)* – The ID of the persistence service.
1637
+ - `itemName` *(str)* – The name of the item.
1638
+ - `time` *(str)* – The timestamp for the stored data.
1639
+ - `state` *(str)* – The state value to be stored.
1640
+
1641
+ **Returns:** The API response after storing the data.
1642
+
1643
+ ##### `deleteItemData(serviceId: str, itemName: str, startTime: str, endTime: str) -> dict`
1644
+
1645
+ Deletes persistence data for a specific item within a given time range.
1646
+
1647
+ - `serviceId` *(str)* – The ID of the persistence service.
1648
+ - `itemName` *(str)* – The name of the item.
1649
+ - `startTime` *(str)* – The start time of the data to be deleted.
1650
+ - `endTime` *(str)* – The end time of the data to be deleted.
1651
+
1652
+ **Returns:** The API response after deleting the data.
1653
+
1654
+ ### ProfileTypes
1655
+
1656
+ The `ProfileTypes` class provides methods to interact with OpenHAB's profile types via the REST API.
1657
+
1658
+ #### Methods
1659
+
1660
+ ##### `getProfileTypes(channelTypeUID: str = None, itemType: str = None, language: str = None) -> dict`
1661
+
1662
+ Retrieves all available profile types.
1663
+
1664
+ - `channelTypeUID` *(Optional, str)* – Filters the results by channel type UID.
1665
+ - `itemType` *(Optional, str)* – Filters the results by item type.
1666
+ - `language` *(Optional, str)* – Specifies the language for the `Accept-Language` header.
1667
+
1668
+ **Returns:** A list of profile types.
1669
+
1670
+ ### Rules
1671
+
1672
+ The `Rules` class provides methods to interact with OpenHAB's rules via the REST API.
1673
+
1674
+ #### Methods
1675
+
1676
+ ##### `getRules(prefix: str = None, tags: list = None, summary: bool = False, staticDataOnly: bool = False) -> dict`
1677
+
1678
+ Retrieves available rules, optionally filtered by tags and/or prefix.
1679
+
1680
+ - `prefix` *(Optional, str)* – Filters results by prefix.
1681
+ - `tags` *(Optional, list)* – Filters results by tag array.
1682
+ - `summary` *(Optional, bool)* – If `True`, only summary fields are returned.
1683
+ - `staticDataOnly` *(Optional, bool)* – If `True`, only static data is returned.
1684
+
1685
+ **Returns:** A list of rules (JSON objects).
1686
+
1687
+ ##### `createRule(ruleData: dict) -> dict`
1688
+
1689
+ Creates a new rule.
1690
+
1691
+ - `ruleData` *(dict)* – The rule data to be created.
1692
+
1693
+ **Returns:** The created rule (JSON).
1694
+
1695
+ ##### `getRule(ruleUID: str) -> dict`
1696
+
1697
+ Retrieves a rule by its UID.
1698
+
1699
+ - `ruleUID` *(str)* – The UID of the rule.
1700
+
1701
+ **Returns:** The rule object (JSON).
1702
+
1703
+ ##### `updateRule(ruleUID: str, ruleData: dict) -> dict`
1704
+
1705
+ Updates an existing rule.
1706
+
1707
+ - `ruleUID` *(str)* – The UID of the rule.
1708
+ - `ruleData` *(dict)* – The new rule data.
1709
+
1710
+ **Returns:** The updated rule (JSON).
1711
+
1712
+ ##### `deleteRule(ruleUID: str) -> dict`
1713
+
1714
+ Removes a rule.
1715
+
1716
+ - `ruleUID` *(str)* – The UID of the rule.
1717
+
1718
+ **Returns:** API response (status code).
1719
+
1720
+ ##### `setRuleState(ruleUID: str, enable: bool) -> dict`
1721
+
1722
+ Activates or deactivates a rule.
1723
+
1724
+ - `ruleUID` *(str)* – The UID of the rule.
1725
+ - `enable` *(bool)* – `True` to enable, `False` to disable.
1726
+
1727
+ **Returns:** API response (status code).
1728
+
1729
+ ##### `enableRule(ruleUID: str) -> dict`
1730
+
1731
+ Enables a rule.
1732
+
1733
+ ##### `disableRule(ruleUID: str) -> dict`
1734
+
1735
+ Disables a rule.
1736
+
1737
+ ##### `runNow(ruleUID: str, contextData: dict = None) -> dict`
1738
+
1739
+ Executes the rule's actions immediately.
1740
+
1741
+ - `ruleUID` *(str)* – The UID of the rule.
1742
+ - `contextData` *(Optional, dict)* – Context data for execution.
1743
+
1744
+ **Returns:** API response (status code).
1745
+
1746
+ ##### `simulateSchedule(fromTime: str, untilTime: str) -> dict`
1747
+
1748
+ Simulates rule executions filtered by the `Schedule` tag within a given timeframe.
1749
+
1750
+ - `fromTime` *(str)* – Start time of the simulation.
1751
+ - `untilTime` *(str)* – End time of the simulation.
1752
+
1753
+ **Returns:** Simulation results (JSON).
1754
+
1755
+ ### Services
1756
+
1757
+ The `Services` class provides methods to interact with OpenHAB's configurable services via the REST API.
1758
+
1759
+ #### Methods
1760
+
1761
+ ##### `getServices(language: str = None) -> dict`
1762
+ Retrieves all configurable services.
1763
+
1764
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1765
+
1766
+ **Returns:** A list of services (JSON).
1767
+
1768
+ ##### `getService(serviceID: str, language: str = None) -> dict`
1769
+
1770
+ Retrieves a specific configurable service by its ID.
1771
+
1772
+ - `serviceID` *(str)* – The ID of the service.
1773
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1774
+
1775
+ **Returns:** The service object (JSON).
1776
+
1777
+ ##### `getServiceConfig(serviceID: str) -> dict`
1778
+
1779
+ Retrieves the configuration of a given service.
1780
+
1781
+ - `serviceID` *(str)* – The ID of the service.
1782
+
1783
+ **Returns:** The configuration of the service (JSON).
1784
+
1785
+ ##### `updateServiceConfig(serviceID: str, configData: dict) -> dict`
1786
+
1787
+ Updates the configuration of a service and returns the old configuration.
1788
+
1789
+ - `serviceID` *(str)* – The ID of the service.
1790
+ - `configData` *(dict)* – The new configuration data.
1791
+
1792
+ **Returns:** The old configuration of the service (JSON).
1793
+
1794
+ ##### `deleteServiceConfig(serviceID: str) -> dict`
1795
+
1796
+ Deletes the configuration of a given service and returns the old configuration.
1797
+
1798
+ - `serviceID` *(str)* – The ID of the service.
1799
+
1800
+ **Returns:** The old configuration of the service (JSON).
1801
+
1802
+ ##### `getServiceContexts(serviceID: str, language: str = None) -> dict`
1803
+
1804
+ Retrieves multiple context service configurations for a given factory PID.
1805
+
1806
+ - `serviceID` *(str)* – The ID of the service.
1807
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1808
+
1809
+ **Returns:** A list of contexts (JSON).
1810
+
1811
+ ### Sitemaps
1812
+
1813
+ The `Sitemaps` class provides methods to interact with OpenHAB's sitemaps via the REST API.
1814
+
1815
+ #### Methods
1816
+
1817
+ ##### `getSitemaps() -> dict`
1818
+
1819
+ Retrieves all available sitemaps.
1820
+
1821
+ **Returns:** A list of sitemaps (JSON).
1822
+
1823
+ ##### `getSitemap(sitemapName: str, language: str = None, type: str = None, jsonCallback: str = None, includeHidden: bool = False) -> dict`
1824
+
1825
+ Retrieves a specific sitemap by name.
1826
+
1827
+ - `sitemapName` *(str)* – The name of the sitemap.
1828
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1829
+ - `type` *(Optional, str)* – Query parameter for type.
1830
+ - `jsonCallback` *(Optional, str)* – Query parameter for JSON callback.
1831
+ - `includeHidden` *(Optional, bool, default=False)* – Whether hidden widgets should be included.
1832
+
1833
+ **Returns:** The sitemap object (JSON).
1834
+
1835
+ ##### `getSitemapPage(sitemapName: str, pageId: str, subscriptionID: str = None, includeHidden: bool = False) -> dict`
1836
+
1837
+ Retrieves the data for a specific page within a sitemap.
1838
+
1839
+ - `sitemapName` *(str)* – The name of the sitemap.
1840
+ - `pageId` *(str)* – The ID of the page.
1841
+ - `subscriptionID` *(Optional, str)* – Query parameter for the subscription ID.
1842
+ - `includeHidden` *(Optional, bool, default=False)* – Whether hidden widgets should be included.
1843
+
1844
+ **Returns:** The sitemap page (JSON).
1845
+
1846
+ ##### `getFullSitemap(sitemapName: str, subscriptionID: str = None, includeHidden: bool = False) -> dict`
1847
+
1848
+ Retrieves data for an entire sitemap.
1849
+ ⚠ **Not recommended due to potentially high traffic.**
1850
+
1851
+ - `sitemapName` *(str)* – The name of the sitemap.
1852
+ - `subscriptionID` *(Optional, str)* – Query parameter for the subscription ID.
1853
+ - `includeHidden` *(Optional, bool, default=False)* – Whether hidden widgets should be included.
1854
+
1855
+ **Returns:** The complete sitemap (JSON).
1856
+
1857
+ ##### `getSitemapEvents(subscriptionID: str, sitemap: str = None, pageId: str = None) -> dict`
1858
+
1859
+ Retrieves events for a specific sitemap or page.
1860
+
1861
+ - `subscriptionID` *(str)* – The ID of the subscription.
1862
+ - `sitemap` *(Optional, str)* – The name of the sitemap.
1863
+ - `pageId` *(Optional, str)* – The ID of the page.
1864
+
1865
+ **Returns:** The events (JSON).
1866
+
1867
+ ##### `getFullSitemapEvents(subscriptionID: str, sitemap: str = None) -> dict`
1868
+
1869
+ Retrieves events for an entire sitemap.
1870
+ ⚠ **Not recommended due to potentially high traffic.**
1871
+
1872
+ - `subscriptionID` *(str)* – The ID of the subscription.
1873
+ - `sitemap` *(Optional, str)* – The name of the sitemap.
1874
+
1875
+ **Returns:** The events for the entire sitemap (JSON).
1876
+
1877
+ ##### `subscribeToSitemapEvents() -> dict`
1878
+
1879
+ Creates a sitemap event subscription.
1880
+
1881
+ **Returns:** The response to the subscription request (JSON).
1882
+
1883
+ ### Systeminfo
1884
+
1885
+ The `Systeminfo` class provides methods to retrieve system information via the OpenHAB REST API.
1886
+
1887
+ #### Methods
1888
+
1889
+ ##### `getSystemInfo(language: str = None) -> dict`
1890
+
1891
+ Retrieves general system information.
1892
+
1893
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1894
+
1895
+ **Returns:** A dictionary containing system information (JSON).
1896
+
1897
+ ##### `getUomInfo(language: str = None) -> dict`
1898
+
1899
+ Retrieves all supported units of measurement (UOM) and their system units.
1900
+
1901
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1902
+
1903
+ **Returns:** A dictionary containing UOM information (JSON).
1904
+
1905
+ ### Tags
1906
+
1907
+ The `Tags` class provides methods to manage semantic tags via the OpenHAB REST API.
1908
+
1909
+ #### Methods
1910
+
1911
+ ##### `getTags(language: str = None) -> dict`
1912
+
1913
+ Retrieves all available semantic tags.
1914
+
1915
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1916
+
1917
+ **Returns:** A list of semantic tags (JSON).
1918
+
1919
+ ##### `createTag(tagData: dict, language: str = None) -> dict`
1920
+
1921
+ Creates a new semantic tag and adds it to the registry.
1922
+
1923
+ - `tagData` *(dict)* – The data object for the tag to be created.
1924
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1925
+
1926
+ **Returns:** The response to the tag creation request (JSON).
1927
+
1928
+ ##### `getTag(tagID: str, language: str = None) -> dict`
1929
+
1930
+ Retrieves a semantic tag and its sub-tags.
1931
+
1932
+ - `tagID` *(str)* – The ID of the tag to retrieve.
1933
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1934
+
1935
+ **Returns:** The tag object and its sub-tags (JSON).
1936
+
1937
+ ##### `updateTag(tagID: str, tagData: dict, language: str = None) -> dict`
1938
+
1939
+ Updates a semantic tag.
1940
+
1941
+ - `tagID` *(str)* – The ID of the tag to be updated.
1942
+ - `tagData` *(dict)* – The new tag data.
1943
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1944
+
1945
+ **Returns:** The response to the tag update request (JSON).
1946
+
1947
+ ##### `deleteTag(tagID: str, language: str = None) -> dict`
1948
+ Removes a semantic tag and its sub-tags from the registry.
1949
+
1950
+ - `tagID` *(str)* – The ID of the tag to be removed.
1951
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1952
+
1953
+ **Returns:** The response to the tag deletion request (JSON).
1954
+
1955
+ ### Templates
1956
+
1957
+ The `Templates` class provides methods to manage templates via the OpenHAB REST API.
1958
+
1959
+ #### Methods
1960
+
1961
+ ##### `getAllTemplates(language: str = None) -> list`
1962
+
1963
+ Retrieves all available templates.
1964
+
1965
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1966
+
1967
+ **Returns:** A list of templates (JSON).
1968
+
1969
+ ##### `getTemplateByUID(templateUID: str, language: str = None) -> dict`
1970
+
1971
+ Retrieves a template corresponding to the given UID.
1972
+
1973
+ - `templateUID` *(str)* – The UID of the template.
1974
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1975
+
1976
+ **Returns:** A dictionary with the details of the template (JSON).
1977
+
1978
+ ### ThingTypes
1979
+
1980
+ The `ThingTypes` class provides methods to retrieve available thing types via the OpenHAB REST API.
1981
+
1982
+ #### Methods
1983
+
1984
+ ##### `getAllThingTypes(bindingId: str = None, language: str = None) -> list`
1985
+
1986
+ Retrieves all available thing types without configuration descriptions, channels, and properties.
1987
+
1988
+ - `bindingId` *(Optional, str)* – Filter the results by a specific binding ID.
1989
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1990
+
1991
+ **Returns:** A list of thing types (JSON).
1992
+
1993
+ ##### `getThingType(thingTypeUID: str, language: str = None) -> dict`
1994
+
1995
+ Retrieves a thing type by its UID.
1996
+
1997
+ - `thingTypeUID` *(str)* – The UID of the thing type.
1998
+ - `language` *(Optional, str)* – Language setting for the `Accept-Language` header.
1999
+
2000
+ **Returns:**
2001
+ A dictionary with the details of the thing type (JSON).
2002
+ If the thing type does not exist, an empty response with status **204** is returned.
2003
+
2004
+ ### Things
2005
+
2006
+ The `Things` class provides methods to interact with available things in the OpenHAB system via the REST API.
2007
+
2008
+ #### Methods
2009
+
2010
+ ##### `getAllThings(summary: bool = False, staticDataOnly: bool = False, language: str = None)`
2011
+
2012
+ Retrieves all available things.
2013
+
2014
+ - `summary` *(Optional, bool)* – If `True`, returns only the summary fields.
2015
+ - `staticDataOnly` *(Optional, bool)* – If `True`, returns a cacheable list.
2016
+ - `language` *(Optional, str)* – The preferred language for the response.
2017
+
2018
+ **Returns:** JSON response with the things.
2019
+
2020
+ ##### `createThing(thingData: dict, language: str = None)`
2021
+
2022
+ Creates a new thing and adds it to the registry.
2023
+
2024
+ - `thingData` *(dict)* – The JSON object containing the thing data.
2025
+ - `language` *(Optional, str)* – The preferred language for the response.
2026
+
2027
+ **Returns:** The API response.
2028
+
2029
+ ##### `getThingByUID(thingUID: str, language: str = None)`
2030
+
2031
+ Gets a thing by UID.
2032
+
2033
+ - `thingUID` *(str)* – The UID of the thing.
2034
+ - `language` *(Optional, str)* – The preferred language for the response.
2035
+
2036
+ **Returns:** JSON response with the thing data.
2037
+
2038
+ ##### `updateThing(thingUID: str, thingData: dict, language: str = None)`
2039
+
2040
+ Updates a thing.
2041
+
2042
+ - `thingUID` *(str)* – The UID of the thing.
2043
+ - `thingData` *(dict)* – The JSON object containing the updated thing data.
2044
+ - `language` *(Optional, str)* – The preferred language for the response.
2045
+
2046
+ **Returns:** The API response.
2047
+
2048
+ ##### `deleteThing(thingUID: str, force: bool = False, language: str = None)`
2049
+
2050
+ Removes a thing from the registry. Set 'force' to `true` if you want the thing to be removed immediately.
2051
+
2052
+ - `thingUID` *(str)* – The UID of the thing.
2053
+ - `force` *(Optional, bool)* – If `True`, the thing will be immediately removed.
2054
+ - `language` *(Optional, str)* – The preferred language for the response.
2055
+
2056
+ **Returns:** The API response.
2057
+
2058
+ ##### `updateThingConfiguration(thingUID: str, configurationData: dict, language: str = None)`
2059
+
2060
+ Updates a thing's configuration.
2061
+
2062
+ - `thingUID` *(str)* – The UID of the thing.
2063
+ - `configurationData` *(dict)* – The configuration data of the thing.
2064
+ - `language` *(Optional, str)* – The preferred language for the response.
2065
+
2066
+ **Returns:** The API response.
2067
+
2068
+ ##### `getThingConfigStatus(thingUID: str, language: str = None)`
2069
+
2070
+ Gets the thing's configuration status.
2071
+
2072
+ - `thingUID` *(str)* – The UID of the thing.
2073
+ - `language` *(Optional, str)* – The preferred language for the response.
2074
+
2075
+ **Returns:** JSON response with the thing's configuration status.
2076
+
2077
+ ##### `setThingStatus(thingUID: str, enabled: bool, language: str = None)`
2078
+
2079
+ Sets the thing's enabled status.
2080
+
2081
+ - `thingUID` *(str)* – The UID of the thing.
2082
+ - `enabled` *(bool)* – If `True`, the thing will be enabled.
2083
+ - `language` *(Optional, str)* – The preferred language for the response.
2084
+
2085
+ **Returns:** The API response.
2086
+
2087
+ ##### `enableThing(thingUID: str)`
2088
+
2089
+ Enables the thing.
2090
+
2091
+ - `thingUID` *(str)* – The UID of the thing.
2092
+
2093
+ **Returns:** The API response.
2094
+
2095
+ ##### `disableThing(thingUID: str)`
2096
+
2097
+ Disables the thing.
2098
+
2099
+ - `thingUID` *(str)* – The UID of the thing.
2100
+
2101
+ **Returns:** The API response.
2102
+
2103
+ ##### `updateThingFirmware(thingUID: str, firmwareVersion: str, language: str = None)`
2104
+
2105
+ Updates the firmware of a thing.
2106
+
2107
+ - `thingUID` *(str)* – The UID of the thing.
2108
+ - `firmwareVersion` *(str)* – The firmware version.
2109
+ - `language` *(Optional, str)* – The preferred language for the response.
2110
+
2111
+ **Returns:** The API response.
2112
+
2113
+ ##### `getThingFirmwareStatus(thingUID: str, language: str = None)`
2114
+
2115
+ Gets the thing's firmware status.
2116
+
2117
+ - `thingUID` *(str)* – The UID of the thing.
2118
+ - `language` *(Optional, str)* – The preferred language for the response.
2119
+
2120
+ **Returns:** JSON response with the firmware status.
2121
+
2122
+ ##### `getThingFirmwares(thingUID: str, language: str = None)`
2123
+
2124
+ Gets all available firmwares for the provided thing UID.
2125
+
2126
+ - `thingUID` *(str)* – The UID of the thing.
2127
+ - `language` *(Optional, str)* – The preferred language for the response.
2128
+
2129
+ **Returns:** A list of available firmwares.
2130
+
2131
+ ##### `getThingStatus(thingUID: str, language: str = None)`
2132
+
2133
+ Gets the thing's status.
2134
+
2135
+ - `thingUID` *(str)* – The UID of the thing.
2136
+ - `language` *(Optional, str)* – The preferred language for the response.
2137
+
2138
+ **Returns:** JSON response with the thing's status.
2139
+
2140
+ ### Transformations
2141
+
2142
+ The `Transformations` class provides methods to interact with transformations in the OpenHAB system via the REST API.
2143
+
2144
+ #### Methods
2145
+
2146
+ ##### `getTransformations()`
2147
+
2148
+ Retrieves a list of all transformations.
2149
+
2150
+ **Returns:** A list of transformations (JSON).
2151
+
2152
+ ##### `getTransformation(transformationUID: str)`
2153
+
2154
+ Gets a single transformation by its UID.
2155
+
2156
+ - `transformationUID` *(str)* – The UID of the transformation to retrieve.
2157
+
2158
+ **Returns:** The transformation (JSON).
2159
+
2160
+ ##### `updateTransformation(transformationUID: str, transformationData)`
2161
+
2162
+ Updates a single transformation.
2163
+
2164
+ - `transformationUID` *(str)* – The UID of the transformation to update.
2165
+ - `transformationData` *(dict)* – The new data for the transformation.
2166
+
2167
+ **Returns:** The response to the transformation update request (JSON).
2168
+
2169
+ ##### `deleteTransformation(transformationUID: str)`
2170
+
2171
+ Deletes a single transformation by its UID.
2172
+
2173
+ - `transformationUID` *(str)* – The UID of the transformation to delete.
2174
+
2175
+ **Returns:** The response to the transformation delete request (JSON).
2176
+
2177
+ ##### `getTransformationServices()`
2178
+
2179
+ Gets all transformation services available.
2180
+
2181
+ **Returns:** A list of transformation services (JSON).
2182
+
2183
+ ### UI
2184
+
2185
+ The `UI` class provides methods to interact with UI components and tiles in the OpenHAB system via the REST API.
2186
+
2187
+ #### Methods
2188
+
2189
+ ##### `getUiComponents(namespace: str, summary: bool = False)`
2190
+
2191
+ Retrieves all registered UI components within the specified namespace.
2192
+
2193
+ - `namespace` *(str)* – The namespace for which UI components should be retrieved.
2194
+ - `summary` *(bool, optional)* – If True, only summary fields will be returned. Default is False.
2195
+
2196
+ **Returns:** A list of UI components (JSON).
2197
+
2198
+ ##### `addUiComponent(namespace: str, componentData)`
2199
+
2200
+ Adds a UI component to the specified namespace.
2201
+
2202
+ - `namespace` *(str)* – The namespace where the UI component should be added.
2203
+ - `componentData` *(dict)* – The data of the UI component to be added (JSON).
2204
+
2205
+ **Returns:** The response to the request (JSON).
2206
+
2207
+ ##### `getUiComponent(namespace: str, componentUID: str)`
2208
+
2209
+ Retrieves a specific UI component in the specified namespace.
2210
+
2211
+ - `namespace` *(str)* – The namespace where the UI component is located.
2212
+ - `componentUID` *(str)* – The UID of the UI component to retrieve.
2213
+
2214
+ **Returns:** The UI component (JSON).
2215
+
2216
+ ##### `updateUiComponent(namespace: str, componentUID: str, componentData)`
2217
+
2218
+ Updates a specific UI component in the specified namespace.
2219
+
2220
+ - `namespace` *(str)* – The namespace where the UI component should be updated.
2221
+ - `componentUID` *(str)* – The UID of the UI component to update.
2222
+ - `componentData` *(dict)* – The new data for the UI component (JSON).
2223
+
2224
+ **Returns:** The response to the request (JSON).
2225
+
2226
+ ##### `deleteUiComponent(namespace: str, componentUID: str)`
2227
+
2228
+ Removes a specific UI component from the specified namespace.
2229
+
2230
+ - `namespace` *(str)* – The namespace where the UI component should be removed.
2231
+ - `componentUID` *(str)* – The UID of the UI component to delete.
2232
+
2233
+ **Returns:** The response to the request (JSON).
2234
+
2235
+ ##### `getUiTiles()`
2236
+
2237
+ Retrieves all registered UI tiles.
2238
+
2239
+ **Returns:** A list of UI tiles (JSON).
2240
+
2241
+ ### UUID
2242
+
2243
+ The `UUID` class provides a method to retrieve a unified unique identifier (UUID) from the OpenHAB system.
2244
+
2245
+ #### Methods
2246
+
2247
+ ##### `getUUID()`
2248
+
2249
+ Retrieves a unified unique identifier (UUID) for the system.
2250
+
2251
+ **Returns:** A string containing the UUID.
2252
+
2253
+ ### Voice
2254
+
2255
+ The `Voice` class provides methods to interact with the voice processing system, including starting and stopping dialogs, interpreting text, and speaking text aloud.
2256
+
2257
+ #### Methods
2258
+
2259
+ ##### `getDefaultVoice()`
2260
+
2261
+ Gets the default voice used by the system.
2262
+
2263
+ **Returns:** A dictionary with details of the default voice.
2264
+
2265
+ ##### `startDialog()`
2266
+
2267
+ Starts dialog processing for a given audio source.
2268
+
2269
+ **Parameters:**
2270
+ - `sourceID` (str): The ID of the audio source.
2271
+ - `ksID` (str, optional): The ID of the keyword spotter.
2272
+ - `sttID` (str, optional): The ID of the speech-to-text system.
2273
+ - `ttsID` (str, optional): The ID of the text-to-speech system.
2274
+ - `voiceID` (str, optional): The ID of the voice.
2275
+ - `hliIDs` (str, optional): A comma-separated list of interpreter IDs.
2276
+ - `sinkID` (str, optional): The ID of the audio output.
2277
+ - `keyword` (str, optional): The keyword used to start the dialog.
2278
+ - `listeningItem` (str, optional): The name of the item to listen to.
2279
+
2280
+ **Returns:** The response from the server.
2281
+
2282
+ ##### `stopDialog()`
2283
+
2284
+ Stops dialog processing for a given audio source.
2285
+
2286
+ **Parameters:**
2287
+ - `sourceID` (str): The ID of the audio source.
2288
+
2289
+ **Returns:** The response from the server.
2290
+
2291
+ ##### `getInterpreters()`
2292
+
2293
+ Gets the list of all interpreters.
2294
+
2295
+ **Parameters:**
2296
+ - `language` (str, optional): The language for the request.
2297
+
2298
+ **Returns:** A list of interpreters if successful.
2299
+
2300
+ ##### `interpretText()`
2301
+
2302
+ Sends a text to the default human language interpreter.
2303
+
2304
+ **Parameters:**
2305
+ - `text` (str): The text to be interpreted.
2306
+ - `language` (str): The language of the text.
2307
+ - `IDs` (list, optional): A list of interpreter IDs.
2308
+
2309
+ **Returns:** The response from the server.
2310
+
2311
+ ##### `getInterpreter()`
2312
+
2313
+ Gets a single interpreter.
2314
+
2315
+ **Parameters:**
2316
+ - `interpreterID` (str): The ID of the interpreter.
2317
+ - `language` (str, optional): The language for the request.
2318
+
2319
+ **Returns:** The details of the interpreter.
2320
+
2321
+ ##### `interpretTextBatch()`
2322
+
2323
+ Sends a text to a given human language interpreter(s).
2324
+
2325
+ **Parameters:**
2326
+ - `text` (str): The text to be interpreted.
2327
+ - `language` (str): The language of the text.
2328
+ - `IDs` (list): A list of interpreter IDs.
2329
+
2330
+ **Returns:** The response from the server.
2331
+
2332
+ ##### `listenAndAnswer()`
2333
+
2334
+ Executes a simple dialog sequence without keyword spotting for a given audio source.
2335
+
2336
+ **Parameters:**
2337
+ - `sourceID` (str): The ID of the audio source.
2338
+ - `sttID` (str): The ID of the speech-to-text system.
2339
+ - `ttsID` (str): The ID of the text-to-speech system.
2340
+ - `voiceID` (str): The ID of the voice.
2341
+ - `hliIDs` (list, optional): A list of interpreter IDs.
2342
+ - `sinkID` (str, optional): The ID of the audio output.
2343
+ - `listeningItem` (str, optional): The name of the item to listen to.
2344
+
2345
+ **Returns:** The response from the server.
2346
+
2347
+ ##### `sayText()`
2348
+
2349
+ Speaks a given text with a given voice through the given audio sink.
2350
+
2351
+ **Parameters:**
2352
+ - `text` (str): The text to be spoken.
2353
+ - `voiceID` (str): The ID of the voice.
2354
+ - `sinkID` (str): The ID of the audio output.
2355
+ - `volume` (str, optional): The volume level (default: `100`).
2356
+
2357
+ **Returns:** The response from the server.
2358
+
2359
+ ##### `getVoices()`
2360
+
2361
+ Gets the list of all voices.
2362
+
2363
+ **Returns:** A list of voices if successful.
2364
+
2365
+ ## Contributing
2366
+
2367
+ Contributions are welcome! Please create an issue or pull request to suggest changes.
2368
+
2369
+ We welcome contributions to improve **python-openhab-rest-client**!
2370
+
2371
+ ### How to contribute:
2372
+ 1. Fork the repository.
2373
+ 2. Create a new branch:
2374
+ ```bash
2375
+ git checkout -b feature/your-feature-name
2376
+ ```
2377
+ 3. Commit your changes:
2378
+ ```bash
2379
+ git commit -m "Add your feature description"
2380
+ ```
2381
+ 4. Push to the branch:
2382
+ ```bash
2383
+ git push origin feature/your-feature-name
2384
+ ```
2385
+ 5. Open a pull request.
2386
+
2387
+ Please ensure your code adheres to PEP 8 guidelines and includes relevant documentation and tests.
2388
+
2389
+ ## License
2390
+
2391
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.