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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. openhab/Actions.py +43 -0
  2. openhab/Addons.py +163 -0
  3. openhab/Audio.py +66 -0
  4. openhab/Auth.py +105 -0
  5. openhab/ChannelTypes.py +54 -0
  6. openhab/Client.py +197 -0
  7. openhab/ConfigDescriptions.py +44 -0
  8. openhab/Discovery.py +28 -0
  9. openhab/Events.py +302 -0
  10. openhab/Iconsets.py +21 -0
  11. openhab/Inbox.py +64 -0
  12. openhab/Items.py +264 -0
  13. openhab/Links.py +98 -0
  14. openhab/Logging.py +55 -0
  15. openhab/ModuleTypes.py +47 -0
  16. openhab/Persistence.py +103 -0
  17. openhab/ProfileTypes.py +32 -0
  18. openhab/Rules.py +206 -0
  19. openhab/Services.py +78 -0
  20. openhab/Sitemaps.py +88 -0
  21. openhab/Systeminfo.py +34 -0
  22. openhab/Tags.py +82 -0
  23. openhab/Templates.py +38 -0
  24. openhab/ThingTypes.py +42 -0
  25. openhab/Things.py +199 -0
  26. openhab/Transformations.py +58 -0
  27. openhab/UI.py +75 -0
  28. openhab/UUID.py +18 -0
  29. openhab/Voice.py +147 -0
  30. openhab/__init__.py +66 -0
  31. python_openhab_rest_client-0.1.0.dist-info/LICENSE +21 -0
  32. python_openhab_rest_client-0.1.0.dist-info/METADATA +2391 -0
  33. python_openhab_rest_client-0.1.0.dist-info/RECORD +70 -0
  34. python_openhab_rest_client-0.1.0.dist-info/WHEEL +5 -0
  35. python_openhab_rest_client-0.1.0.dist-info/top_level.txt +2 -0
  36. tests/__init__.py +0 -0
  37. tests/actions.py +55 -0
  38. tests/addons.py +96 -0
  39. tests/audio.py +16 -0
  40. tests/auth.py +45 -0
  41. tests/channel_events.py +14 -0
  42. tests/channel_types.py +29 -0
  43. tests/config_descriptions.py +23 -0
  44. tests/discovery.py +23 -0
  45. tests/events.py +41 -0
  46. tests/iconsets.py +19 -0
  47. tests/inbox.py +53 -0
  48. tests/inbox_events.py +15 -0
  49. tests/item_events.py +38 -0
  50. tests/items.py +120 -0
  51. tests/link_events.py +14 -0
  52. tests/links.py +74 -0
  53. tests/logging_test.py +43 -0
  54. tests/module_types.py +14 -0
  55. tests/persistence.py +78 -0
  56. tests/profile_types.py +13 -0
  57. tests/rules.py +151 -0
  58. tests/services.py +52 -0
  59. tests/sitemaps.py +65 -0
  60. tests/systeminfo.py +14 -0
  61. tests/tags.py +53 -0
  62. tests/templates.py +28 -0
  63. tests/test.py +11 -0
  64. tests/thing_events.py +17 -0
  65. tests/thing_types.py +28 -0
  66. tests/things.py +75 -0
  67. tests/transformations.py +38 -0
  68. tests/ui.py +70 -0
  69. tests/uuid.py +18 -0
  70. tests/voice.py +119 -0
