Pushover OH3

Hi,
another migration problem i have,
I understand from the doc files that now a thing needs to be created, compared to previous cfg file.

Now the DOC says it should look like:

val actions = getActions("pushover", "pushover:pushover-account:account")
actions.sendMessage("Hello <font color='green'>World</font>!", "openHAB")

Does the old-fashioned way not work anymore? (huffff)
sendPushoverMessage(pushoverBuilder("..........").withTitle("ETA SH20 | Heating").withSound("bugle"))

Because for me it looks way more complex and i do not need any success feedback…is there a more simple way with a single line like before? Thanks

No.

One more question, @rossko57
Does this structure have to be replicated for each and every rule, or the first line val actions =… is stored somewhere globally?
Otherwise i will now have two lines of code per rule definition.

Kind Regards
Norbert

That’s up to you, there is a choice if you are using DSL xxx.rules files.

rule "some rule"
...
   val anyvariable = somestuff
   // anyvariable is local to this rule only
end

rule "other rule"
...
   val anyvariable = somedifferentstuff
   // this different anyvariable is local to this rule only
   // there's nothing special about actions in this respect
end

alternative

val anyvariable =  somestuff
// this is a "global" and will be available within any rule in this file
// but not in other files

rule "some rule"
...
var fred = anyvariable + 2
// this will use the 'anyvariable' defined at file head
end

This was exactly the same behaviour in OH2,nothing has changed there.

However, beware.
A ‘global’ defined in file head will be created at file load time. When you’re using Actions there, you’re hoping the binding is ready to provide them. At system boot time, it might not be, there’s lots of stuff initialising.
When you obtain Actions in the body of the rule, that will be at rule runtime - necessarily later than load time. Chances are better that it works, so I would advise doing it that way.

This costs you exactly nothing.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.