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].
- Install NMA app on your Android device(s).
- 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.
Pingback: Sending Pushover notifications from Openremote | Michał Rutka / Openremote
Pingback: No more free DynDNS … time for ORDNS :-) | Michał Rutka / Openremote