Charger — Commands
Fetch pending command (long polling)
The charger polls for pending commands using long polling. If no command is available, the request hangs until the timeout expires (default 30 seconds, max 60) or a command arrives.
Related: proposed remote diagnostic command types (reboot, run_self_test, calibrate_sensor, fetch_logs) are documented in Proposed Extensions.
GET
/
device
/
commands
Fetch pending command (long polling)
curl --request GET \
--url https://api.telluspower.example.com/v1/device/commands \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telluspower.example.com/v1/device/commands"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.telluspower.example.com/v1/device/commands', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.telluspower.example.com/v1/device/commands",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.telluspower.example.com/v1/device/commands"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.telluspower.example.com/v1/device/commands")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telluspower.example.com/v1/device/commands")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"data": {
"command_id": "<string>",
"command": "<string>",
"params": {},
"expiry": "2023-11-07T05:31:56Z"
}
}Authorizations
Charger-side bearer token. Obtained by exchanging device_id and
device_secret (issued at registration) at /v1/device/token.
Valid for 24 hours.
Query Parameters
Required range:
x >= 1Maximum wait time in seconds.
Required range:
1 <= x <= 60Response
200 - application/json
Command available, or no command (timeout).
Standard response envelope. code is 0 on success and a non-zero
application code on error (see Error Codes — §14).
⌘I
Fetch pending command (long polling)
curl --request GET \
--url https://api.telluspower.example.com/v1/device/commands \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.telluspower.example.com/v1/device/commands"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.telluspower.example.com/v1/device/commands', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.telluspower.example.com/v1/device/commands",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.telluspower.example.com/v1/device/commands"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.telluspower.example.com/v1/device/commands")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telluspower.example.com/v1/device/commands")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"code": 123,
"message": "<string>",
"data": {
"command_id": "<string>",
"command": "<string>",
"params": {},
"expiry": "2023-11-07T05:31:56Z"
}
}