Help logging data?
-
Hello everyone,
I am struggling to understand how to get a raw data set through mycontroller on to my local machine some how? If at all possible?
Can anyone offer any help?
-
@mattjones Yes, you can get raw data with /mc/rest/metrics/stats API
Example: GET https://<ip>:8443//mc/rest/metrics/stats?uid=sensor1&bucketDuration=raw&duration=1h
-
@jkandasa thanks for your quick reply. Can you spell it out a bit clearer for the less able ones out there? The links didnt seem to work.
-
@mattjones I hope you are using latest SNAPSHOT version, If you are not, please use http://forum.mycontroller.org/topic/58/download-snapshot-build
Here is the example:
My Raspberry IP:192.168.1.209
I have a created a UID tag for my sensor variable water level as
water-level
as displayed below,
I use Restlet client in chrome to fetch REST data.
Here is the actual query:
GEThttps://192.168.1.209:8443/mc/rest/metrics/stats?uid=water-level&bucketDuration=12h&duration=2d
uid
: uid tag for sensor variable. You can useresourceType
andresourceId
also (ask me if you want more about this).bucketDuration
: interval optionsraw
and minute(mn
), hours(h
), day(d
), month(m
) 1 minute =1mn
, 12 hours =12h
duration
: default 8 hours. You can mention last x hours(h
), minutes(mn
), days(d
), months(m
)
Query samples:
- I would like to query for last 12 hours in 4 hours interval.
https://192.168.1.209:8443/mc/rest/metrics/stats?uid=water-level&bucketDuration=4h&duration=12h
[ { "timestamp" : 1500537004582, "empty" : false, "min" : 94.4, "max" : 100.0, "avg" : 96.3425, "samples" : 320 }, { "timestamp" : 1500551404582, "empty" : false, "min" : 92.3, "max" : 94.4, "avg" : 93.58117283950608, "samples" : 324 }, { "timestamp" : 1500565804582, "empty" : false, "min" : 90.9, "max" : 99.3, "avg" : 95.56230529595034, "samples" : 321 } ]
- I would like to query for last 10 minutes raw data
https://192.168.1.209:8443/mc/rest/metrics/stats?uid=water-level&bucketDuration=raw&duration=10mn
[ { "timestamp" : 1500565352695, "empty" : false, "min" : 97.9, "max" : 97.9, "avg" : 97.9, "samples" : 2 }, { "timestamp" : 1500565412695, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 1 }, { "timestamp" : 1500565472695, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 1 }, { "timestamp" : 1500565532695, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 2 }, { "timestamp" : 1500565592695, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 1 }, { "timestamp" : 1500565652695, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 1 }, { "timestamp" : 1500565712695, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 2 }, { "timestamp" : 1500565772695, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 1 }, { "timestamp" : 1500565790547, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 1 }, { "timestamp" : 1500565835758, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 1 }, { "timestamp" : 1500565880537, "empty" : false, "min" : 97.2, "max" : 97.2, "avg" : 97.2, "samples" : 1 } ]
I hope this will address your requirement.
-
@jkandasa
Can you help me in getting this thing working. I get the following error message "HTTP 401 Unauthorized".
I have an UID for a Sensor Variable named N001S01 and I use the following link where <rpi_ip> is replaced by the actual Raspberry Pi's IP Address.https://<rpi_ip>:8443/mc/rest/metrics/stats?uid=N001S01&bucketDuration=raw&duration=1h.
-
@naguraob on your client you should add authentication details.
-
Hi, I have a similar question regarding using REST API functionality of mycontroler software - how can I send data to a sensor variable (having UID) from a remote station using REST request ?
The question may seem stupid but as my hardware sensor devices are very limitted in power supply (actually they realy only on harvested power) I cannot use mysensor library. However I can send http requests (via my own "specialized" wifi-connected gateway). So my sensors communicate directly with "my" gateway and I wont the gateway to send data to mycontroller software.
Any example would be appreciated.
Besides - mycontroller is really a nice piece of programmers work
Best regards,
wkwj00 -
@wkwj00 MyController does not have any direct support for REST API endpoints. You may use MQTT, or other REST API like Sparkfun, etc.,