MickMake / GoSungrow

GoLang implementation to access the iSolarCloud API updated by SunGrow inverters.
https://mickmake.com/
GNU General Public License v2.0
185 stars 48 forks source link

strconv.Atoi error #107

Open illuzn opened 9 months ago

illuzn commented 9 months ago

Using the patched gosungrow build with the new API and APP key. I get the following error:

[04:37:56] INFO: Syncing data from gateway https://augateway.isolarcloud.com ...
2024/02/06 04:37:56 INFO: Connecting to MQTT HASSIO Service...
2024/02/06 04:37:56 INFO: Connecting to SunGrow...
2024/02/06 04:37:56 INFO: Found SunGrow 5 devices
2024/02/06 04:37:56 INFO: Caching Sungrow metadata...
2024/02/06 04:37:56 INFO: Cached 1015 Sungrow data points...
PsId: required
JSON request:   {"ps_id":1259467}

2024/02/06 04:37:57 ERROR: SetResponse: strconv.Atoi: parsing "1559776_1559777": invalid syntax
Error: SetResponse: strconv.Atoi: parsing "1559776_1559777": invalid syntax

I have no clue about Golang but it appears this gets called in only a few places:

Debug logging doesn't reveal anymore information. Not sure how to provide further information to diagnose this issue.

Paraphraser commented 9 months ago

Well, on the face of it, the string "1559776_1559777" has been passed to the "convert string to integer" function. That function has (correctly) returned an error because a string containing an underscore doesn't represent a valid integer.

I think the real question is where is "1559776_1559777" coming from?

From your question it's not clear exactly how you are running GoSungrow. When you say "patched gosungrow build" do you mean you have just recompiled the binary as per part 1 of this gist. Or do you mean you're running the pre-built Docker image (as per part 2 of the gist). The log messages don't look the same as I see in Home Assistant so I'm guessing you're not doing this in HA.

To put that last para another way, if you don't explain exactly what you are doing, you make it difficult for anyone else to try to replicate to see if they do hit the same problem (meaning it's something that would likely be able to be fixed by the community), or they don't hit the same problem (meaning it's more likely to be something peculiar to your system).

When I look at the container log in Home Assistant, I see:

[11:17:34] INFO: Syncing data from gateway https://augateway.isolarcloud.com ...
2024/02/06 11:17:34 INFO: Connecting to MQTT HASSIO Service...
2024/02/06 11:17:34 INFO: Connecting to SunGrow...
2024/02/06 11:17:34 INFO: Found SunGrow 3 devices
2024/02/06 11:17:35 INFO: Caching Sungrow metadata...
2024/02/06 11:17:35 INFO: Cached 958 Sungrow data points...
2024/02/06 11:17:35 INFO: Syncing 461 entries with HASSIO from queryDeviceList.
2024/02/06 11:17:35 INFO: Syncing 148 entries with HASSIO from getPsList.
--CUCUCUCUCUCU-CUCUCU-CU-CU--CU--CUCU-CUCUCU---CU-CU---CUCUCU
…

You'll note that after the "Cached" message, I get two "Syncing" messages followed by what I think of as the usual gibberish pattern with the CU stuff. Conversely, your log mentions PsId: required at that point.

What do you see when you run:

$ GoSungrow api login
$ GoSungrow show ps list

What's in the "Ps Id" column? Is it the integer "1259467" or is it that problem string?

If you only just followed Part 1 of the gist then perhaps also confirm the version of Go you are using. My standalone binary was compiled on Jan 22 with Go version 1.21.6. Does that match the compiler version you are using?

illuzn commented 9 months ago

Sorry to be unclear. Was running the homeassistant addon with only Part 2 of that patch applied.

I'll try installing this stand alone then running those commands directly.

Paraphraser commented 9 months ago

