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

Poblem with functions.sh #31

Closed BlazejosP closed 1 year ago

BlazejosP commented 1 year ago

Anyone has a problem with this script now from my perspective looks like that Huawei again change something and login function working correct but after that when first question to API about available stations

getStationList

is made error appear. So I asked Huawei support centre about actually reference file pdf and hope that I can fix this. Anyone has the same problem with both interfaces graphical and txt?

januweness commented 1 year ago

Hi, the following modifications to functions.sh made it work again for me:

line 994 < IFS=';'

IFS=':'

line 1002 < local logowanie=${array[2]}

local logowanie=${array[19]}

line 1005 < IFS=':'

IFS='='

line 1016 < IFS='='

IFS=';'

lines 1024 < local logowanie=${array[1]}

local logowanie=${array[0]}

Best, Jan-Uwe

From: BlazejosP @.> Sent: 26 October 2022 10:42 To: BlazejosP/huawei-sun2000-API-CLI @.> Cc: Subscribed @.***> Subject: [BlazejosP/huawei-sun2000-API-CLI] Poblem with functions.sh (Issue #31)

Anyone has a problem with this script now from my perspective looks like that Huawei again change something and login function working correct but after that when first question to API about available stations

getStationList

is made error appear. So I asked Huawei support centre about actually reference file pdf and hope that I can fix this. Anyone has the same problem with both interfaces graphical and txt?

- Reply to this email directly, view it on GitHubhttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FBlazejosP%2Fhuawei-sun2000-API-CLI%2Fissues%2F31&data=05%7C01%7CJan.Uwe.Ness%40esa.int%7Cd6cd41ab21db4817891e08dab72e03a0%7C9a5cacd02bef4dd7ac5c7ebe1f54f495%7C0%7C0%7C638023705495243306%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=qx%2B8KqwrjCHDTaVfcRlYJ3Ap%2BNi45zhQ9c061BNRiN0%3D&reserved=0, or unsubscribehttps://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABTM3ACLQPIHLK5LA3XD3XLWFDVFLANCNFSM6AAAAAAROX53QQ&data=05%7C01%7CJan.Uwe.Ness%40esa.int%7Cd6cd41ab21db4817891e08dab72e03a0%7C9a5cacd02bef4dd7ac5c7ebe1f54f495%7C0%7C0%7C638023705495399522%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=tbwrd4pm9u48WZyYhsi1V0Z8LM4s8RrVqgwIyGLxUI0%3D&reserved=0. 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 1 year ago

Thanks @januweness I checked your changes and login is working correct like :) before. Problem in my case is somewhere else inside function getStationList lines 1478 to 1817

Error said that line 1521 curent_time_actually=$(echo ${curent_time::-3})

can't extract time of question straight from API answer that is why my suspicion is that again something was changes on API answer side without any warning.

look on lines 1518-1519 # we take actually time for other question to API too curent_time=$(echo ''$getStationList'' | jq '.params' )

curent_time=$(echo ''$curent_time'' | jq '.currentTime' )

when I investigate problem a little bit deeper looks like on question to API line 1504 local getStationList=$(printf '{}'| http --follow --timeout 7200 POST https://eu5.fusionsolar.huawei.com/thirdData/getStationList XSRF-TOKEN:''$xsrf_token'' Content-Type:'application/json' Cookie:'web-auth=true; XSRF-TOKEN='$xsrf_token'')

I haven't correct answer with list of stations and .currentTime but some error code ? I check this with Postman without use of this software and result is the same login works correctly but when I try to ask about stations list also such error? So looks that Huawei change something inside API that is why I asked them about newest version of their API reference pdf. I'm also curious that meaby you and other's are affected by this changes?

BlazejosP commented 1 year ago

Hi, the following modifications to functions.sh made it work again for me: line 994 < IFS=';' ---

Hi @januweness you have right problem was in function login_to_API

Without any warning Huawei change something in response of this function so XSRF-TOKEN wasn't extracted correctly that has affected all other function because they all need this session token . So program stops to work Curious how long ago that happens? I made changes inside login_to_API and on my computer looks like all is working back will be great If you and other peoples will check this also on their computers ( P.S. changes are different that proposed by you but finally token is extracted from answer)