Seite 2 von 2
Re: Notification Rule von DSL nach javascript migrieren
Verfasst: 18. Feb 2021 16:01
von udo1toni
Nein, die Helper Libraries stehen meines Wissens noch nicht zur Verfügung.
Der import muss zu Beginn der Datei stehen, außerhalb der Rule. Du könntest auch noch versuchen, es ohne den Import zu schreiben, so:
Code: Alles auswählen
org.openhab.io.openhabcloud.NotificationAction.sendNotification('openhab@lentscher.de', 'Test PUSH!');
Ich weiß aber nicht, ob das so zulässig ist.
Re: Notification Rule von DSL nach javascript migrieren
Verfasst: 18. Feb 2021 19:20
von lenschith
ne, funktioniert auch nicht. Der import steht in der ersten Zeile des Scripts.
Code: Alles auswählen
triggers:
- id: "1"
configuration:
itemName: TestSwitch
state: ON
type: core.ItemStateChangeTrigger
conditions:
- inputs: {}
id: "2"
configuration:
type: application/javascript
script: >-
//import org.openhab.io.openhabcloud.NotificationAction as
NotificationAction;
var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
org.openhab.io.openhabcloud.NotificationAction.sendNotification('openhab@lentscher.de', 'Test PUSH!');
logger.info("Notification");
type: script.ScriptCondition
actions: []
Re: Notification Rule von DSL nach javascript migrieren
Verfasst: 18. Feb 2021 19:59
von lenschith
Ich bin einen Schritt weiter. Es kommt eine Pushnachricht an.
Code: Alles auswählen
var NotificationAction = org.openhab.io.openhabcloud.NotificationAction;
var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
NotificationAction.sendNotification('name@domain.de', "Test PUSH!");
logger.info("Notification");