Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getDevRealKpi date: invalid date ‘@’ #22

Closed
mnuxx opened this issue Aug 18, 2021 · 23 comments
Closed

getDevRealKpi date: invalid date ‘@’ #22

mnuxx opened this issue Aug 18, 2021 · 23 comments
Labels
bug Something isn't working

Comments

@mnuxx
Copy link

mnuxx commented Aug 18, 2021

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

@BlazejosP
Copy link
Owner

BlazejosP commented Aug 20, 2021

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

  • String Inverter
  • PowerMeter
  • Smart Logger

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
Copy link
Author

mnuxx commented Aug 20, 2021

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
Copy link
Owner

BlazejosP commented Aug 20, 2021

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

  • ID:63 Distributed SmartLogger
  • ID:17 Grid meter
  • ID:1 String Inverter

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 ##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
Copy link
Author

mnuxx commented Aug 22, 2021

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
Copy link
Collaborator

januweness commented Aug 22, 2021 via email

@mnuxx
Copy link
Author

mnuxx commented Aug 22, 2021

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

@januweness
Copy link
Collaborator

januweness commented Aug 22, 2021 via email

@mnuxx
Copy link
Author

mnuxx commented Aug 22, 2021

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
Copy link
Collaborator

januweness commented Aug 22, 2021 via email

@mnuxx
Copy link
Author

mnuxx commented Aug 22, 2021

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
Copy link
Author

mnuxx commented Aug 23, 2021

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
Copy link
Owner

BlazejosP commented Aug 24, 2021

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 #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
Copy link
Author

mnuxx commented Aug 26, 2021

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 BlazejosP added the bug Something isn't working label Aug 28, 2021
@BlazejosP
Copy link
Owner

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 #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
Copy link
Collaborator

januweness commented Aug 29, 2021 via email

@BlazejosP
Copy link
Owner

BlazejosP commented Aug 30, 2021

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:

  • getStationRealKpi
  • getKpiStationHour
  • getKpiStationHour
  • getKpiStationDay
  • getKpiStationMonth
  • getKpiStationYear

for Device

  • getDevRealKpi
  • getDevFiveMinutes
  • getDevKpiDay
  • getDevKpiMonth
  • getDevKpiYear

Additional questions:

  • getAlarmList
  • login_to_API
  • getStationList
  • getDevList
  • logout_from_API

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
Copy link
Author

mnuxx commented Aug 30, 2021

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

@BlazejosP
Copy link
Owner

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
Copy link
Owner

"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
Copy link
Author

mnuxx commented Sep 12, 2021

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

@mnuxx
Copy link
Author

mnuxx commented Sep 14, 2021

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
Copy link
Owner

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
Copy link
Owner

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? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants