Mushroomizer / SolarmanApiDotNet

GNU General Public License v3.0
7 stars 3 forks source link

stationList error #4

Closed akmadov closed 11 months ago

akmadov commented 11 months ago

Hello! I am running your program but I get an error saying that stationList cannot be null. The webpage shows the same error. Can you help me on that?

Mushroomizer commented 11 months ago

Sure let me check what the problem is

akmadov commented 11 months ago

Thank you! Let me know if you need more information, as I am merely a user and have no idea what you might need :)

Mushroomizer commented 11 months ago

No worries, If you pull the code again and run, you should see an error if the token couldnt be set. AFAIK Solarman is in the process of updating their apis and auth, so it could be that your token is just invalid

akmadov commented 11 months ago

I will try it now, I have just today received my API details from them

Mushroomizer commented 11 months ago

Did you set your details in appsettings.json? { "Serilog": { "MinimumLevel": "Information", "Override": {}, "WriteTo": [ { "Name": "Console", "Args": { "outputTemplate": "{Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] {Message}{NewLine}{Exception}" } } ] }, "Kestrel": { "EndPoints": { "Http": { "Url": "http://localhost:5555" } } }, "AllowedHosts": "", "SolarmanApiOptions": { "BaseUrl": "https://globalapi.solarmanpv.com" }, "SolarmanAuthenticationOptions": { "issuer": "https://globalapi.solarmanpv.com", "appSecret": "the appsecret they gave you", "appId": "the appid they gave you", "email": "yourEmail, "password": "YourPAssword (sha256 from here https://sha256.online/)" }, "CronOptions": [ { "serviceName": "ScheduledGetLiveData", "schedule": "/10 ", "runOnStart": true } ] }

akmadov commented 11 months ago

Yes, I did

Mushroomizer commented 11 months ago

image Mine looks ok, your issue is probably related to your details, or a password being incorrect.

akmadov commented 11 months ago

Value cannot be null. (Parameter 'source') at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at SolarmanApi.Services.SolarmanApiV1.GetStationDataAsync() in C:\Users\Aleksandar\Desktop\SolarmanApiDotNet-master\SolarmanApi\Services\SolarmanApiV1.cs:line 80 at SolarmanApi.Services.SolarmanApiV1.GetRealtimeDataAsync() in C:\Users\Aleksandar\Desktop\SolarmanApiDotNet-master\SolarmanApi\Services\SolarmanApiV1.cs:line 37 at SolarmanApi.Controllers.SolarmanController.GetCurrentLiveData() in C:\Users\Aleksandar\Desktop\SolarmanApiDotNet-master\SolarmanApi\Controllers\SolarmanController.cs:line 27

This is what I am getting

akmadov commented 11 months ago

14:03:07 [Error] [SolarmanApi.Services.SolarmanAuthentication] Could not set token: {"Data":{"expires_in":0},"Code":200,"StatusCode":200,"OriginalHttpResponseMes sage":{"Version":"1.1","Content":{"Headers":[{"Key":"Content-Type","Value":["application/json; charset=UTF-8"]},{"Key":"Expires","Value":["0"]}]},"StatusCode":20 0,"ReasonPhrase":"OK","Headers":[{"Key":"Date","Value":["Tue, 28 Nov 2023 12:03:07 GMT"]},{"Key":"Transfer-Encoding","Value":["chunked"]},{"Key":"Connection","Va lue":["keep-alive"]},{"Key":"Vary","Value":["Accept-Encoding"]},{"Key":"Set-Cookie","Value":["acw_tc=4ddbe0fb4d18e45062cb6f8c3bc40f8f970b0aa95a53adad67534d5a4b48 cfb9;path=/;HttpOnly;Max-Age=1800"]},{"Key":"X-Content-Type-Options","Value":["nosniff"]},{"Key":"X-XSS-Protection","Value":["1; mode=block"]},{"Key":"Cache-Cont rol","Value":["no-store, must-revalidate, no-cache, max-age=0"]},{"Key":"Pragma","Value":["no-cache"]},{"Key":"X-Frame-Options","Value":["DENY"]}],"TrailingHeade rs":[],"RequestMessage":{"Version":"1.1","VersionPolicy":0,"Content":{"Headers":[{"Key":"Content-Type","Value":["application/json; charset=utf-8"]},{"Key":"Conte nt-Length","Value":["161"]}]},"Method":{"Method":"POST"},"RequestUri":"https://globalapi.solarmanpv.com/account/v1.0/token?appId=202309265067052&language=en","He aders":[{"Key":"traceparent","Value":["00-ae14d8bb52daf34fa6d32b15f82fc993-9a8662eb1436b04a-00"]}],"Properties":{},"Options":{}},"IsSuccessStatusCode":true},"Raw Data":"{\"code\":\"2101021\",\"msg\":\"auth invalid appId\",\"success\":false,\"requestId\":\"9512536cc744c34b\"}","IsError":false,"RequestTime":"00:00:00","Requ estTimeMs":0} 14:03:07 [Error] [SolarmanApi.Services.SolarmanApiV1] Could not get station list System.ArgumentNullException: Value cannot be null. (Parameter 'source') at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at SolarmanApi.Services.SolarmanApiV1.GetStationDataAsync() in C:\Users\Aleksandar\Desktop\SolarmanApiDotNet-master\SolarmanApi\Services\SolarmanApiV1.cs:line 80 14:03:07 [Error] [SolarmanApi.Services.SolarmanApiV1] Could not get realtime data System.ArgumentNullException: Value cannot be null. (Parameter 'source') at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at SolarmanApi.Services.SolarmanApiV1.GetStationDataAsync() in C:\Users\Aleksandar\Desktop\SolarmanApiDotNet-master\SolarmanApi\Services\SolarmanApiV1.cs:line 80 at SolarmanApi.Services.SolarmanApiV1.GetRealtimeDataAsync() in C:\Users\Aleksandar\Desktop\SolarmanApiDotNet-master\SolarmanApi\Services\SolarmanApiV1.cs:lin e 37

And this in the console in Rider

Mushroomizer commented 11 months ago

This part here ata":"{"code":"2101021","msg":"auth invalid

Is what I got when I had invalid details Dont share your auth creds, but you need to double check them Make sure your appsecret and appid are correct according to their email

Then use your email that you use to login here https://home.solarmanpv.com/login

Your password should be typed into this box image Click on the hash darling, hash! Button, it looks like it only hashes it properly once you do that

akmadov commented 11 months ago

I have done all that but unfortunately with no success. I will try to contact them again for them to check the details provided and will try again. Thank you very much! Will report back if I have a solution.

Mushroomizer commented 11 months ago

Cool, ps, Ive added a sha converter, so if you pull, you can put your cleartext password in your appsettings.json file

Mushroomizer commented 11 months ago

Hey @akmadov, any luck with your project?

akmadov commented 11 months ago

Hi, unfortunately not. My installers have created two personal/user accounts for me and I have received API details for both of these accounts from Solarman but none work. I am absolutely certain that I am entering all the details correctly, there must be something else. I am now thinking whether it's possible that only the installer can have access to the API. Alternatively, as I have a Deye inverter and they have a dedicated app (which I am sure is calling Solarman's API), if I want to log in the Deye app I need to choose region China with the other option being EMEA (European countries). The EMEA option does not work, only China does for me. Maybe it has something to do with that. In any case, I will try to contact Solarman support and let them know about the invalid appID response. Thanks!

Mushroomizer commented 11 months ago

Thats unfortunate, if you do get it solved, please let me know, I might be able to build in a check to prevent others from having the same issue

akmadov commented 11 months ago

They are now asking me to provide: "CURL for us to check, screenshots are preferred. REQUEST: Header+Body RESPONSE: Body" Can you help me on that? Would the output in the console on http://localhost:5555/swagger/index.html be enough for them?

Mushroomizer commented 11 months ago

Sure, they just want the auth curl Here it is for Windows(via gitBash): curl --header "Content-Type: application/json" --request POST --data "{\"appSecret\":\"[your app secret]\",\"email\":\"[your email]\",\"password\":\"[your sha256 hashed password]\"}" https://globalapi.solarmanpv.com/account/v1.0/token?appId=[your appID]&language=en

akmadov commented 11 months ago

Dear Sir, we have a resolution - it turns out that the installer, who created my user account, has set up their own account as in the China region, rather than the global region. This means that our accounts (mine and the installer's) are serviced not by the globaAPI but by https://api.solarmanpv.com/. This is a bit unfortunate, as I was willing to use PVoutput.org to set up an automation for my home, but the platform has switched to using the globalapi, but I will see what I can do. Thank you for your quick support!

Mushroomizer commented 11 months ago

Hey! thats good news! You can try change the api url in appsettings.json, ill update the readme too