Alarms allow you to check particular conditions on incoming data and eventually trigger custom behavior. More technically speaking, each check is executed each time a new measurement for a given parameter is to be stored on Omnyvore's Big Data. For example, you may want to be alerted whenever a stove senses a concerning level of carbon monoxide.
In the following subsections, we will illustrate you how you can define these convenient handles on Omnyvore.
Select the Add button in the top right corner of the tab:
Then, you can configure the new alarm by filling out a dedicated window:
Each time a thing sends data to Omnyvore, some data may be stored in a big data. If this is the case, a check for an alarm may be performed. Writing alarm expressions or scripts is thoroughly explained in the Web UI in the More info pop-up. Nevertheless, we will provide you with a brief explanation in this section for the sake of clarity. Expressions are arguably easier to write, but this come at a price: they do not have the same expressiveness as a Javascript snippet, and their range of feature is limited since, with expressions, alarms are triggered just within Omnyvore.
For example, VAL(co) > 20
may be a valid expression as long as the parameter co exists in the thing family for which you are writing the alarm.
Let us suppose that a stove senses a value of co equal to 34: in this case, an alarm in Omnyvore is raised, causing also a notification to appear in the top-right corner of the Web UI.
If you need more expressiveness, then scripts might be what you are looking for. For example, consider the following script:
var e = new EvaluationResult();
var co = VAL(co);
var now = new Date().getTime();
if(co > 20) {
e.persist = true;
e.measurements.add(new Measurement('dizzyExcess', co - 20, now));
}
if(co > 60) {
var now = new Date().getTime();e.measurements.add(new Measurement('lifeHazardExcess', co - 60, now));
}
return e;
An EvaluationResult is an object used by Omnyvore to decide whether an alarm is to be raised, and if the alarm generated some measurements that have to be stored in the big data. In our example, the decision on whether to raise the alarm within Omnyvore is based on a simple comparison between the carbon monoxide level (co) and 20, which is an arbitrary threshold. Then two measurements are generated, respectively the amount of carbon monoxide exceeding the limit to feel dizzy and the one exceeding the limit over which you are risking to die (the values have been chosen arbitrarily). Let us suppose that a stove senses a value of co equal to 34. In this case:
Please keep in mind that if you want to store measurements, the parameters you use (in our example co, dizzyExcess and lifeHazardExcess) have to be first defined for the thing family.
Should you need more details on which classes are available in Omnyvore by default, please refer to the appendix on available classes.