-
Notifications
You must be signed in to change notification settings - Fork 2
SolarNode DataSource Expressions
Many Data Source plugins for SolarNode support a general expressions framework that can be used to derive property values out of the raw values captured from the device the data source captures data from. In the SolarNode UI a typical data source might present a configurable list of expression settings like this:

In this example screen shot, each time the data source captures data from the device it is
communicating with it will derive a new watts property by multiplying the captured amps and
volts properties. In essence the expression is like this code:
watts = amps × volts
When the expression is evaluated, it is evaluated against a so-called root object. The root object is what holds the captured property values and allows the expression to refer to them.
A basic data source will provide a root object which has the following properties available to expressions:
| Property | Type | Description |
|---|---|---|
datum |
GeneralNodeDatum |
A GeneralNodeDatum object, populated with the property values read from the device. |
props |
Map<String,Object> |
Simple map based access to all properties in datum, to simplify expressions. |
Let's assume a captured datum like this, expressed as JSON:
{
"i" : {
"amps" : 4.2,
"volts" : 240.0,
},
"a" : {
"reading" : 38009138
},
"s" : {
"state" : "Ok"
}
}Then here are some example SpEL expressions and the results they would produce:
| Expression | Result | Comment |
|---|---|---|
datum.s['status] |
Ok |
Returns the state status property directly, which is Ok. |
props['status'] |
Ok |
Same result as datum.s['status'] but using the short-cut props accessor. |
props['amps'] * props['volts'] |
1008.0 |
Returns the result of multiplying the amps and volts properties together: 4.2 × 240.0 = 1008.0. |