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

getDevRealKpi date: invalid date ‘@’ #22

Closed mnuxx closed 2 years ago

mnuxx commented 3 years ago

String Inverter Model: SUN2000-30KTL-M3 API getDevRealKpi connection OK Normal Status date: invalid date ‘@’ Time of your Request to API:

BlazejosP commented 3 years ago

From this what I read in your previous post you have:

First question this error appears when you ask about getDevRealKpi from which device? Can you upload screenshot when this error appears (of course please remove some data like inverter serial number etc)

BTW that is strange because when we ask about realtime data date is not sended into this particular function

getDevRealKpi ${device_Id_array[0]} ${device_TypeId_array[0]}

Device Id number and Device type number

mnuxx commented 3 years ago

Please wait connecting! Connection to API

API login to server OK Username & Password accepted by Huawei Server Normal Status

API getStationList connection OK Normal Status Time of your Request to API: R 20 aug 2021 17:10:43 EEST

    Plant 1: NE=somenr
    Plant Name: myplant
    Address of the plant: myaddress
    Installed capacity: 0 MWp
    Plant contact: Encrypted
    Contact phone number: Encrypted
    Poverty alleviation plant: Unknown

API getDevList connection OK Normal Status Time of your Request to API: R 20 aug 2021 17:10:44 EEST

Plant 1: NE=somenr Number of devices: 3

    Device 1: logg
    Distributed SmartLogger Model: Smart Logger
    Device Name: logg
    Device SN: 
    Software version: V300R001C00SPC050
    longitude: 
    latitude:

    Device 2: meter
    Grid meter      Model: PowerMeter
    Device Name: meter
    Device SN: 
    Software version: V100R001C01AM001
    longitude: 
    latitude: 

    Device 3: inveter
    String Inverter Model: SUN2000-30KTL-M3
    Device Name: inveter
    Device SN: sn
    Software version: V100R001C20SPC107
    longitude: 
    latitude:

API getDevRealKpi connection OK Normal Status date: invalid date ‘@’ Time of your Request to API:

Please wait disconnecting! Disconnection from API

API logout from server OK Logout accepted by Huawei Server Normal Status

BlazejosP commented 3 years ago

From this what I see on your account finding Plant and then devices working correctly.

Problem starts when you ask devices about real-time data

first some observations from code of functions.sh line 165 Device_type_ID () your first device is with

So if we go to function getDevRealKpi() in functions.sh line 3001 you can ask about realtime data only Grid meter and String inverter that is from documentation of Huawei devices and is implemented in code look to line 3030 in functions.sh they are

#we have inverter
if [[ $2 == 1  ]];

only for that two devices. Distributed SmartLogger simply haven't possibility to be asked about real-time data. My mistake I should write code which will inform user that such operation is not permitted.

So now probably you have not modified fusionsolarapp.sh like described #https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/12

in your case line 188

# Devices data precisious all voltages etc real-time
getDevRealKpi  ${device_Id_array[0]} ${device_TypeId_array[0]}  

should be different than 0 because in array under 0 is Distributed SmartLogger which can't working with this function under 1 Grid meter and under 2 String Inverter so you can insert there such code

# Devices data precisious all voltages etc real-time
# ask Grid meter
getDevRealKpi  ${device_Id_array[1]} ${device_TypeId_array[1]}  
# ask String Inverter
getDevRealKpi  ${device_Id_array[2]} ${device_TypeId_array[2]}  

Hope that will help and solve your problem if not we can start search for problem much deeper. Tell me what is behavior of fusionsolarapp.sh now?

mnuxx commented 3 years ago

Now i get Device 3: String Inverter Model: SUN2000-30KTL-M3 Device Name: Device SN: Software version: V100R001C20SPC107 longitude: latitude:

date: invalid date ‘+%s’ functions.sh: line 2315: -3: substring expression < 0 functions.sh: line 2316: 1629633725- : syntax error: operand expected (error token is "- ")

januweness commented 3 years ago

What have you have typed?

If you type ./fusionsolarapp.sh 20210822 for today, it would work.

