-
Notifications
You must be signed in to change notification settings - Fork 2
SolarNode Pushing Data To SolarNet
Typically a SolarNode device collects data from various devices and stores the data locally. That data isn't meant to stay on the node very long, however. After being stored locally, it is meant to get pushed up into the SolarNet cloud "in the near future". The "near future" can vary based on the type of data being collected, from "within seconds" to "within a few minutes" or nearly anything at all. If the SolarNode device has limited internet connectivity, the "near future" might actually be quite some time away.
The typical method for data to get pushed up into SolarNet is via the net.solarnetwork.node.BulkUploadService API. The net.solarnetwork.node.upload.bulkjsonwebpost plug-in provides an implementation of that service. That plug-in provides a periodic job that queries the local data store for Datum
objects and then pushes them up to SolarNet using the SolarIn API.
After data has been uploaded to SolarNet successfully, it remains in the local database until another periodic job runs and deletes data that has already been uploaded.
SolarNode also supports storing and retrieving metadata attached to source ID values. Recall that every datum in SolarNetwork has a required sourceId
property. The net.solarnetwork.node.DatumMetadataService API allows plug-ins to manipulate this source ID level metadata. Unlike datum data, however, metadata is not persisted locally because it is not meant to change much over time.
To give an example of using metadata, the CurrentCost power meter allows users to tag the source ID as consumption or generation, which can be helpful if you have two devices capturing data, one at a meter box, measuring load, and one at the AC output of a PV inverter, measuring generation. Conceptually, that class does this:
String sourceId = getSourceId(); // e.g. "Meter"
// associate consumption/generation tags with this source
GeneralDatumMetadata sourceMeta = new GeneralDatumMetadata();
if ( isTagConsumption() ) {
sourceMeta.addTag("consumption");
} else {
sourceMeta.addTag("power");
}
// post metadata to SolarNet
DatumMetadataService service = getDatumMetadataService();
service.addSourceMetadata(sourceId, meta);
The net.solarnetwork.node.upload.bulkjsonwebpost plug-in provides an implementation of the DatumMetadataService
service.