rustyy / ecoflow-api

sdk for ecoflow api
https://rustyy.github.io/ecoflow-api/
MIT License
0 stars 0 forks source link

Feature Request: Include "productName" in getDevicesPlain response #2

Closed Thomptronics closed 1 month ago

Thomptronics commented 1 month ago

The EcoFlow API now returns product names when you query a device list. It would be great if getDevicesPlain() included this new productName field in its response.

rustyy commented 1 month ago

Thanks for the information. Didn't noticed it yet. Gonna add it.

rustyy commented 1 month ago

@Thomptronics - I had a look at the docs and the response from the api as well. Question: what do you mean by "productName" - do you mean the name that you can set per device within the app - like "My Delta2" or do you mean the product-type like delta2, powerstream etc?

In the docs only the "deviceName" is mentioned and only this is returned by the API. So the current API output is as follows:

{
    "code": "0",
    "message": "Success",
    "data": [
      { "sn": "HW51XXXXX", "online": 1, "deviceName": "PowerStream" },
      { "sn": "HW52XXXXX", "online": 1, "deviceName": "ESP1" },
      {
        "sn": "HW52XXXXX",
        "online": 1,
        "deviceName": "My desk"
      },
      { "sn": "HW52XXXX", "online": 1, "deviceName": "TV" }
    ]
}

This is also returned by the getDevicesPlain()-method.

If you have additional information, just let me know.

Nid01 commented 1 month ago

@Thomptronics - I had a look at the docs and the response from the api as well. Question: what do you mean by "productName" - do you mean the name that you can set per device within the app - like "My Delta2" or do you mean the product-type like delta2, powerstream etc?

In the docs only the "deviceName" is mentioned and only this is returned by the API. So the current API output is as follows:

{
    "code": "0",
    "message": "Success",
    "data": [
      { "sn": "HW51XXXXX", "online": 1, "deviceName": "PowerStream" },
      { "sn": "HW52XXXXX", "online": 1, "deviceName": "ESP1" },
      {
        "sn": "HW52XXXXX",
        "online": 1,
        "deviceName": "My desk"
      },
      { "sn": "HW52XXXX", "online": 1, "deviceName": "TV" }
    ]
}

This is also returned by the getDevicesPlain()-method.

If you have additional information, just let me know.

@rustyy I just reloaded my Home Asisstant integration and am able to confirm, that the JSON response now contains productName elements. Thanks to that I can remove some code needed to determine the product by the SN. 😄

"data": [
        {
            "sn": "DAEB***********",
            "deviceName": "DELTA Max",
            "online": 0,
            "productName": "DELTA Max"
        },
        {
            "sn": "HW51************",
            "deviceName": "PowerStream",
            "online": 1,
            "productName": "PowerStream"
        },
        {
            "sn": "HW52************",
            "deviceName": "Smart Plug 2",
            "online": 0,
            "productName": "Smart Plug"
        },
        {
            "sn": "HW52************",
            "deviceName": "Smart Plug Fridge",
            "online": 0,
            "productName": "Smart Plug"
        },
        {
            "sn": "HZ31************",
            "deviceName": "SAST Left",
            "online": 1,
            "productName": "Single Axis Solar Tracker"
        },
        {
            "sn": "HZ31************",
            "deviceName": "SAST Right",
            "online": 1,
            "productName": "Single Axis Solar Tracker"
        }
    ]
Thomptronics commented 1 month ago

@Thomptronics - I had a look at the docs and the response from the api as well. Question: what do you mean by "productName" - do you mean the name that you can set per device within the app - like "My Delta2" or do you mean the product-type like delta2, powerstream etc?

In the docs only the "deviceName" is mentioned and only this is returned by the API. So the current API output is as follows:

{
    "code": "0",
    "message": "Success",
    "data": [
      { "sn": "HW51XXXXX", "online": 1, "deviceName": "PowerStream" },
      { "sn": "HW52XXXXX", "online": 1, "deviceName": "ESP1" },
      {
        "sn": "HW52XXXXX",
        "online": 1,
        "deviceName": "My desk"
      },
      { "sn": "HW52XXXX", "online": 1, "deviceName": "TV" }
    ]
}

This is also returned by the getDevicesPlain()-method.

If you have additional information, just let me know.

@rustyy See Nid01's response above for the additional info. And, thanks again for looking into this. If you aren't getting the same results, I wonder if it's a difference between api-e (Europe) and api-a (America).

rustyy commented 1 month ago

interesting 🧐 ... which host are you using @Thomptronics , @Nid01 ? I had a similar assumption about a difference between EU and US

Nid01 commented 1 month ago

interesting 🧐 ... which host are you using @Thomptronics , @Nid01 ?

@rustyy I'm connecting to api-e.

Thomptronics commented 1 month ago

@rustyy I'm using https://api-a.ecoflow.com

rustyy commented 1 month ago

Okay now I get it as well 😅

rustyy commented 1 month ago

So there is a new version for the schema-package released. If you update, getDevicesPlain() returns the "productName"

Thomptronics commented 1 month ago

Awesome. Thanks so much. Will this update to github automatically update NPM, or is that a separate operation for you?

rustyy commented 1 month ago

The package has already been updated on NPM , so you need to ensure to have @ecoflow-api/schemas in version 0.0.9. You can check by running "npm outdated".

Thomptronics commented 1 month ago

Got it. Works beautifully. Cheers.

FYI, if you need someone to help test any Delta Pro or SHP1 additions, I'd be happy to help.

rustyy commented 1 month ago

@Thomptronics , this would be great!

On the one hand could provide some data-examples that gets returned by the getDevicePropertiesPlain so I could create some schemas for this, as the official docs at some points are misleading and its not clear how the actual structure looks like, especially for the SHP.

Here is an example on how I did at least for the devices I own or where the docs are clear: packages/rest-client/src/fixtures/delta2Properties.ts - a json would be totally fine. If you do so, strip off/change all sensitive values. The most important things are the structure itself.

On the other hand, you could then test all the commands, once I've implemented the DP and SHP device classes.

Feel free to open up additional feature requests for those devices :) ... you may provide some data there or send me an email

Thomptronics commented 1 month ago

Files sent via email. Glad to help.

rustyy commented 1 month ago

Feature requests created for SHP and DP: