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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. openhab/Actions.py +43 -0
  2. openhab/Addons.py +163 -0
  3. openhab/Audio.py +66 -0
  4. openhab/Auth.py +105 -0
  5. openhab/ChannelTypes.py +54 -0
  6. openhab/Client.py +197 -0
  7. openhab/ConfigDescriptions.py +44 -0
  8. openhab/Discovery.py +28 -0
  9. openhab/Events.py +302 -0
  10. openhab/Iconsets.py +21 -0
  11. openhab/Inbox.py +64 -0
  12. openhab/Items.py +264 -0
  13. openhab/Links.py +98 -0
  14. openhab/Logging.py +55 -0
  15. openhab/ModuleTypes.py +47 -0
  16. openhab/Persistence.py +103 -0
  17. openhab/ProfileTypes.py +32 -0
  18. openhab/Rules.py +206 -0
  19. openhab/Services.py +78 -0
  20. openhab/Sitemaps.py +88 -0
  21. openhab/Systeminfo.py +34 -0
  22. openhab/Tags.py +82 -0
  23. openhab/Templates.py +38 -0
  24. openhab/ThingTypes.py +42 -0
  25. openhab/Things.py +199 -0
  26. openhab/Transformations.py +58 -0
  27. openhab/UI.py +75 -0
  28. openhab/UUID.py +18 -0
  29. openhab/Voice.py +147 -0
  30. openhab/__init__.py +66 -0
  31. python_openhab_rest_client-0.1.0.dist-info/LICENSE +21 -0
  32. python_openhab_rest_client-0.1.0.dist-info/METADATA +2391 -0
  33. python_openhab_rest_client-0.1.0.dist-info/RECORD +70 -0
  34. python_openhab_rest_client-0.1.0.dist-info/WHEEL +5 -0
  35. python_openhab_rest_client-0.1.0.dist-info/top_level.txt +2 -0
  36. tests/__init__.py +0 -0
  37. tests/actions.py +55 -0
  38. tests/addons.py +96 -0
  39. tests/audio.py +16 -0
  40. tests/auth.py +45 -0
  41. tests/channel_events.py +14 -0
  42. tests/channel_types.py +29 -0
  43. tests/config_descriptions.py +23 -0
  44. tests/discovery.py +23 -0
  45. tests/events.py +41 -0
  46. tests/iconsets.py +19 -0
  47. tests/inbox.py +53 -0
  48. tests/inbox_events.py +15 -0
  49. tests/item_events.py +38 -0
  50. tests/items.py +120 -0
  51. tests/link_events.py +14 -0
  52. tests/links.py +74 -0
  53. tests/logging_test.py +43 -0
  54. tests/module_types.py +14 -0
  55. tests/persistence.py +78 -0
  56. tests/profile_types.py +13 -0
  57. tests/rules.py +151 -0
  58. tests/services.py +52 -0
  59. tests/sitemaps.py +65 -0
  60. tests/systeminfo.py +14 -0
  61. tests/tags.py +53 -0
  62. tests/templates.py +28 -0
  63. tests/test.py +11 -0
  64. tests/thing_events.py +17 -0
  65. tests/thing_types.py +28 -0
  66. tests/things.py +75 -0
  67. tests/transformations.py +38 -0
  68. tests/ui.py +70 -0
  69. tests/uuid.py +18 -0
  70. tests/voice.py +119 -0
