calaos_base icon indicating copy to clipboard operation
calaos_base copied to clipboard

Dev/nae/charts

Open naguirre opened this issue 4 years ago • 0 comments

Fix bug and bad log + add new HTTP API for charts/datalogger points retrieval.

This api act as a proxy for influxdb database. If datalooger is disable, this api return "success" : "false" otherwise, the content of the q key of the json request is send to influxdb. Influxdb output is then returned as json payload.

Example of json payload (get 1hour of points for Calaos IO named "Outside Temperature")

{ "cn_user": "USERNAME", "cn_pass": "PASSWORD", "action": "datalogger", "q": "SELECT  \"value\" from \"Outside Temperature\" WHERE time >= now() - 1h" }

Example of json returned :

{
    "results": [
        {
            "statement_id": 0,
            "series": [
                {
                    "name": "Outside Temperature",
                    "columns": [
                        "time",
                        "value"
                    ],
                    "values": [
                        [
                            "2020-09-19T14:25:30.148879183Z",
                            29.2
                        ],
                        [
                            "2020-09-19T14:30:30.148224696Z",
                            29.2
                        ],
                        [
                            "2020-09-19T14:35:30.146235282Z",
                            29.2
                        ],
                        [
                            "2020-09-19T14:40:30.147027598Z",
                            29.2
                        ],
                        [
                            "2020-09-19T14:45:30.149729178Z",
                            29.2
                        ],
                        [
                            "2020-09-19T14:48:32.524887511Z",
                            29
                        ],
                        [
                            "2020-09-19T14:50:30.147821093Z",
                            29
                        ],
                        [
                            "2020-09-19T14:55:30.148496147Z",
                            29
                        ],
                        [
                            "2020-09-19T15:00:30.150516343Z",
                            29
                        ],
                        [
                            "2020-09-19T15:05:30.150021941Z",
                            29
                        ],
                        [
                            "2020-09-19T15:10:30.150139142Z",
                            29
                        ],
                        [
                            "2020-09-19T15:15:30.152617019Z",
                            29
                        ],
                        [
                            "2020-09-19T15:20:30.153415413Z",
                            29
                        ]
                    ]
                }
            ]
        }
    ]
}

naguirre avatar Sep 19 '20 15:09 naguirre