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/Voice.py ADDED
@@ -0,0 +1,147 @@
1
+ from .Client import OpenHABClient
2
+ import json
3
+
4
+ class Voice:
5
+ def __init__(self, client: OpenHABClient):
6
+ """
7
+ Initializes the Voice 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 getDefaultVoice(self):
14
+ """
15
+ Gets the default voice.
16
+
17
+ :return: A dictionary with the details of the default voice.
18
+ """
19
+ return self.client.get('/voice/defaultvoice', header={"Accept": "application/json"})
20
+
21
+ def startDialog(self, sourceID: str, ksID: str = None, sttID: str = None,
22
+ ttsID: str = None, voiceID: str = None, hliIDs: str = None,
23
+ sinkID: str = None, keyword: str = None, listeningItem: str = None):
24
+ """
25
+ Start dialog processing for a given audio source.
26
+
27
+ :param sourceID: The ID of the audio source.
28
+ :param ksID: The ID of the keyword spotter (optional).
29
+ :param sttID: The ID of the speech-to-text system (optional).
30
+ :param ttsID: The ID of the text-to-speech system (optional).
31
+ :param voiceID: The ID of the voice (optional).
32
+ :param hliIDs: A comma-separated list of interpreter IDs (optional).
33
+ :param sinkID: The ID of the audio output (optional).
34
+ :param keyword: The keyword used to start the dialog (optional).
35
+ :param listeningItem: The name of the item to listen to (optional).
36
+
37
+ :return: The response from the server.
38
+ """
39
+ return self.client.post('/voice/dialog/start', params={'sourceId': sourceID, 'ksId': ksID, 'sttID': sttID, 'ttsId': ttsID, 'voiceId': voiceID, 'hliIds': hliIDs, 'sinkId': sinkID, 'keyword': keyword, 'listeningItem': listeningItem})
40
+
41
+ def stopDialog(self, sourceID: str):
42
+ """
43
+ Stop dialog processing for a given audio source.
44
+
45
+ :param sourceID: The ID of the audio source.
46
+ :return: The response from the server.
47
+ """
48
+ return self.client.post('/voice/dialog/stop', params={'sourceId': sourceID})
49
+
50
+ def getInterpreters(self, language: str = None):
51
+ """
52
+ Get the list of all interpreters.
53
+
54
+ :param language: The language for the request (optional).
55
+
56
+ :return: A list of interpreters if successful.
57
+ """
58
+ header = {"Accept": "application/json"}
59
+ if language:
60
+ header["Accept-Language"] = language
61
+
62
+ return self.client.get('/voice/interpreters', header=header)
63
+
64
+ def interpretText(self, text: str, language: str, IDs: list = None):
65
+ """
66
+ Sends a text to the default human language interpreter.
67
+
68
+ :param text: The text to be interpreted.
69
+ :param language: The language of the text.
70
+ :param IDs: A list of interpreter IDs (optional).
71
+
72
+ :return: The response from the server.
73
+ """
74
+ header = {"Content-Type": "text/plain"}
75
+ if language:
76
+ header["Accept-Language"] = language
77
+
78
+ return self.client.post('/voice/interpreters', header=header, params={'ids': ','.join(IDs)} if IDs else {}, data={'text': text})
79
+
80
+ def getInterpreter(self, interpreterID: str, language: str = None):
81
+ """
82
+ Gets a single interpreter.
83
+
84
+ :param interpreterID: The ID of the interpreter.
85
+ :param language: The language for the request (optional).
86
+
87
+ :return: The details of the interpreter.
88
+ """
89
+ header = {"Content-Type": "application/json"}
90
+ if language:
91
+ header["Accept-Language"] = language
92
+
93
+ return self.client.get(f'/voice/interpreters/{interpreterID}', header=header)
94
+
95
+ def interpretTextBatch(self, text: str, language: str, IDs: list):
96
+ """
97
+ Sends a text to a given human language interpreter(s).
98
+
99
+ :param text: The text to be interpreted.
100
+ :param language: The language of the text.
101
+ :param IDs: A list of interpreter IDs.
102
+
103
+ :return: The response from the server.
104
+ """
105
+ header = {"Content-Type": "text/plain"}
106
+ if language:
107
+ header["Accept-Language"] = language
108
+
109
+ return self.client.post('/voice/interpreters', header=header, params={'ids': ','.join(IDs)}, data=json.dumps({'text': text}))
110
+
111
+ def listenAndAnswer(self, sourceID: str, sttID: str, ttsID: str, voiceID: str,
112
+ hliIDs: list = None, sinkID: str = None, listeningItem: str = None):
113
+ """
114
+ Executes a simple dialog sequence without keyword spotting for a given audio source.
115
+
116
+ :param sourceID: The ID of the audio source.
117
+ :param sttID: The ID of the speech-to-text system.
118
+ :param ttsID: The ID of the text-to-speech system.
119
+ :param voiceID: The ID of the voice.
120
+ :param hliIDs: A list of interpreter IDs (optional).
121
+ :param sinkID: The ID of the audio output (optional).
122
+ :param listeningItem: The name of the item to listen to (optional).
123
+
124
+ :return: The response from the server.
125
+ """
126
+ return self.client.post('/voice/listenandanswer', data={'sourceId': sourceID, 'sttId': sttID, 'ttsId': ttsID, 'voiceId': voiceID, 'hliIds': ','.join(hliIDs) if hliIDs else None, 'sinkId': sinkID, 'listeningItem': listeningItem})
127
+
128
+ def sayText(self, text: str, voiceID: str, sinkID: str, volume: str = '100'):
129
+ """
130
+ Speaks a given text with a given voice through the given audio sink.
131
+
132
+ :param text: The text to be spoken.
133
+ :param voiceID: The ID of the voice.
134
+ :param sinkID: The ID of the audio output.
135
+ :param volume: The volume level (default: 100).
136
+
137
+ :return: The response from the server.
138
+ """
139
+ return self.client.post('/voice/say', params={'voiceId': voiceID, 'sinkId': sinkID, 'volume': volume}, data={'text': text}, header={"Content-Type": "text/plain"})
140
+
141
+ def getVoices(self):
142
+ """
143
+ Get the list of all voices.
144
+
145
+ :return: A list of voices if successful.
146
+ """
147
+ return self.client.get('/voice/voices', header={"Accept": "application/json"})
openhab/__init__.py ADDED
@@ -0,0 +1,66 @@
1
+ from .Actions import Actions
2
+ from .Addons import Addons
3
+ from .Audio import Audio
4
+ from .Auth import Auth
5
+ from .ChannelTypes import ChannelTypes
6
+ from .Client import OpenHABClient
7
+ from .ConfigDescriptions import ConfigDescriptions
8
+ from .Discovery import Discovery
9
+ from .Events import Events, ItemEvents, ThingEvents, InboxEvents, LinkEvents, ChannelEvents
10
+ from .Iconsets import Iconsets
11
+ from .Inbox import Inbox
12
+ from .Items import Items
13
+ from .Links import Links
14
+ from .Logging import Logging
15
+ from .ModuleTypes import ModuleTypes
16
+ from .Persistence import Persistence
17
+ from .ProfileTypes import ProfileTypes
18
+ from .Rules import Rules
19
+ from .Services import Services
20
+ from .Sitemaps import Sitemaps
21
+ from .Systeminfo import Systeminfo
22
+ from .Tags import Tags
23
+ from .Templates import Templates
24
+ from .ThingTypes import ThingTypes
25
+ from .Things import Things
26
+ from .Transformations import Transformations
27
+ from .UI import UI
28
+ from .UUID import UUID
29
+ from .Voice import Voice
30
+
31
+ __all__ = [
32
+ "Actions",
33
+ "Addons",
34
+ "Audio",
35
+ "Auth",
36
+ "ChannelTypes",
37
+ "ConfigDescriptions",
38
+ "Discovery",
39
+ "Events",
40
+ "Iconsets",
41
+ "Inbox",
42
+ "Items",
43
+ "Links",
44
+ "Logging",
45
+ "ModuleTypes",
46
+ "OpenHABClient",
47
+ "Persistence",
48
+ "ProfileTypes",
49
+ "Rules",
50
+ "Services",
51
+ "Sitemaps",
52
+ "Systeminfo",
53
+ "Tags",
54
+ "Templates",
55
+ "ThingTypes",
56
+ "Things",
57
+ "Transformations",
58
+ "UI",
59
+ "UUID",
60
+ "Voice",
61
+ "ItemEvents",
62
+ "ThingEvents",
63
+ "InboxEvents",
64
+ "LinkEvents",
65
+ "ChannelEvents"
66
+ ]
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Michael Christian Dörflinger
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.