And sorry to be unclear myself. The point I was trying to make (and obviously failing) was that I wasn't seeing the problem with my HA instance. Therefore assuming your setup didn't differ materially from mine in some way that wasn't immediately obvious from your post, the underlying cause was unlikely to be found in HA or the (replacement) add-on, and more likely to be found in either your configuration (ie the bits in the HA UI where to tell GoSungrow your credentials etc) or something peculiar to your inverter (ie the bits you configure using the iSolarCloud app) or your inverter's relationship with the Sungrow cloud. I think the latter will become evident with those GoSungrow commands.

What's most puzzling to me is the PsId required because, as far as I can tell, the discovery of that is automatic. The fact that mine doesn't show that line while yours does was either going to be explained by you not actually running HA (now eliminated) or perhaps bad credentials. But, assuming you can login correctly then auto discovery of the PsId should occur (ie like mine) rather than PsId required (like yours). And how that then gets us to malformed integers...

All very weird.

illuzn commented 9 months ago

Does it have to do with me having 2 sites connected to my account work and home?

Paraphraser commented 9 months ago

If you mean that you have inverters at home and work, and they are both connected to the same Sungrow account, then I have no idea. I only have the one Sungrow inverter.

If you mean that you have HA running at both home and work, connected to the same Sungrow account and pulling data associated with your inverter(s) then I can't see why that would make any difference. As far as I can tell, the iSolarCloud app, HA, and non-HA invocations of GoSungrow are all doing the same thing in API terms. I'm using the iSolarCloud app (mainly to view "now" data), the HA version (for nothing other than to prove it's working) plus a cron job firing once a day to call GoSungrow standalone to download data for "yesterday" which I load into a database. I also run standalone GoSungrow when trying to answer questions here on GitHub. So, by my count, I have four totally independent usages of the API and I don't see anything like you're seeing.

copetogo commented 9 months ago

@Paraphraser i second the issue raised here. I don't think 2 accounts is an issue because i had 2 inverters in isolar account but it anyways used to show 1 account as the other account was a shared account from another email ID . I am facing the same issue at about the same timeline when this issue has been raised. I tried deleting the whole add on reinstall which gave me the api error for which you had released the patch but the problem continued

Token File: /data/.GoSungrow/AppService_login.json [05:10:36] INFO: Syncing data from gateway https://gateway.isolarcloud.com.hk ... 2024/02/09 05:10:36 INFO: Connecting to MQTT HASSIO Service... 2024/02/09 05:10:36 INFO: Connecting to SunGrow... 2024/02/09 05:10:37 INFO: Found SunGrow 2 devices 2024/02/09 05:10:37 INFO: Option[loglevel] set to 'info' 2024/02/09 05:10:37 INFO: Caching Sungrow metadata... 2024/02/09 05:10:40 INFO: Cached 888 Sungrow data points... PsId: required JSON request: {"ps_id":1228950}

2024/02/09 05:10:41 ERROR: SetResponse: strconv.Atoi: parsing "3071048_3071049": invalid syntax Error: SetResponse: strconv.Atoi: parsing "3071048_3071049": invalid syntax Usage: GoSungrow mqtt run [flags]

Aliases: run,

Examples: GoSungrow mqtt run

illuzn commented 9 months ago

Not sure if its's safe to show the outputs of:

./GoSungrow api login
./GoSungrow show ps list

But both commands complete sucessfully and show the following general output (santitised):

┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Ps Key           ┃ Ps Id   ┃ Device Type ┃ Device Code ┃ Channel Id ┃ Serial #    ┃ Factory Name ┃ Device Model   ┃
┣━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┫
┃ psid1_1_1_1      │ psid1   │ 1           │ 1           │ 1          │ ###         │ SUNGROW      │ SG10RT         ┃
┃ psid1_22_247_1   │ psid1   │ 22          │ 247         │ 1          │ ###         │ SUNGROW      │ WiFi V31       ┃
┃ psid1_7_1_1      │ psid1   │ 7           │ 1           │ 1          │ ###         │ SUNGROW      │ SG Smart Meter ┃
┃ psid2_1_1_1      │ psid2   │ 1           │ 1           │ 1          │ ###         │ SUNGROW      │ SG30CX         ┃
┃ psid2_22_247_1   │ psid2   │ 22          │ 247         │ 1          │ ###         │ SUNGROW      │ EyeM4          ┃
┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━┛

Running ./GoSungrow mqtt run (which seems to the be command which performs a one-shot data pull and is the one which hangs). Generates the same error above.

Now to the meat of what I've discovered.

Running ./GoSungrow mqtt run psid1 generates the strconv.Atoi error which I'm encountering above.

Running ./GoSungrow mqtt run psid2 generates the "Repeated request" error I was encountering previously.

That explains the behaviour I was experiencing previously with different errors. For whatever reason the first site it decided to pull was different between my installs.

Interestingly, I have the "EyeM4" which seems to be relatively new and may not be supported and on the other site I have a Smart Meter (which may also not be supported).

msmitka commented 6 months ago

Hello to everybody, i have problem with ERROR: SetResponse: strconv.Atoi: parsing "4050146_4050147": invalid syntax. With the help of @Paraphraser I found that this occurs with "show device list" where the error occurs. 4050146_4050147 occurs in "device_area":"4050146_4050147" in the dir cache in the devicelist file

info here: https://gist.github.com/Paraphraser/cad3b0aa6428c58ee87bc835ac12ed37?permalink_comment_id=5072228#gistcomment-5072228 Can any of you help me or fix the image?

Thank you very much Michal

starlit-rocketship commented 3 months ago

I am getting the same error. Does anyone know where I can look to get more information on the error and where it is happening?

[01:54:15] INFO: Login to iSolarCloud using gateway https://augateway.isolarcloud.com ... Logging in again Email: xxxxxxxx@gmail.com Create Date: Fri Apr 21 11:01:16 CST 2023 Login Last Date: 2024-08-20 09:54:16 Login Last IP:
Login State: 1 User Account: a60gxxxxxx User Id: 392360 User Name: xxxxxxxxxxxx Is Online: false Token: 392360_32423540d00347e8xxxxxxxxxxxxxx Token File: /data/.GoSungrow/AppService_login.json [01:54:16] INFO: Syncing data from gateway https://augateway.isolarcloud.com ... 2024/08/20 01:54:16 INFO: Connecting to MQTT HASSIO Service... 2024/08/20 01:54:16 INFO: Connecting to SunGrow... 2024/08/20 01:54:16 INFO: Found SunGrow 3 devices 2024/08/20 01:54:17 INFO: Caching Sungrow metadata... 2024/08/20 01:54:17 INFO: Cached 1042 Sungrow data points... PsId: required JSON request: {"ps_id":1219098}

2024/08/20 01:54:18 ERROR: strconv.Atoi: parsing "1423777_1423778": invalid syntax Error: strconv.Atoi: parsing "1423777_1423778": invalid syntax Usage: GoSungrow mqtt run [flags]

Aliases: run,

Examples: GoSungrow mqtt run

Flags: Use "GoSungrow help flags" for more info.

Additional help topics:

ERROR: strconv.Atoi: parsing "1423777_1423778": invalid syntax s6-rc: info: service legacy-services: stopping s6-rc: info: service legacy-services successfully stopped s6-rc: info: service legacy-cont-init: stopping s6-rc: info: service legacy-cont-init successfully stopped s6-rc: info: service fix-attrs: stopping s6-rc: info: service fix-attrs successfully stopped s6-rc: info: service s6rc-oneshot-runner: stopping s6-rc: info: service s6rc-oneshot-runner successfully stopped

copetogo commented 2 months ago

i guess no progress on this issue. :(. i somehow think having 2 accounts one of them being shared with the main account may be the reason

starlit-rocketship commented 2 months ago

i somehow think having 2 accounts one of them being shared with the main account may be the reason

I had several accounts shared but I unshared them to test the theory. I still get the same error unfortunately.