DataLogger

From ago control wiki
Revision as of 21:00, 5 February 2015 by Bjacobse (Talk | contribs)

Jump to: navigation, search

Data Logger

The data logger logs all events which are sent by devices. You can request values in a specific time range for a device and you will get them back in JSON format. You have to set up a database first:

cd /var/opt/agocontrol
sqlite3 datalogger.db

Create the primary table:

CREATE TABLE data(id INTEGER PRIMARY KEY AUTOINCREMENT, uuid TEXT, environment TEXT, unit TEXT, level REAL, timestamp TIMESTAMP);

Below is maybe not needed anymore Start the Logger (perhaps in a screen session):

python datalogger.py

Now the data logger is logging all events to the SQLite DB and you can get out data with the messagesend command:

/opt/agocontrol/bin/messagesend.py -c getloggergraph -p deviceid=000000-0000-0000-0000-000000000000 -p start="2012-12-24 12:00:00" -p end="2012-12-24 13:00:00" -p env="temperature" -p freq="5Min"

For the command getloggergraph you need this parameters:

  • deviceid = UUID of device
  • start = Start time for e.g.: 2012-12-24 12:00:00
  • end = End time e.g.: 2012-12-24 13:00:00
  • env = environment e.g.: temperature
  • freq = frequency e.g.: 5Min for 5 minutes - or 10Min, 15Min

With command getdeviceenvironments you will get back a JSON with all devices and their environment's.

curl example

Command:

curl -X POST -d '{"jsonrpc" : "2.0", "method" : "message", "params" : {"content":{ "command":"getloggergraph", "deviceid":"e0227340-2e0e-4048-be06-b1238df38c45", "start":"2013-3-23 08:00:00", "end":"2013-03-23 10:00:00", "env":"temperature", "freq":"5Min"}}, "id":1 }' http://localhost:8008/jsonrpc 

Response:

{"jsonrpc": "2.0", "result": {"unit":"degC","values":{"2013-03-23 08:00:00":["18.06"],"2013-03-23 08:05:00":["18.06"],"2013-03-23 08:10:00":["18.06"],"2013-03-23 08:15:00":["18.06"],"2013-03-23 08:20:00":["18.10"],"2013-03-23 08:25:00":["18.10"],"2013-03-23 08:30:00":["18.10"],"2013-03-23 08:35:00":["18.10"],"2013-03-23 08:40:00":["18.10"],"2013-03-23 08:45:00":["18.10"],"2013-03-23 08:50:00":["18.10"],"2013-03-23 08:55:00":["18.10"],"2013-03-23 09:00:00":["18.10"],"2013-03-23 09:05:00":["18.10"],"2013-03-23 09:10:00":["18.10"],"2013-03-23 09:15:00":["18.10"],"2013-03-23 09:20:00":["18.06"],"2013-03-23 09:25:00":["18.10"],"2013-03-23 09:30:00":["18.10"],"2013-03-23 09:35:00":["18.10"],"2013-03-23 09:40:00":["18.10"],"2013-03-23 09:45:00":["18.10"],"2013-03-23 09:50:00":["18.10"],"2013-03-23 09:55:00":["18.10"],"2013-03-23 10:00:00":["18.20"]}}, "id": 1
Personal tools