From: "mnuxx" @.> To: "BlazejosP/huawei-sun2000-API-CLI" @.> Cc: "Subscribed" @.***> Sent: Sunday, August 22, 2021 2:06:14 PM Subject: Re: [BlazejosP/huawei-sun2000-API-CLI] getDevRealKpi date: invalid date ‘@’ (#22)

Now i get Device 3: String Inverter Model: SUN2000-30KTL-M3 Device Name: Device SN: Software version: V100R001C20SPC107 longitude: latitude:

date: invalid date ‘+%s’ functions.sh: line 2315: -3: substring expression < 0 functions.sh: line 2316: 1629633725- : syntax error: operand expected (error token is "- ")

— You are receiving this because you are subscribed to this thread. Reply to this email directly, [ https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/22#issuecomment-903258699 | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/ABTM3AHOHAQRD5ZOCF5Q7PTT6DR3NANCNFSM5CMWL46Q | unsubscribe ] . Triage notifications on the go with GitHub Mobile for [ https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 | iOS ] or [ https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email | Android ] .

This message is intended only for the recipient(s) named above. It may contain proprietary information and/or protected content. Any unauthorised disclosure, use, retention or dissemination is prohibited. If you have received this e-mail in error, please notify the sender immediately. ESA applies appropriate organisational measures to protect personal data, in case of data privacy queries, please contact the ESA Data Protection Officer @.***).

mnuxx commented 3 years ago

Not for me unfortunately, throw me that invalid date error. Same error came with or without adding date to script.

januweness commented 3 years ago

Ok, sorry about it, this is now fixed.

From: "mnuxx" @.> To: "BlazejosP/huawei-sun2000-API-CLI" @.> Cc: "Jan-Uwe Ness" @.>, "Comment" @.> Sent: Sunday, August 22, 2021 4:39:24 PM Subject: Re: [BlazejosP/huawei-sun2000-API-CLI] getDevRealKpi date: invalid date ‘@’ (#22)

Not for me unfortunately, throw me that invalid date error. Same error came with or without adding date to script.

— You are receiving this because you commented. Reply to this email directly, [ https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/22#issuecomment-903278970 | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/ABTM3AFDIMPQX6OG3WXADRLT6EDZZANCNFSM5CMWL46Q | unsubscribe ] . Triage notifications on the go with GitHub Mobile for [ https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 | iOS ] or [ https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email | Android ] .

This message is intended only for the recipient(s) named above. It may contain proprietary information and/or protected content. Any unauthorised disclosure, use, retention or dissemination is prohibited. If you have received this e-mail in error, please notify the sender immediately. ESA applies appropriate organisational measures to protect personal data, in case of data privacy queries, please contact the ESA Data Protection Officer @.***).

mnuxx commented 3 years ago

PI getKpiStationHour connection OK Normal Status Time of your Request to API: L 21 aug 2021 00:00:00 EEST Response time: 167408 s

API getDevRealKpi connection OK Normal Status date: invalid date ‘@’ Time of your Request to API:

Please wait disconnecting! Disconnection from API

januweness commented 3 years ago

Strange, here all fine. With direct download and filling config.conf, without changing anything, I get:

./fusionsolarapp.sh Please wait connecting! Connection to API

API login to server OK Username & Password accepted by Huawei Server Normal Status

API getStationList connection OK Normal Status Time of your Request to API: dom 22 ago 2021 21:37:25 CEST

Plant 1: _____ Plant Name: __ Address of the plant: _ Installed capacity: __ MWp Plant contact: Encrypted Contact phone number: Encrypted Poverty alleviation plant: No

API getDevList connection OK Normal Status Time of your Request to API: dom 22 ago 2021 21:37:27 CEST

Plant 2: ____ Number of devices: 2

Device 1: __ Residential inverter Model: SUN2000-2KTL-L1 Device Name: __ Device SN: Software version: V200R001C00SPC109 longitude: _____ latitude: ____

Device 2: __ Power Sensor Model: null Device Name: Power Sensor Device SN: null Software version: null longitude: ____ latitude: ___

API getKpiStationHour connection OK Normal Status Time of your Request to API: mié 26 may 2021 00:18:56 CEST Response time: 7679913 s

API getDevRealKpi connection OK Normal Status Time of your Request to API: dom 22 ago 2021 21:37:31 CEST

Numbers of Devices to check: 1

Residential inverter ID: _____ Inverter status: Standby: No sunlight Grid AB voltage: 0 V Grid BC voltage: 0 V Grid CA voltage: 0 V Phase A voltage: 0 V Phase B voltage: 0 V Phase C voltage: 0 V Grid phase A current: 0 A Grid phase B current: 0 A Grid phase C current: 0 A Inverter conversion efficiency (manufacturer): 0 % Inverter internal temperature: 0 °C Power factor: 0 Grid frequency: 0 Hz Active power: 0 Kw Reactive output power: 0 KVar Yield today: 0 Kwh MPPT (Maximum Power Point Tracking) total input power: 0 Kw PV1 input voltage: 0 V PV2 input voltage: 0 V PV3 input voltage: 0 V PV4 input voltage: 0 V PV5 input voltage: 0 V PV6 input voltage: 0 V PV7 input voltage: 0 V PV8 input voltage: 0 V PV1 input current: 0 A PV2 input current: 0 A PV3 input current: 0 A PV4 input current: 0 A PV5 input current: 0 A PV6 input current: 0 A PV7 input current: 0 A PV8 input current: 0 A Total yield: 306.42 Kwh Inverter last startup time: sáb 21 ago 2021 07:54:51 CEST Inverter last shutdown time: sáb 21 ago 2021 21:01:59 CEST Total DC input energy: Kwh MPPT 1 DC total energy: ____ Kwh MPPT 2 DC total energy: 0 Kwh MPPT 3 DC total energy: 0 Kwh MPPT 4 DC total energy: 0 Kwh Status: Disconnected

Please wait disconnecting! Disconnection from API

API logout from server OK Logout accepted by Huawei Server Normal Status

From: "mnuxx" @.> To: "BlazejosP/huawei-sun2000-API-CLI" @.> Cc: "Jan-Uwe Ness" @.>, "Comment" @.> Sent: Sunday, August 22, 2021 9:33:48 PM Subject: Re: [BlazejosP/huawei-sun2000-API-CLI] getDevRealKpi date: invalid date ‘@’ (#22)

PI getKpiStationHour connection OK Normal Status Time of your Request to API: L 21 aug 2021 00:00:00 EEST Response time: 167408 s

API getDevRealKpi connection OK Normal Status date: invalid date ‘@’ Time of your Request to API:

Please wait disconnecting! Disconnection from API

— You are receiving this because you commented. Reply to this email directly, [ https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/22#issuecomment-903319310 | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/ABTM3AG4EH2MQYQCUPES5IDT6FGJZANCNFSM5CMWL46Q | unsubscribe ] . Triage notifications on the go with GitHub Mobile for [ https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 | iOS ] or [ https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email | Android ] .

This message is intended only for the recipient(s) named above. It may contain proprietary information and/or protected content. Any unauthorised disclosure, use, retention or dissemination is prohibited. If you have received this e-mail in error, please notify the sender immediately. ESA applies appropriate organisational measures to protect personal data, in case of data privacy queries, please contact the ESA Data Protection Officer @.***).

mnuxx commented 3 years ago

API getKpiStationHour connection OK Normal Status Time of your Request to API: P 22 aug 2021 00:00:00 EEST Response time: 86029 s

API getDevRealKpi connection OK Normal Status date: invalid date ‘@’ Time of your Request to API:

Please wait disconnecting! Disconnection from API

API logout from server OK Logout accepted by Huawei Server Normal Status

mnuxx commented 3 years ago

Withoud date in shell script parameter: API getKpiStationHour connection OK Normal Status Time of your Request to API: K 26 mai 2021 01:18:56 EEST Response time: 7720254 s date: invalid date ‘@’

paste: tempu9PJZr.dates: No such file or directory

API getDevRealKpi connection OK Normal Status date: invalid date ‘@’ Time of your Request to API:

Please wait disconnecting! Disconnection from API

and With date: API getKpiStationHour connection OK Normal Status Time of your Request to API: E 23 aug 2021 00:00:00 EEST Response time: 35475 s

API getDevRealKpi connection OK Normal Status date: invalid date ‘@’ Time of your Request to API:

Please wait disconnecting! Disconnection from API

BlazejosP commented 3 years ago

Now i get Device 3: String Inverter Model: SUN2000-30KTL-M3 Device Name: Device SN: Software version: V100R001C20SPC107 longitude: latitude:

date: invalid date ‘+%s’ functions.sh: line 2315: -3: substring expression < 0 functions.sh: line 2316: 1629633725- : syntax error: operand expected (error token is "- ")

I just looking for your case and I think that error in your case happens because problems with calculation of time which is used to show difference between question to API and answer in seconds. Is possible that answer happens before question and that is why time with minus "-" what is impossibility.

Lines 2315 and 3216

local curent_time_of_request=$(echo ${collectTime::-3})
local difference_in_secounds=$(( $curent_time_actually-$curent_time_of_request ))

As you see we first calculate curent_time_of_request and then local difference_in_secounds and my feeling is that in your case this time is something like -5s what is impossibility! Why meaby time zone is incorrect on your computer. I also don't know why this error happens in getKpiStationHour() function if you try use getDevRealKpi().

My proposition is in fussionsolarapp.sh use only functions

login_to_API
getStationList
getDevList ${stations_Code_array[0]} $number_of_plants
getDevRealKpi  ${device_Id_array[2]} ${device_TypeId_array[2]}  
logout_from_API

To use only getDevRealKpi number in your case 2 because that is String inverter which is third in your power plant based on https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/19 your data

Then you have negative response time try for test comment this part of code in this function getDevRealKpi() file function.sh lines 3792 to 3804

#echo "Current Time: "$currentTime
#shorter time for read in unix
if [[ $success == "true"  ]];
    then    
        local curent_time_actually=$(echo ${currentTime::-3})
        local curent_time_of_request=$(date -d @$curent_time_actually)

        if [ ! -z "$DIALOG" ];
        then
                info_for_dialog_screen=$info_for_dialog_screen"\nTime of your Request to API: "$curent_time_of_request
        else
                echo "Time of your Request to API: "$curent_time_of_request
        fi

Hope that will help if not will be necessary to find reason of that or second solution made negative "-" time positive again + so your power plant stops to travel in time backward ;)

mnuxx commented 3 years ago

Now getting: API getKpiStationHour connection OK Normal Status Time of your Request to API: K 26 mai 2021 01:18:56 EEST Response time: 8001107 s date: invalid date ‘@’

paste: templ6Ua3y.dates: No such file or directory

API getDevRealKpi connection OK Normal Status date: invalid date ‘@’ Time of your Request to API:

Please wait disconnecting! Disconnection from API

I have ntp enabled and my timezone is Europe/Tallinn

BlazejosP commented 3 years ago

Hello looks that I come to wall and haven't any another clue how helps you in this way. I have a proposition which work with other person last time look here https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/4 of course your problem is different but I may solve this in similar way. Is some possibility that you gave me an access temporary to your account lets said for 2/3 days in that time I try to found based on behaviour of code what is the reason and why you have invalid date ‘@’ and solve this problem after that upload patched version to repository and you change password on your account to the new one and I haven't after that access any more. So what is your opinion about this type of solution.? Will be great that for that operation before you will remove private data from eu5.fusionsolar.huawei.com (address, photo of solar panels) you can upload them again when you change password to private one. If you will be interested we can arrange time which will be convenient for both of us.

januweness commented 3 years ago

Hi, sorry for my silence, very busy. I suspect one of the problems may be that the global temporary variable I named "out" is not defined in the function. For me it works because I have exported the variable, but the export may not work as I expect on all operating systems. Not sure, difficult to test.....

Subject: Re: [BlazejosP/huawei-sun2000-API-CLI] getDevRealKpi date: invalid date ‘@’ (#22)

Hello looks that I come to wall and haven't any another clue how helps you in this way. I have a proposition which work with other person last time look here https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/4 of course your problem is different but I may solve this in similar way. Is some possibility that you gave me an access temporary to your account lets said for 2/3 days in that time I try to found based on behaviour of code what is the reason and why you have invalid date ‘@’ and solve this problem after that upload patched version to repository and you change password on your account to the new one and I haven't after that access any more. So what is your opinion about this type of solution.? Will be great that for that operation before you will remove private data from eu5.fusionsolar.huawei.com (address, photo of solar panels) you can upload them again when you change password to private one.

If you will be interested we can arrange time which will be convenient for both of us.

This message is intended only for the recipient(s) named above. It may contain proprietary information and/or protected content. Any unauthorised disclosure, use, retention or dissemination is prohibited. If you have received this e-mail in error, please notify the sender immediately. ESA applies appropriate organisational measures to protect personal data, in case of data privacy queries, please contact the ESA Data Protection Officer @.***).

BlazejosP commented 3 years ago

I HAVE SOME IDEA WHAT THAT MAY BE!

After upgrade of server by Huawei in May on my account starts a strange behaviour simple for some question you receive no answer you can check this if you ask your account without use of this software for example with use of Postman program https://www.postman.com/ to be certain that problem is not related with code of this software.

API has this type of questions: (I checked this which are working for me)

For Power Plant:

for Device

Additional questions:

So when I check how is working this question which is not working on my account I receive similar error to you with wrong date „@”

answer is like this

{
  "data": [],
  "failCode": 0,
  "message": null,
  "params": {
    "currentTime": 1630329033362,
    "collectTime": 1630328098623,
    "stationCodes": "XXXXXX"
  },
  "success": true
}

So what that means: answer is empty and the reason is on server side cased by error in Huawei API. If you test this

uncomment line in 1940 in functions.sh

 #echo $getStationRealKpi | jq

and check what is displayed . Then inPostman you receive similar answer for getStationRealKpi independent from this program that means that your account on fusionsolarapp server is affected and only what you can do is to explain this to eu_inverter_support@huawei.com they may help and unblock this affected API questions. Looks like different persons have affected different questions there is no similar pattern in that so is possible that you have getStationRealKpi blocked by this huwei server error. Write me what happens on your account which functions are affected on your account I'm courious because I also d'like to explain to Huawei that this parts of API are not working on my account.

mnuxx commented 3 years ago

"failCode": 0, "message": null, "params": { "currentTime": 1630352467352, "stationCodes": "NE=somenumber" }, "success": true }

BlazejosP commented 3 years ago

Exactly that is this type of problem. You must check either in postman or with use of of functions.sh every function like I done this and have answer which of them working and shows data and which are affected and show "success": true but without data. On beginning of each function is something like this with name of particular function

 #echo $getStationRealKpi | jq

simple uncomment this and uncomment function which you d'like to check in fusionsolarapp.sh

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

            # Statistical data about particular device/devices inside Power Plant

            # Devices data precisious all voltages etc real-time
            #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
            #Months in previous year
            #getDevKpiMonth ${device_Id_array[0]} ${device_TypeId_array[0]} $(expr $curent_time - 31622399000) # minus one year
            #getDevKpiYear ${device_Id_array[0]} ${device_TypeId_array[0]} $(expr $curent_time - 31622399000) # minus one year
            #getDevKpiYear ${device_Id_array[0]} ${device_TypeId_array[0]} $curent_time #actually year

you can see in terminal for every function API answer. Check everyone and notice which gave you this strange answer "success": true but without data and they must be mentioned in email to Huawei helpdesk. Only they can repair this because your account is affected and some functions have invalid behavior ant that is why this bash code can't handle them. Write me when you finish test I'm courius which API questions/functions are affected on your account and how that looks like in comprasion to this affected on my account. I'm consider meaby I should add some code which in cases like this write on screen that you need to contact with helpdesk or in automatics way check which function are affected by this strange Huwei API error to fastrack someone straight to contact with helpdesk?

BlazejosP commented 2 years ago

"failCode": 0, "message": null, "params": { "currentTime": 1630352467352, "stationCodes": "NE=somenumber" }, "success": true }

So how is with that did you have some answer from Huawei helpdesk and is this function working in your case?

mnuxx commented 2 years ago

Sorry being away, wrote to support, lets see what they figure out.

mnuxx commented 2 years ago

I asked: Hi, please open ticket again, it seems that my account dont have all API requests allowed.

Im trying to use:

getKpiStationHour

getDevRealKpi

and i dont get any data from there.

Huawei said: The account has all the options , please make some screenshots from the interrogation way.

Did i asked correctly ?

BlazejosP commented 2 years ago

The best will be if you send them screenshots with question and answer from postman they use this software as I found dealing with them and that may be indicator that problem is not related which any specific software but rather their API where something broken on random accounts. If you tested questions in postman and only this two are broken returning sucess:true but without any data you must now prove them that this is the issues and you need action from their side.

BTW. Before upgrade of API in May they wasn't such problems but after that don't know why sometimes on on random accounts by random pattern some questions stops to work. My account also is affected and I by use of Postman try to explain them that mentioned above questions to API don't work even if all looks correct on first look.

BlazejosP commented 2 years ago

Is already a month since you asked Huawei support about this wrong answers of API on your account we are curious how goes dealing with them and If they repair this questions to API. So hope that now this software will working correctly? :)