tijsverkoyen / HomeAssistant-FusionSolar

Integrate FusionSolar into your Home Assistant.
MIT License
133 stars 25 forks source link

getStationList deprecated? #68

Closed arohl closed 1 year ago

arohl commented 1 year ago

I am in Australia and using the API at https://au5.fusionsolar.huawei.com/thirdData/

The integration authenticates fine but fails when it calls getStationList. The log says

Retrieving the data for https://au5.fusionsolar.huawei.com/thirdData/getStationList failed with failCode: 401, message: None

I have a document from Huawei titled Northbound Interface Reference- V6(SmartPVMS) and dated 19th January 2023 which says:

https://Domain name of the management system/thirdData/getStationList is about to go offline

and that the new function is

https://Domain name of the management system/thirdData/stations

Using Postman, I can confirm that getStationList doesn't work (with not surprisingly the same error code as the integration reports) and that stations does return a plantCode.

Is this a uniquely Australian situation? Or are they perhaps trying the updated API on us first?

tijsverkoyen commented 1 year ago

I don't know of this is something specific for the Australian market or not. Would you be so kind to contact the support and ask them? You can put me in cc (fusionsolar [at] verkoyen.eu).

tijsverkoyen commented 1 year ago

@arohl Is you would be so kind to email (fusionsolar [at] verkoyen.eu) me your OpenAPI credentials then I will try to make it work with the new endpoint.

arohl commented 1 year ago

Done!

tijsverkoyen commented 1 year ago

@arohl From what I can see the documentation is completely different. The calls also return data in a completely different format. So I don't think it will be a simple fix.

I also get an empty list of stations if I call /thirdData/stations, with your credentials:

{
    "data": {
        "list": [],
        "pageCount": 1,
        "pageNo": 100,
        "pageSize": 100,
        "total": 1
    },
    "failCode": 0,
    "message": "get plant list success",
    "success": true
}

Could it be that no stations are linked to your account?

tijsverkoyen commented 1 year ago

Nm. I should use pageNo: 1

arohl commented 1 year ago

Interesting - I thought pageNo was mandatory and so would give an error if you didn't include it.

tijsverkoyen commented 1 year ago

Do you have a batter and power sensor installed? I don't get any data back for these devices. This is probably because they are not installed, or you don't have access

arohl commented 1 year ago

I certainly have a battery, so I guess I don’t have access. I can see the battery on the app. Can you please let me know what call you tried.

Andrew

From: Tijs Verkoyen @.> Date: Tuesday, 28 February 2023 at 8:48 pm To: tijsverkoyen/HomeAssistant-FusionSolar @.> Cc: Andrew Rohl @.>, Mention @.> Subject: Re: [tijsverkoyen/HomeAssistant-FusionSolar] getStationList deprecated? (Issue #68)

Do you have a batter and power sensor installed? I don't get any data back for these devices. This is probably because they are not installed, or you don't have access

— Reply to this email directly, view it on GitHubhttps://github.com/tijsverkoyen/HomeAssistant-FusionSolar/issues/68#issuecomment-1448122331, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACTZWLDE5ERA7BCEBLJWIGTWZXXZTANCNFSM6AAAAAAVIMQU2Y. You are receiving this because you were mentioned.Message ID: @.***>

tijsverkoyen commented 1 year ago

I will tag a release which should fix the issue. But the empty data for some of your devices should be checked by Huawei.

arohl commented 1 year ago

Are there simple instructions for how I install a tagged release so I can test?

tijsverkoyen commented 1 year ago

I just tagged the new release, So you can update the repository through HACS, or just wait a few hours until the version pops up in Home Assistant.

tijsverkoyen commented 1 year ago

Thx! Really appreciated!

tijsverkoyen commented 1 year ago

@arohl about the empty data for the Battery:

curl --location 'https://au5.fusionsolar.huawei.com/thirdData/getDevRealKpi' \
--header 'XSRF-TOKEN: x-REDACTED' \
--header 'Content-Type: application/json' \
--data '{
  "devIds": "1000000033759325",
  "devTypeId": "39"
}'

