Hello Wilson,
Virtual Resources are what you need here to store strings, arrays (objects), numbers, boolean, etc data types
Here is an example:
function(event) {
var temperature = Datahub.read(“/redSensor/imu/temp/value”,0).value;
var pressure = Datahub.read(“/redSensor/pressure/value”,0).value;
var lat = 0;
var lon = 0;
var pos = Datahub.read(“/location/coordinates/value”,0);
if (pos) {
lat = pos.lat;
lon = pos.lon
}
var light = Datahub.read(“/redSensor/light/value”,0).value;
var bars = Datahub.read(“/util/cellular/signal/value”,0).value.bars;
var technology = Datahub.read(“/util/cellular/signal/value”,0).value.rat;
// Create the contents of an array
var report = {
“temperature”: temperature,
“pressure”: pressure,
“location”: { “lat”: lat, “lon”: lon },
“light”: light,
“signal_bars”: bars,
“cell_technology”: technology
}
return {
// store the contents of the array in a virtual resource If the virtual resource does not already exist in the /
// resource tree, the virtual resource will be created.
“vr://report”: [report]
}
}
You can learn more about virtual resources here:
Here is a bit more complex definition of a lighting schedule to turn off and on lights from a schedule. It is stored in a virtual resource.
“vr_lighting_schedule”: {
“dt”: 4,
“v”: {
“Lighting_Schedule_Table”: [
{
“day”: “Sunday”,
“end_time”: “20:00”,
“id”: “0”,
“start_time”: “16:00”
},
{
“day”: “Monday”,
“end_time”: “19:00”,
“id”: 1,
“start_time”: “16:00”
},
{
“day”: “Tuesday”,
“end_time”: “19:00”,
“id”: 2,
“start_time”: “16:00”
},
{
“day”: “Wednesday”,
“end_time”: “19:00”,
“id”: “3”,
“start_time”: “16:00”
},
{
“day”: “Thursday”,
“end_time”: “20:00”,
“id”: “4”,
“start_time”: “16:00”
},
{
“day”: “Friday”,
“end_time”: “19:00”,
“id”: “5”,
“start_time”: “16:00”
},
{
“day”: “Saturday”,
“end_time”: “19:00”,
“id”: “6”,
“start_time”: “16:00”
}
]
}
},
If you were to create this via the Octave UI rather than in an edge action as in the previous example, it would look like this:
I hope this helps.