Hi,
I would like to start migrating from DSL to JavaScript rules. I have many rules sending notifications using Pushover, so first requirement/PoC for me would be to be able to send a notification using JS.
Current DSL rule snippet:
val actions = getActions("pushover", "pushover:pushover-account:account")
actions.sendMessage("Body", "Title")
(as documented in Pushover - Bindings | openHAB)
So I’ve read:
So following the Pushsafer example, this is now written like this in JS (not sure why API key is now needed):
let { actions } = require('openhab');
actions.Pushsafer.pushsafer("<your pushsafer api key>", "Body", "Title", "", "", "", "")
And in DSL like this:
val actions = getActions("pushsafer", "pushsafer:pushsafer-account:account")
actions.sendPushsaferMessage("Body", "Title")
So I’ve tried (file-based):
rules.JSRule({
name: "Test Pushover",
description: "My first JS rule",
triggers: [triggers.ItemStateChangeTrigger('Test', 'OFF', 'ON')],
execute: data => {
actions.Pushover.sendMessage('Body', 'Title');
}
});
Result: Failed to execute rule Test-Pushover-bd382cbc-02d9-4061-8a0e-6b0e5df7c7ce: TypeError: undefined has no such function “sendMessage”: TypeError: undefined has no such function “sendMessage”
Then:
actions.Pushover.pushover.sendMessage('Body', 'Title');
Result: Failed to execute rule Test-Pushover-a7e357c7-b988-4f66-90e4-79c953b328f4: TypeError: Cannot read property “pushover” from undefined: TypeError: Cannot read property “pushover” from undefined
So it seems that Pushover is missing from available actions. Am I right that each binding action needs to be explicitly reimplemented for JavaScript usage, or am I missing something?
Is it possible to use the action with some other syntax from JS?
Best regards,
Jacob Laursen