It responds with empty data:

{
    "data": [
        {
            "devId": 1000000033759325,
            "dataItemMap": {},
            "sn": "null"
        }
    ],
    "failCode": 0,
    "message": null,
    "params": {
        "currentTime": 1677590785939,
        "devIds": "1000000033759325",
        "devTypeId": 39
    },
    "success": true
}

For the Inverter it gets data:

curl --location 'https://au5.fusionsolar.huawei.com/thirdData/getDevRealKpi' \
--header 'XSRF-TOKEN: x-REDACTED' \
--header 'Content-Type: application/json' \
--data '{
  "devIds": "1000000033759324",
  "devTypeId": "1"
}'
arohl commented 1 year ago

Thx! Really appreciated!

Hope its enough for a G&T in Europe!

Its getting late here, so I'll update the easy way in the morning and get in touch with Huawei

tijsverkoyen commented 1 year ago

I will enjoy it for sure! Let me know if there is still something wrong.

Argosy87 commented 1 year ago

Hi, if the response is empty just ask your installer to set correct permissions. Had the same issue and installer forgot to set the rigth permissions. After that all the data will show.

aretokas commented 1 year ago

This doesn't affect just AU, it is likely to affect all endpoints (Can confirm on intl. as well) - In fact, I wrote almost the same code as you to fix it, but have now pulled across your changes.

The reference is here: https://support.huawei.com/enterprise/en/doc/EDOC1100261860/e2cc6ca3/to-be-offline-interfaces

Basically, my understanding is this:

If this was C# I could fix it in a flash :). However, I'm willing to test/poke my own code in there for review as nobody judges too harshly. I'd probably attack it in such a way that if /getStationList returns the error, attempt /stations. It's a little more work, but it ensures the result works for everyone.

Alternatively, a toggle in the settings to "Use the new interfaces" or something.

tijsverkoyen commented 1 year ago

@aretokas thx! I have contacted Huawei to see if there is way to programmatically decide which endpoint to use. Or how the user can check which endpoint to use. I will look into it further and probably implement a toggle or something like that.

arohl commented 1 year ago

Hi, if the response is empty just ask your installer to set correct permissions. Had the same issue and installer forgot to set the rigth permissions. After that all the data will show.

I emailed them and all sorted. Now just need to figure out what all the numbers mean!

tijsverkoyen commented 1 year ago

@arohl The integration is programmed against the docs you can find in https://github.com/tijsverkoyen/HomeAssistant-FusionSolar/tree/master/docs. All names for the entities are the ones used in the documentation.

aretokas commented 1 year ago

@tijsverkoyen here is the error it returns if you try to access it if you haven't seen it:

{ "data": null, "failCode": 401, "message": "Invalid access to current interface!", "params": {}, "success": false }

I feel like the easiest flow would be, try the original endpoint, and if you receive this error, try the new one. If that then works, flip a toggle in the background for the user so you skip the first check from that point onwards.

I certainly couldn't find any other way of identifying whether it was going to work or not. Not in their documentation and not with my stuffing around with the API and permissions etc. I'll be curious to know what they say.

tijsverkoyen commented 1 year ago

That would probably the way to go, or a setting. But if they can tell me how to decide it programmatically it would mean less useless calls

tijsverkoyen commented 1 year ago

Just an update: They're not really helpful at Huawei / Fusion Solar. So it will be probably a setting, or multiple calls. I will wait just till the weekend to see of I get a decent answer from Huawei / Fusion Solar. If not I will develop the setting / multiple calls.

Edvliet commented 4 months ago

I received a response from my provider: Het is mij bekend dat er onderhoud gepleegd wordt op het FusionSolar platform en dat daarbij deze functie even niet beschikbaar is. Daarop heeft Youen verder geen invloed.

Translated: I am aware that maintenance is being carried out on the FusionSolar platform and that this function is temporarily unavailable. The provider has no further influence on this.

So it seems that we have to wait until the maintenance is resolved...