python-openhab-rest-client 0.1.2__tar.gz → 0.2.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-0.1.2/python_openhab_rest_client.egg-info → python_openhab_rest_client-0.2.1}/PKG-INFO +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Actions.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Addons.py +15 -23
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Audio.py +4 -4
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Auth.py +30 -29
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/ChannelTypes.py +5 -6
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Client.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/ConfigDescriptions.py +4 -4
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Discovery.py +46 -4
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Events.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Iconsets.py +6 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Inbox.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Items.py +14 -14
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Links.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Logging.py +5 -4
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/ModuleTypes.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Persistence.py +20 -12
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/ProfileTypes.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Rules.py +10 -11
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Services.py +22 -8
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Sitemaps.py +15 -13
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Systeminfo.py +4 -12
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Tags.py +14 -17
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Templates.py +4 -4
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/ThingTypes.py +5 -8
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Things.py +13 -18
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Transformations.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/UI.py +5 -5
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/UUID.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/Voice.py +3 -13
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Actions.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Addons.py +14 -14
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Auth.py +18 -21
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/ChannelTypes.py +7 -7
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/ConfigDescriptions.py +6 -6
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Discovery.py +15 -6
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Events.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Iconsets.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Inbox.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Items.py +34 -25
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Links.py +21 -11
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Logging.py +6 -6
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/ModuleTypes.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Persistence.py +18 -18
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/ProfileTypes.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Rules.py +11 -11
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Services.py +9 -9
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Sitemaps.py +23 -13
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Systeminfo.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Tags.py +10 -10
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Templates.py +6 -6
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/ThingEvents.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/ThingTypes.py +6 -6
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Things.py +18 -18
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Transformations.py +4 -4
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/UI.py +5 -5
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/UUID.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Voice.py +8 -7
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1/python_openhab_rest_client.egg-info}/PKG-INFO +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/setup.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Actions.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Auth.py +2 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/ChannelTypes.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/ConfigDescriptions.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Discovery.py +2 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Events.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Iconsets.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Inbox.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Items.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Links.py +3 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Logging.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/ModuleTypes.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Persistence.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Rules.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Services.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Sitemaps.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Templates.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/ThingTypes.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Things.py +3 -3
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/UUID.py +1 -1
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Voice.py +2 -2
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/LICENSE +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/README.md +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/__init__.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/Audio.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/ChannelEvents.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/InboxEvents.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/ItemEvents.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/LinkEvents.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/tests/__init__.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/python_openhab_rest_client.egg-info/SOURCES.txt +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/python_openhab_rest_client.egg-info/dependency_links.txt +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/python_openhab_rest_client.egg-info/requires.txt +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/python_openhab_rest_client.egg-info/top_level.txt +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/setup.cfg +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Addons.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Audio.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/ChannelEvents.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/InboxEvents.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/ItemEvents.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/LinkEvents.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/ProfileTypes.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Systeminfo.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Tags.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/ThingEvents.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/Transformations.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/UI.py +0 -0
- {python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-openhab-rest-client
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
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
5
|
Home-page: https://github.com/Michdo93/python-openhab-rest-client
|
|
6
6
|
Author: Michael Christian Dörflinger
|
|
@@ -12,7 +12,7 @@ class Actions:
|
|
|
12
12
|
"""
|
|
13
13
|
self.client = client
|
|
14
14
|
|
|
15
|
-
def
|
|
15
|
+
def getActions(self, thingUID: str, language: str = None) -> list:
|
|
16
16
|
"""
|
|
17
17
|
Get all available actions for provided thing UID.
|
|
18
18
|
|
|
@@ -21,7 +21,7 @@ class Actions:
|
|
|
21
21
|
|
|
22
22
|
:return: A list of actions.
|
|
23
23
|
"""
|
|
24
|
-
header = {"
|
|
24
|
+
header = {"Accept": "application/json"}
|
|
25
25
|
if language:
|
|
26
26
|
header["Accept-Language"] = language
|
|
27
27
|
|
|
@@ -65,7 +65,7 @@ class Actions:
|
|
|
65
65
|
|
|
66
66
|
:return: A response from the server.
|
|
67
67
|
"""
|
|
68
|
-
header = {"Content-Type": "application/json"}
|
|
68
|
+
header = {"Content-Type": "application/json", "Accept": "application/json"}
|
|
69
69
|
if language:
|
|
70
70
|
header["Accept-Language"] = language
|
|
71
71
|
|
|
@@ -23,7 +23,7 @@ class Addons:
|
|
|
23
23
|
:return: A dictionary containing the add-ons data.
|
|
24
24
|
"""
|
|
25
25
|
params = {"serviceId": serviceID} if serviceID else {}
|
|
26
|
-
header = {"
|
|
26
|
+
header = {"Accept": "application/json"}
|
|
27
27
|
if language:
|
|
28
28
|
header["Accept-Language"] = language
|
|
29
29
|
|
|
@@ -63,7 +63,7 @@ class Addons:
|
|
|
63
63
|
:return: A dictionary containing details of the specified add-on.
|
|
64
64
|
"""
|
|
65
65
|
params = {"serviceId": serviceID} if serviceID else {}
|
|
66
|
-
header = {"
|
|
66
|
+
header = {"Accept": "application/json"}
|
|
67
67
|
if language:
|
|
68
68
|
header["Accept-Language"] = language
|
|
69
69
|
|
|
@@ -106,7 +106,7 @@ class Addons:
|
|
|
106
106
|
|
|
107
107
|
try:
|
|
108
108
|
response = self.client.get(
|
|
109
|
-
f"/addons/{addonID}/config", header={"
|
|
109
|
+
f"/addons/{addonID}/config", header={"Accept": "application/json"}, params=params)
|
|
110
110
|
|
|
111
111
|
if isinstance(response, dict) and "status" in response:
|
|
112
112
|
status_code = response["status"]
|
|
@@ -151,7 +151,7 @@ class Addons:
|
|
|
151
151
|
|
|
152
152
|
try:
|
|
153
153
|
response = self.client.put(
|
|
154
|
-
f"/addons/{addonID}/config", header={"Content-Type": "application/json"}, data=json.dumps(data))
|
|
154
|
+
f"/addons/{addonID}/config", header={"Content-Type": "application/json", "Accept": "application/json"}, data=json.dumps(data))
|
|
155
155
|
|
|
156
156
|
if isinstance(response, dict) and "status" in response:
|
|
157
157
|
status_code = response["status"]
|
|
@@ -179,24 +179,20 @@ class Addons:
|
|
|
179
179
|
|
|
180
180
|
return {"error": f"Unexpected response: {status_code}"}
|
|
181
181
|
|
|
182
|
-
def installAddon(self, addonID: str, serviceID: str = None
|
|
182
|
+
def installAddon(self, addonID: str, serviceID: str = None) -> dict:
|
|
183
183
|
"""
|
|
184
184
|
Installs an add-on by its ID.
|
|
185
185
|
|
|
186
186
|
:param addonID: The unique identifier of the add-on.
|
|
187
187
|
:param serviceID: Optional service ID to specify the target service.
|
|
188
|
-
:param language: Optional language preference for the response.
|
|
189
188
|
|
|
190
189
|
:return: A dictionary containing the installation status.
|
|
191
190
|
"""
|
|
192
191
|
data = {"serviceId": serviceID} if serviceID else {}
|
|
193
|
-
header = {"Content-Type": "application/json"}
|
|
194
|
-
if language:
|
|
195
|
-
header["Accept-Language"] = language
|
|
196
192
|
|
|
197
193
|
try:
|
|
198
194
|
response = self.client.post(
|
|
199
|
-
f"/addons/{addonID}/install",
|
|
195
|
+
f"/addons/{addonID}/install", data=data)
|
|
200
196
|
|
|
201
197
|
if isinstance(response, dict) and "status" in response:
|
|
202
198
|
status_code = response["status"]
|
|
@@ -220,24 +216,20 @@ class Addons:
|
|
|
220
216
|
|
|
221
217
|
return {"error": f"Unexpected response: {status_code}"}
|
|
222
218
|
|
|
223
|
-
def uninstallAddon(self, addonID: str, serviceID: str = None
|
|
219
|
+
def uninstallAddon(self, addonID: str, serviceID: str = None) -> dict:
|
|
224
220
|
"""
|
|
225
221
|
Uninstalls an add-on by its ID.
|
|
226
222
|
|
|
227
223
|
:param addonID: The unique identifier of the add-on.
|
|
228
224
|
:param serviceID: Optional service ID to specify the target service.
|
|
229
|
-
:param language: Optional language preference for the response.
|
|
230
225
|
|
|
231
226
|
:return: A dictionary containing the uninstallation status.
|
|
232
227
|
"""
|
|
233
228
|
data = {"serviceId": serviceID} if serviceID else {}
|
|
234
|
-
header = {"Content-Type": "application/json"}
|
|
235
|
-
if language:
|
|
236
|
-
header["Accept-Language"] = language
|
|
237
229
|
|
|
238
230
|
try:
|
|
239
231
|
response = self.client.post(
|
|
240
|
-
f"/addons/{addonID}/uninstall",
|
|
232
|
+
f"/addons/{addonID}/uninstall", data=data)
|
|
241
233
|
|
|
242
234
|
if isinstance(response, dict) and "status" in response:
|
|
243
235
|
status_code = response["status"]
|
|
@@ -269,7 +261,7 @@ class Addons:
|
|
|
269
261
|
|
|
270
262
|
:return: A dictionary containing the available add-on services.
|
|
271
263
|
"""
|
|
272
|
-
header = {"
|
|
264
|
+
header = {"Accept": "application/json"}
|
|
273
265
|
if language:
|
|
274
266
|
header["Accept-Language"] = language
|
|
275
267
|
|
|
@@ -303,7 +295,7 @@ class Addons:
|
|
|
303
295
|
|
|
304
296
|
:return: A dictionary containing suggested add-ons.
|
|
305
297
|
"""
|
|
306
|
-
header = {"
|
|
298
|
+
header = {"Accept": "application/json"}
|
|
307
299
|
if language:
|
|
308
300
|
header["Accept-Language"] = language
|
|
309
301
|
|
|
@@ -329,7 +321,7 @@ class Addons:
|
|
|
329
321
|
|
|
330
322
|
return {"error": f"Unexpected response: {status_code}"}
|
|
331
323
|
|
|
332
|
-
def getAddonTypes(self, language: str = None) -> dict:
|
|
324
|
+
def getAddonTypes(self, serviceID: str = None, language: str = None) -> dict:
|
|
333
325
|
"""
|
|
334
326
|
Retrieves a list of all available add-on types.
|
|
335
327
|
|
|
@@ -337,13 +329,14 @@ class Addons:
|
|
|
337
329
|
|
|
338
330
|
:return: A dictionary containing available add-on types.
|
|
339
331
|
"""
|
|
340
|
-
|
|
332
|
+
params = {"serviceId": serviceID} if serviceID else {}
|
|
333
|
+
header = {"Accept": "application/json"}
|
|
341
334
|
if language:
|
|
342
335
|
header["Accept-Language"] = language
|
|
343
336
|
|
|
344
337
|
try:
|
|
345
338
|
response = self.client.get(
|
|
346
|
-
"/addons/types", header=header, params=
|
|
339
|
+
"/addons/types", header=header, params=params)
|
|
347
340
|
|
|
348
341
|
if isinstance(response, dict) and "status" in response:
|
|
349
342
|
status_code = response["status"]
|
|
@@ -379,8 +372,7 @@ class Addons:
|
|
|
379
372
|
endpoint = f"/addons/url/{encoded_url}/install"
|
|
380
373
|
|
|
381
374
|
try:
|
|
382
|
-
response = self.client.post(
|
|
383
|
-
endpoint, header={"Content-Type": "text/plain"}, data=None)
|
|
375
|
+
response = self.client.post(endpoint, data=None)
|
|
384
376
|
|
|
385
377
|
if isinstance(response, dict) and "status" in response:
|
|
386
378
|
status_code = response["status"]
|
|
@@ -19,7 +19,7 @@ class Audio:
|
|
|
19
19
|
|
|
20
20
|
:return: A dictionary containing information about the default sink.
|
|
21
21
|
"""
|
|
22
|
-
header = {"
|
|
22
|
+
header = {"Accept": "application/json"}
|
|
23
23
|
if language:
|
|
24
24
|
header["Accept-Language"] = language
|
|
25
25
|
|
|
@@ -56,7 +56,7 @@ class Audio:
|
|
|
56
56
|
|
|
57
57
|
:return: A dictionary containing information about the default source.
|
|
58
58
|
"""
|
|
59
|
-
header = {"
|
|
59
|
+
header = {"Accept": "application/json"}
|
|
60
60
|
if language:
|
|
61
61
|
header["Accept-Language"] = language
|
|
62
62
|
|
|
@@ -93,7 +93,7 @@ class Audio:
|
|
|
93
93
|
|
|
94
94
|
:return: A list of available sinks.
|
|
95
95
|
"""
|
|
96
|
-
header = {"
|
|
96
|
+
header = {"Accept": "application/json"}
|
|
97
97
|
if language:
|
|
98
98
|
header["Accept-Language"] = language
|
|
99
99
|
|
|
@@ -126,7 +126,7 @@ class Audio:
|
|
|
126
126
|
|
|
127
127
|
:return: A list of available sources.
|
|
128
128
|
"""
|
|
129
|
-
header = {"
|
|
129
|
+
header = {"Accept": "application/json"}
|
|
130
130
|
if language:
|
|
131
131
|
header["Accept-Language"] = language
|
|
132
132
|
|
|
@@ -13,7 +13,7 @@ class Auth:
|
|
|
13
13
|
"""
|
|
14
14
|
self.client = client
|
|
15
15
|
|
|
16
|
-
def getAPITokens(self
|
|
16
|
+
def getAPITokens(self) -> dict:
|
|
17
17
|
"""
|
|
18
18
|
Retrieve the API tokens associated with the authenticated user.
|
|
19
19
|
|
|
@@ -21,9 +21,7 @@ class Auth:
|
|
|
21
21
|
|
|
22
22
|
:return: JSON response from the server.
|
|
23
23
|
"""
|
|
24
|
-
header = {"
|
|
25
|
-
if language:
|
|
26
|
-
header["Accept-Language"] = language
|
|
24
|
+
header = {"Accept": "application/json"}
|
|
27
25
|
|
|
28
26
|
try:
|
|
29
27
|
response = self.client.get("/auth/apitokens", header=header)
|
|
@@ -54,7 +52,7 @@ class Auth:
|
|
|
54
52
|
|
|
55
53
|
return {"error": f"Unexpected response: {status_code}"}
|
|
56
54
|
|
|
57
|
-
def revokeAPIToken(self, tokenName: str
|
|
55
|
+
def revokeAPIToken(self, tokenName: str) -> dict:
|
|
58
56
|
"""
|
|
59
57
|
Revoke a specific API token associated with the authenticated user.
|
|
60
58
|
|
|
@@ -63,13 +61,9 @@ class Auth:
|
|
|
63
61
|
|
|
64
62
|
:return: JSON response from the server.
|
|
65
63
|
"""
|
|
66
|
-
header = {"Content-Type": "application/json"}
|
|
67
|
-
if language:
|
|
68
|
-
header["Accept-Language"] = language
|
|
69
|
-
|
|
70
64
|
try:
|
|
71
65
|
response = self.client.delete(
|
|
72
|
-
f"/auth/apitokens/{tokenName}"
|
|
66
|
+
f"/auth/apitokens/{tokenName}")
|
|
73
67
|
|
|
74
68
|
if isinstance(response, dict) and "status" in response:
|
|
75
69
|
status_code = response["status"]
|
|
@@ -97,22 +91,25 @@ class Auth:
|
|
|
97
91
|
|
|
98
92
|
return {"error": f"Unexpected response: {status_code}"}
|
|
99
93
|
|
|
100
|
-
def logout(self, refreshToken: str,
|
|
94
|
+
def logout(self, refreshToken: str, sessionID: str) -> dict:
|
|
101
95
|
"""
|
|
102
96
|
Terminate the session associated with a refresh token.
|
|
103
97
|
|
|
104
98
|
:param refreshToken: The refresh token used to delete the session.
|
|
105
|
-
:param
|
|
99
|
+
:param id: The user ID associated with the refresh token.
|
|
106
100
|
|
|
107
101
|
:return: JSON response from the server.
|
|
108
102
|
"""
|
|
109
103
|
header = {"Content-Type": "application/x-www-form-urlencoded"}
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
|
|
105
|
+
data = {
|
|
106
|
+
"refresh_token": refreshToken,
|
|
107
|
+
"id": sessionID
|
|
108
|
+
}
|
|
112
109
|
|
|
113
110
|
try:
|
|
114
111
|
response = self.client.post(
|
|
115
|
-
"/auth/logout", header=header, data=
|
|
112
|
+
"/auth/logout", header=header, data=data)
|
|
116
113
|
|
|
117
114
|
if isinstance(response, dict) and "status" in response:
|
|
118
115
|
status_code = response["status"]
|
|
@@ -140,17 +137,13 @@ class Auth:
|
|
|
140
137
|
|
|
141
138
|
return {"error": f"Unexpected response: {status_code}"}
|
|
142
139
|
|
|
143
|
-
def getSessions(self
|
|
140
|
+
def getSessions(self) -> dict:
|
|
144
141
|
"""
|
|
145
142
|
Retrieve the sessions associated with the authenticated user.
|
|
146
143
|
|
|
147
|
-
:param language: (Optional) Language setting for the API request.
|
|
148
|
-
|
|
149
144
|
:return: JSON response from the server.
|
|
150
145
|
"""
|
|
151
|
-
header = {"
|
|
152
|
-
if language:
|
|
153
|
-
header["Accept-Language"] = language
|
|
146
|
+
header = {"Accept": "application/json"}
|
|
154
147
|
|
|
155
148
|
try:
|
|
156
149
|
response = self.client.get("/auth/sessions", header=header)
|
|
@@ -181,17 +174,18 @@ class Auth:
|
|
|
181
174
|
|
|
182
175
|
return {"error": f"Unexpected response: {status_code}"}
|
|
183
176
|
|
|
184
|
-
def getToken(self,
|
|
177
|
+
def getToken(self, useCookie: bool = False, grantType: str = None, code: str = None, redirectURI: str = None, clientID: str = None,
|
|
178
|
+
refreshToken: str = None, codeVerifier: str = None) -> dict:
|
|
185
179
|
"""
|
|
186
180
|
Obtain access and refresh tokens.
|
|
187
181
|
|
|
188
|
-
:param
|
|
182
|
+
:param useCookie: (Optional) Whether to use cookies for the session.
|
|
183
|
+
:param grantType: (Optional) The type of grant being requested.
|
|
189
184
|
:param code: (Optional) Authorization code for authentication.
|
|
190
185
|
:param redirectUri: (Optional) Redirect URI for OAuth authentication.
|
|
191
186
|
:param clientID: (Optional) Client ID for authentication.
|
|
192
187
|
:param refreshToken: (Optional) Refresh token for token renewal.
|
|
193
188
|
:param codeVerifier: (Optional) Code verifier for PKCE authentication.
|
|
194
|
-
:param language: (Optional) Language setting for the API request.
|
|
195
189
|
|
|
196
190
|
:return: JSON response from the server.
|
|
197
191
|
"""
|
|
@@ -200,6 +194,11 @@ class Auth:
|
|
|
200
194
|
"Accept": "application/json"
|
|
201
195
|
}
|
|
202
196
|
|
|
197
|
+
params = {
|
|
198
|
+
"useCookie": str(useCookie).lower()
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
# Body mit den erforderlichen Parametern
|
|
203
202
|
body = {
|
|
204
203
|
"grant_type": grantType,
|
|
205
204
|
"code": code,
|
|
@@ -208,15 +207,17 @@ class Auth:
|
|
|
208
207
|
"refresh_token": refreshToken,
|
|
209
208
|
"code_verifier": codeVerifier
|
|
210
209
|
}
|
|
211
|
-
|
|
210
|
+
|
|
211
|
+
# Entferne alle None-Werte aus dem Body
|
|
212
212
|
body = {k: v for k, v in body.items() if v is not None}
|
|
213
213
|
|
|
214
|
-
#
|
|
214
|
+
# Kodierung als application/x-www-form-urlencoded
|
|
215
215
|
encodedBody = urlencode(body)
|
|
216
216
|
|
|
217
217
|
try:
|
|
218
|
+
# Request mit den encoded Daten senden
|
|
218
219
|
response = self.client.post(
|
|
219
|
-
"/auth/token", header=header, data=encodedBody)
|
|
220
|
+
"/auth/token", header=header, data=encodedBody, params=params)
|
|
220
221
|
|
|
221
222
|
if isinstance(response, dict) and "status" in response:
|
|
222
223
|
status_code = response["status"]
|
|
@@ -234,8 +235,8 @@ class Auth:
|
|
|
234
235
|
return {"error": f"Request error: {str(err)}"}
|
|
235
236
|
|
|
236
237
|
if status_code == 200:
|
|
237
|
-
return
|
|
238
|
+
return response # Gebe die gesamte Antwort zurück
|
|
238
239
|
elif status_code == 400:
|
|
239
240
|
return {"error": "Invalid request parameters."}
|
|
240
241
|
|
|
241
|
-
return {"error": f"Unexpected response: {status_code}"}
|
|
242
|
+
return {"error": f"Unexpected response: {status_code}"}
|
{python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/ChannelTypes.py
RENAMED
|
@@ -11,7 +11,7 @@ class ChannelTypes:
|
|
|
11
11
|
"""
|
|
12
12
|
self.client = client
|
|
13
13
|
|
|
14
|
-
def
|
|
14
|
+
def getChannelTypes(self, prefixes: str = None, language: str = None) -> list:
|
|
15
15
|
"""
|
|
16
16
|
Retrieves all available channel types.
|
|
17
17
|
|
|
@@ -20,7 +20,7 @@ class ChannelTypes:
|
|
|
20
20
|
|
|
21
21
|
:return: A list of channel types.
|
|
22
22
|
"""
|
|
23
|
-
header = {}
|
|
23
|
+
header = {"Accept": "application/json"}
|
|
24
24
|
if language:
|
|
25
25
|
header["Accept-Language"] = language
|
|
26
26
|
|
|
@@ -50,7 +50,7 @@ class ChannelTypes:
|
|
|
50
50
|
|
|
51
51
|
return {"error": f"Unexpected response: {status_code}"}
|
|
52
52
|
|
|
53
|
-
def
|
|
53
|
+
def getChannelType(self, channelTypeUID: str, language: str = None) -> dict:
|
|
54
54
|
"""
|
|
55
55
|
Retrieves the item types the given trigger channel type UID can be linked to.
|
|
56
56
|
|
|
@@ -59,7 +59,7 @@ class ChannelTypes:
|
|
|
59
59
|
|
|
60
60
|
:return: Details of the specific channel type.
|
|
61
61
|
"""
|
|
62
|
-
header = {}
|
|
62
|
+
header = {"Accept": "application/json"}
|
|
63
63
|
if language:
|
|
64
64
|
header["Accept-Language"] = language
|
|
65
65
|
|
|
@@ -97,10 +97,9 @@ class ChannelTypes:
|
|
|
97
97
|
|
|
98
98
|
:return: A list of item types.
|
|
99
99
|
"""
|
|
100
|
-
|
|
101
100
|
try:
|
|
102
101
|
response = self.client.get(
|
|
103
|
-
f"/channel-types/{channelTypeUID}/linkableItemTypes")
|
|
102
|
+
f"/channel-types/{channelTypeUID}/linkableItemTypes", header={"Accept": "application/json"})
|
|
104
103
|
|
|
105
104
|
if isinstance(response, dict) and "status" in response:
|
|
106
105
|
status_code = response["status"]
|
|
@@ -213,7 +213,7 @@ class OpenHABClient:
|
|
|
213
213
|
|
|
214
214
|
:return: The response from the PUT request.
|
|
215
215
|
"""
|
|
216
|
-
return self.__executeRequest(header, endpoint, "put", data=data)
|
|
216
|
+
return self.__executeRequest(header, endpoint, "put", data=data, params=params)
|
|
217
217
|
|
|
218
218
|
def delete(self, endpoint: str, header: dict = None, data=None, params: dict = None):
|
|
219
219
|
"""
|
{python_openhab_rest_client-0.1.2 → python_openhab_rest_client-0.2.1}/openhab/ConfigDescriptions.py
RENAMED
|
@@ -11,7 +11,7 @@ class ConfigDescriptions:
|
|
|
11
11
|
"""
|
|
12
12
|
self.client = client
|
|
13
13
|
|
|
14
|
-
def
|
|
14
|
+
def getConfigDescriptions(self, scheme: str = None, language: str = None) -> list:
|
|
15
15
|
"""
|
|
16
16
|
Retrieves all available config descriptions.
|
|
17
17
|
|
|
@@ -20,7 +20,7 @@ class ConfigDescriptions:
|
|
|
20
20
|
|
|
21
21
|
:return: A list of configuration descriptions.
|
|
22
22
|
"""
|
|
23
|
-
header = {}
|
|
23
|
+
header = {"Accept": "application/json"}
|
|
24
24
|
if language:
|
|
25
25
|
header["Accept-Language"] = language
|
|
26
26
|
|
|
@@ -50,7 +50,7 @@ class ConfigDescriptions:
|
|
|
50
50
|
|
|
51
51
|
return {"error": f"Unexpected response: {status_code}"}
|
|
52
52
|
|
|
53
|
-
def
|
|
53
|
+
def getConfigDescription(self, uri: str, language: str = None) -> dict:
|
|
54
54
|
"""
|
|
55
55
|
Retrieves a config description by URI.
|
|
56
56
|
|
|
@@ -59,7 +59,7 @@ class ConfigDescriptions:
|
|
|
59
59
|
|
|
60
60
|
:return: Details of the specific configuration description.
|
|
61
61
|
"""
|
|
62
|
-
header = {}
|
|
62
|
+
header = {"Accept": "application/json"}
|
|
63
63
|
if language:
|
|
64
64
|
header["Accept-Language"] = language
|
|
65
65
|
|
|
@@ -11,14 +11,14 @@ class Discovery:
|
|
|
11
11
|
"""
|
|
12
12
|
self.client = client
|
|
13
13
|
|
|
14
|
-
def
|
|
14
|
+
def getDiscoveryBindings(self) -> list:
|
|
15
15
|
"""
|
|
16
16
|
Gets all bindings that support discovery.
|
|
17
17
|
|
|
18
18
|
:return: Eine Liste der Bindings als Strings.
|
|
19
19
|
"""
|
|
20
20
|
try:
|
|
21
|
-
response = self.client.get("/discovery")
|
|
21
|
+
response = self.client.get("/discovery", header={"Accept": "application/json"})
|
|
22
22
|
|
|
23
23
|
if isinstance(response, dict) and "status" in response:
|
|
24
24
|
status_code = response["status"]
|
|
@@ -38,17 +38,59 @@ class Discovery:
|
|
|
38
38
|
|
|
39
39
|
return {"error": f"Unexpected response: {status_code}"}
|
|
40
40
|
|
|
41
|
-
def
|
|
41
|
+
def getBindingInfo(self, bindingID: str, language: str = None) -> dict:
|
|
42
|
+
"""
|
|
43
|
+
Gets information about the discovery services for a binding.
|
|
44
|
+
|
|
45
|
+
:param bindingId: The ID of the binding to get discovery information for.
|
|
46
|
+
:param language: Optional language parameter for the response (Accept-Language header).
|
|
47
|
+
|
|
48
|
+
:return: Information about the discovery service for the specified binding.
|
|
49
|
+
"""
|
|
50
|
+
header = {"Accept": "application/json"}
|
|
51
|
+
if language:
|
|
52
|
+
header["Accept-Language"] = language
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
response = self.client.get(
|
|
56
|
+
f"/discovery/bindings/{bindingID}/info", header=header)
|
|
57
|
+
|
|
58
|
+
if isinstance(response, dict) and "status" in response:
|
|
59
|
+
status_code = response["status"]
|
|
60
|
+
else:
|
|
61
|
+
return response
|
|
62
|
+
|
|
63
|
+
except requests.exceptions.HTTPError as err:
|
|
64
|
+
status_code = err.response.status_code
|
|
65
|
+
if status_code == 404:
|
|
66
|
+
return {"error": "Discovery service not found."}
|
|
67
|
+
elif status_code != 200:
|
|
68
|
+
return {"error": f"HTTP error {status_code}: {str(err)}"}
|
|
69
|
+
|
|
70
|
+
except requests.exceptions.RequestException as err:
|
|
71
|
+
return {"error": f"Request error: {str(err)}"}
|
|
72
|
+
|
|
73
|
+
if status_code == 200:
|
|
74
|
+
return response
|
|
75
|
+
|
|
76
|
+
return {"error": f"Unexpected response: {status_code}"}
|
|
77
|
+
|
|
78
|
+
def startBindingScan(self, bindingID: str, input: str = None) -> int:
|
|
42
79
|
"""
|
|
43
80
|
Starts asynchronous discovery process for a binding and returns the timeout in seconds of the discovery operation.
|
|
44
81
|
|
|
45
82
|
:param bindingID: The ID of the binding for which the discovery is to be started.
|
|
83
|
+
:param input: An input parameter to start the discovery.
|
|
46
84
|
|
|
47
85
|
:return: Timeout duration of the discovery operation in seconds.
|
|
48
86
|
"""
|
|
87
|
+
params = {
|
|
88
|
+
"input": input
|
|
89
|
+
}
|
|
90
|
+
|
|
49
91
|
try:
|
|
50
92
|
response = self.client.post(
|
|
51
|
-
f"/discovery/bindings/{bindingID}/scan")
|
|
93
|
+
f"/discovery/bindings/{bindingID}/scan", header={"Accept": "text/plain"}, params=params)
|
|
52
94
|
|
|
53
95
|
if isinstance(response, dict) and "status" in response:
|
|
54
96
|
status_code = response["status"]
|
|
@@ -11,7 +11,7 @@ class Iconsets:
|
|
|
11
11
|
"""
|
|
12
12
|
self.client = client
|
|
13
13
|
|
|
14
|
-
def
|
|
14
|
+
def getIconsets(self, language: str = None) -> list:
|
|
15
15
|
"""
|
|
16
16
|
Gets all icon sets.
|
|
17
17
|
|
|
@@ -19,9 +19,12 @@ class Iconsets:
|
|
|
19
19
|
|
|
20
20
|
:return: A list of icon sets with details such as ID, label, description and supported formats.
|
|
21
21
|
"""
|
|
22
|
+
header = {"Accept": "application/json"}
|
|
23
|
+
if language:
|
|
24
|
+
header["Accept-Language"] = language
|
|
25
|
+
|
|
22
26
|
try:
|
|
23
|
-
response = self.client.get(
|
|
24
|
-
"/iconsets", header={"Accept-Language": language} if language else {})
|
|
27
|
+
response = self.client.get("/iconsets", header=header)
|
|
25
28
|
|
|
26
29
|
if isinstance(response, dict) and "status" in response:
|
|
27
30
|
status_code = response["status"]
|
|
@@ -11,7 +11,7 @@ class Inbox:
|
|
|
11
11
|
"""
|
|
12
12
|
self.client = client
|
|
13
13
|
|
|
14
|
-
def
|
|
14
|
+
def getDiscoveredThings(self, includeIgnored: bool = True) -> list:
|
|
15
15
|
"""
|
|
16
16
|
Get all discovered things.
|
|
17
17
|
|
|
@@ -21,7 +21,7 @@ class Inbox:
|
|
|
21
21
|
"""
|
|
22
22
|
try:
|
|
23
23
|
response = self.client.get(
|
|
24
|
-
"/inbox", params={"includeIgnored": str(includeIgnored).lower()})
|
|
24
|
+
"/inbox", header={"Accept": "application/json"}, params={"includeIgnored": str(includeIgnored).lower()})
|
|
25
25
|
|
|
26
26
|
if isinstance(response, dict) and "status" in response:
|
|
27
27
|
status_code = response["status"]
|