Skip to main content

Read Telemetry

Having a list of devices with their telemetry attributes and commands, we can use the HTTP API to read telemetry and execute commands. Let's start by reading telemetry.

Current Telemetry​

Method telemetry/v1/now allows you to read the last received telemetry value for specified devices. See method reference to get full information.

Let's request telemetry attributes uptime on device 123e4567-e89b-12d3-a456-426614174000:

$ curl http://enapter-gateway.local/api/telemetry/v1/now -X GET -G \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d 'devices[123e4567-e89b-12d3-a456-426614174000]=uptime'

You should get a success response containing value and timestamp for every requested telemetry attribute:

{
"devices": {
"123e4567-e89b-12d3-a456-426614174000": {
"uptime": {
"value": 12345,
"timestamp": 1659860807
}
}
}
}

Time Series​

Method telemetry/v1/timeseries allows you to request time series — a sequence of measurements, ordered in time. See method reference to get full information.

Let's request time series for voltage on device 123e4567-e89b-12d3-a456-426614174000:

$ curl http://enapter-gateway.local/api/telemetry/v1/timeseries -X POST \
-H 'X-Enapter-Auth-Token: {ACCESS_TOKEN}' \
-d '{
"from": "2022-10-11T00:00:00Z",
"to": "2022-10-11T00:01:00Z",
"granularity": "1s",
"telemetry": [{
"device": "123e4567-e89b-12d3-a456-426614174000",
"attribute": "voltage",
"aggregation": "avg"
}]
}'

You should get a success response containing time series data in CSV format:

ts,telemetry=voltage device=123e4567-e89b-12d3-a456-426614174000 aggregation=auto granularity=1s gap_filling_method=none gap_filling_look_around=0s
1665446400,4.3087
1665446410,4.3556
1665446419,4.3712
1665446428,4.3325
1665446437,4.3712
1665446445,4.3481
1665446454,4.3169
Hardware diversity is welcome. Integrate any device into a unified energy network.
© 2024 Enapter
Developer toolkit
DocumentationReference