Hallo,
hat jemand Erfahrungen, wie man sich in Javascript mit der neuen Ecoflow-Api verbinden kann?
Die Dokumentation zeigt wie es per https funktioniert:
https://developer-eu.ecoflow.com/us/document/introduction
Ist es möglich das auch mit Javascript umzusetzen?
Um die Stromabgabe der Powerstream abzufragen, müsste man wahrscheinlich diesen String:
params.quotas=20_1.permanentWatts&sn=meineseriennr&accessKey=meinaccesskey&nonce=123456×tamp=1725201337126
verschlüsseln und mit Curl senden.
Hier ein Teil der Original-Doku (siehe Link oben)
Step 1: request parameters must be sorted by ASCII value and concatenated with characters =, &
E.g. str=param1=value1¶m2=value2
Step 2: if the type is nested, expand and splice according to the method of step 1.
Step 3: concatenate accessKey, nonce, timestamp
E.g. str=param1=value1¶m2=value2&accessKey=***&nonce=...×tamp=...
Step 4: encrypt
E.g. byte[] signBytes = HMAC-SHA256(str, secretKey)
Step 5: convert byte[] to hexadecimal string. String sign = bytesToHexString(signBytes)
E.g. sign=85776ede686fe4783eac48135b0b1748ba2d7e9bb7791b826dc942fc29d4ada8
Step 6: add accessKey, nonce, timestamp, sign to HTTP header
Step 7: get request data according to Content-Type header
Step8: verify that the steps to generate the signature are correct
// request
curl -X GET https://api-e.ecoflow.com/iot-open/sign/device/list \
-H 'accessKey:OCHzRuj6NLF7o43***' \
-H 'timestamp:1681796503289' \
-H 'nonce:234762' \
-H 'sign:f560c3e31d96ad31e4567939f9b3dca7b2c454ca7003f60***'
// response
{
"code":"0",
"message":"Success",
"data":[
{
"sn":"DCABZ****",
"online":1
}
]
}