@@ -0,0 +1,70 @@
1
+ openhab/Actions.py,sha256=GbinHkpBIY0fw7hQHLjvcFJDHO7b7JqGIL61IEQXvsQ,1643
2
+ openhab/Addons.py,sha256=8z9oeD5jv5FG1XLkgq4SSarPB8lcmKKagUZL0h5GTHU,6422
3
+ openhab/Audio.py,sha256=pU058tmGYZLA-eNt_QALfBldXXUSh_IdqTLBgOS7OR8,2214
4
+ openhab/Auth.py,sha256=ecWm8a_ZwDaMZubejuGDrodTOK1Zv72PM97aVNk3bHE,3928
5
+ openhab/ChannelTypes.py,sha256=18_PO8CyTpN-2H5SePZl8Jv9M8Fj46n4pNDBYgVYggA,1913
6
+ openhab/Client.py,sha256=SR8M8IonsnjwlpRLEStKSxoA72pR00O3fDU7z5kFz48,8255
7
+ openhab/ConfigDescriptions.py,sha256=-zDzPd3kRj-6aByhJ_8ttg17VtOseKij1YgMCOaEGJQ,1546
8
+ openhab/Discovery.py,sha256=pa5ZhEEyijb5MficD6ACTzjz12Rson0UOsIHCiFGd0w,987
9
+ openhab/Events.py,sha256=ipnIW1TO7p0INDNpnChWKY3ZhZAuct05qXckt7EyVtI,11228
10
+ openhab/Iconsets.py,sha256=LM-0CUhWFxQlo1aBbVbALHwptLJ-h7SfUrG_MJajiMQ,742
11
+ openhab/Inbox.py,sha256=C6UHCGB49zjsj5Xn-yhN84u2qAFMfuvVjUgbzHZsCyI,2541
12
+ openhab/Items.py,sha256=CntLVgsTSLr--dSDC1f_u-BpKVR7C9XWEsB7JzccgUI,9696
13
+ openhab/Links.py,sha256=oZWHq3d43NjvKqP4JTvUKWz1Wf8oS_OMiOKOUM6U4Rc,3579
14
+ openhab/Logging.py,sha256=bgKkTB-jG4bmSWvThr77WOdPCodhM2DWFj0bOyhKI84,1615
15
+ openhab/ModuleTypes.py,sha256=EPX4UlIHg8Totw8yIfF4AXcVjoQEHrg_2FVuW5f9rdA,1628
16
+ openhab/Persistence.py,sha256=MhTYmhCHiWD-GZn944l32glUJrVst1caRqSn_sWrvP8,4305
17
+ openhab/ProfileTypes.py,sha256=Rg1kq2TqTibC9LLkEiym6aYJjYMaLk1pgZPZR0Z_Rwk,1113
18
+ openhab/Rules.py,sha256=CyfS4EHM-WsDqCeSu3_v4NIaczyi1vxRxD9dqL3atTk,7700
19
+ openhab/Services.py,sha256=cpQuM2uyQpVUg_PohssoWrTFb3D3JUpccBl45HZpWxU,2888
20
+ openhab/Sitemaps.py,sha256=f-V_VMHuyiGDi8Xx2OJiDgPzD-qsNVLyypd1xqIYeDI,3621
21
+ openhab/Systeminfo.py,sha256=B2HOZKfqfHaOFktYR7yUKD3Iw7y2MSAuBRyEUFJKKzk,1058
22
+ openhab/Tags.py,sha256=pHHEIIYN3tDW0rSg_vIOWPB8d31w4GzCye7iu0CRu8k,2862
23
+ openhab/Templates.py,sha256=IHPY13I-pjLAAQtHNwYk0MzpYM2HuwZqZehHJ87A5Q8,1321
24
+ openhab/ThingTypes.py,sha256=_f7sS9WVzxotmwpeUWt1HNXTcCZrrDOiqHUSp76daVI,1556
25
+ openhab/Things.py,sha256=yaLLuZxno7z_ZX8pPxwO-QqR2wKnm8mmBMJ1nUpmTSQ,7360
26
+ openhab/Transformations.py,sha256=-Mfe54hJaDIpbf1lNfSdxDoC5Owmg0kuUc3sahmvcbA,2003
27
+ openhab/UI.py,sha256=qIN1MOur0YACxEzWytEJToBpueDfbRE2CeFZgMxMOQE,2893
28
+ openhab/UUID.py,sha256=vp1pE3PbERTHJaG4hN8ipDbK8_2Q5YWrVnCaNTC6K_k,475
29
+ openhab/Voice.py,sha256=I4b2jUYTGWX5pfM3l8vWJyIxzh7XMe2_JzA6o8-bXfU,6132
30
+ openhab/__init__.py,sha256=iclKWQq7ATCCSGOBIqqyHjXEadi0DajGcgzu_A031ZQ,1523
31
+ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
+ tests/actions.py,sha256=Y2qbByVMUoNjZHxbtWEXgCvecXmu9bvE9t03wczff4E,2128
33
+ tests/addons.py,sha256=Aunqp37-0u_Ebyr1DZTRPty_rTUwaVR6Wu8okyDBWEY,3823
34
+ tests/audio.py,sha256=8DPmrKA-8GkXXbCvUdH6JC8Dpxv07JXhEGManxBvDnw,513
35
+ tests/auth.py,sha256=NwLNHPtZeLDraujX47L8pV_1z0UmjfwqC6fxpnlk7Uw,1573
36
+ tests/channel_events.py,sha256=0YoHK_4tumusZpsqmO2NnpPht13WOx-OLaaP1xRAF8M,509
37
+ tests/channel_types.py,sha256=SlzmyL50LuQYU3VOOuuukg7NYHqANn03ffrWT-pKa3s,1189
38
+ tests/config_descriptions.py,sha256=fso30IuSjpX0M2FanTs_yRqfRzh-B_E4WADwj-Fuv1A,919
39
+ tests/discovery.py,sha256=EzyEP5VenkJRnV5EkQp316bJzAI886zVJl4YWjo43VM,815
40
+ tests/events.py,sha256=3pBB7LR-8TJwCtXK6uigxEZsyT7ZDInZp64bEhi2hz8,1393
41
+ tests/iconsets.py,sha256=4E08bKDWRVfWbwLZ4qdP2nhA1Uw4g7hbOeyJQdHLmd0,611
42
+ tests/inbox.py,sha256=ygy7A0OlEM-VDfi1zrniBNVR8uoYl1vB4DQrb2wPrCY,2094
43
+ tests/inbox_events.py,sha256=QPicsQpNMkgrMmZ8ltuKE8CI5eGYQeCurTkNxcmAFag,522
44
+ tests/item_events.py,sha256=w-RgnRJrjKcHGBt8GavhbQHxPP01qvEAUU7827-MS_Y,1191
45
+ tests/items.py,sha256=k531MXLOLPPkNoSYijnI_fbEieyL6L75aNmqUzwMyHE,3761
46
+ tests/link_events.py,sha256=oe0WGfKfKSIcWWkPiqRWVjxrFeBfYP9j7u_uGcfoSXY,505
47
+ tests/links.py,sha256=ZYqzeg-pfrduQ9g7rUGQ5sNHISN0bIkGwi6wGOqUlEI,2718
48
+ tests/logging_test.py,sha256=fjun4M8OxfvpeBg4NxJ8SjhOUt7oPvaheQScq0xYr7w,1302
49
+ tests/module_types.py,sha256=THIjf4aru3IkE689ONb84hGt0vYheMX96uIEFMpLoQw,505
50
+ tests/persistence.py,sha256=crjmyiqTk5n3leUP-a7P6k8l7uyHO2WE1Fu_Q720Qf0,3156
51
+ tests/profile_types.py,sha256=CMpTPgTKvdXuhdEkIBaX5wIUB9C_9VK77UsQy2ANeVI,447
52
+ tests/rules.py,sha256=oQ3m5FmvXyaeL0GR4X0KvSetfIEyaNw_zVQq_LsiLfc,4776
53
+ tests/services.py,sha256=HimsJqDOqm5Xw9f4R0wEawH2ICLfKZ0EEgwJm92XoJM,1750
54
+ tests/sitemaps.py,sha256=m4--Q-LI1fCDgL4lXpydM8uf6X7MwLJc9fMJ2BCUdCY,2375
55
+ tests/systeminfo.py,sha256=yNsiLmsEEZbWqVBT3feTrIvmiBnT5jAOFXCcs4dP4Fo,479
56
+ tests/tags.py,sha256=C5BvFf2xQePDT6RH25JBi9AosGiYp64ujXJtK2Kp1tI,1467
57
+ tests/templates.py,sha256=VsxpbP264LZ0o_NzIHiv7UAITVlEnlVmO0rOTiB96Nk,991
58
+ tests/test.py,sha256=2yWlAvR6FaIveKoOL8TnRQQbWNraL_HSbKgQDNQRLcM,497
59
+ tests/thing_events.py,sha256=3H31OCkY3Ghsu7BrYN5LKH_Rrcdoenr-ZYDRvIbaGLg,619
60
+ tests/thing_types.py,sha256=6VcuMZDuzmxXD95Wilfwr2--elGnjr3u4RSV7BDFcyM,1009
61
+ tests/things.py,sha256=bxOve2HAcpS-Wu8YH0izcKPTwk3wuyoP48BJQZNWRgw,2783
62
+ tests/transformations.py,sha256=zwKNxXg8pIZVomTqqZn5HTwV5jIcExGtS7Hbr72skT4,1253
63
+ tests/ui.py,sha256=Z4gjDSwCpsgLTU6CgbGU5c_uOIYJAUzhf1_7AMo3MHs,2028
64
+ tests/uuid.py,sha256=Ne55N6pPGubPCY1SRQA6G99DWOFChoqQUdmC4_55ZD4,713
65
+ tests/voice.py,sha256=5DyzU7oB5OI7t5JuHdF8ASbgUKST2Z19Y_DkR9Dmojk,4163
66
+ python_openhab_rest_client-0.1.0.dist-info/LICENSE,sha256=69QhqD8S8OPNY1BAzQIPayy_M-A5ltuK0v5kRvS75ZI,1086
67
+ python_openhab_rest_client-0.1.0.dist-info/METADATA,sha256=MvlM-bdFl1K8osS-wbzk4HNbjcEJnFdZAX_ditG1MPA,66987
68
+ python_openhab_rest_client-0.1.0.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
69
+ python_openhab_rest_client-0.1.0.dist-info/top_level.txt,sha256=m5d0ZGvuMBPyd81BONJW6I-kWCeHagriOKWruLGt1u8,14
70
+ python_openhab_rest_client-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.3.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ openhab
2
+ tests
tests/__init__.py ADDED
File without changes
tests/actions.py ADDED
@@ -0,0 +1,55 @@
1
+ import sys
2
+ import os
3
+ from datetime import datetime
4
+ import pytz
5
+
6
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
7
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
8
+ from openhab import OpenHABClient, Actions
9
+
10
+ # Client initialisieren (ersetze 'http://openhab-url' mit deiner URL und 'auth_token' mit deinem Token)
11
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
12
+ actionsApi = Actions(client)
13
+
14
+ # Alle Aktionen für ein Thing abrufen
15
+ thingUid = "astro:sun:560560e11a" # Beispiel-Thing UID
16
+ try:
17
+ actions = actionsApi.getAllActions(thingUid)
18
+ print("Verfügbare Aktionen:")
19
+ for action in actions:
20
+ print(f"Aktion UID: {action['actionUid']}, Label: {action['label']}")
21
+ except Exception as e:
22
+ print(f"Fehler beim Abrufen der Aktionen: {e}")
23
+
24
+ # Eine Aktion ausführen
25
+ actionUid = "astro.getEventTime" # Beispiel-Aktions-UID
26
+
27
+ # Eingabedaten vorbereiten (wir wählen den Phase "SUNSET" als Beispiel)
28
+ phaseName = "SUN_SET" # Korrekt geschriebener Phase Name (z. B. "SUNRISE", "SUNSET", "NOON")
29
+ momentValue = "START" # Standardwert für "moment" ist "START"
30
+
31
+ # Aktuelles Datum und Uhrzeit im ISO 8601-Format mit Zeitzone (ZonedDateTime)
32
+ # Hier wird ein korrekt formatierter "ZonedDateTime"-String erzeugt
33
+ now = datetime.now(pytz.utc)
34
+ dateValueZoned = now.strftime('%Y-%m-%dT%H:%M:%S%z') # Format: "2025-01-27T14:30:00+00:00"
35
+
36
+ # Hier wird ein Beispiel für die Eingabedaten vorbereitet
37
+ actionInputs = {
38
+ "phaseName": phaseName, # Phase Name ist erforderlich
39
+ "date": str(dateValueZoned), # Datum im korrekten ZonedDateTime-Format
40
+ "moment": momentValue # Moment (START oder END)
41
+ }
42
+
43
+ try:
44
+ # Eine Aktion ausführen
45
+ response = actionsApi.executeAction(thingUid, actionUid, actionInputs)
46
+ print(f"Aktionsantwort: {response}")
47
+
48
+ # Antwort prüfen
49
+ if isinstance(response, dict):
50
+ print(f"Antwort von der Aktion: {response}")
51
+ else:
52
+ print(f"Unerwarteter Rückgabetyp: {type(response)}")
53
+
54
+ except Exception as e:
55
+ print(f"Fehler beim Ausführen der Aktion: {e}")
tests/addons.py ADDED
@@ -0,0 +1,96 @@
1
+ import sys
2
+ import os
3
+ import json
4
+
5
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
7
+ from openhab import OpenHABClient, Addons
8
+
9
+ # Client initialisieren
10
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
11
+ addonsApi = Addons(client)
12
+
13
+ # Teste den Endpunkt, um alle Add-ons zu holen
14
+ def testGetAddons():
15
+ print("Teste getAddons...")
16
+ response = addonsApi.getAddons()
17
+ print("Antwort von getAddons:", json.dumps(response, indent=2))
18
+
19
+ # Teste den Endpunkt, um ein spezifisches Add-on zu holen
20
+ def testGetAddon():
21
+ addonId = "binding-astro"
22
+ print(f"Teste getAddon für ID {addonId}...")
23
+ response = addonsApi.getAddon(addonId)
24
+ print(f"Antwort von getAddon für {addonId}:", json.dumps(response, indent=2))
25
+
26
+ # Teste den Endpunkt, um ein Add-on zu installieren
27
+ def testInstallAddon():
28
+ addonId = "binding-astro"
29
+ print(f"Teste installAddon für ID {addonId}...")
30
+ response = addonsApi.installAddon(addonId)
31
+ print(f"Antwort von installAddon für {addonId}:", json.dumps(response, indent=2))
32
+
33
+ # Teste den Endpunkt, um ein Add-on zu deinstallieren
34
+ def testUninstallAddon():
35
+ addonId = "binding-astro"
36
+ print(f"Teste uninstallAddon für ID {addonId}...")
37
+ response = addonsApi.uninstallAddon(addonId)
38
+ print(f"Antwort von uninstallAddon für {addonId}:", json.dumps(response, indent=2))
39
+
40
+ # Teste den Endpunkt, um Add-on-Typen zu holen
41
+ def testGetAddonTypes():
42
+ print("Teste getAddonTypes...")
43
+ response = addonsApi.getAddonTypes()
44
+ print("Antwort von getAddonTypes:", json.dumps(response, indent=2))
45
+
46
+ # Teste den Endpunkt, um empfohlene Add-ons zu holen
47
+ def testGetAddonSuggestions():
48
+ print("Teste getAddonSuggestions...")
49
+ response = addonsApi.getAddonSuggestions()
50
+ print("Antwort von getAddonSuggestions:", json.dumps(response, indent=2))
51
+
52
+ # Teste den Endpunkt, um die Add-on-Konfiguration zu holen
53
+ def testGetAddonConfig():
54
+ addonId = "binding-astro"
55
+ print(f"Teste getAddonConfig für ID {addonId}...")
56
+ response = addonsApi.getAddonConfig(addonId)
57
+ print(f"Antwort von getAddonConfig für {addonId}:", json.dumps(response, indent=2))
58
+
59
+ # Teste den Endpunkt, um die Add-on-Konfiguration zu aktualisieren
60
+ def testUpdateAddonConfig():
61
+ addonId = "binding-astro" # OpenHAB Binding für Sonnen- und Mondzeiten
62
+ configData = {
63
+ "latitude": 52.52, # Berlin
64
+ "longitude": 13.405,
65
+ "interval": 300 # Aktualisierung alle 5 Minuten
66
+ }
67
+ print(f"Teste updateAddonConfig für ID {addonId} mit {configData}...")
68
+ response = addonsApi.updateAddonConfig(addonId, configData)
69
+ print(f"Antwort von updateAddonConfig für {addonId}:", json.dumps(response, indent=2))
70
+
71
+ # Teste den Endpunkt, um Add-on-Services zu holen
72
+ def testGetAddonServices():
73
+ print("Teste getAddonServices...")
74
+ response = addonsApi.getAddonServices()
75
+ print("Antwort von getAddonServices:", json.dumps(response, indent=2))
76
+
77
+ def testInstallAddonFromUrl():
78
+ # Ersetze diese URL durch eine echte OpenHAB-Add-on-URL
79
+ url = "https://repo1.maven.org/maven2/org/smarthomej/addons/bundles/org.smarthomej.binding.amazonechocontrol/4.2.0/org.smarthomej.binding.amazonechocontrol-4.2.0.kar"
80
+
81
+ print(f"Teste installAddonFromUrl für URL {url}...")
82
+ response = addonsApi.installAddonFromUrl(url)
83
+ print(f"Antwort von installAddonFromUrl für URL {url}:", json.dumps(response, indent=2))
84
+
85
+ if __name__ == "__main__":
86
+ # Führe alle Tests aus
87
+ testGetAddons()
88
+ testGetAddon()
89
+ testInstallAddon()
90
+ testUninstallAddon()
91
+ testGetAddonTypes()
92
+ testGetAddonSuggestions()
93
+ testGetAddonConfig()
94
+ testUpdateAddonConfig()
95
+ testGetAddonServices()
96
+ testInstallAddonFromUrl()
tests/audio.py ADDED
@@ -0,0 +1,16 @@
1
+ import sys
2
+ import os
3
+
4
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
+ from openhab import OpenHABClient, Audio
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+ audioApi = Audio(client)
11
+
12
+ # Teste Audio-Endpunkte
13
+ print(audioApi.getDefaultSink())
14
+ print(audioApi.getDefaultSource())
15
+ print(audioApi.getSinks())
16
+ print(audioApi.getSources())
tests/auth.py ADDED
@@ -0,0 +1,45 @@
1
+ import json
2
+ import sys
3
+ import os
4
+
5
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
7
+ from openhab import OpenHABClient, Auth
8
+
9
+ # openhab
10
+ # habopen
11
+ # oh.openhab.U0doM1Lz4kJ6tPlVGjH17jjm4ZcTHIHi7sMwESzrIybKbCGySmBMtysPnObQLuLf7PgqnI7jWQ5LosySY8Q
12
+
13
+ # Client initialisieren
14
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
15
+ authApi = Auth(client)
16
+
17
+ # 1. Alle API-Tokens abrufen
18
+ tokens = authApi.getApiTokens()
19
+ print("API Tokens:", tokens)
20
+
21
+ # 2. Ein API-Token widerrufen
22
+ revokeResponse = authApi.revokeApiToken("openhab")
23
+ print("Token widerrufen:", revokeResponse)
24
+
25
+ # 3. Sessions abfragen
26
+ sessions = authApi.getSessions()
27
+ print("Sessions:", json.dumps(sessions, indent=4))
28
+
29
+ # 4. Refresh-Token erstellen (simuliert durch einen spezifischen API-Endpunkt oder OAuth)
30
+ # Ersetzt die Parameter durch gültige Werte, falls erforderlich
31
+ tokenResponse = authApi.getToken(
32
+ grantType="authorization_code", # Für die Demo: Nutze einen gültigen grantType
33
+ code="your-auth-code",
34
+ redirectUri="http://127.0.0.1",
35
+ clientID="your-client-id"
36
+ )
37
+ print("Token Response:", json.dumps(tokenResponse, indent=4))
38
+
39
+ # 5. Mit einem gültigen Refresh-Token abmelden
40
+ refreshToken = tokenResponse.get("refresh_token", "")
41
+ if refreshToken:
42
+ logoutResponse = authApi.logout(refreshToken=refreshToken)
43
+ print("Logout Response:", json.dumps(logoutResponse, indent=4))
44
+ else:
45
+ print("Kein Refresh-Token vorhanden. Abmelden nicht möglich.")
@@ -0,0 +1,14 @@
1
+ import sys
2
+ import os
3
+
4
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
+ from openhab import OpenHABClient, ChannelEvents
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+ channelEvents = ChannelEvents(client)
11
+
12
+ # Beispielaufrufe
13
+ print(channelEvents.ChannelDescriptionChangedEvent("*"))
14
+ print(channelEvents.ChannelTriggeredEvent("*"))
tests/channel_types.py ADDED
@@ -0,0 +1,29 @@
1
+ import sys
2
+ import os
3
+
4
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
+ from openhab import OpenHABClient, ChannelTypes
7
+
8
+ # Beispiel: OpenHABClient initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+
11
+ # ChannelTypes-Klasse instanziieren
12
+ channelTypesApi = ChannelTypes(client)
13
+
14
+ allChannelTypes = channelTypesApi.getAllChannelTypes(language="en")
15
+ print("Alle verfügbaren Channel-Typen:")
16
+ for channel in allChannelTypes:
17
+ print(channel.get("UID", "Kein UID gefunden"))
18
+
19
+ # Alle Channel-Typen abrufen
20
+ allChannelTypes = channelTypesApi.getAllChannelTypes(language="en", prefixes="mqtt")
21
+ print("Alle Channel-Typen:", allChannelTypes)
22
+
23
+ # Einen spezifischen Channel-Typ nach UID abrufen
24
+ channelTypeDetails = channelTypesApi.getChannelTypeByUid(channelTypeUid="mqtt:trigger", language="en")
25
+ print("Channel-Typ-Details:", channelTypeDetails)
26
+
27
+ # Linkbare Item-Typen für einen Channel-Typ abrufen
28
+ linkableItemTypes = channelTypesApi.getLinkableItemTypes(channelTypeUid="mqtt:trigger")
29
+ print("Linkbare Item-Typen:", linkableItemTypes)
@@ -0,0 +1,23 @@
1
+ import sys
2
+ import os
3
+
4
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
+ from openhab import OpenHABClient, ConfigDescriptions
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+
11
+ # ConfigDescriptions-Klasse instanziieren
12
+ configDescriptionsApi = ConfigDescriptions(client)
13
+
14
+ # Alle Konfigurationsbeschreibungen abrufen
15
+ allConfigs = configDescriptionsApi.getAllConfigDescriptions(language="en")
16
+ print("Alle Konfigurationsbeschreibungen:", allConfigs)
17
+
18
+ # Eine spezifische Konfigurationsbeschreibung nach URI abrufen
19
+ try:
20
+ configByUri = configDescriptionsApi.getConfigDescriptionByUri(uri="channel-type:mqtt:ha-channel", language="en")
21
+ print("Konfigurationsbeschreibung für URI:", configByUri)
22
+ except ValueError as e:
23
+ print("Fehler:", e)
tests/discovery.py ADDED
@@ -0,0 +1,23 @@
1
+ import sys
2
+ import os
3
+
4
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
+ from openhab import OpenHABClient, Discovery
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+
11
+ # Discovery-Klasse instanziieren
12
+ discoveryApi = Discovery(client)
13
+
14
+ # Alle Bindings abrufen, die Discovery unterstützen
15
+ bindings = discoveryApi.getAllDiscoveryBindings()
16
+ print("Bindings mit Discovery-Funktion:", bindings)
17
+
18
+ # Einen Discovery-Scan für ein bestimmtes Binding starten
19
+ try:
20
+ timeout = discoveryApi.startBindingScan(bindingID="some-binding-id")
21
+ print(f"Discovery gestartet. Timeout: {timeout} Sekunden")
22
+ except ValueError as e:
23
+ print("Fehler:", e)
tests/events.py ADDED
@@ -0,0 +1,41 @@
1
+ import sys
2
+ import os
3
+
4
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
+ from openhab import OpenHABClient, Events
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+
11
+ # Events-Klasse instanziieren
12
+ eventsApi = Events(client)
13
+
14
+ # Alle Events abrufen
15
+ try:
16
+ events = eventsApi.getAllEvents(topics="topic1,topic2")
17
+ print("Gefilterte Events:", events)
18
+ except ValueError as e:
19
+ print("Fehler beim Abrufen der Events:", e)
20
+
21
+ # Neue Status-Tracker-Verbindung initiieren
22
+ try:
23
+ connectionIdResponse = eventsApi.initiateStateTracker()
24
+ print("Neue Verbindungs-ID:", connectionIdResponse)
25
+ except Exception as e:
26
+ print("Fehler beim Starten der Status-Tracker-Verbindung:", e)
27
+
28
+ connectionId = None
29
+ for line in connectionIdResponse.iter_lines():
30
+ if line.startswith(b"data: "): # Die Zeile mit der ID suchen
31
+ connectionId = line.decode().split("data: ")[1].strip()
32
+ break # Nur die erste "data: ..." Zeile auslesen
33
+
34
+ print("Gefundene Connection ID:", connectionId)
35
+
36
+ # Verbindung aktualisieren
37
+ try:
38
+ result = eventsApi.updateSseConnectionItems(connectionId=connectionId, items=["item1", "item2"])
39
+ print(result)
40
+ except ValueError as e:
41
+ print("Fehler beim Aktualisieren der Verbindung:", e)
tests/iconsets.py ADDED
@@ -0,0 +1,19 @@
1
+ import sys
2
+ import os
3
+
4
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
+ from openhab import OpenHABClient, Iconsets
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+
11
+ # Iconsets-Klasse instanziieren
12
+ iconsetsApi = Iconsets(client)
13
+
14
+ # Alle Iconsets abrufen
15
+ try:
16
+ iconsets = iconsetsApi.getAllIconsets(language="de")
17
+ print("Verfügbare Iconsets:", iconsets)
18
+ except Exception as e:
19
+ print("Fehler beim Abrufen der Iconsets:", e)
tests/inbox.py ADDED
@@ -0,0 +1,53 @@
1
+ import sys
2
+ import os
3
+
4
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
+ from openhab import OpenHABClient, Inbox
7
+
8
+ # OpenHAB-Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+
11
+ # Inbox-API instanziieren
12
+ inboxApi = Inbox(client)
13
+
14
+ # 1. Alle entdeckten Dinge abrufen
15
+ try:
16
+ discoveredThings = inboxApi.getAllDiscoveredThings()
17
+ print("Entdeckte Dinge:", discoveredThings)
18
+ except Exception as e:
19
+ print("Fehler beim Abrufen der entdeckten Dinge:", e)
20
+
21
+ # 2. Ein Entdeckungsergebnis entfernen
22
+ thingUidToRemove = "avmfritz:fritzbox:192_168_3_1"
23
+ try:
24
+ response = inboxApi.removeDiscoveryResult(thingUidToRemove)
25
+ print(f"Entdeckungsergebnis '{thingUidToRemove}' entfernt:", response)
26
+ except Exception as e:
27
+ print(f"Fehler beim Entfernen des Entdeckungsergebnisses '{thingUidToRemove}':", e)
28
+
29
+ # 3. Ein Gerät genehmigen
30
+ thingUidToApprove = "avmfritz:fritzbox:192_168_2_1"
31
+ thingLabel = "Mein FritzBox Router"
32
+ try:
33
+ response = inboxApi.approveDiscoveryResult(thingUidToApprove, thingLabel)
34
+ print(f"Entdeckungsergebnis '{thingUidToApprove}' genehmigt:", response)
35
+ except Exception as e:
36
+ print(f"Fehler beim Genehmigen des Entdeckungsergebnisses '{thingUidToApprove}':", e)
37
+
38
+ # 4. Ein Entdeckungsergebnis ignorieren
39
+ thingUidToIgnore = "avmfritz:fritzbox:192_168_2_1"
40
+ try:
41
+ response = inboxApi.ignoreDiscoveryResult(thingUidToIgnore)
42
+ print(f"Entdeckungsergebnis '{thingUidToIgnore}' ignoriert:", response)
43
+ except Exception as e:
44
+ print(f"Fehler beim Ignorieren des Entdeckungsergebnisses '{thingUidToIgnore}':", e)
45
+
46
+ # 5. Ein ignoriertes Gerät wieder sichtbar machen
47
+ thingUidToUnignore = "avmfritz:fritzbox:192_168_2_1"
48
+ try:
49
+ response = inboxApi.unignoreDiscoveryResult(thingUidToUnignore)
50
+ print(f"Entdeckungsergebnis '{thingUidToUnignore}' wieder aktiviert:", response)
51
+ except Exception as e:
52
+ print(f"Fehler beim Wiederherstellen des Entdeckungsergebnisses '{thingUidToUnignore}':", e)
53
+
tests/inbox_events.py ADDED
@@ -0,0 +1,15 @@
1
+ import sys
2
+ import os
3
+
4
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
5
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
+ from openhab import OpenHABClient, InboxEvents
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+ inboxEvents = InboxEvents(client)
11
+
12
+ # Beispielaufrufe
13
+ print(inboxEvents.InboxAddedEvent("*"))
14
+ print(inboxEvents.InboxRemovedEvent("*"))
15
+ print(inboxEvents.InboxUpdatedEvent("*"))
tests/item_events.py ADDED
@@ -0,0 +1,38 @@
1
+ import sys
2
+ import os
3
+ import json
4
+
5
+ # Füge den Projektwurzelpfad (eine Ebene höher) zum Python-Suchpfad hinzu
6
+ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
7
+ from openhab import OpenHABClient, ItemEvents
8
+
9
+ # Client initialisieren
10
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
11
+ itemEvents = ItemEvents(client)
12
+
13
+ # Beispielaufrufe
14
+ print(itemEvents.ItemEvent())
15
+ print(itemEvents.ItemAddedEvent("*"))
16
+ print(itemEvents.ItemRemovedEvent("*"))
17
+ print(itemEvents.ItemUpdatedEvent("*"))
18
+ print(itemEvents.ItemCommandEvent("*"))
19
+ print(itemEvents.ItemStateEvent("*"))
20
+ print(itemEvents.ItemStatePredictedEvent("*"))
21
+ print(itemEvents.ItemStateChangedEvent("*"))
22
+ print(itemEvents.GroupItemStateChangedEvent("*", "*"))
23
+
24
+
25
+ response = itemEvents.ItemStateChangedEvent()
26
+
27
+ with response as events:
28
+ for line in events.iter_lines():
29
+ line = line.decode()
30
+
31
+ if "data" in line:
32
+ line = line.replace("data: ", "")
33
+
34
+ try:
35
+ data = json.loads(line)
36
+ print(data)
37
+ except json.decoder.JSONDecodeError:
38
+ print("Event could not be converted to JSON")