Channels are the means by which things deliver information to Omnyvore. More technically speaking, channels are bound to topics and enable online processing for the payload of incoming messages.
For example, a stove may pack several measurements in a single message payload such as <TEMPERATURE>;<HUMIDITY>;<CONSUMPTION>
.
Therefore, the message 300;40;3
should cause Omnyvore to store 300K as the temperature, 40% of humidity, and 3kW consumed in its data storage.
In the following subsections, we will illustrate you how Omnyvore makes this possible for you.
Select the Add button in the top right corner of the tab:
Then, you can configure the new channel by filling out a dedicated window:
To modify an existing channel, click on it from the channel list and then an editing window similar to the one used at creation time will appear. Nevertheless, this window has also the test feature, which allows you to test channels before sending actual data from the device: this utility might be useful if you want to perform some dry runs before committing some modifications to an already existing script. Payload processing tests are described more in detail in the Script section.
To delete an existing channel, click on it from the channel list and then an editing window similar to the one used at creation time will appear. At this point, you just have to click on the Delete link in the bottom left corner of the window.
With Omnyvore's DSL (Domain Specific Language), you can process data avoiding all the nitty-gritty required to write a Javascript snippet.
When using this option (which is called Editor in the Edit channel window), you can write an expression which will be used to parse incoming data.
Writing these expressions is quite simple: you just have to compose a template which will be used to parse the payload.
As a result, when Omnyvore encounters a PAR(parameterCode)
will generate and store in its big data a measurement for the parameter parameterCode
.
Hereafter there are some examples, in which:
# Expression
PAR(speed)
# Payload
24
# Outcome
Omnyvore stores a measurement for the parameter 'speed' with a value of 24
# Expression
PAR(lat);PAR(lon)
# Payload
42;67.59
# Outcome
Omnyvore stores two measurements:
- a measurement for the parameter 'lat' with a value of 42
- a measurement for the parameter 'lon' with a value of 67.59
# Expression
{ "h2o": PAR(h2o), "hcl": PAR(hcl) }
# Payload
{ "h2o": 56, "hcl": 3 }
# Outcome
Omnyvore stores two measurements:
- a measurement for the parameter 'h2o' with a value of 56
- a measurement for the parameter 'hcl' with a value of 3
Even if Omnyvore's DSL is fairly convenient for a number of cases, you might need something more complex to process incoming data. For example, how to cope with a JSON payload which has optional fields? Or how to conditionally publish a command on MQTT when a given value is received for a specific parameter? Omnyvore scripts can deal with all this complex logic by letting you write Javascript code which will be executed when data is processed.
Omnyvore scripts for channels return a List of Measurements.
Hereafter there is an example of scripts which perform the same operation as the examples which have been provided for Omnyvore's DSL.
// deals with spaces at the beginning and at the end of the string, which was not possible with Omnyvore's DSL
var speed = OMV.toString(payload).trim();
var now = (new Date()).getTime();
var returnedList = new List();
returnedList.add(new Measurement('speed', speed, now));
return returnedList;
var position = OMV.toString(payload).trim();
var now = (new Date()).getTime();
var positionArray = position.split(';');
var lat = java.lang.Double.parseDouble(OMV.toString(positionArray[0].trim()));
var lon = java.lang.Double.parseDouble(OMV.toString(positionArray[1].trim()));
var returnedList = new List();
returnedList.add(new Measurement('lat', lat, now));
returnedList.add(new Measurement('lon', lon, now));
return returnedList;
var obj = OMV.toString(payload).trim();
var now = (new Date()).getTime();
var jsonObj = JSON.parse(obj);
var h2o = obj.h2o;
var hcl = obj.hcl;
var returnedList = new List();
returnedList.add(new Measurement('h2o', h2o, now));
returnedList.add(new Measurement('hcl', hcl, now));
return returnedList;
For more details on which classes you can use in Javascript snippets, please refer to our appendix.