MickMake / HomeAssistantAddons

MIT License
43 stars 26 forks source link

GoSungrow mqtt run generates "panic: runtime error: invalid memory address or nil pointer dereference" #32

Open razsultana opened 1 year ago

razsultana commented 1 year ago

Hi Mick, GoSungrow looks awesome. I have the same problem that you had - I am trying to get my Sungrow SH5K-20 inverter integrated in Home Assistant. I managed to get GoSungrow to connect to the iSolarCloud API and report data back using standalone GoSungrow. When I tried though to get it working in HomeAssistant, it fails at the GoSungrow mqtt run stage with the error stack below, which I got by running manually the docker entrypoint script inside the docker container. The MQTT integration works fine with the same parameters (host, user, pass) that are used by the GoSungrow add-on.

I have no experience with golang, so it's a bit tricky to even attempt to debug the panic error below - it sounds like it's a variable that's supposed to have a non-nil value and it's nil, but I'm not quite sure which one is that. The panic seems to be triggered by a call to the GetValue function defined here: (https://github.com/MickMake/GoSungrow/blob/master/iSolarCloud/api/GoStruct/struct_reflect.go#L984) called from somewhere around here: (https://github.com/MickMake/GoSungrow/blob/master/iSolarCloud/AppService/queryDeviceList/data.go#L427) but the line in data.go is not the one that's in the error stack, since there is no GetValue call on line 434 in the current commit of the repo. This raises the question of which exactly is the commit of GoSungrow that is used to generate the docker image that is deployed by the add-on and I don't know the answer to that question either. This also means that even if I can add some code to avoid processing nil pointers, I don't know how to generate a new docker image with that code.

Since you mention in the README that the API changes occasionally, it could be a result of such a change. It could also be a result of a badly configured or defective inverter, which doesn't report properly certain values. I noticed that even in iSolarCloud, the "load" values are sometimes absent, sometimes they show up for a while, so the report is very confusing, which is one of the reasons I want to get away from it. Unfortunately, GoSungrow still relies on the data that is reported by the iSolarCloud API, so the GIGO principle will make this data useless.

Can you have a look and see if there's any obvious culprit, so I can at least get some data in HomeAssistant, even if it's missing some values (e.g. the load)? Thanks, Razvan

