Open jpillora opened 1 year ago
I'm in the middle of doing a major rewrite - adding that feature wouldn't be too hard. So I'll tack it on to the end of release 2.0.0.
But if you're impatient - you'll need to follow:
Setup
ca.Api.SunGrow = iSolarCloud.NewSunGro(ca.Api.Url, ca.CacheDir)
ca.Error = ca.Api.SunGrow.Init()
The Init() will load all the endpoints up. If you don't want to do that, then you'll need to load them up manually. Each endpoint is managed within itself, so you can do that easily.
login
ca.Error = ca.Api.SunGrow.Login(login.SunGrowAuth{
AppKey: ca.Api.AppKey,
UserAccount: ca.Api.Username,
UserPassword: ca.Api.Password,
TokenFile: ca.Api.ApiTokenFile,
Force: false,
})
Query
Have a look at highlevel.go
, which shows examples of how to query some endpoints.
ep := sg.GetByStruct(
"AppService.queryMutiPointDataList",
queryMutiPointDataList.RequestData {
// PsId: api.SetIntegerValue(psId),
PsId: psId,
PsKey: pskeys,
Points: valueTypes.SetStringValue(pointNames.PrintPoints()),
MinuteInterval: valueTypes.SetStringValue("5"),
StartTimeStamp: valueTypes.SetStringValue(when.GetDayStartTimestamp()),
EndTimeStamp: valueTypes.SetStringValue(when.GetDayEndTimestamp()),
},
DefaultCacheTimeout,
)
Note, you'll need to Assert the endpoint to be able to see the locally scoped data within the endpoint interface.
data := queryMutiPointDataList.Assert(ep)
data.GetData()
table := data.GetPointDataTable(pointNames)
But, once again... major rewrite happening which will be completed in the next couple of days. So some things may have broken.
BTW... I recently found a new endpoint which returns static data on what data points are supported for your device.
GoSungrow data table WebIscmAppService.modelPointsPage DeviceModelId:714 DeviceType:14
From an existing Go program, I'd like to get my current Sungrow inverter's current kw/hr output. I could use the binary and run a shell script, though it'd be awesome if I could call a function in my Go program. Is there a small example of this?
This is what I've tried, but it crashes