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

order in device_Id_array #11

Closed pol22pol closed 3 years ago

pol22pol commented 3 years ago

In fusionsolarapp.sh you are using static relation to second position in array device_Id_array. You should check type of device because fusion can send device in other order. For example in my installation I received

Device 1: 7534929584736
Smart String Inverter   Inverter Type: SUN2000-5KTL-M0
Device Name: HV20500....
Device SN: HV20500....
Software version: V100R001C00SPC122

Device 2: 45711197793123
Dongle  Device Name: HV20500....
Device SN: HV20500....
Software version: V100R001C00SPC115
BlazejosP commented 3 years ago

Thanks for mentioning that. That was for now just the temporary solution just to proof that data can be pulled and show on the screen even if is just working in this specific configuration One Plant -> 2 devices [first inverter second Dongle] I have exactly the same configuration . I d'like to write interface which will show dynamically data on screen with use of TUI LINUX terminal TUI for user usage here you will be able chose from which Plant (Is possible more than one) and which device (as you mentioned can be in different order or can be more than one inverter or even more devices battery for example) you can present data on screen. Second issue is when TUI will be written will be just for user lookup sometimes. Real use of this script will be automatically pull up data to InfluxDB/domoticz/MQTT. Actually my plan is to made in TUI configuration option where you chose what will be scraped from which Plant->specific device that will be saved in config file and then in background file will pull-up data which you chosen before with use of TUI.

BlazejosP commented 3 years ago

No that is my

Device 1: [12345679]
Dongle  Device Name: bla bla
Device SN: [bla bla]
Software version: V100R001C00SPC111

Device 2: [12345679]
Smart String Inverter   Inverter Type: SUN2000-5KTL-M0
Device Name: [bla bla] 
Device SN: [bla bla]
Software version: V100R001C00SPC120

So inverter in in second place as (Device 2) That is when I call inverter device inside different functions I use position 1 in array we start from 0 in my case that is dongle in your case is reverse as you mentioned in your previous post.

My case

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

Proposition of solution for your configuration

getDevRealKpi  ${device_Id_array[0]} ${device_TypeId_array[0]}          
getDevFiveMinutes ${device_Id_array[0]} ${device_TypeId_array[0]} $curent_time
getDevKpiDay ${device_Id_array[0]} ${device_TypeId_array[0]} $curent_time
getDevKpiMonth ${device_Id_array[0]} ${device_TypeId_array[0]} $curent_time
getDevKpiYear ${device_Id_array[0]} ${device_TypeId_array[0]} $curent_time

But configurations and order of devices my be different for any person that is you have right is necessary to solve this in dynamical way whatever devices and order person will have. So this now is just temporary until I wrote interface in TUI and such numbers will be inserted inside functions in dynamically way. BTW if you d'like contribute your code related to this problem I will be really happy just create pull request :)

The same problem is with Power plants. I have only one because small solar installation but may existing peoples with more than one Plant. that is now is hardcoded position 0 in array. That must be also changed dynamically way

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

# Statistical data about whole Power Plant

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