DSL rule problem. Script execution of rule with UID 'testrule-1' failed: null in testrule

Hello. My rule file (testrule.rules):

val MyEmail = "my_email@email.com"
val UKEmail = "service@service.com"
val EmailSubject = "Counters state"
val EmailAction = getActions("mail", "mail:smtp:c54071a235")
val PushAction = getActions("pushover", "pushover:pushover-account:b03d58c4f9")
val MailFailedText = "Email send error"

rule "Send water counters to e-mail and PUSH"
	Time cron "0 0 9 15 * ?"
	if (Poseidon_Hotwatercounter.state instanceof Number && Poseidon_Coldwatercounter.state instanceof Number) {	
		val HotWaterText = "Hot: " + Math::round((Poseidon_Hotwatercounter.state as Number).floatValue / 1000).toString + " м³"
		val ColdWaterText = "Cold: " + Math::round((Poseidon_Coldwatercounter.state as Number).floatValue / 1000).toString + " м³"
		val TotalString = HotWaterText + "\n" + ColdWaterText
	    if ( ! EmailAction.sendMail(UKEmail, EmailSubject, TotalString + "\nSomeText"))
			PushAction.sendMessage(MailFailedText, PushHeader)
		if ( ! EmailAction.sendMail(MyEmail, EmailSubject, TotalString))
			PushAction.sendMessage(MailFailedText, PushHeader)
	  	PushAction.sendMessage(TotalString, PushHeader)
		if ( ! EmailAction.sendMail(MyEmail, "Counters TX error", "Check states"))
			PushAction.sendMessage(MailFailedText, PushHeader)
    	PushAction.sendMessage("States error", EmailSubject)

At the moment the rule is triggered, I receive this message in the logs:

DSL rule problem. Script execution of rule with UID 'testrule-1' failed: null in testrule

What i am doing wrong?

Try this to begin with

When getActions() is used to fetch an Action at rules file load time, the binding may not be ready e.g. still connecting to some remote server.
Used at rule run time improves your chances.

1 Like

I tried to run this rule manually (Run Now) several times. And I was getting the same error.
I just copied the code into a separate rule and ran it manually via “Run Now”.
There were no problems with the execution.
After that, I added a test line to the initial rule for writing to the log. There were no problems again!
This is fine?

And when you edited that, the rules file was reloaded.

It won’t try again until next time you reload the rules file.