bash-5.1# /usr/local/bin/run.sh
[07:50:03] INFO: Setting up GoSungrow config ...
[07:50:08] INFO: Writing GoSungrow config ...
Using config file '/data/.GoSungrow/config.json'
New config:
+-----------------+------------+-------------------------+--------------------------------+-----------------------------------+
|      FLAG       | SHORT FLAG |       ENVIRONMENT       |          DESCRIPTION           |        VALUE (* = DEFAULT)        |
+-----------------+------------+-------------------------+--------------------------------+-----------------------------------+
| --config        |            | GOSUNGROW_CONFIG        | GoSungrow: config file.        | /data/.GoSungrow/config.json      |
| --debug         |            | GOSUNGROW_DEBUG         | GoSungrow: Debug mode.         | false *                           |
| --quiet         |            | GOSUNGROW_QUIET         | GoSungrow: Silence all         | false *                           |
|                 |            |                         | messages.                      |                                   |
| --timeout       |            | GOSUNGROW_TIMEOUT       | Web timeout.                   | 1m0s                              |
| --user          | -u         | GOSUNGROW_USER          | SunGrow: api username.         | my_user@gmail.com                 |
| --password      | -p         | GOSUNGROW_PASSWORD      | SunGrow: api password.         | my_password                       |
| --appkey        |            | GOSUNGROW_APPKEY        | SunGrow: api application key.  | 93D72E60331ABDCDC7B39ADC2D1F32B3  |
|                 |            |                         |                                | *                                 |
| --host          |            | GOSUNGROW_HOST          | SunGrow: Provider API URL.     | https://augateway.isolarcloud.com |
|                 |            |                         |                                | *                                 |
| --token-expiry  |            | GOSUNGROW_TOKEN_EXPIRY  | SunGrow: last login.           | 2023-05-24T15:46:39               |
| --save          | -s         | GOSUNGROW_SAVE          | Save output as a file.         | false *                           |
| --mqtt-user     |            | GOSUNGROW_MQTT_USER     | HASSIO: mqtt username.         | mqtt_user                         |
| --mqtt-password |            | GOSUNGROW_MQTT_PASSWORD | HASSIO: mqtt password.         | mqtt_pass                         |
| --mqtt-host     |            | GOSUNGROW_MQTT_HOST     | HASSIO: mqtt host.             | my_mqtt_host_ip                   |
| --mqtt-port     |            | GOSUNGROW_MQTT_PORT     | HASSIO: mqtt port.             |                              1883 |
+-----------------+------------+-------------------------+--------------------------------+-----------------------------------+
[07:50:08] INFO: Login to iSolarCloud using gateway https://augateway.isolarcloud.com ...
Email:  my_user@gmail.com
Create Date:    Sat Jun 18 15:10:39 CST 2022
Login Last Date:    2023-05-24 15:50:08
Login Last IP:
Login State:    1
User Account:   xxxxxxxxxxx
User Id:    xxxxxxx
User Name:  xxxxxxx
Is Online:  false
Token:  xxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Token File: /data/.GoSungrow/AppService_login.json
[07:50:08] INFO: Syncing data from gateway https://augateway.isolarcloud.com ...
2023/05/24 07:50:09 INFO: Connecting to MQTT HASSIO Service...
2023/05/24 07:50:09 INFO: Connecting to SunGrow...
2023/05/24 07:50:09 INFO: Found SunGrow 1 devices
2023/05/24 07:50:09 INFO: Caching Sungrow metadata...
2023/05/24 07:50:09 INFO: Cached 227 Sungrow data points...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6d2c9f]

goroutine 1 [running]:
GoSungrow/iSolarCloud/api/GoStruct.(*Reflect).GetValueFloat(0x0)
    /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/api/GoStruct/struct_reflect.go:984 +0x7f
GoSungrow/iSolarCloud/AppService/queryDeviceList.(*EndPoint).SetPvPoints(_, {{_, _, _}}, {0xc0006dfc80, {0xc0006ddd57, 0x7}, {0xc1138e4c42b2d296, 0x2ee5af8, 0x48d4da0}, ...})
    /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/AppService/queryDeviceList/data.go:434 +0xcaf
GoSungrow/iSolarCloud/AppService/queryDeviceList.(*EndPoint).GetEnergyStorageSystem(_, {0xc0006dfc80, {0xc0006ddd57, 0x7}, {0xc1138e4c42b2d296, 0x2ee5af8, 0x48d4da0}, {{0xc0006cc100, 0x2, 0x2}}, ...})
    /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/AppService/queryDeviceList/data.go:299 +0x3b5
GoSungrow/iSolarCloud/AppService/queryDeviceList.(*EndPoint).GetData(_)
    /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/AppService/queryDeviceList/data.go:259 +0xb8
GoSungrow/iSolarCloud/AppService/queryDeviceList.EndPoint.GetEndPointData(...)
    /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/AppService/queryDeviceList/struct.go:367
GoSungrow/iSolarCloud.(*SunGrowData).CallEndpoint(_, {_, _}, {{0xc0006de9f0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...})
    /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/data.go:161 +0x433
GoSungrow/iSolarCloud.(*SunGrowData).getDataSinglePsIdRequired(0xc000b8f488, {0x2f0ebd0, 0xc00036d500})
    /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/data.go:281 +0x325
GoSungrow/iSolarCloud.(*SunGrowData).GetDataSingle(0xc000b8f488, {0xc000427150, 0xf})
    /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/data.go:236 +0x14f
GoSungrow/iSolarCloud.(*SunGrowData).GetData(0xc000b8f488)
    /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/data.go:207 +0x125
GoSungrow/cmd.(*CmdMqtt).Cron(0xc0000b0750)
    /Users/mick/Documents/GoLang/Solar/GoSungrow/cmd/cmd_mqtt.go:368 +0x2b7
GoSungrow/cmd.(*CmdMqtt).CmdMqttRun(0xc0000b0750, 0x0?, {0x0?, 0x0?, 0x0?})
    /Users/mick/Documents/GoLang/Solar/GoSungrow/cmd/cmd_mqtt.go:266 +0x85
github.com/spf13/cobra.(*Command).execute(0xc0002d8900, {0xc00018e170, 0x0, 0x0})
    /Users/mick/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:916 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc000118000)
    /Users/mick/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:1044 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
    /Users/mick/go/pkg/mod/github.com/spf13/cobra@v1.6.1/command.go:968
github.com/MickMake/GoUnify/Unify.(*Commands).Execute(...)
    /Users/mick/go/pkg/mod/github.com/!mick!make/!go!unify/!unify@v0.0.0-20221125023651-ff4a37b1928a/struct.go:258
github.com/MickMake/GoUnify/Unify.(*Unify).Execute(0xc0000bcb40)
    /Users/mick/go/pkg/mod/github.com/!mick!make/!go!unify/!unify@v0.0.0-20221125023651-ff4a37b1928a/struct.go:201 +0x385
GoSungrow/cmd.Execute(...)
    /Users/mick/Documents/GoLang/Solar/GoSungrow/cmd/commands.go:90
main.main()
    /Users/mick/Documents/GoLang/Solar/GoSungrow/main.go:11 +0x6f
razsultana commented 1 year ago

I just noticed issue #11 , which seems very closely related to this one. You asked the reporter of issue #11 to provide the output of GoSungrow ha lovelace, so here is what I got:

bash-5.1# GoSungrow ha lovelace
Can't find DeviceType 22 attached to ps_id 1151314.

which is similar to what he got but the DeviceType reported in his case by the error was 43 (he had a DeviceType 22 though listed by GoSungrow show ps list).

Here is what I get listing my devices:

bash-5.1# GoSungrow show ps list
┏━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Ps Key         ┃ Ps Id   ┃ Device Type ┃ Device Code ┃ Channel Id ┃ Serial #    ┃ Factory Name ┃ Device Model ┃
┣━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┫
┃ 1151314_14_1_1 │ 1151314 │ 14          │ 1           │ 1          │ A1912190548 │ SUNGROW      │ SH5K         ┃
┗━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┛

I can see from the example output in your README.md that Device Type 22 represents the WiNet-S WiFi stick. My system is probably older as it has a WiFi stick that is simply referred as "WiFi" in the iSolarCloud interface, when you try a local connection and click the "manual connection" button - there are many other sticks there e.g. WiNet-S, EyeS4-EU, WiFi-P2, EyeM4, Logger1000 and similar Bluetooth devices. So if the code is looking for DeviceType 22, it won't find it :(

razsultana commented 1 year ago

I have figured that my first error stack was generated by GoSungrow release 3.0.3, therefore the culprit is this call: https://github.com/MickMake/GoSungrow/blob/v3.0.3/iSolarCloud/AppService/queryDeviceList/data.go#L434 , i.e.

tmp2 := totalDailyEnergy.GetValueFloat() - gridToLoadEnergy.GetValueFloat()

These two calls of GetValueFloat are made by these two structures: https://github.com/MickMake/GoSungrow/blob/v3.0.3/iSolarCloud/AppService/queryDeviceList/data.go#L415

totalDailyEnergy := entries.CopyPointFromName(epp.AddString("p13199"), epp, "total_daily_energy", "Total Daily Energy (p13199)")

and https://github.com/MickMake/GoSungrow/blob/v3.0.3/iSolarCloud/AppService/queryDeviceList/data.go#L432

gridToLoadEnergy := entries.GetReflect(epp.AddString("p13147"))

So I checked whether those points (whatever that means) have values in my case. It turns out that sometimes they have values, sometimes they don't (so the above comment about DeviceType 22 is most likely a red herring).

I first checked whether I have those points - I do!

bash-5.1# GoSungrow show ps points|grep 'p13199\|p13147'
┃ p13147   │ Daily Purchased Energy                                   │ kWh    │ 7         │ 1151314 │ 14          │ SH5K_001_001 ┃
┃ p13199   │ Daily Load Consumption                                   │ kWh    │ 7         │ 1151314 │ 14          │ SH5K_001_001 ┃

Then I tried to pull data for 4 different days this year:

bash-5.1# GoSungrow show point data 20230501 20230502 120 1151314_14_1_1.p13199

# DataTable AppService.queryMutiPointDataList.ResultData.Data - Points:p13199 PsId:1151314 StartTimeStamp:20230501000000 EndTimeStamp:20230502000000 MinuteInterval:120 PsKeys:1151314_14_1_1
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Timestamp              ┃ Ps Key            ┃ 1151314_14_1_1.p13199    ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ 2023-05-01 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 02:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 04:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 06:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 08:00:00    ┃ 1151314_14_1_1    ┃ 100                      ┃
┃ 2023-05-01 10:00:00    ┃ 1151314_14_1_1    ┃ 2300                     ┃
┃ 2023-05-01 12:00:00    ┃ 1151314_14_1_1    ┃ 6000                     ┃
┃ 2023-05-01 14:00:00    ┃ 1151314_14_1_1    ┃ 9600                     ┃
┃ 2023-05-01 16:00:00    ┃ 1151314_14_1_1    ┃ 12100                    ┃
┃ 2023-05-01 18:00:00    ┃ 1151314_14_1_1    ┃ 12200                    ┃
┃ 2023-05-01 20:00:00    ┃ 1151314_14_1_1    ┃ 12200                    ┃
┃ 2023-05-01 22:00:00    ┃ 1151314_14_1_1    ┃ 12200                    ┃
┃ 2023-05-02 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛
bash-5.1# GoSungrow show point data 20230501 20230502 120 1151314_14_1_1.p13147

# DataTable AppService.queryMutiPointDataList.ResultData.Data - Points:p13147 PsId:1151314 StartTimeStamp:20230501000000 EndTimeStamp:20230502000000 MinuteInterval:120 PsKeys:1151314_14_1_1
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Timestamp              ┃ Ps Key            ┃ 1151314_14_1_1.p13147    ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ 2023-05-01 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 02:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 04:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 06:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 08:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 10:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 12:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 14:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 16:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 18:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 20:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-01 22:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-05-02 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛
bash-5.1# GoSungrow show point data 20230401 20230402 120 1151314_14_1_1.p13199

# DataTable AppService.queryMutiPointDataList.ResultData.Data - EndTimeStamp:20230402000000 MinuteInterval:120 PsKeys:1151314_14_1_1 Points:p13199 PsId:1151314 StartTimeStamp:20230401000000
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Timestamp              ┃ Ps Key            ┃ 1151314_14_1_1.p13199    ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ 2023-04-01 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 02:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 04:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 06:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 08:00:00    ┃ 1151314_14_1_1    ┃ 200                      ┃
┃ 2023-04-01 10:00:00    ┃ 1151314_14_1_1    ┃ 1000                     ┃
┃ 2023-04-01 12:00:00    ┃ 1151314_14_1_1    ┃ 2000                     ┃
┃ 2023-04-01 14:00:00    ┃ 1151314_14_1_1    ┃ 3100                     ┃
┃ 2023-04-01 16:00:00    ┃ 1151314_14_1_1    ┃ 4600                     ┃
┃ 2023-04-01 18:00:00    ┃ 1151314_14_1_1    ┃ 5400                     ┃
┃ 2023-04-01 20:00:00    ┃ 1151314_14_1_1    ┃ 5400                     ┃
┃ 2023-04-01 22:00:00    ┃ 1151314_14_1_1    ┃ 5400                     ┃
┃ 2023-04-02 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛
bash-5.1# GoSungrow show point data 20230401 20230402 120 1151314_14_1_1.p13147

