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