jgriss / FusionSolarPy

A basic client to the Huawei Fusion Solar cloud interface for solar power plants
MIT License
31 stars 12 forks source link

Weird data Received from the new subdomains #24

Closed mtziortzis closed 3 months ago

mtziortzis commented 8 months ago

First off, thanks for this great library. I was using this just fine until i got migrated to the new subdomain. The data i receive now are a bit off. I verified:

Here is the response i am getting from the fsclient.get_last_plant_data(plant)

{'onGridPowerRatio': None, 'selfUsePower': {'time': '2024-02-11 13:03', 'value': None}, 'selfUsePowerRatioByUse': None, 'existInverter': True, 'totalBuyPower': None, 'existEnergyStore': False, 'totalProductPower': 25.67, 'existIrradiation': False, 'dischargePower': {'time': '2024-02-11 13:03', 'value': None}, 'radiationDosePower': {'time': '2024-02-11 13:03', 'value': None}, 'mainsUsePower': {'time': '2024-02-11 13:03', 'value': None}, 'buyPowerRatio': None, 'selfUsePowerRatioByProduct': None, 'totalSelfUsePower': None, 'chargePower': {'time': '2024-02-11 13:03', 'value': None}, 'existCharge': False, 'existMeter': False, 'onGridPower': {'time': '2024-02-11 13:03', 'value': None}, 'dieselProductPower': {'time': '2024-02-11 13:03', 'value': None}, 'disGridPower': {'time': '2024-02-11 13:03', 'value': None}, 'selfProvide': None, 'productPower': {'time': '2024-02-11 13:03', 'value': None}, 'usePower': {'time': '2024-02-11 13:03', 'value': None}, 'meterActivePower': {'time': '2024-02-11 13:03', 'value': None}, 'totalUsePower': 25.67, 'chargeAndDisChargePower': {'time': '2024-02-11 13:03', 'value': None}, 'existUsePower': False, 'totalOnGridPower': None}

The actual values of totalProductPower and also the value of stats.current_power_kw are way off.

Is there anything else i should try ? Notice all the 'None' values - i assume that is not right

remedix commented 8 months ago

any ideas @jgriss ? :)

Edit: I think i figured it out. It seems the plant_id being returned is not the one i use. After some debugging from their API i found another plant id and when i use that I get the exact same data back.

Edit2: Nevermind. That data just happen to match the ones i was expecting. It is not the right ones i was looking for. However after digging more around I found that the data i am looking for are coming from

uni003eu5.fusionsolar.huawei.com/rest/pvms/web/station/v1/overview/station-real-kpi

Can you please add this functionality there ?

jgriss commented 7 months ago

Hi @remedix

First of all thank you for reporting this issue! Unfortunately, my time to work on the package is very limited at the moment.

Since moving to the new API, I am also experiencing a lot of missing values in the plant_data structure. Yet, all the values that are returned are correct in my case. I just compared totalBuyPower, totalUsePower and totalOnGridPower etc.

Could you let me know, which values exactly you are looking for?

mtziortzis commented 7 months ago

Hi @jgriss Thank you for taking some time to look into this.

I think it comes down to state results. Let me explain.

In the current dashboard of fusionsolar there are two sets of data. The Plant KPIs (which seems to be off (delayed?) as shown here:

Screenshot 2024-03-11 at 9 57 04 AM

And the almost realtime data shown here:

Screenshot 2024-03-11 at 9 57 10 AM

The method fsclient.get_power_status() gets the first data (Plant KPIs) - the 'stale' ones

However the API endpoint uni003eu5.fusionsolar.huawei.com/rest/pvms/web/station/v1/overview/station-real-kpi seems to have the latest (real time) ones.

I tried the following from the browser

Nothing seems to be changing the stale data so they must be coming from the server.

I think fsclient.get_power_status() should get the data from the endpoint as explained above - this will ensure the latest data. I hope this steers you to the right direction.

jgriss commented 3 months ago

Hi @mtziortzis ,

Sorry, time available for the project is a bit irregular...

Your observation is correct, the numbers shown in the overview seem to be stale.

Yet, you can already get the up-to-date data shown in the table using the get_plant_stats function combined with get_last_plant_data.

There, the productPower slot corresponds to the current production value.

jgriss commented 3 months ago

Sorry, just read the first part of your message. In my tests, the values shown in the table and the ones in get_last_plant data match. I'll check how I can support the new endpoint though

jgriss commented 3 months ago

Hi,

A second update: The more up-to-date data is also available in the station list which you can retrieve using get_station_list

jgriss commented 3 months ago

@mtziortzis I've added a new function get_current_plant_data in version 0.0.24 that uses the new endpoint.