# DataTable AppService.queryMutiPointDataList.ResultData.Data - Points:p13147 PsId:1151314 StartTimeStamp:20230401000000 EndTimeStamp:20230402000000 MinuteInterval:120 PsKeys:1151314_14_1_1
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Timestamp              ┃ Ps Key            ┃ 1151314_14_1_1.p13147    ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ 2023-04-01 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 02:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 04:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 06:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 08:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 10:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 12:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 14:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 16:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 18:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 20:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-01 22:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-04-02 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛
bash-5.1# GoSungrow show point data 20230201 20230202 120 1151314_14_1_1.p13199
No data table results for 'queryMutiPointDataList.ResultData.Data'

#  - has no data.
bash-5.1# GoSungrow show point data 20230201 20230202 120 1151314_14_1_1.p13147

# DataTable AppService.queryMutiPointDataList.ResultData.Data - PsKeys:1151314_14_1_1 Points:p13147 PsId:1151314 StartTimeStamp:20230201000000 EndTimeStamp:20230202000000 MinuteInterval:120
┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Timestamp              ┃ Ps Key            ┃ 1151314_14_1_1.p13147    ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ 2023-02-01 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 02:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 04:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 06:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 08:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 10:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 12:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 14:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 16:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 18:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 20:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-01 22:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┃ 2023-02-02 00:00:00    ┃ 1151314_14_1_1    ┃ 0                        ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━┛
bash-5.1# GoSungrow show point data 20230101 20230102 120 1151314_14_1_1.p13199
No data table results for 'queryMutiPointDataList.ResultData.Data'

#  - has no data.
bash-5.1# GoSungrow show point data 20230101 20230102 120 1151314_14_1_1.p13147
No data table results for 'queryMutiPointDataList.ResultData.Data'

#  - has no data.

So while in May and April I have data for both points, in February I have no data for "Daily Load Consumption" (p13199) - which is what I noticed in iSolarCloud as well, and in January I have no data for either of them (I remember neglecting the inverter over the holiday and realizing that it wasn't connected to the WiFi around mid-January).

I think that this explains the error, but I'm not sure what to do about it. It seems that missing data is more of a feature of iSolarCloud rather than an exception, so unfortunately the code has to deal with this missingness.

BTW, the "Daily purchased energy" is always 0 in my case, even when there is data reported, which is obviously wrong and tells me that the system has deep installation flaws (the system came with the house when I bought it and the company that installed it is out of business - less than 6 years later). Even so, I would still like to monitor the inverter from HA and collect data to show to an installer for repairs, so any help getting "0" for the missing data instead of "nil" data would be appreciated.

flare04 commented 12 months ago

I have this issue too or a very similar error 2023/07/07 13:03:01 INFO: Cached 250 Sungrow data points... panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0xc8 pc=0x441a60] goroutine 1 [running]: GoSungrow/iSolarCloud/AppService/queryDeviceList.(*EndPoint).SetPvPoints(_, {{_, _, _}}, {0x400075b4a0, {0x40009007e6, 0x6}, {0xc12221215296c70d, 0x2666cd5c, 0x411eca0}, ...}) /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/AppService/queryDeviceList/data.go:419 +0x630 GoSungrow/iSolarCloud/AppService/queryDeviceList.(*EndPoint).GetEnergyStorageSystem(_, {0x400075b4a0, {0x40009007e6, 0x6}, {0xc12221215296c70d, 0x2666cd5c, 0x411eca0}, {{0x400034eea0, 0x2, 0x2}}, ...}) /Users/mick/Documents/GoLang/Solar/GoSungrow/iSolarCloud/AppService/queryDeviceList/data.go:299 +0x2e0 GoSungrow/iSolarCloud/AppService/queryDeviceList.(*EndPoint).GetData(_)

shelldor commented 6 months ago

I hade the same problem.[08:53:47] INFO: Login to iSolarCloud using gateway gateway.isolarcloud.eu ... panic: runtime error: invalid memory address or nil pointer dereference

I just changed hostname from gateway.isolarcloud.eu to https://gateway.isolarcloud.eu and now it works