openhab/Sitemaps.py ADDED
@@ -0,0 +1,88 @@
1
+ from .Client import OpenHABClient
2
+
3
+ class Sitemaps:
4
+ def __init__(self, client: OpenHABClient):
5
+ """
6
+ Initializes the Sitemaps class with an OpenHABClient object.
7
+
8
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
9
+ """
10
+ self.client = client
11
+
12
+ def getSitemaps(self):
13
+ """
14
+ Get all available sitemaps.
15
+
16
+ :return: A list of sitemaps (JSON).
17
+ """
18
+ return self.client.get("/sitemaps")
19
+
20
+ def getSitemap(self, sitemapName: str, language=None, type=None, jsonCallback=None, includeHidden=False):
21
+ """
22
+ Get sitemap by name.
23
+
24
+ :param sitemapName: The name of the sitemap to retrieve.
25
+ :param language: Optional language setting (as header).
26
+ :param type: Optional query parameter for type.
27
+ :param jsonCallback: Optional query parameter for JSON callback.
28
+ :param includeHidden: Whether hidden widgets should be included.
29
+
30
+ :return: The sitemap object (JSON).
31
+ """
32
+ return self.client.get(f"/sitemaps/{sitemapName}", header={"type": type, "jsoncallback": jsonCallback, "includeHidden": includeHidden}, params={"Accept-Language": language} if language else {})
33
+
34
+ def getSitemapPage(self, sitemapName: str, pageId: str, subscriptionID=None, includeHidden=False):
35
+ """
36
+ Polls the data for one page of a sitemap.
37
+
38
+ :param sitemapName: The name of the sitemap.
39
+ :param pageId: The ID of the page.
40
+ :param subscriptionID: Optional query parameter for the subscription ID.
41
+ :param includeHidden: Whether hidden widgets should be included.
42
+
43
+ :return: The sitemap page (JSON).
44
+ """
45
+ return self.client.get(f"/sitemaps/{sitemapName}/{pageId}", params={"subscriptionID": subscriptionID, "includeHidden": includeHidden})
46
+
47
+ def getFullSitemap(self, sitemapName: str, subscriptionID=None, includeHidden=False):
48
+ """
49
+ Polls the data for a whole sitemap. Not recommended due to potentially high traffic.
50
+
51
+ :param sitemapName: The name of the sitemap.
52
+ :param subscriptionID: Optional query parameter for the subscription ID.
53
+ :param includeHidden: Whether hidden widgets should be included.
54
+
55
+ :return: The complete sitemap (JSON).
56
+ """
57
+ return self.client.get(f"/sitemaps/{sitemapName}/*", params={"subscriptionID": subscriptionID, "includeHidden": includeHidden})
58
+
59
+ def getSitemapEvents(self, subscriptionID: str, sitemap=None, pageId=None):
60
+ """
61
+ Get sitemap events.
62
+
63
+ :param subscriptionID: The ID of the subscription.
64
+ :param sitemap: The name of the sitemap (optional).
65
+ :param pageId: The ID of the page (optional).
66
+
67
+ :return: The events (JSON).
68
+ """
69
+ return self.client.get(f"/sitemaps/events/{subscriptionID}", params={"sitemap": sitemap, "pageId": pageId})
70
+
71
+ def getFullSitemapEvents(self, subscriptionID: str, sitemap=None):
72
+ """
73
+ Get sitemap events for a whole sitemap. Not recommended due to potentially high traffic.
74
+
75
+ :param subscriptionID: The ID of the subscription.
76
+ :param sitemap: The name of the sitemap (optional).
77
+
78
+ :return: The events for the entire sitemap (JSON).
79
+ """
80
+ return self.client.get(f"/sitemaps/events/{subscriptionID}/*", params={"sitemap": sitemap})
81
+
82
+ def subscribeToSitemapEvents(self):
83
+ """
84
+ Creates a sitemap event subscription.
85
+
86
+ :return: The response to the subscription request (JSON).
87
+ """
88
+ return self.client.post("/sitemaps/events/subscribe")
openhab/Systeminfo.py ADDED
@@ -0,0 +1,34 @@
1
+ from .Client import OpenHABClient
2
+
3
+ class Systeminfo:
4
+ def __init__(self, client: OpenHABClient):
5
+ """
6
+ Initializes the Systeminfo class with an OpenHABClient object.
7
+
8
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
9
+ """
10
+ self.client = client
11
+
12
+ def getSystemInfo(self, language: str = None):
13
+ """
14
+ Gets information about the system.
15
+
16
+ :return: A Dictionary with system informations.
17
+ """
18
+ header = {"Content-Type": "application/json"}
19
+ if language:
20
+ header["Accept-Language"] = language
21
+
22
+ return self.client.get("/systeminfo", header=header)
23
+
24
+ def getUomInfo(self, language: str = None):
25
+ """
26
+ Get all supported dimensions and their system units.
27
+
28
+ :return: A Dictionary with UOM informations.
29
+ """
30
+ header = {"Content-Type": "application/json"}
31
+ if language:
32
+ header["Accept-Language"] = language
33
+
34
+ return self.client.get("/systeminfo/uom", header=header)
openhab/Tags.py ADDED
@@ -0,0 +1,82 @@
1
+ from .Client import OpenHABClient
2
+ import json
3
+
4
+ class Tags:
5
+ def __init__(self, client: OpenHABClient):
6
+ """
7
+ Initializes the Tags class with an OpenHABClient object.
8
+
9
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
10
+ """
11
+ self.client = client
12
+
13
+ def getTags(self, language=None):
14
+ """
15
+ Get all available semantic tags.
16
+
17
+ :param language: Optional header for language setting.
18
+
19
+ :return: A list of semantic tags (JSON).
20
+ """
21
+ return self.client.get("/tags", header={"Accept-Language": language} if language else {})
22
+
23
+ def createTag(self, tagData, language=None):
24
+ """
25
+ Creates a new semantic tag and adds it to the registry.
26
+
27
+ :param tagData: The data object for the tag to be created.
28
+ :param language: Optional header for language setting.
29
+
30
+ :return: The response to the tag creation request (JSON).
31
+ """
32
+ header = {"Content-Type": "application/json", "Accept": "application/json"}
33
+ if language:
34
+ header["Accept-Language"] = language
35
+
36
+ return self.client.post("/tags", data=json.dumps(tagData), header=header)
37
+
38
+ def getTag(self, tagID: str, language=None):
39
+ """
40
+ Gets a semantic tag and its sub-tags.
41
+
42
+ :param tagID: The ID of the tag to retrieve.
43
+ :param language: Optional header for language setting.
44
+
45
+ :return: The tag object and its sub-tags (JSON).
46
+ """
47
+ header = {"Content-Type": "application/json", "Accept": "application/json"}
48
+ if language:
49
+ header["Accept-Language"] = language
50
+
51
+ return self.client.get(f"/tags/{tagID}", header=header)
52
+
53
+ def updateTag(self, tagID: str, tagData, language=None):
54
+ """
55
+ Updates a semantic tag.
56
+
57
+ :param tagID: The ID of the tag to be updated.
58
+ :param tagData: The new tag data.
59
+ :param language: Optional header for language setting.
60
+
61
+ :return: The response to the tag update request (JSON).
62
+ """
63
+ header = {"Content-Type": "application/json", "Accept": "application/json"}
64
+ if language:
65
+ header["Accept-Language"] = language
66
+
67
+ return self.client.put(f"/tags/{tagID}", data=json.dumps(tagData), header=header)
68
+
69
+ def deleteTag(self, tagID: str, language=None):
70
+ """
71
+ Removes a semantic tag and its sub-tags from the registry.
72
+
73
+ :param tagID: The ID of the tag to be removed.
74
+ :param language: Optional header for language setting.
75
+
76
+ :return: The response to the tag deletion request (JSON).
77
+ """
78
+ header = {"Content-Type": "application/json", "Accept": "application/json"}
79
+ if language:
80
+ header["Accept-Language"] = language
81
+
82
+ return self.client.delete(f"/tags/{tagID}", header=header)
openhab/Templates.py ADDED
@@ -0,0 +1,38 @@
1
+ from .Client import OpenHABClient
2
+
3
+ class Templates:
4
+ def __init__(self, client: OpenHABClient):
5
+ """
6
+ Initializes the Templates class with an OpenHABClient object.
7
+
8
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
9
+ """
10
+ self.client = client
11
+
12
+ def getAllTemplates(self, language: str = None) -> list:
13
+ """
14
+ Get all available templates.
15
+
16
+ :param language: (Optional) Language setting for the Accept-Language header.
17
+ :return: A list of templates.
18
+ """
19
+ header = {"Content-Type": "application/json"}
20
+ if language:
21
+ header["Accept-Language"] = language
22
+
23
+ return self.client.get("/templates", header=header)
24
+
25
+ def getTemplateByUID(self, templateUID: str, language: str = None) -> dict:
26
+ """
27
+ Gets a template corresponding to the given UID.
28
+
29
+ :param templateUID: The UID of the template.
30
+ :param language: (Optional) Language setting for the Accept-Language header.
31
+
32
+ :return: A dictionary with the details of the template.
33
+ """
34
+ header = {"Content-Type": "application/json"}
35
+ if language:
36
+ header["Accept-Language"] = language
37
+
38
+ return self.client.get(f"/templates/{templateUID}", header=header)
openhab/ThingTypes.py ADDED
@@ -0,0 +1,42 @@
1
+ from .Client import OpenHABClient
2
+
3
+ class ThingTypes:
4
+ def __init__(self, client: OpenHABClient):
5
+ """
6
+ Initializes the ThingTypes class with an OpenHABClient object.
7
+
8
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
9
+ """
10
+ self.client = client
11
+
12
+ def getAllThingTypes(self, bindingId: str = None, language: str = None) -> list:
13
+ """
14
+ Gets all available thing types without config description, channels, and properties.
15
+
16
+ :param bindingId: (Optional) Filter by binding ID.
17
+ :param language: (Optional) Language setting for the Accept-Language header.
18
+
19
+ :return: A list of thing types.
20
+ """
21
+ params = {}
22
+ if bindingId:
23
+ params["bindingId"] = bindingId
24
+ if language:
25
+ header["Accept-Language"] = language
26
+
27
+ return self.client.get("/thing-types", header={"Content-Type": "application/json"}, params=params)
28
+
29
+ def getThingType(self, thingTypeUID: str, language: str = None) -> dict:
30
+ """
31
+ Gets a thing type by UID.
32
+
33
+ :param thingTypeUID: The UID of the thing type.
34
+ :param language: (Optional) Language setting for the Accept-Language header.
35
+
36
+ :return: A dictionary with the details of the thing type or an empty response with status 204.
37
+ """
38
+ header = {"Content-Type": "application/json"}
39
+ if language:
40
+ header["Accept-Language"] = language
41
+
42
+ return self.client.get(f"/thing-types/{thingTypeUID}", header=header)
openhab/Things.py ADDED
@@ -0,0 +1,199 @@
1
+ from .Client import OpenHABClient
2
+ import json
3
+
4
+ class Things:
5
+ def __init__(self, client: OpenHABClient):
6
+ """
7
+ Initializes the Things class with an OpenHABClient object.
8
+
9
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
10
+ """
11
+ self.client = client
12
+
13
+ def getAllThings(self, summary: bool = False, staticDataOnly: bool = False, language: str = None):
14
+ """
15
+ Get all available things.
16
+
17
+ :param summary: If True, returns only the summary fields.
18
+ :param staticDataOnly: If True, returns a cacheable list.
19
+ :param language: The preferred language for the response.
20
+
21
+ :return: JSON response with the things.
22
+ """
23
+ header = {"Content-Type": "application/json"}
24
+ if language:
25
+ header["Accept-Language"] = language
26
+
27
+ return self.client.get('/things', params={'summary': summary, 'staticDataOnly': staticDataOnly}, header=header)
28
+
29
+ def createThing(self, thingData: dict, language: str = None):
30
+ """
31
+ Creates a new thing and adds it to the registry.
32
+
33
+ :param thingData: The JSON object containing the thing data.
34
+ :param language: The preferred language for the response.
35
+
36
+ :return: The API response.
37
+ """
38
+ header = {"Content-Type": "application/json", "Accept": "application/json"}
39
+ if language:
40
+ header["Accept-Language"] = language
41
+
42
+ return self.client.post('/things', data=json.dumps(thingData), header=header)
43
+
44
+ def getThingByUID(self, thingUID: str, language: str = None):
45
+ """
46
+ Gets a thing by UID.
47
+
48
+ :param thingUID: The UID of the thing.
49
+ :param language: The preferred language for the response.
50
+
51
+ :return: JSON response with the thing data.
52
+ """
53
+ header = {"Content-Type": "application/json"}
54
+ if language:
55
+ header["Accept-Language"] = language
56
+
57
+ return self.client.get(f'/things/{thingUID}', header=header)
58
+
59
+ def updateThing(self, thingUID: str, thingData: dict, language: str = None):
60
+ """
61
+ Updates a thing.
62
+
63
+ :param thingUID: The UID of the thing.
64
+ :param thingData: The JSON object containing the updated thing data.
65
+ :param language: The preferred language for the response.
66
+
67
+ :return: The API response.
68
+ """
69
+ header = {"Content-Type": "application/json", "Accept": "application/json"}
70
+ if language:
71
+ header["Accept-Language"] = language
72
+
73
+ return self.client.put(f'/things/{thingUID}', data=json.dumps(thingData), header=header)
74
+
75
+ def deleteThing(self, thingUID: str, force: bool = False, language: str = None):
76
+ """
77
+ Removes a thing from the registry. Set 'force' to __true__ if you want the thing to be removed immediately.
78
+
79
+ :param thingUID: The UID of the thing.
80
+ :param force: If True, the thing will be immediately removed.
81
+ :param language: The preferred language for the response.
82
+
83
+ :return: The API response.
84
+ """
85
+ return self.client.delete(f'/things/{thingUID}', params={'force': force}, header={'Accept-Language': language} if language else {})
86
+
87
+ def updateThingConfiguration(self, thingUID: str, configurationData: dict, language: str = None):
88
+ """
89
+ Updates a thing's configuration.
90
+
91
+ :param thingUID: The UID of the thing.
92
+ :param configurationData: The configuration data of the thing.
93
+ :param language: The preferred language for the response.
94
+
95
+ :return: The API response.
96
+ """
97
+ header = {"Content-Type": "application/json", "Accept": "application/json"}
98
+ if language:
99
+ header["Accept-Language"] = language
100
+
101
+ return self.client.put(f'/things/{thingUID}/config', data=json.dumps(configurationData), header=header)
102
+
103
+ def getThingConfigStatus(self, thingUID: str, language: str = None):
104
+ """
105
+ Gets the thing's configuration status.
106
+
107
+ :param thingUID: The UID of the thing.
108
+ :param language: The preferred language for the response.
109
+
110
+ :return: JSON response with the thing's configuration status.
111
+ """
112
+ header = {"Content-Type": "application/json"}
113
+ if language:
114
+ header["Accept-Language"] = language
115
+
116
+ return self.client.get(f'/things/{thingUID}/config/status', header=header)
117
+
118
+ def setThingStatus(self, thingUID: str, enabled: bool, language: str = None):
119
+ """
120
+ Sets the thing's enabled status.
121
+
122
+ :param thingUID: The UID of the thing.
123
+ :param enabled: If True, the thing will be enabled.
124
+ :param language: The preferred language for the response.
125
+
126
+ :return: The API response.
127
+ """
128
+ header = {"Content-Type": "text/plain"}
129
+ if language:
130
+ header["Accept-Language"] = language
131
+
132
+ return self.client.put(f'/things/{thingUID}/enable', data="true" if enabled else "false", header=header)
133
+
134
+ def enableThing(self, thingUID: str):
135
+ return self.setThingStatus(thingUID, True)
136
+
137
+ def disableThing(self, thingUID: str):
138
+ return self.setThingStatus(thingUID, False)
139
+
140
+ def updateThingFirmware(self, thingUID: str, firmwareVersion: str, language: str = None):
141
+ """
142
+ Updates the firmware of a thing.
143
+
144
+ :param thingUID: The UID of the thing.
145
+ :param firmwareVersion: The firmware version.
146
+ :param language: The preferred language for the response.
147
+
148
+ :return: The API response.
149
+ """
150
+ header = {"Content-Type": "application/json", "Accept": "application/json"}
151
+ if language:
152
+ header["Accept-Language"] = language
153
+
154
+ return self.client.put(f'/things/{thingUID}/firmware/{firmwareVersion}', header=header)
155
+
156
+ def getThingFirmwareStatus(self, thingUID: str, language: str = None):
157
+ """
158
+ Gets the thing's firmware status.
159
+
160
+ :param thingUID: The UID of the thing.
161
+ :param language: The preferred language for the response.
162
+
163
+ :return: JSON response with the firmware status.
164
+ """
165
+ header = {"Content-Type": "application/json"}
166
+ if language:
167
+ header["Accept-Language"] = language
168
+
169
+ return self.client.get(f'/things/{thingUID}/firmware/status', header=header)
170
+
171
+ def getThingFirmwares(self, thingUID: str, language: str = None):
172
+ """
173
+ Gets all available firmwares for the provided thing UID.
174
+
175
+ :param thingUID: The UID of the thing.
176
+ :param language: The preferred language for the response.
177
+
178
+ :return: A list of available firmwares.
179
+ """
180
+ header = {"Content-Type": "application/json"}
181
+ if language:
182
+ header["Accept-Language"] = language
183
+
184
+ return self.client.get(f'/things/{thingUID}/firmwares', header=header)
185
+
186
+ def getThingStatus(self, thingUID: str, language: str = None):
187
+ """
188
+ Gets the thing's status.
189
+
190
+ :param thingUID: The UID of the thing.
191
+ :param language: The preferred language for the response.
192
+
193
+ :return: JSON response with the thing's status.
194
+ """
195
+ header = {"Content-Type": "application/json"}
196
+ if language:
197
+ header["Accept-Language"] = language
198
+
199
+ return self.client.get(f'/things/{thingUID}/status', header=header)
@@ -0,0 +1,58 @@
1
+ from .Client import OpenHABClient
2
+ import json
3
+
4
+ class Transformations:
5
+ def __init__(self, client: OpenHABClient):
6
+ """
7
+ Initializes the Transformations class with an OpenHABClient object.
8
+
9
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
10
+ """
11
+ self.client = client
12
+
13
+ def getTransformations(self):
14
+ """
15
+ Get a list of all transformations.
16
+
17
+ :return: A list of transformations (JSON).
18
+ """
19
+ return self.client.get("/transformations")
20
+
21
+ def getTransformation(self, transformationUID: str):
22
+ """
23
+ Get a single transformation.
24
+
25
+ :param transformationUID: The transformationUID of the transformation to retrieve.
26
+
27
+ :return: The transformation (JSON).
28
+ """
29
+ return self.client.get(f"/transformations/{transformationUID}")
30
+
31
+ def updateTransformation(self, transformationUID: str, transformationData):
32
+ """
33
+ Update a single transformation.
34
+
35
+ :param transformationUID: The transformationUID of the transformation to update.
36
+ :param transformationData: The new data for the transformation.
37
+
38
+ :return: The response to the transformation update request (JSON).
39
+ """
40
+ return self.client.put(f"/transformations/{transformationUID}", data=json.dumps(transformationData), header={"Content-Type": "application/json"})
41
+
42
+ def deleteTransformation(self, transformationUID: str):
43
+ """
44
+ Delete a single transformation.
45
+
46
+ :param transformationUID: The transformationUID of the transformation to delete.
47
+
48
+ :return: The response to the transformation delete request (JSON).
49
+ """
50
+ return self.client.delete(f"/transformations/{transformationUID}")
51
+
52
+ def getTransformationServices(self):
53
+ """
54
+ Get all transformation services.
55
+
56
+ :return: A list of transformation services (JSON).
57
+ """
58
+ return self.client.get("/transformations/services")
openhab/UI.py ADDED
@@ -0,0 +1,75 @@
1
+ from .Client import OpenHABClient
2
+ import json
3
+
4
+ class UI:
5
+ def __init__(self, client: OpenHABClient):
6
+ """
7
+ Initializes the UI class with an OpenHABClient object.
8
+
9
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
10
+ """
11
+ self.client = client
12
+
13
+ def getUiComponents(self, namespace: str, summary: bool = False):
14
+ """
15
+ Get all registered UI components in the specified namespace.
16
+
17
+ :param namespace: The namespace for which UI components should be retrieved.
18
+ :param summary: If True, only summary fields will be returned.
19
+
20
+ :return: A list of UI components (JSON).
21
+ """
22
+ return self.client.get(f"/ui/components/{namespace}", params={'summary': summary} if summary else {})
23
+
24
+ def addUiComponent(self, namespace: str, componentData):
25
+ """
26
+ Add a UI component in the specified namespace.
27
+
28
+ :param namespace: The namespace where the UI component should be added.
29
+ :param componentData: The data of the UI component (JSON) to be added.
30
+
31
+ :return: The response to the request (JSON).
32
+ """
33
+ return self.client.post(f"/ui/components/{namespace}", data=json.dumps(componentData), header={"Content-Type": "application/json"})
34
+
35
+ def getUiComponent(self, namespace: str, componentUID: str):
36
+ """
37
+ Get a specific UI component in the specified namespace.
38
+
39
+ :param namespace: The namespace where the UI component is located.
40
+ :param componentUID: The UID of the UI component to retrieve.
41
+
42
+ :return: The UI component (JSON).
43
+ """
44
+ return self.client.get(f"/ui/components/{namespace}/{componentUID}")
45
+
46
+ def updateUiComponent(self, namespace: str, componentUID: str, componentData):
47
+ """
48
+ Update a specific UI component in the specified namespace.
49
+
50
+ :param namespace: The namespace where the UI component should be updated.
51
+ :param componentUID: The UID of the UI component to update.
52
+ :param componentData: The new data for the UI component (JSON).
53
+
54
+ :return: The response to the request (JSON).
55
+ """
56
+ return self.client.put(f"/ui/components/{namespace}/{componentUID}", data=json.dumps(componentData))
57
+
58
+ def deleteUiComponent(self, namespace: str, componentUID: str):
59
+ """
60
+ Remove a specific UI component in the specified namespace.
61
+
62
+ :param namespace: The namespace where the UI component should be removed.
63
+ :param componentUID: The UID of the UI component to delete.
64
+
65
+ :return: The response to the request (JSON).
66
+ """
67
+ return self.client.delete(f"/ui/components/{namespace}/{componentUID}")
68
+
69
+ def getUiTiles(self):
70
+ """
71
+ Get all registered UI tiles.
72
+
73
+ :return: A list of UI tiles (JSON).
74
+ """
75
+ return self.client.get("/ui/tiles")
openhab/UUID.py ADDED
@@ -0,0 +1,18 @@
1
+ from .Client import OpenHABClient
2
+
3
+ class UUID:
4
+ def __init__(self, client: OpenHABClient):
5
+ """
6
+ Initializes the UUID class with an OpenHABClient object.
7
+
8
+ :param client: An instance of OpenHABClient that is used for REST-API communication.
9
+ """
10
+ self.client = client
11
+
12
+ def getUUID(self) -> str:
13
+ """
14
+ A unified unique id.
15
+
16
+ :return: The UUID as String.
17
+ """
18
+ return self.client.get("/uuid").strip()