Pushover is a simple mobile notification system available for Android and iOS. It is similar to the Notify My Android however it is not free. Its API makes it possible to configure messages with custom icons (see images left) and notifications are easily send from within OpenRemote.
To send a message first you need to create a command:
There are more parameters available and described in details on Pushover API’s page.
Note that the call uses ${param} to pass the message text from a rule:
rule "System start"
when eval(true)
then
execute.command("pushover.post", "System start");
end
Openremote android app is not very useful for detecting alarm situations from OpenRemote. It lacks push notifications, however it is quite simple to use a 3rd party push solution like Notify My Android.
Here is example of NMA app screen on my smartphone with messages from OpenRemote:
The steps to do this are:
Create an account by Notify My Android and generate ApiKey which you will need for sending notifications. Put it in the following code in place of [your ApiKey from notifymyandroid.com].
NMA offers many APIs but for OpenRemote the most obvious one is Java api. Download NMAClientLib.jar and place it in OpenRemote-Controller/webapps/controller/WEB-INF/lib/ directory.
Add the following rules:
// Notify my Android NMA
import com.usk.lib.NMAClientLib;
declare NMA_message
apiKey : String
appName : String
priority : int
event : String
desc : String
devKey : String
end
declare My_NMA
message : String
priority : int
end
rule "System start"
when eval(true)
then
My_NMA nma = new My_NMA("OpenRemote controller's drools started", 1);
insert(nma);
end
rule "System NMA"
when
$vt : My_NMA()
then
NMA_message n = new NMA_message();
n.setApiKey("[your ApiKey from notifymyandroid.com]");
n.setEvent("System");
n.setDesc($vt.getMessage());
n.setPriority($vt.getPriority());
n.setDevKey(null);
insert(n);
retract($vt);
end
rule "Notify my Android"
when
$n : NMA_message()
then
try{
if(NMAClientLib.notify("OpenRemote", $n.getEvent(), $n.getDesc(), $n.getPriority(), $n.getApiKey(), $n.getDevKey())!=1)
throw new RuntimeException();
}finally{
retract($n);
}
end
// NMA
This code will generate “OpenRemote controller’s drools started” notification with priority 1 each time the controller boots. Notifications are very handy for debugging rules file.