Get query to my ecoflow River Pro

Hello

In my homey pro I want to to do a flow to get the level of the battery in my ecoflow: if battery level is lower than 20% send me a message. How can I do ? Ecoflow gave me this request below and I don’t know how to use it in my homey pro. Someone could help me ? Than you very much. Best

curl -X GET \ https://api.ecoflow.com/iot-service/open/api/device/queryDeviceQuota?sn=ABC \ -H ‘Content-Type: application/json’ \ -H 'appKey: 123456’ \ -H 'secretKey: 123456’

Hey, there are quite some examples for fetch through HomeyScript.
You might want that, since its just a request that you need executed.

(Sorry for the short answer, but i’m on my phone)

Thank you very much for your help. I install HomeyScript, I took the exemple “example-fetch.js” and replace the fetch of the example by curl -X GET \ https://api.ecoflow.com/iot-service/open/api/device/queryDeviceQuota?sn=MYSERIAL \ -H ‘Content-Type: application/json’ \ -H 'appKey: MYAPPKEY’ \ -H 'secretKey: MYSECRETKEY’ and it’s not working. I m not a coder so I don’t understand much about it. Do you have an idea how to write the code as it’s work ? Thank you very much.

Yeah, ill take a look tomorrow.

1 Like

You need to fill in the serial, key and secret.
But then it should work, i get a correct deny.

const res = await fetch('https://api.ecoflow.com/iot-service/open/api/device/queryDeviceQuota?sn=MYSERIAL', {
  headers: {
      'Content-Type': 'application/json',
      'appKey': 'MYAPPKEY',
      'secretKey': 'MYSECRETKEY'
    },
});
if (!res.ok) {
  throw new Error(res.statusText);
}
// Get the body JSON
const body = await res.json();

console.log(body);

Hello, thank you so much. I will try it, keep you in touch. Best

1 Like

Hello,

I have this output : { code: ‘6047’, message: ‘device does not exist’ }

I will check with the manufacturer

Best, A

1 Like