BlazejosP / huawei-sun2000-API-CLI

Huawei SUN2000 compatible devices which working with Huawei Cloud Service command line bash API for monitoring or download data from their FusionSolarApp API
https://www.buymeacoffee.com/blazejosP
GNU General Public License v3.0
110 stars 15 forks source link

info about fusionsolarapp.sh #12

Open BlazejosP opened 3 years ago

BlazejosP commented 3 years ago

Until whole code of fusionsolarapp.sh will be written you my encounter problems with this file not everything is ready. In actually version kioskmode.sh is now fully working with InfluxDB/MQTT/Domoticz and you can use this file for pull basic data or download older version 1.2 where kioskmode.sh&fusionsolarapp.sh are ready to use and can pull simpler data and insert them in InfluxDB and are fully working that is second temporary solution

As for now fusionsolarapp.sh can pull data from Huawei cloud service and show on screen nothing else some parts are temporary hardcoded like positions of Power Plants & Devices inside question to functions look into order in device_Id_array. If you use this new version you must modified them manually to fit to your configuration. But that is because code is in progress and that will be solved in not so long time. Such things will change dynamically in next versions of this file. So If you encounter problems I'm happy to share your solution or propose some on this forum.

If someone of you are in mood for experimenting I mention here some tips for pull more data from this experimental fusionsolarapp.sh

If you look on ${stations_Code_array[0]} I put 0 because I have only one plant and array counting starts from position 0 if you have more you can put there different number equal to your second power plant for example. And pull different data from this second plant.

getStationRealKpi ${stations_Code_array[0]} 
getKpiStationHour ${stations_Code_array[0]} $curent_time
getKpiStationDay ${stations_Code_array[0]} $curent_time
getKpiStationMonth ${stations_Code_array[0]} $curent_time
getKpiStationYear ${stations_Code_array[0]} $curent_time

If you look on this second variable $curent_time we insert into functions actually time but API allows ask for every time since your plants were created. So you can ask about hourly production in historically day actually by hardcoding particular date

# time Sat Jan 30 2021 11:39:40 in unix time ms format for tests
#161200678044
getKpiStationHour ${stations_Code_array[0]} 161200678044

and answer will be production for every hour in 30 January 2021

Use this page to have times for experimenting Epoch converter

The same issue is with particular device info First we ask about devices inside plant we must insert our station code and number of plants related to our account like previously my station is only one so have index 0. That ma be different only if you have more plants.

# We start function to get list of devices inside one particular plant
getDevList ${stations_Code_array[0]} $number_of_plants 

We receive answer

API getDevList connection OK
Normal Status
Build Code: 2
Time of your Request to API: nie, 4 kwi 2021, 13:31:14 CEST

Plant 1: XXXXXXXXXX
Number of devices: 2

    Device 1: 5555555555555
    Dongle  Device Name: XXXXXXXXXX
    Device SN: XXXXXXXXXX
    Software version: V100R001C00SPC111

    Device 2: 4444444444444
    Smart String Inverter   Inverter Type: SUN2000-5KTL-M0
    Device Name: XXXXXXXXXX
    Device SN: XXXXXXXXXX
    Software version: V100R001C00SPC120

So we can only ask about parameters of inverter if you ask about dongle you receive error from API you can check yourself. In my case inverter is as Device 2. By indexing in array that is 1 because we start with 0. That is why in question to API I insert ${device_Id_array[1]} below.

# Devices data precision all voltages etc real-time
getDevRealKpi  ${device_Id_array[1]} ${device_TypeId_array[1]}          
getDevFiveMinutes ${device_Id_array[1]} ${device_TypeId_array[1]} $curent_time
getDevKpiDay ${device_Id_array[1]} ${device_TypeId_array[1]} $curent_time
getDevKpiMonth ${device_Id_array[1]} ${device_TypeId_array[1]} $curent_time
getDevKpiYear ${device_Id_array[1]} ${device_TypeId_array[1]} $curent_time

In case of variable $curent_time you can experiment with different times inserted manually hardcoded instead of variable into function in the same way like in case of Plants so you should receive data for different time periods.

That is how you can experimenting now until code for that part will be written and such manipulations will be handled by TUI and program itself.