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
tests/items.py ADDED
@@ -0,0 +1,120 @@
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, Items
7
+
8
+ # Client initialisieren (ersetze 'http://openhab-url' mit deiner URL und 'auth_token' mit deinem Token)
9
+ #client = OpenHABClient(base_url='http://openhab-url', auth_token='your_auth_token')
10
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
11
+ itemsApi = Items(client)
12
+
13
+ # Beispiele für jede Methode in Items
14
+ def examples():
15
+
16
+ # Alle Items abrufen
17
+ allItems = itemsApi.getAllItems()
18
+ print("All Items:", allItems)
19
+
20
+
21
+ # Ein einzelnes Item abrufen
22
+ testSwitch = itemsApi.getItem("testSwitch")
23
+ print("testSwitch Details:", testSwitch)
24
+
25
+ # Neues Item hinzufügen oder aktualisieren
26
+ newItemData = {
27
+ "type": "Switch",
28
+ "name": "newSwitch",
29
+ "label": "New Switch",
30
+ "groupNames": ["Static"],
31
+ "tags": ["SwitchTag"],
32
+ "category": "Switch"
33
+ }
34
+ itemsApi.addOrUpdateItem("newSwitch", newItemData)
35
+ print("New Switch added/updated.")
36
+
37
+ # Liste von Items hinzufügen oder aktualisieren
38
+ newItems = [
39
+ {
40
+ "type": "Number",
41
+ "name": "newNumber",
42
+ "label": "New Number",
43
+ "groupNames": ["Static"],
44
+ "tags": ["NumberTag"],
45
+ "category": "Number"
46
+ },
47
+ {
48
+ "type": "String",
49
+ "name": "newString",
50
+ "label": "New String",
51
+ "groupNames": ["Static"],
52
+ "tags": ["StringTag"],
53
+ "category": "String"
54
+ }
55
+ ]
56
+ itemsApi.addOrUpdateItems(newItems)
57
+ print("New Items added/updated.")
58
+
59
+ # Befehl an ein Item senden
60
+ itemsApi.sendCommand("testSwitch", "ON")
61
+ print("Command sent to testSwitch.")
62
+
63
+ # Zustand eines Items aktualisieren
64
+ itemsApi.updateItemState("testNumber", "42")
65
+ print("State of testNumber updated.")
66
+
67
+ # Zustand eines Items abrufen
68
+ testSwitchState = itemsApi.getItemState("testSwitch")
69
+ print("testSwitch State:", testSwitchState)
70
+
71
+ # Ein Item löschen
72
+ itemsApi.deleteItem("newSwitch")
73
+ print("newSwitch deleted.")
74
+
75
+ # Gruppenmitglied hinzufügen
76
+ itemsApi.addGroupMember("Static", "newNumber")
77
+ print("newNumber added to Static group.")
78
+
79
+ # Gruppenmitglied entfernen
80
+ itemsApi.removeGroupMember("Static", "newNumber")
81
+ print("newNumber removed from Static group.")
82
+
83
+ # Metadaten hinzufügen
84
+ metadata = {
85
+ "value": "metadata_value",
86
+ "config": {
87
+ "key1": "value1",
88
+ "key2": "value2"
89
+ }
90
+ }
91
+ itemsApi.addMetadata("testSwitch", "exampleNamespace", metadata)
92
+ print("Metadata added to testSwitch.")
93
+
94
+ # Metadaten entfernen
95
+ itemsApi.removeMetadata("testSwitch", "exampleNamespace")
96
+ print("Metadata removed from testSwitch.")
97
+
98
+ # Metadaten-Namespaces eines Items abrufen
99
+ metadataNamespaces = itemsApi.getMetadataNamespaces("testSwitch")
100
+ print("Metadata namespaces for testSwitch:", metadataNamespaces)
101
+
102
+ # Item mit semantischer Klasse abrufen
103
+ #semanticItem = itemsApi.getSemanticItem("testLocation", "Location")
104
+ #print("Semantic item for testLocation:", semanticItem)
105
+
106
+ # Einem Item ein Tag hinzufügen
107
+ itemsApi.addTag("testSwitch", "NewTag")
108
+ print("Tag added to testSwitch.")
109
+
110
+ # Einem Item ein Tag entfernen
111
+ itemsApi.removeTag("testSwitch", "NewTag")
112
+ print("Tag removed from testSwitch.")
113
+
114
+ # Verwaiste Metadaten löschen
115
+ itemsApi.purgeOrphanedMetadata()
116
+ print("Orphaned metadata purged.")
117
+
118
+ # Funktion ausführen
119
+ if __name__ == "__main__":
120
+ examples()
tests/link_events.py ADDED
@@ -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, LinkEvents
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+ linkEvents = LinkEvents(client)
11
+
12
+ # Beispielaufrufe
13
+ print(linkEvents.ItemChannelLinkAddedEvent("*", "*"))
14
+ print(linkEvents.ItemChannelLinkRemovedEvent("*", "*"))
tests/links.py ADDED
@@ -0,0 +1,74 @@
1
+ import sys
2
+ import os
3
+ import json
4
+ import time
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
+
9
+ from openhab import OpenHABClient, Links
10
+
11
+ # OpenHAB-Client initialisieren
12
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
13
+
14
+ # Links-Klasse instanziieren
15
+ linksApi = Links(client)
16
+
17
+ # Test-Daten (basierend auf deiner Liste)
18
+ testLinks = [
19
+ {"itemName": "Sunrise_Time", "channelUID": "astro:sun:home:rise#start"},
20
+ {"itemName": "Sunset_Time", "channelUID": "astro:sun:home:set#start"},
21
+ {"itemName": "Azimuth", "channelUID": "astro:sun:home:position#azimuth"},
22
+ {"itemName": "Elevation", "channelUID": "astro:sun:home:position#elevation"},
23
+ {"itemName": "Moon_Phase", "channelUID": "astro:moon:home:phase#name"},
24
+ {"itemName": "Moon_Azimuth", "channelUID": "astro:moon:home:position#azimuth"},
25
+ {"itemName": "Moon_Elevation", "channelUID": "astro:moon:home:position#elevation"},
26
+ ]
27
+
28
+ try:
29
+ print("\n**1. Alle Links abrufen**")
30
+ allLinks = linksApi.getAllLinks()
31
+ print(json.dumps(allLinks, indent=2))
32
+
33
+ itemName = "Sunrise_Time2"
34
+ channelUid = "astro:sun:home:rise#start"
35
+
36
+ print(f"\n**2. Einzelnen Link abrufen: {itemName} -> {channelUid}**")
37
+ try:
38
+ singleLink = linksApi.getIndividualLink(itemName, channelUid)
39
+ print(json.dumps(singleLink, indent=2))
40
+ except Exception as e:
41
+ print(f"Fehler: {e}")
42
+
43
+ print(f"\n**3. Lösche den Link: {itemName} -> {channelUid}**")
44
+ try:
45
+ unlinkResponse = linksApi.unlinkItemFromChannel(itemName, channelUid)
46
+ print(f"Link entfernt: {unlinkResponse}")
47
+ time.sleep(1) # Kleine Pause für API-Stabilität
48
+ except Exception as e:
49
+ print(f"Fehler: {e}")
50
+
51
+ print(f"\n**4. Verknüpfe Item erneut: {itemName} -> {channelUid}**")
52
+ try:
53
+ config = {} # Falls Konfiguration notwendig ist, hier ergänzen
54
+ linkResponse = linksApi.linkItemToChannel(itemName, channelUid, config)
55
+ print(f"Link erstellt: {json.dumps(linkResponse, indent=2)}")
56
+ except Exception as e:
57
+ print(f"Fehler: {e}")
58
+
59
+ print("\n**5. Orphan-Links abrufen**")
60
+ try:
61
+ orphanLinks = linksApi.getOrphanLinks()
62
+ print(json.dumps(orphanLinks, indent=2))
63
+ except Exception as e:
64
+ print(f"Fehler bei Orphan-Links: {e}")
65
+
66
+ print("\n**6. Unbenutzte Links bereinigen**")
67
+ try:
68
+ purgeResponse = linksApi.purgeUnusedLinks()
69
+ print(f"Unbenutzte Links bereinigt: {purgeResponse}")
70
+ except Exception as e:
71
+ print(f"Fehler: {e}")
72
+
73
+ except Exception as e:
74
+ print(f"**Gesamtfehler:** {e}")
tests/logging_test.py ADDED
@@ -0,0 +1,43 @@
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, Logging
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+
11
+ # Logging-Klasse instanziieren
12
+ loggingApi = Logging(client)
13
+
14
+ # Alle Loggers abrufen
15
+ try:
16
+ loggers = loggingApi.getAllLoggers()
17
+ print("Alle Loggers:", loggers)
18
+ except Exception as e:
19
+ print("Fehler beim Abrufen der Loggers:", e)
20
+
21
+ # Einen einzelnen Logger abrufen
22
+ loggerName = "org.openhab"
23
+ try:
24
+ logger = loggingApi.getSingleLogger(loggerName)
25
+ print(f"Logger {loggerName}:", logger)
26
+ except Exception as e:
27
+ print("Fehler beim Abrufen des Loggers:", e)
28
+
29
+ # Logger modifizieren oder hinzufügen
30
+ loggerName = "org.openhab"
31
+ level = "DEBUG"
32
+ try:
33
+ response = loggingApi.modifyOrAddLogger(loggerName, level)
34
+ print(f"Logger {loggerName} modifiziert:", response)
35
+ except Exception as e:
36
+ print("Fehler beim Modifizieren des Loggers:", e)
37
+
38
+ # Logger entfernen
39
+ try:
40
+ response = loggingApi.removeLogger(loggerName)
41
+ print(f"Logger {loggerName} entfernt:", response)
42
+ except Exception as e:
43
+ print("Fehler beim Entfernen des Loggers:", e)
tests/module_types.py ADDED
@@ -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, ModuleTypes
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+ moduleTypesApi = ModuleTypes(client)
11
+
12
+ # Teste Modultypen
13
+ print(moduleTypesApi.getModuleTypes())
14
+ print(moduleTypesApi.getModuleType("timer.GenericCronTrigger"))
tests/persistence.py ADDED
@@ -0,0 +1,78 @@
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, Persistence
8
+
9
+ # Client initialisieren
10
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
11
+
12
+ # Persistence-Klasse instanziieren
13
+ persistenceApi = Persistence(client)
14
+
15
+ # Alle Persistence-Dienste abrufen
16
+ try:
17
+ services = persistenceApi.getAllServices()
18
+ print("Alle Persistence-Dienste:", json.dumps(services, indent=4))
19
+ except Exception as e:
20
+ print("Fehler beim Abrufen der Persistence-Dienste:", e)
21
+
22
+ # Konfiguration eines bestimmten Persistence-Dienstes abrufen
23
+ serviceId = "mapdb"
24
+ try:
25
+ config = persistenceApi.getServiceConfiguration(serviceId)
26
+ print(f"Konfiguration für {serviceId}:", json.dumps(config, indent=4))
27
+ except Exception as e:
28
+ print("Fehler beim Abrufen der Konfiguration:", e)
29
+
30
+ # Konfiguration eines bestimmten Persistence-Dienstes setzen
31
+ newConfig = {"retention": "30d"}
32
+ try:
33
+ updatedConfig = persistenceApi.setServiceConfiguration(serviceId, newConfig)
34
+ print(f"Aktualisierte Konfiguration für {serviceId}:", json.dumps(updatedConfig, indent=4))
35
+ except Exception as e:
36
+ print("Fehler beim Setzen der Konfiguration:", e)
37
+
38
+ # Konfiguration eines bestimmten Persistence-Dienstes löschen
39
+ try:
40
+ deleteResponse = persistenceApi.deleteServiceConfiguration(serviceId)
41
+ print(f"Konfiguration für {serviceId} gelöscht:", json.dumps(deleteResponse, indent=4))
42
+ except Exception as e:
43
+ print("Fehler beim Löschen der Konfiguration:", e)
44
+
45
+ # Items für einen Persistence-Dienst abrufen
46
+ try:
47
+ items = persistenceApi.getItemsForService(serviceId)
48
+ print(f"Items für den Dienst {serviceId}:", json.dumps(items, indent=4))
49
+ except Exception as e:
50
+ print("Fehler beim Abrufen der Items:", e)
51
+
52
+ # Persistence-Daten für ein Item abrufen
53
+ itemName = "TemperatureSensor1"
54
+ startTime = "2025-01-01T00:00:00.000Z"
55
+ endTime = "2025-01-31T23:59:59.999Z"
56
+ try:
57
+ itemData = persistenceApi.getItemPersistenceData(serviceId, itemName, startTime=startTime, endTime=endTime)
58
+ print(f"Persistence-Daten für {itemName}:", json.dumps(itemData, indent=4))
59
+ except Exception as e:
60
+ print("Fehler beim Abrufen der Persistence-Daten für Item:", e)
61
+
62
+ # Persistence-Daten für ein Item speichern
63
+ time = "2025-01-27T15:30:00.000Z" # Zeit im richtigen Format
64
+ state = "22.5" # Beispiel für den Zustand des Items
65
+ try:
66
+ response = persistenceApi.storeItemData(serviceId, itemName, time, state)
67
+ print("Daten erfolgreich gespeichert:", response)
68
+ except Exception as e:
69
+ print("Fehler beim Speichern der Daten:", e)
70
+
71
+ # Persistence-Daten für ein Item löschen
72
+ startTimeDelete = "2025-01-01T00:00:00.000Z"
73
+ endTimeDelete = "2025-01-31T23:59:59.999Z"
74
+ try:
75
+ deleteItemResponse = persistenceApi.deleteItemData(serviceId, itemName, startTimeDelete, endTimeDelete)
76
+ print(f"Persistence-Daten für {itemName} gelöscht:", json.dumps(deleteItemResponse, indent=4))
77
+ except Exception as e:
78
+ print("Fehler beim Löschen der Persistence-Daten für Item:", e)
tests/profile_types.py ADDED
@@ -0,0 +1,13 @@
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, ProfileTypes
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+ profileTypesApi = ProfileTypes(client)
11
+
12
+ # Teste Profiltypen
13
+ print(profileTypesApi.getProfileTypes())
tests/rules.py ADDED
@@ -0,0 +1,151 @@
1
+ import sys
2
+ import os
3
+ import time
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, Rules
8
+
9
+ # Client initialisieren
10
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
11
+ rulesApi = Rules(client)
12
+
13
+ def rulesExamples():
14
+ try:
15
+ # Alle Regeln abrufen
16
+ allRules = rulesApi.getRules()
17
+ print("All Rules:", allRules)
18
+ except Exception as e:
19
+ print("Error getting all rules:", e)
20
+
21
+ try:
22
+ # Details zu einer Regel abrufen
23
+ testRule = rulesApi.getRule("test_color-1")
24
+ print("testRule Details:", testRule)
25
+ except Exception as e:
26
+ print("Error getting rule details:", e)
27
+
28
+ try:
29
+ # Neue Regel hinzufügen
30
+ newRuleData = {
31
+ "uid": "newRule",
32
+ "name": "New Rule",
33
+ "description": "This is a new rule",
34
+ "triggers": [],
35
+ "conditions": [],
36
+ "actions": []
37
+ }
38
+ rulesApi.createRule(newRuleData)
39
+ print("New Rule created.")
40
+ except Exception as e:
41
+ print("Error creating rule:", e)
42
+
43
+ try:
44
+ # Regel aktualisieren
45
+ updatedRuleData = {"name": "Updated Rule"}
46
+ rulesApi.updateRule("newRule", updatedRuleData)
47
+ print("Rule updated.")
48
+ except Exception as e:
49
+ print("Error updating rule:", e)
50
+
51
+ try:
52
+ # Regel aktivieren
53
+ rulesApi.setRuleState("newRule", True)
54
+ print("newRule enabled.")
55
+ except Exception as e:
56
+ print("Error enabling rule:", e)
57
+
58
+ try:
59
+ # Regel deaktivieren
60
+ rulesApi.setRuleState("newRule", False)
61
+ print("newRule disabled.")
62
+ except Exception as e:
63
+ print("Error disabling rule:", e)
64
+
65
+ try:
66
+ # Regel löschen
67
+ rulesApi.deleteRule("newRule")
68
+ print("newRule deleted.")
69
+ except Exception as e:
70
+ print("Error deleting rule:", e)
71
+
72
+ try:
73
+ # Triggers abrufen
74
+ triggers = rulesApi.getTriggers("test_color-1")
75
+ print("Triggers:", triggers)
76
+ except Exception as e:
77
+ print("Error getting triggers:", e)
78
+
79
+ try:
80
+ # Bedingungen abrufen
81
+ conditions = rulesApi.getConditions("test_color-1")
82
+ print("Conditions:", conditions)
83
+ except Exception as e:
84
+ print("Error getting conditions:", e)
85
+
86
+ try:
87
+ # Aktionen abrufen
88
+ actions = rulesApi.getActions("test_color-1")
89
+ print("Actions:", actions)
90
+ except Exception as e:
91
+ print("Error getting actions:", e)
92
+
93
+ try:
94
+ # Regelkonfiguration abrufen
95
+ config = rulesApi.getConfiguration("test_color-1")
96
+ print("Configuration:", config)
97
+ except Exception as e:
98
+ print("Error getting configuration:", e)
99
+
100
+ try:
101
+ # Regelkonfiguration aktualisieren
102
+ rulesApi.updateConfiguration("test_color-1", {"param": "value"})
103
+ print("Configuration updated.")
104
+ except Exception as e:
105
+ print("Error updating configuration:", e)
106
+
107
+ try:
108
+ # Regel sofort ausführen
109
+ rulesApi.runNow("test_color-1")
110
+ print("Rule executed immediately.")
111
+ except Exception as e:
112
+ print("Error running rule:", e)
113
+
114
+ try:
115
+ # Modul abrufen
116
+ module = rulesApi.getModule("test_color-1", "actions", "script")
117
+ print("Module:", module)
118
+ except Exception as e:
119
+ print("Error getting module:", e)
120
+
121
+ try:
122
+ # Modulkonfiguration abrufen
123
+ moduleConfig = rulesApi.getModuleConfig("test_color-1", "actions", "script")
124
+ print("Module Configuration:", moduleConfig)
125
+ except Exception as e:
126
+ print("Error getting module configuration:", e)
127
+
128
+ try:
129
+ # Modul-Konfigurationsparameter abrufen
130
+ paramValue = rulesApi.getModuleConfigParam("test_color-1", "actions", "script", "exampleParam")
131
+ print("Module Config Param:", paramValue)
132
+ except Exception as e:
133
+ print("Error getting module config param:", e)
134
+
135
+ try:
136
+ # Modul-Konfigurationsparameter setzen
137
+ rulesApi.setModuleConfigParam("test_color-1", "actions", "script", "exampleParam", "newValue")
138
+ print("Module Config Param updated.")
139
+ except Exception as e:
140
+ print("Error setting module config param:", e)
141
+
142
+ try:
143
+ # Zeitplansimulation ausführen
144
+ simulationResult = rulesApi.simulateSchedule("2025-02-03T10:20:00.987Z", "2025-02-03T10:38:00.987Z")
145
+ print("Schedule Simulation Result:", simulationResult)
146
+ except Exception as e:
147
+ print("Error simulating schedule:", e)
148
+
149
+ # Funktion ausführen
150
+ if __name__ == "__main__":
151
+ rulesExamples()
tests/services.py ADDED
@@ -0,0 +1,52 @@
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, Services
7
+
8
+ def main():
9
+ # OpenHAB-Client initialisieren
10
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
11
+
12
+ serviceId = "org.openhab.i18n"
13
+
14
+ # Services-API-Objekt erstellen
15
+ servicesApi = Services(client)
16
+
17
+ # 1. Alle Services abrufen
18
+ print("Alle Services:")
19
+ allServices = servicesApi.getServices(language="de")
20
+ print(allServices)
21
+
22
+ # 2. Einzelnen Service abrufen
23
+ print("Einzelner Service:")
24
+ singleService = servicesApi.getService(serviceId)
25
+ print(singleService)
26
+
27
+ # 3. Konfiguration eines spezifischen Services abrufen
28
+ print(f"\nKonfiguration für den Service {serviceId}:")
29
+ serviceConfig = servicesApi.getServiceConfig(serviceId)
30
+ print(serviceConfig)
31
+
32
+ # 4. Konfiguration für einen Service aktualisieren
33
+ newConfig = {
34
+ "enabled": True,
35
+ "setting1": "newValue1"
36
+ }
37
+ print(f"\nAktualisierte Konfiguration für {serviceId}:")
38
+ oldConfig = servicesApi.updateServiceConfig(serviceId, newConfig)
39
+ print("Alte Konfiguration:", oldConfig)
40
+
41
+ # 5. Konfiguration eines Services löschen
42
+ print(f"\nService-Konfiguration für {serviceId} löschen:")
43
+ deletedConfig = servicesApi.deleteServiceConfig(serviceId)
44
+ print("Gelöschte Konfiguration:", deletedConfig)
45
+
46
+ # 6. Alle Kontexte eines Services abrufen
47
+ print(f"\nKontexte für {serviceId}:")
48
+ serviceContexts = servicesApi.getServiceContexts(serviceId)
49
+ print(serviceContexts)
50
+
51
+ if __name__ == "__main__":
52
+ main()
tests/sitemaps.py ADDED
@@ -0,0 +1,65 @@
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, Sitemaps
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+ sitemapsApi = Sitemaps(client)
11
+
12
+ # Beispiele für die Sitemaps-API
13
+ def sitemapsExamples():
14
+ # 1. Alle Sitemaps abrufen
15
+ try:
16
+ allSitemaps = sitemapsApi.getSitemaps()
17
+ print("All Sitemaps:", allSitemaps)
18
+ except Exception as e:
19
+ print("Error fetching all sitemaps:", e)
20
+
21
+ # 2. Details zu einer bestimmten Sitemap abrufen (z.B. 'Sitemap')
22
+ try:
23
+ testSitemap = sitemapsApi.getSitemap("Sitemap")
24
+ print("Sitemap Details:", testSitemap)
25
+ except Exception as e:
26
+ print("Error fetching Sitemap details:", e)
27
+
28
+ # 3. Eine bestimmte Seite einer Sitemap abrufen
29
+ try:
30
+ sitemapPage = sitemapsApi.getSitemapPage("astro", "astro")
31
+ print("Sitemap Page Details:", sitemapPage)
32
+ except Exception as e:
33
+ print("Error fetching sitemap page:", e)
34
+
35
+ # 4. Alle Daten einer ganzen Sitemap abrufen
36
+ try:
37
+ fullSitemap = sitemapsApi.getFullSitemap("astro")
38
+ print("Full Sitemap Details:", fullSitemap)
39
+ except Exception as e:
40
+ print("Error fetching full sitemap:", e)
41
+
42
+ # 5. Ereignisse für eine Sitemap abrufen
43
+ try:
44
+ sitemapEvents = sitemapsApi.getSitemapEvents("013328fd-d3fd-4de4-8f7d-efe01bad7eac", sitemap="Sitemap")
45
+ print("Sitemap Events:", sitemapEvents)
46
+ except Exception as e:
47
+ print("Error fetching sitemap events:", e)
48
+
49
+ # 6. Ereignisse für die gesamte Sitemap abrufen
50
+ try:
51
+ fullSitemapEvents = sitemapsApi.getFullSitemapEvents("013328fd-d3fd-4de4-8f7d-efe01bad7eac", sitemap="Sitemap")
52
+ print("Full Sitemap Events:", fullSitemapEvents)
53
+ except Exception as e:
54
+ print("Error fetching full sitemap events:", e)
55
+
56
+ # 7. Eine Subscription für Sitemap-Ereignisse erstellen
57
+ try:
58
+ subscribeResponse = sitemapsApi.subscribeToSitemapEvents()
59
+ print("Subscription Response:", subscribeResponse)
60
+ except Exception as e:
61
+ print("Error subscribing to sitemap events:", e)
62
+
63
+ # Funktion ausführen
64
+ if __name__ == "__main__":
65
+ sitemapsExamples()
tests/systeminfo.py ADDED
@@ -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, Systeminfo
7
+
8
+ # Client initialisieren
9
+ client = OpenHABClient(url="http://127.0.0.1:8080", username="openhab", password="habopen")
10
+ systemInfoApi = Systeminfo(client)
11
+
12
+ # Teste Systeminformationen
13
+ print(systemInfoApi.getSystemInfo())
14
+ print(systemInfoApi.getUomInfo())