Page 1 of 1

openHAB 3 - Syntax for sending

Posted: 25. May 2021, 17:39
by stianeik
Hi,

I have created the pushsafer thing in the UI and are trying to send a message in a rule. According to the example the following shall be used

sendPushsaferMessage(String message, @Nullable String title) // ref https://www.pushsafer.com/en/openhab3

I have the used the following
sendPushsaferMessage("Test message", "MyTitle")
and are only recieving the following error message

[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'test-1' failed: An error occurred during the script execution: index=2, size=2 in test

What am I doing wrong?

Re: openHAB 3 - Syntax for sending

Posted: 25. May 2021, 19:22
by admin
Hello,

go the things and open the pushsafer binding you created.
Now copy the identifier that you need in the script.

Example Script:

Code: Select all

val actions = getActions("pushsafer", "pushsafer:pushsafer-account:**********")  
//var receipt = actions.sendPushsaferAttachmentMessage("HelloWorld", "openHAB3", "D:/path/image.jpg","jpeg","")
//var receipt = actions.sendPushsaferAttachmentMessage("HelloWorld", "openHAB3", "http://192.168.2.222:8088/tmpfs/snap.jpg","jpeg","admin:password")
//var receipt = actions.sendPushsaferAttachmentMessage("HelloWorld", "openHAB3", "https://www.pushsafer.com/de/assets/img/screenshot_en_01.jpg","jpeg","")
//var receipt = actions.sendPushsaferMessage("HelloWorld", "openHAB3")
var receipt = actions.sendPushsaferURLMessage("HelloWorld", "openHAB3", "https://www.openhab.org/addons/", "Open openHab AddOns")
Hope that helps

Kevin

Re: openHAB 3 - Syntax for sending

Posted: 26. May 2021, 07:37
by stianeik
Thanks, it is now working!

Re: openHAB 3 - Syntax for sending

Posted: 26. May 2021, 10:31
by admin
great :D

Re: openHAB 3 - Syntax for sending

Posted: 13. Aug 2022, 23:04
by vbevan
Hi I have installed the OH3 binding and have a pushsafer Account Thing online.

I have the correct pushsafer:pushsafer-account:******** identifier, but I am having problems with setting a rule in OH3. I tried using the synatx that you replied to @stiannek but this didn't work for me.

My rule (extract) looks like this:

var myaction = actions.thingActions("pushsafer","pushsafer:pushsafer-account:********")
myaction.sendPushsaferMessage("Test", "BEVHOME")

and the rule file saves correctly (no synatx errors reported by OH3).

However when I execute the rule, OH3 reports "[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'sms-1' failed: An error occurred during the script execution: index=0, size=0 in sms" (the rule file is sms.rules)."

I tried using a var (variable) and a val (value) statement but neither works. I also changed the name of the variable/value to "myaction" as I read somewhere that "actions" is reserved by OH. Can you tell me what I am doing wrong?

Many thanks in advance!

vbevan

Re: openHAB 3 - Syntax for sending

Posted: 14. Aug 2022, 07:25
by admin
Hi,

As the error log already says, the problem is not with Pushafer but with the SMS plugin, uninstall it and try again.

Kevin

Re: openHAB 3 - Syntax for sending

Posted: 14. Aug 2022, 09:37
by vbevan
admin wrote:
14. Aug 2022, 07:25
Hi,

As the error log already says, the problem is not with Pushafer but with the SMS plugin, uninstall it and try again.

Kevin
Hi Kevin, I created a new rules file just for pushsafer alerting, the rule (alert.rules) text complete is:

Code: Select all

rule "Send Alert"

when
    Item testalert changed from OFF to ON
then
	logInfo("ALERT:", "Alert message sent")
	var myaction = actions.thingActions("pushsafer","pushsafer:pushsafer-account:2******1")
	myaction.sendpushSaferMessage("Test", "BEVHOME")

end
I use another test_alert.rules file to trigger the alert based on switch item testalert. I still get a similar message, here the fronttail log from OH3:

Code: Select all

2022-08-14 11:33:48.939 [INFO ] [org.openhab.core.model.script.ALERT:] - Alert message sent
2022-08-14 11:33:48.942 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'alert-1' failed: An error occurred during the script execution: index=0, size=0 in alert
So the rule is firing, the log is populated with the logInfo text but then fails on the further code.
Any help appreciated ;)

Cheers

Vincent

Re: openHAB 3 - Syntax for sending

Posted: 14. Aug 2022, 10:45
by admin
Hello,

i think it is not a pushsafer plugin issue.
Please write a thread to the openhab3 forum and reffer to this post.
They will help better than i can

Kevin

Re: openHAB 3 - Syntax for sending

Posted: 15. Aug 2022, 19:54
by vbevan
admin wrote:
14. Aug 2022, 10:45
Hello,

i think it is not a pushsafer plugin issue.
Please write a thread to the openhab3 forum and reffer to this post.
They will help better than i can

Kevin
Ok thx Kevin

Cheers

Vincent