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

Problems with login to huawei server since 30th December 2021 after huawei upgrade #26

Closed BlazejosP closed 2 years ago

BlazejosP commented 2 years ago

Look like that after server upgrade on Fusionsolarapp Huawei side again something was changed on and function login_to_API in functions.sh can't take correct xsrf token. Result is that when server was resumed again in 30th of December 2021 this software has problem with login to API in both interfaces CLI and TUI. I will try found why now xlrf token is wrong extracted hope that will solve problems. As for now I will be happy if you can check if you have the same problem?

Also a kioskmode is affected but this because is now different URL to API and I think I will solve this quite fast so kioskmode will work.

BlazejosP commented 2 years ago

So Url to kioskmode improved and now working with API and TUI please check this on yours configurations! Login still unresolved.

new link to kioskmode was a solution in functions.sh already added to the code local kioskmode=$(http --follow --timeout 3600 GET https://region02eu5.fusionsolar.huawei.com/rest/pvms/web/kiosk/v1/station-kiosk-file?kk=$kiosk_mode_token)

januweness commented 2 years ago

Hi, I have written yesterday, but not sure it arrived - I confirm having the same problem: Please wait connecting! Connection to API

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

http: error: ConnectionError: HTTPSConnectionPool(host='eu5.fusionsolar.huawei.com', port=443): Max retries exceeded with url: /thirdData/getStationList (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x1498da7436a0>: Failed to establish a new connection: [Errno 110] Connection timed out')) while doing POST request to URL: [ https://eu5.fusionsolar.huawei.com/thirdData/getStationList | https://eu5.fusionsolar.huawei.com/thirdData/getStationList ] functions.sh: line 1519: -3: substring expression < 0

ndefined Error \nReturned data:

Does the code need to be changed with each server update then? I think it would be legitimate to ask Huawei to avoid such changes every few months.

Thanks, Jan

From: "BlazejosP" @.> To: "BlazejosP/huawei-sun2000-API-CLI" @.> Cc: "Subscribed" @.***> Sent: Saturday, January 1, 2022 6:37:24 PM Subject: [BlazejosP/huawei-sun2000-API-CLI] Problems with login to huawei server since 30th December 2021 after huawei upgrade (Issue #26)

Look like that after server upgrade on [ https://eu5.fusionsolar.huawei.com/unisso/login.action?service=%2Funisess%2Fv1%2Fauth%3Fservice%3D%252Fnetecowebext%252Fhome%252Findex.html#/LOGIN | Fusionsolarapp ] Huawei side again something was changed on and function login_to_API in functions.sh can't take correct xsrf token. Result is that when server was resumed again in 30th of December 2021 this software has problem with login to API in both interfaces CLI and TUI. I will try found why now xlrf token is wrong extracted hope that will solve problems. As for now I will be happy if you can check if you have the same problem?

— Reply to this email directly, [ https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/26 | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/ABTM3AHRBVOVYYTLX5F2SWTUT43VJANCNFSM5LCV7T3Q | 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&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub | Android ] . You are receiving this because you are subscribed to this thread. Message ID: @.***>

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 2 years ago

What I identified for now that responsible is functions.sh file and inside this file function

function login_to_API line 942

when I uncomment line 983 #echo $logowanie

xsrf-token is extracted and visible but I suspect that during extraction and obfuscation of xlrf-token value something goes wrong between lines 986 to 1138 so that is area which need rewriten from my side and that my take a few days. Hope after that wasn't any changes in other questions to API and will work without propblems.

As temporary solution you can extract data from kioskmode which was also affected but of course changes were small just a link were changed so is working now. I know that there is less data but hope will help for this time until login is not working.

When @januweness mentioned about this changes in API I can confirm that this is quite frustrating now!

  1. First version of this software was written in 2020
  2. Major changes from Huawei FusionSolarApp in API in May 2021 -> takes around a mouth to write new functions to login etc. most functions were rewritten
  3. Minor changes December 2021 -> hope this time changes will be smaller and faster implemented

About question to Huawei API maintainer (whoever is that) I'm curious what we as a community can propose what can be done with this changes to API every half a year. API should be stable because third-part software depends from it. But look like with every server upgrade Huawei implement some small changes to links or other small parts. Meaby as a whole community we should write an email to help-desk describe how this small changes affected third-pard software and ask about more caution implementation of changes which are related to API? What is your opinion?

bhaezlr commented 2 years ago

I had the same problem. In a script based upon fusionsolarapp.sh I changed the following line.

Get the cookies

echo "Cookies = ${array[1]}"

local logowanie=${array[3]}

local logowanie=${array[1]}

IFS='='

januweness commented 2 years ago

Hi, there are several of these lines in the functions file, sometimes with array 1 and IFS=':' other times array with 3 and IFS='=', where does it need to be changed? If I change all, it doesn't work.

Thanks,

On 19/1/22 11:57, bhaezlr wrote:

I had the same problem. In a script based upon fusionsolarapp.sh I changed the following line.

Get the cookies

echo "Cookies = ${array[1]}"

local logowanie=${array[3]}

local logowanie=${array[1]}

IFS='='

— Reply to this email directly, view it on GitHub https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/26#issuecomment-1016329553, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTM3AFJGIE2H7RZPNGCBZTUW2KLHANCNFSM5LCV7T3Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.

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 @.***).

januweness commented 2 years ago

Hello,

I think I found what the problem that in line 1030 of functions.sh, the value of the token is empty.

Two lines need to be changed : line 1002: local logowanie=${array[2]} => local logowanie=${array[1]}

line 1013: local logowanie=${array[3]} => local logowanie=${array[1]}

For some reason I can no longer edit the code or upload, but maybe one of you can make these two changes?

Thanks, Jan

From: "BlazejosP" @.> To: "BlazejosP/huawei-sun2000-API-CLI" @.> Cc: "Jan-Uwe Ness" @.>, "Mention" @.> Sent: Monday, January 3, 2022 9:59:28 AM Subject: Re: [BlazejosP/huawei-sun2000-API-CLI] Problems with login to huawei server since 30th December 2021 after huawei upgrade (Issue #26)

What I identified for now that responsible is functions.sh file and inside this file function

function login_to_API line 942

when I uncomment line 983

echo $logowanie

xsrf-token is extracted and visible but I suspect that during extraction and obfuscation of xlrf-token value something goes wrong between lines 986 to 1138 so that is area which need rewriten from my side and that my take a few days. Hope after that wasn't any changes in other questions to API and will work without propblems.

As temporary solution you can extract data from kioskmode which was also affected but of course changes were small just a link were changed so is working now. I know that there is less data but hope will help for this time until login is not working.

When [ https://github.com/januweness | @januweness ] mentioned about this changes in API I can confirm that this is quite frustrating now!

1. First version of this software was written in 2020 
2. Major changes from Huawei FusionSolarApp in API in May 2021 -> takes around a mouth to write new functions to login etc. most functions were rewritten 
3. Minor changes December 2021 -> hope this time changes will be smaller and faster implemented 

— Reply to this email directly, [ https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/26#issuecomment-1003948419 | view it on GitHub ] , or [ https://github.com/notifications/unsubscribe-auth/ABTM3ACQ3PU7FJJDZZIV27TUUFQPBANCNFSM5LCV7T3Q | 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&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub | Android ] . You are receiving this because you were mentioned. Message ID: @.***>

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 2 years ago

Hello @januweness That great that you found the reason why main login is not working I to be honest have problem to identified why is not working and what need to be changed. Hope that Huawei server will be not changed so much in future.

About your problem with pushing changes to repository you are still allowed nothing was revoked problem is that now github need new token around every 3 months so you must generate a new one!

About this modification which you mentioned here I will test this and push myself or will wait if youd'like made this yourself. Of course credit for found an error and solution belongs to you. :)

BlazejosP commented 2 years ago

Here is solution In my case using recipe of @januweness

file functions.sh line 1002 changed to local logowanie=${array[2]} before was local logowanie=${array[1]}

line 1013 changed to local logowanie=${array[1]} before was local logowanie=${array[3]}

And is working now for me so waiting for your decision @januweness with changes in repository if you d'like yourself improve this error in repository after token regeneration or you prefer whoever made this change if is working? :1st_place_medal:

First time I can see any data from year 2022 after successfully login [ picture with use of https://postimages.org/ screenshot-of-2022.png

januweness commented 2 years ago

Hi, I am glad it works. I seem capable of finding the problem, but for recovering the token I seem to miss the needed brain cells ;-) So please go a head an push these changes yourself (or someone else). No credits needed, main thing it works!

Thanks, Jan

On 20/1/22 13:59, BlazejosP wrote:

Here is solution In my case using recipe of @januweness https://github.com/januweness

file functions.sh line 1002 changed to |local logowanie=${array[2]}| before was local logowanie=${array[1]}

line 1013 changed to `local logowanie=${array[1]} before was local logowanie=${array[3]}

And is working now for me so waiting for your decision @januweness https://github.com/januweness with changes in repository if you d'like yourself improve this error in repository after token regeneration or you prefer whoever made this change if is working? 🥇

— Reply to this email directly, view it on GitHub https://github.com/BlazejosP/huawei-sun2000-API-CLI/issues/26#issuecomment-1017482044, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTM3AFTQNYIGB7FD5OQQ6TUXABKLANCNFSM5LCV7T3Q. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

--

P.S. This e-mail might reach you during non-working hours. This is a matter of my personal work-life balance and travel schedule only. I do not expect to receive a reply outside of your usual working hours.

Dr. Jan-Uwe Ness Operations Scientist Chair of ESAC Science Faculty European Space Astronomy Centre Camino Bajo del Castillo s/n Urb. Villafranca del Castillo 28692 Villanueva de la Canada Madrid, Spain http://januweness.eu http://januweness.eu ORCID 0000-0003-0440-7193

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 2 years ago

So changes are official in repository #4b5698881d767e743ebf9176d5a83ff16619fbd