Retrieving values table from sensor graphs
-
Another post from me I'm afraid. Is there a way to extract a table of readings from the sensor graphs, whether as a text file, csv etc.?
-
@mtbhuw This feature yet to implement on https://github.com/mycontroller-org/mycontroller/issues/361
This might help you https://forum.mycontroller.org/topic/79/temperature-min-max-avg
-
Thanks, I tried running the script:
var myImports = new JavaImporter(java.io, java.lang, java.util, java.text); with(myImports) { var sVar = mcApi.uidTag().getByUid("temp-outside").getResource(); // Get sensor variable object with UidTag api var minMaxData = mcApi.metric().getSensorVariableMetricDouble(sVar, 0,1479833863195); //(sensor-variable-object, from-timestamp, to-timestamp) }
changing "temp-outside" to my own uidTag for my sensor. It worked but seemed to return a lot more information than needed, although I see that the value (distance) is there, but among a lot of unwanted data. Is there a way of extracting just time/distance from this? Here's a sample of what was returned....
{ "sVar": { "id": 7, "sensor": { "id": 8, "sensorId": "1", "type": "S_DISTANCE", "name": "", "lastSeen": 1509978854438, "node": { "id": 10, "eui": "1", "gatewayTable": { "id": 1, "enabled": true, "name": "Serial Gateway", "networkType": "MY_SENSORS", "state": "UP", "statusMessage": "Connected Successfully", "statusSince": 1509967019993, "type": "SERIAL", "properties": { "br": 115200, "rdr": "jSerialComm", "rf": 30, "txDelay": 0, "dr": "Auto", "pn": "/dev/ttyACM0" } }, "name": "Distance Sensor", "version": "1.0", "type": "S_ARDUINO_NODE", "libVersion": "2.1.1", "state": "UP", "lastSeen": 1509978855129, "properties": { "hbTx": 1509978436346 }, "registrationState": "REGISTERED", "smartSleepEnabled": false }, "variableTypes": [ "Distance" ], "idforVariables": 8 }, "variableType": "V_DISTANCE", "metricType": "DOUBLE", "timestamp": 1509978853779, "value": "151", "previousValue": "150", "unitType": "U_DISTANCE", "readOnly": false, "offset": 0, "priority": 100, "properties": { "marginRight": 20, "color": "#ff7f0e", "interpolate": "linear", "subType": "line", "marginBottom": 60, "useGlobal": true, "type": "lineChart", "marginTop": 5, "marginLeft": 65 }, "metricsGraph": { "id": 5, "metricName": "Distance", "type": "lineChart", "interpolate": "linear", "subType": "line", "color": "#ff7f0e" } }, "myImports": {}, "minMaxData": { "variable": { "id": 7, "sensor": { "id": 8, "sensorId": "1", "type": "S_DISTANCE", "name": "", "lastSeen": 1509978854438, "node": { "id": 10, "eui": "1", "gatewayTable": { "id": 1, "enabled": true, "name": "Serial Gateway", "networkType": "MY_SENSORS", "state": "UP", "statusMessage": "Connected Successfully", "statusSince": 1509967019993, "type": "SERIAL", "properties": { "br": 115200, "rdr": "jSerialComm", "rf": 30, "txDelay": 0, "dr": "Auto", "pn": "/dev/ttyACM0" } }, "name": "Distance Sensor", "version": "1.0", "type": "S_ARDUINO_NODE", "libVersion": "2.1.1", "state": "UP", "lastSeen": 1509978855129, "properties": { "hbTx": 1509978436346 }, "registrationState": "REGISTERED", "smartSleepEnabled": false }, "variableTypes": [ "Distance" ], "idforVariables": 8 }, "variableType": "V_DISTANCE", "metricType": "DOUBLE", "timestamp": 1509978853779, "value": "151", "previousValue": "150", "unitType": "U_DISTANCE", "readOnly": false, "offset": 0, "priority": 100, "properties": { "marginRight": 20, "color": "#ff7f0e", "interpolate": "linear", "subType": "line", "marginBottom": 60, "useGlobal": true, "type": "lineChart", "marginTop": 5, "marginLeft": 65 }, "metricsGraph": { "id": 5, "metricName": "Distance", "type": "lineChart", "interpolate": "linear", "subType": "line", "color": "#ff7f0e" } } } }