Calculated Value Select
machlake (Unlicensed)
Andrew Kim
This API is for geting automatically constructed statistical values based on the input raw values. This function is usually used to quickly draw charts for a long period of time, such as months or years. The supported functions are min, max, sum, count, average specified by calc_mode. See the Parameters section below for more details.
HTTP Request
Parameters
Optional | Type | Description | Example |
---|
Optional | Type | Description | Example |
---|---|---|---|
type | string | select type | &type=calc |
tag_name | string | tag name with , separator | &tag_name=tag1,tag2,tag3 |
date_format | string | date format of select time | &date_format=YYYY-MM-DD HH24:MI:SS (default : YYYY-MM-DD HH24:MI:SS) |
start_time | string | start time of select (MUST be less than end_time!) type 1 : time string format
type 2 : timestamp (second or millisecond)
| &start_time=2018-01-16 14:40:05 000
|
end_time | string | end time of select (MUST be more than start_time!)
| same as start_time |
calc_mode | string | min,max,cnt,avg,sum | &calc_mode=min (default : avg) |
interval_type | string | sec,min,hour,day (or s,m,h,d) | &interval_type=hour (default : sec) |
interval_value | int | duration value | &interval_value=10 (default : 1) |
separator | string | separator for tag_name, columns, and_condition | &separator=| (default : ,) |
direction | int | ascend or descent by time | &direction=0 |
limit | int | count of display | &limit=1000 (default : Limited according to Lake tier) |
offset | int | count of skip | &offset=500 |
Request Example
Response Example
Sample Code
Also this API has lots of parameters, but sample case contain few case, but should combine variety parameter combination from these example
chcp 65001
:: Text Encoding to UTF-8 in CMD
:: Example For Select Calculated Data for tag API by using curl in window script
:: written by yeony kim
set API_KEY=YOUR_API_KEY
set LAKE_ID=YOUR_LAKE_ID
set CLOUD_VENDOR=YOUR_CLOUD_VENDOR
set CLOUD_REGION=YOUR_CLOUD_REGION
set CONTENT_HEADER="Content-Type: application/json"
set API_HEADER="x-api-key: %API_KEY%"
set URL="https://%CLOUD_VENDOR%.%CLOUD_REGION%.machlake.com/v1/lakes/%LAKE_ID%/values"
set SELECT_TYPE=calc
set TAG_NAME=sensor1,sensor2
:: ------------------------------------------------------------------------------------------------- ::
:: CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=min
set CALC_MODE=min
set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn
set START_TIME=2021-01-06 17:00:00 000:000:000
set END_TIME=2021-01-06 21:00:00 000:000:000
curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% \
--data-urlencode "type=%SELECT_TYPE%" \
--data-urlencode "tag_name=%TAG_NAME%" \
--data-urlencode "calc_mode=%CALC_MODE%" \
--data-urlencode "start_time=%START_TIME%" \
--data-urlencode "end_time=%END_TIME%" \
--data-urlencode "date_format=%DATE_FORMAT%"
:: Return Format
:: {
:: "success": true,
:: "reason": "success",
:: "data":{
:: "columns":[
:: {"name":"NAME","type":5,"length":80},
:: {"name":"TIME","type":5,"length":4096},
:: {"name":"VALUE","type":20,"length":17}
:: ],
:: "rows":[
:: ["sensor1","2021-01-06 17:00:00 000:000:000",1],
:: ["sensor2","2021-01-06 17:00:00 000:000:000",1],
:: ["sensor2","2021-01-06 17:00:01 000:000:000",1.5],
:: ["sensor2","2021-01-06 17:00:02 000:000:000",2],
:: ["sensor2","2021-01-06 17:00:03 000:000:000",1],
:: ["sensor2","2021-01-06 17:00:04 000:000:000",1.5],
:: ["sensor2","2021-01-06 17:00:05 000:000:000",2],
:: ["sensor1","2021-01-06 18:00:00 000:000:000",2],
:: ["sensor2","2021-01-06 18:00:00 000:000:000",2],
:: ["sensor1","2021-01-06 20:00:04 000:000:000",2],
:: ["sensor2","2021-01-06 20:00:04 000:000:000",2],
:: ["sensor1","2021-01-06 20:00:05 000:000:000",2.5],
:: ["sensor2","2021-01-06 20:00:05 000:000:000",2.5],
:: ["sensor1","2021-01-06 20:00:06 000:000:000",2]
:: ["sensor2","2021-01-06 20:00:06 000:000:000",2]
:: ]
:: }
:: }
:: ------------------------------------------------------------------------------------------------- ::
:: CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=max and interval_value=3
set CALC_MODE=max
set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn
set START_TIME=2021-01-06 17:00:00 000:000:000
set END_TIME=2021-01-06 21:00:00 000:000:000
set INTERVAL_VALUE=3
curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% \
--data-urlencode "type=%SELECT_TYPE%" \
--data-urlencode "tag_name=%TAG_NAME%" \
--data-urlencode "calc_mode=%CALC_MODE%" \
--data-urlencode "start_time=%START_TIME%" \
--data-urlencode "end_time=%END_TIME%" \
--data-urlencode "date_format=%DATE_FORMAT%" \
--data-urlencode "interval_value=%INTERVAL_VALUE%"
:: Return Format
:: {
:: "success": true,
:: "reason": "success",
:: "data":{
:: "columns":[
:: {"name":"NAME","type":5,"length":80},
:: {"name":"TIME","type":5,"length":4096},
:: {"name":"VALUE","type":20,"length":17}
:: ],
:: "rows":[
:: ["sensor2","2021-01-06 17:00:00 000:000:000",2],
:: ["sensor1","2021-01-06 17:00:00 000:000:000",2],
:: ["sensor2","2021-01-06 17:00:03 000:000:000",2],
:: ["sensor2","2021-01-06 18:00:00 000:000:000",2.5],
:: ["sensor1","2021-01-06 18:00:00 000:000:000",2.5],
:: ["sensor2","2021-01-06 20:00:03 000:000:000",2.5],
:: ["sensor1","2021-01-06 20:00:03 000:000:000",2.5],
:: ["sensor2","2021-01-06 20:00:06 000:000:000",2],
:: ["sensor1","2021-01-06 20:00:06 000:000:000",2]
:: ]
:: }
:: }
:: ------------------------------------------------------------------------------------------------- ::
:: CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=min and interval_type=m and interval_value=90
set CALC_MODE=min
set DATE_FORMAT=YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn
set START_TIME=2021-01-06 17:00:00 000:000:000
set END_TIME=2021-01-06 21:00:00 000:000:000
set INTERVAL_TYPE=m
set INTERVAL_VALUE=90
curl -k -G %URL% -H %CONTENT_HEADER% -H %API_HEADER% \
--data-urlencode "type=%SELECT_TYPE%" \
--data-urlencode "tag_name=%TAG_NAME%" \
--data-urlencode "calc_mode=%CALC_MODE%" \
--data-urlencode "start_time=%START_TIME%" \
--data-urlencode "end_time=%END_TIME%" \
--data-urlencode "date_format=%DATE_FORMAT%" \
--data-urlencode "interval_value=%INTERVAL_VALUE%" \
--data-urlencode "interval_type=%INTERVAL_TYPE%"
:: Return Format
:: {
:: "success": true,
:: "reason": "success",
:: "data":{
:: "columns":[
:: {"name":"NAME","type":5,"length":80},
:: {"name":"TIME","type":5,"length":4096},
:: {"name":"VALUE","type":12,"length":20}
:: ],
:: "rows":[
:: ["sensor1","2021-01-06 16:30:00 000:000:000",1],
:: ["sensor2","2021-01-06 16:30:00 000:000:000",1],
:: ["sensor1","2021-01-06 18:00:00 000:000:000",1],
:: ["sensor2","2021-01-06 18:00:00 000:000:000",1],
:: ["sensor1","2021-01-06 19:30:00 000:000:000",1],
:: ["sensor2","2021-01-06 19:30:00 000:000:000",1],
:: ]
:: }
:: }
# Text Encoding to UTF-8 in CMD
# Example For Select Calculated Data for tag API by using curl in ubuntu
LAKE_ID=$YOUR_LAKE_ID
API_KEY=$YOUR_API_KEY
CLOUD_VENDOR=$YOUR_CLOUD_VENDOR
CLOUD_REGION=$YOUR_CLOUD_REGION
CONTENT_HEADER=Content-Type:application/json
API_HEADER=x-api-key:$API_KEY
URL=https://${CLOUD_VENDOR}.${CLOUD_REGION}.machlake.com/v1/lakes/${LAKE_ID}/values
SELECT_TYPE=calc
TAG_NAME=sensor1,sensor2
# ------------------------------------------------------------------------------------------------- #
# CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=min
CALC_MODE=min
DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn"
START_TIME="2021-01-06 17:00:00 000:000:000"
END_TIME="2021-01-06 21:00:00 000:000:000"
curl -k -G $URL -H $CONTENT_HEADER -H $API_HEADER \
--data-urlencode "type=$SELECT_TYPE" \
--data-urlencode "tag_name=$TAG_NAME" \
--data-urlencode "calc_mode=$CALC_MODE" \
--data-urlencode "start_time=$START_TIME" \
--data-urlencode "end_time=$END_TIME" \
--data-urlencode "date_format=$DATE_FORMAT"
# Return Format
# {
# "success": true,
# "reason": "success",
# "data":{
# "columns":[
# {"name":"NAME","type":5,"length":80},
# {"name":"TIME","type":5,"length":4096},
# {"name":"VALUE","type":20,"length":17}
# ],
# "rows":[
# ["sensor1","2021-01-06 17:00:00 000:000:000",1],
# ["sensor2","2021-01-06 17:00:00 000:000:000",1],
# ["sensor2","2021-01-06 17:00:01 000:000:000",1.5],
# ["sensor2","2021-01-06 17:00:02 000:000:000",2],
# ["sensor2","2021-01-06 17:00:03 000:000:000",1],
# ["sensor2","2021-01-06 17:00:04 000:000:000",1.5],
# ["sensor2","2021-01-06 17:00:05 000:000:000",2],
# ["sensor1","2021-01-06 18:00:00 000:000:000",2],
# ["sensor2","2021-01-06 18:00:00 000:000:000",2],
# ["sensor1","2021-01-06 20:00:04 000:000:000",2],
# ["sensor2","2021-01-06 20:00:04 000:000:000",2],
# ["sensor1","2021-01-06 20:00:05 000:000:000",2.5],
# ["sensor2","2021-01-06 20:00:05 000:000:000",2.5],
# ["sensor1","2021-01-06 20:00:06 000:000:000",2]
# ["sensor2","2021-01-06 20:00:06 000:000:000",2]
# ]
# }
# }
# ------------------------------------------------------------------------------------------------- #
# CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=max and interval_value=3
CALC_MODE=max
DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn"
START_TIME="2021-01-06 17:00:00 000:000:000"
END_TIME="2021-01-06 21:00:00 000:000:000"
INTERVAL_VALUE=3
curl -k -G $URL -H $CONTENT_HEADER -H $API_HEADER \
--data-urlencode "type=$SELECT_TYPE" \
--data-urlencode "tag_name=$TAG_NAME" \
--data-urlencode "calc_mode=$CALC_MODE" \
--data-urlencode "start_time=$START_TIME" \
--data-urlencode "end_time=$END_TIME" \
--data-urlencode "date_format=$DATE_FORMAT" \
--data-urlencode "interval_value=$INTERVAL_VALUE"
# Return Format
# {
# "success": true,
# "reason": "success",
# "data":{
# "columns":[
# {"name":"NAME","type":5,"length":80},
# {"name":"TIME","type":5,"length":4096},
# {"name":"VALUE","type":20,"length":17}
# ],
# "rows":[
# ["sensor2","2021-01-06 17:00:00 000:000:000",2],
# ["sensor1","2021-01-06 17:00:00 000:000:000",2],
# ["sensor2","2021-01-06 17:00:03 000:000:000",2],
# ["sensor2","2021-01-06 18:00:00 000:000:000",2.5],
# ["sensor1","2021-01-06 18:00:00 000:000:000",2.5],
# ["sensor2","2021-01-06 20:00:03 000:000:000",2.5],
# ["sensor1","2021-01-06 20:00:03 000:000:000",2.5],
# ["sensor2","2021-01-06 20:00:06 000:000:000",2],
# ["sensor1","2021-01-06 20:00:06 000:000:000",2]
# ]
# }
# }
# ------------------------------------------------------------------------------------------------- #
# CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=min and interval_type=m and interval_value=90
CALC_MODE=min
DATE_FORMAT="YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn"
START_TIME="2021-01-06 17:00:00 000:000:000"
END_TIME="2021-01-06 21:00:00 000:000:000"
INTERVAL_TYPE=m
INTERVAL_VALUE=90
curl -k -G $URL -H $CONTENT_HEADER -H $API_HEADER \
--data-urlencode "type=$SELECT_TYPE" \
--data-urlencode "tag_name=$TAG_NAME" \
--data-urlencode "calc_mode=$CALC_MODE" \
--data-urlencode "start_time=$START_TIME" \
--data-urlencode "end_time=$END_TIME" \
--data-urlencode "date_format=$DATE_FORMAT" \
--data-urlencode "interval_value=$INTERVAL_VALUE" \
--data-urlencode "interval_type=$INTERVAL_TYPE"
# Return Format
# {
# "success": true,
# "reason": "success",
# "data":{
# "columns":[
# {"name":"NAME","type":5,"length":80},
# {"name":"TIME","type":5,"length":4096},
# {"name":"VALUE","type":12,"length":20}
# ],
# "rows":[
# ["sensor1","2021-01-06 16:30:00 000:000:000",1],
# ["sensor2","2021-01-06 16:30:00 000:000:000",1],
# ["sensor1","2021-01-06 18:00:00 000:000:000",1],
# ["sensor2","2021-01-06 18:00:00 000:000:000",1],
# ["sensor1","2021-01-06 19:30:00 000:000:000",1],
# ["sensor2","2021-01-06 19:30:00 000:000:000",1],
# ]
# }
# }
// Example For Select Calculated Data for tag API by using request in node js
// process.env.NODE_TLS_REJECT_UNAUTHORIZED ="0";
const API_KEY ="YOUR_API_TOKEN";
const LAKE_ID ="YOUR_LAKE_ID";
const CLOUD_VENDOR="CLOUD_VENDOR";
const CLOUD_REGION="CLOUD_REGION";
const URL = `https://${CLOUD_VENDOR}.${CLOUD_REGION}.machlake.com/v1/lakes/${LAKE_ID}/values`;
const SELECT_TYPE="calc";
const TAG_NAME = "sensor1,sensor2";
var request = require('request');
/* ------------------------------------------------------------------------------------------------- */
// CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=min
request.get({
url: URL,
qs: {
type: SELECT_TYPE,
tag_name: TAG_NAME,
calc_mode: "min",
date_format: "YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn",
start_time: "2021-01-06 17:00:00 000:000:000",
end_time: "2021-01-06 21:00:00 000:000:000"
},
headers: {
"x-api-key": API_KEY
}},
function(error, response, body) {
console.log(body);
// Return Format
// {
// "success": true,
// "reason": "success",
// "data":{
// "columns":[
// {"name":"NAME","type":5,"length":80},
// {"name":"TIME","type":5,"length":4096},
// {"name":"VALUE","type":20,"length":17}
// ],
// "rows":[
// ["sensor1","2021-01-06 17:00:00 000:000:000",1],
// ["sensor2","2021-01-06 17:00:00 000:000:000",1],
// ["sensor2","2021-01-06 17:00:01 000:000:000",1.5],
// ["sensor2","2021-01-06 17:00:02 000:000:000",2],
// ["sensor2","2021-01-06 17:00:03 000:000:000",1],
// ["sensor2","2021-01-06 17:00:04 000:000:000",1.5],
// ["sensor2","2021-01-06 17:00:05 000:000:000",2],
// ["sensor1","2021-01-06 18:00:00 000:000:000",2],
// ["sensor2","2021-01-06 18:00:00 000:000:000",2],
// ["sensor1","2021-01-06 20:00:04 000:000:000",2],
// ["sensor2","2021-01-06 20:00:04 000:000:000",2],
// ["sensor1","2021-01-06 20:00:05 000:000:000",2.5],
// ["sensor2","2021-01-06 20:00:05 000:000:000",2.5],
// ["sensor1","2021-01-06 20:00:06 000:000:000",2]
// ["sensor2","2021-01-06 20:00:06 000:000:000",2]
// ]
// }
// }
})
/* ------------------------------------------------------------------------------------------------- */
// CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=max and interval_value=3
request.get({
url: URL,
qs: {
type: SELECT_TYPE,
tag_name: TAG_NAME,
calc_mode: "max",
date_format: "YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn",
start_time: "2021-01-06 17:00:00 000:000:000",
end_time: "2021-01-06 21:00:00 000:000:000",
interval_value: 3
},
headers: {
"x-api-key": API_KEY
}},
function(error, response, body) {
console.log(body);
// Return Format
// {
// "success": true,
// "reason": "success",
// "data":{
// "columns":[
// {"name":"NAME","type":5,"length":80},
// {"name":"TIME","type":5,"length":4096},
// {"name":"VALUE","type":20,"length":17}
// ],
// "rows":[
// ["sensor2","2021-01-06 17:00:00 000:000:000",2],
// ["sensor1","2021-01-06 17:00:00 000:000:000",2],
// ["sensor2","2021-01-06 17:00:03 000:000:000",2],
// ["sensor2","2021-01-06 18:00:00 000:000:000",2.5],
// ["sensor1","2021-01-06 18:00:00 000:000:000",2.5],
// ["sensor2","2021-01-06 20:00:03 000:000:000",2.5],
// ["sensor1","2021-01-06 20:00:03 000:000:000",2.5],
// ["sensor2","2021-01-06 20:00:06 000:000:000",2],
// ["sensor1","2021-01-06 20:00:06 000:000:000",2]
// ]
// }
// }
})
// CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=min and interval_type=m and interval_value=90
request.get({
url: URL,
qs: {
type: SELECT_TYPE,
tag_name: TAG_NAME,
calc_mode: "min",
date_format: "YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn",
start_time: "2021-01-06 17:00:00 000:000:000",
end_time: "2021-01-06 21:00:00 000:000:000",
interval_type: "m",
interval_value: 90
},
headers: {
"x-api-key": API_KEY
}},
function(error, response, body) {
console.log(body);
// Return Format
// {
// "success": true,
// "reason": "success",
// "data":{
// "columns":[
// {"name":"NAME","type":5,"length":80},
// {"name":"TIME","type":5,"length":4096},
// {"name":"VALUE","type":12,"length":20}
// ],
// "rows":[
// ["sensor1","2021-01-06 16:30:00 000:000:000",1],
// ["sensor2","2021-01-06 16:30:00 000:000:000",1],
// ["sensor1","2021-01-06 18:00:00 000:000:000",1],
// ["sensor2","2021-01-06 18:00:00 000:000:000",1],
// ["sensor1","2021-01-06 19:30:00 000:000:000",1],
// ["sensor2","2021-01-06 19:30:00 000:000:000",1],
// ]
// }
// }
})
"""
Example For Select Calculated Data for tag API by using request in python
written by yeony kim
"""
import requests
API_KEY = "YOUR_API_TOKEN"
LAKE_ID = "YOUR_LAKE_ID"
CLOUD_VENDOR="CLOUD_VENDOR"
CLOUD_REGION="CLOUD_REGION"
URL = f"https://{CLOUD_VENDOR}.{CLOUD_REGION}.machlake.com/v1/lakes/{LAKE_ID}/values"
SELECT_TYPE="calc"
TAG_NAME="sensor1,sensor2"
headers = {
"Content-Type": "application/json",
"x-api-key": API_KEY
}
# ------------------------------------------------------------------------------------------------- #
# CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=min
params = {
"type": SELECT_TYPE,
"tag_name": TAG_NAME,
"calc_mode": "min",
"date_format": "YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn",
"start_time": "2021-01-06 17:00:00 000:000:000",
"end_time": "2021-01-06 21:00:00 000:000:000"
}
response = requests.get(URL, headers=headers, params=params, verify=False)
print(response.content.decode("utf-8"))
# Return Format
# {
# "success": true,
# "reason": "success",
# "data":{
# "columns":[
# {"name":"NAME","type":5,"length":80},
# {"name":"TIME","type":5,"length":4096},
# {"name":"VALUE","type":20,"length":17}
# ],
# "rows":[
# ["sensor1","2021-01-06 17:00:00 000:000:000",1],
# ["sensor2","2021-01-06 17:00:00 000:000:000",1],
# ["sensor2","2021-01-06 17:00:01 000:000:000",1.5],
# ["sensor2","2021-01-06 17:00:02 000:000:000",2],
# ["sensor2","2021-01-06 17:00:03 000:000:000",1],
# ["sensor2","2021-01-06 17:00:04 000:000:000",1.5],
# ["sensor2","2021-01-06 17:00:05 000:000:000",2],
# ["sensor1","2021-01-06 18:00:00 000:000:000",2],
# ["sensor2","2021-01-06 18:00:00 000:000:000",2],
# ["sensor1","2021-01-06 20:00:04 000:000:000",2],
# ["sensor2","2021-01-06 20:00:04 000:000:000",2],
# ["sensor1","2021-01-06 20:00:05 000:000:000",2.5],
# ["sensor2","2021-01-06 20:00:05 000:000:000",2.5],
# ["sensor1","2021-01-06 20:00:06 000:000:000",2]
# ["sensor2","2021-01-06 20:00:06 000:000:000",2]
# ]
# }
# }
# ------------------------------------------------------------------------------------------------- #
# CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=max and interval_value=3
params = {
"type": SELECT_TYPE,
"tag_name": TAG_NAME,
"calc_mode": "max",
"date_format": "YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn",
"start_time": "2021-01-06 17:00:00 000:000:000",
"end_time": "2021-01-06 21:00:00 000:000:000",
"interval_value": 3
}
response = requests.get(URL, headers=headers, params=params, verify=False)
print(response.content.decode("utf-8"))
# Return Format
# {
# "success": true,
# "reason": "success",
# "data":{
# "columns":[
# {"name":"NAME","type":5,"length":80},
# {"name":"TIME","type":5,"length":4096},
# {"name":"VALUE","type":20,"length":17}
# ],
# "rows":[
# ["sensor2","2021-01-06 17:00:00 000:000:000",2],
# ["sensor1","2021-01-06 17:00:00 000:000:000",2],
# ["sensor2","2021-01-06 17:00:03 000:000:000",2],
# ["sensor2","2021-01-06 18:00:00 000:000:000",2.5],
# ["sensor1","2021-01-06 18:00:00 000:000:000",2.5],
# ["sensor2","2021-01-06 20:00:03 000:000:000",2.5],
# ["sensor1","2021-01-06 20:00:03 000:000:000",2.5],
# ["sensor2","2021-01-06 20:00:06 000:000:000",2],
# ["sensor1","2021-01-06 20:00:06 000:000:000",2]
# ]
# }
# }
# ------------------------------------------------------------------------------------------------- #
# CASE - Calculated DATA GET with date format YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn with calc_mode=min and interval_type=m and interval_value=90
params = {
"type": SELECT_TYPE,
"tag_name": TAG_NAME,
"calc_mode": "min",
"date_format": "YYYY-MM-DD HH24:MI:SS mmm:uuu:nnn",
"start_time": "2021-01-06 17:00:00 000:000:000",
"end_time": "2021-01-06 21:00:00 000:000:000",
"interval_type": "m",
"interval_value": 90
}
response = requests.get(URL, headers=headers, params=params, verify=False)
print(response.content.decode("utf-8"))
# Return Format
# {
# "success": true,
# "reason": "success",
# "data":{
# "columns":[
# {"name":"NAME","type":5,"length":80},
# {"name":"TIME","type":5,"length":4096},
# {"name":"VALUE","type":12,"length":20}
# ],
# "rows":[
# ["sensor1","2021-01-06 16:30:00 000:000:000",1],
# ["sensor2","2021-01-06 16:30:00 000:000:000",1],
# ["sensor1","2021-01-06 18:00:00 000:000:000",1],
# ["sensor2","2021-01-06 18:00:00 000:000:000",1],
# ["sensor1","2021-01-06 19:30:00 000:000:000",1],
# ["sensor2","2021-01-06 19:30:00 000:000:000",1],
# ]
# }
# }