Skip to content

Commit

Permalink
v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Feb 22, 2022
1 parent 04b36ed commit 3f646bc
Show file tree
Hide file tree
Showing 1,009 changed files with 3,089 additions and 4,125 deletions.
1 change: 1 addition & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,184 changes: 45 additions & 1,139 deletions .idea/workspace.xml

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,28 @@ So far I have mapped out all the API calls, but now figuring out JSON POST data

It's tricky as their "API" changes regularly.

I've currently mapped out these API EndPoints:
```
+-------------------+-------------------+--------------------+------------+
| AREAS | ENABLED ENDPOINTS | DISABLED ENDPOINTS | COVERAGE % |
+-------------------+-------------------+--------------------+------------+
| AliSmsService | 0 | 1 | 0.0 % |
| AppService | 41 | 533 | 7.7 % |
| MttvScreenService | 0 | 30 | 0.0 % |
| PowerPointService | 0 | 1 | 0.0 % |
| WebAppService | 2 | 187 | 1.1 % |
| WebIscmAppService | 0 | 184 | 0.0 % |
| ---------------- | ---------------- | ----------------- | --------- |
| Total | 43 | 936 | 4.6 % |
+-------------------+-------------------+--------------------+------------+
```

## What does it do?

This GoLang package does several things:
1. Update a GitHub repo with SunGrow PV data, (provide full revision history for any changes made to the SunGrow PV).
2. Update a Google sheet with SunGrow PV data.
3. Provides ready access to all API calls via a simple get/put framework.
1. Provides ready access to all API calls via a simple get/put framework.
2. Update a GitHub repo with SunGrow PV data, (provide full revision history for any changes made to the SunGrow PV).
3. Update a Google sheet with SunGrow PV data.

To be added:
1. MQTT client to push to things like [HomeAssistant](https://www.home-assistant.io/).
Expand Down
46 changes: 42 additions & 4 deletions examples.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
./bin/GoSungrow api get WebAppService.showPSView '{"ps_id":"1129147"}'
./bin/GoSungrow api get checkUnitStatus
./bin/GoSungrow api get energyTrend
./bin/GoSungrow api get findPsType '{"ps_id":"1129147"}'
./bin/GoSungrow api get getPsDetailWithPsType '{"ps_id":"1129147"}'
./bin/GoSungrow api get getPowerStatistics '{"ps_id":"1129147"}'
./bin/GoSungrow api get getAllPowerDeviceSetName
./bin/GoSungrow api get getAreaList
./bin/GoSungrow api get getCloudList
./bin/GoSungrow api get getConfigList
./bin/GoSungrow api get getDeviceInfo
./bin/GoSungrow api get getDeviceList
./bin/GoSungrow api get getDeviceModelInfoList
./bin/GoSungrow api get getDevicePoints '{"point_id":"13003"}'
./bin/GoSungrow api get getDeviceTypeInfoList
./bin/GoSungrow api get getDeviceTypeList
./bin/GoSungrow api get getInvertDataList
./bin/GoSungrow api get getOrgListByName
./bin/GoSungrow api get getPowerDevicePointNames '{"device_type":"1"}'
./bin/GoSungrow api get getPowerDevicePointNames '{"device_type":"2"}'
./bin/GoSungrow api get getPowerDevicePointNames '{"device_type":"7"}'
./bin/GoSungrow api get getPowerPictureList
./bin/GoSungrow api get getPowerStatistics '{"ps_id":"1129147"}'
./bin/GoSungrow api get getPsDetail
./bin/GoSungrow api get getPsDetail '{"ps_id":"1129147"}'
./bin/GoSungrow api get getPsDetailWithPsType '{"ps_id":"1129147"}'
./bin/GoSungrow api get getPsHealthState '{"ps_id":"1129147"}'
./bin/GoSungrow api get getPsList
./bin/GoSungrow api get WebAppService.showPSView '{"ps_id":"1129147"}'

./bin/GoSungrow api get getPsListByName
./bin/GoSungrow api get getPsListStaticData '{"ps_id":"1129147"}'
./bin/GoSungrow api get getPsReport '{"report_type":"1","date_id":"20220201","date_type":"1","ps_id":"1129147"}'
./bin/GoSungrow api get getPsReport '{"report_type":"1","date_id":"20220201","date_type":"2","ps_id":"1129147"}'
./bin/GoSungrow api get getPsReport '{"report_type":"1","date_id":"20220201","date_type":"3","ps_id":"1129147"}'
./bin/GoSungrow api get getPsUser
./bin/GoSungrow api get getPsWeatherList '{"ps_id":"1129147"}'
./bin/GoSungrow api get getTemplateList
./bin/GoSungrow api get getUserList
./bin/GoSungrow api get getUserPsOrderList
./bin/GoSungrow api get powerDevicePointList
./bin/GoSungrow api get queryAllPsIdAndName '{"ps_id":"1129147"}'
./bin/GoSungrow api get queryDeviceList
./bin/GoSungrow api get queryDeviceListByUserId '{"ps_id":"1129147"}'
./bin/GoSungrow api get queryDeviceListForApp '{"ps_id":"1129147"}'
./bin/GoSungrow api get queryUserList
./bin/GoSungrow api get reportList '{"ps_id":"1129147","report_type":"1"}'
./bin/GoSungrow api get reportList '{"ps_id":"1129147","report_type":"2"}'
./bin/GoSungrow api get reportList '{"ps_id":"1129147","report_type":"3"}'
./bin/GoSungrow api get reportList '{"ps_id":"1129147","report_type":"4"}'
./bin/GoSungrow api login
4 changes: 2 additions & 2 deletions iSolarCloud/api/nullEndPoint/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (e EndPoint) IsError() bool {
}

func (e EndPoint) ReadFile() error {
return e.FileRead("", &e.Response)
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
return e.FileWrite("", e.Response, api.DefaultFileMode)
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
Expand Down
8 changes: 6 additions & 2 deletions iSolarCloud/api/struct_area.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func (as AreaStruct) ListEndpoints() {
}
}

func (as AreaStruct) CountEndpoints() int {
return as.EndPoints.CountEndpoints()
func (as AreaStruct) CountEnabled() int {
return len(as.EndPoints.GetEnabled())
}

func (as AreaStruct) CountDisabled() int {
return len(as.EndPoints.GetDisabled())
}
27 changes: 24 additions & 3 deletions iSolarCloud/api/struct_areas.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,33 @@ func (an Areas) ListAreas() {
fmt.Println("Listing all endpoint areas:")

table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Areas", "EndPoints"})
table.SetHeader([]string{"Areas", "Enabled EndPoints", "Disabled EndPoints", "Coverage %"})
table.SetBorder(true)
te := 0
td := 0
for _, area := range an.SortAreas() {
size := fmt.Sprintf("%d", an[area].CountEndpoints())
table.Append([]string{string(area), size})
e := an[area].CountEnabled()
d := an[area].CountDisabled()
p := (float64(e) / float64(d)) * 100
table.Append([]string{
string(area),
fmt.Sprintf("%d", e),
fmt.Sprintf("%d", d),
fmt.Sprintf("%.1f %%", p),
})
te += e
td += d
}

table.Append([]string{"----------------", "----------------", "-----------------", "---------"})

p := (float64(te) / float64(td)) * 100
table.Append([]string{
"Total",
fmt.Sprintf("%d", te),
fmt.Sprintf("%d", td),
fmt.Sprintf("%.1f %%", p),
})
table.Render()
}
}
Expand Down
107 changes: 71 additions & 36 deletions iSolarCloud/api/struct_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,45 @@ func (ps TypeEndPoints) Exists(name EndPointName) error {
func (ps TypeEndPoints) String() string {
var ret string
for range Only.Once {
s := ps.SortEndPoints()
if len(s) == 0 {
break
}

buf := new(bytes.Buffer)
table := tablewriter.NewWriter(buf)
table.SetHeader([]string{"EndPoint", "Url"})
table.SetBorder(true)
for _, endpoint := range s {
if ps[endpoint].GetName() == NullEndPoint {
continue

ep := ps.GetEnabled()
if len(ep) > 0 {
table := tablewriter.NewWriter(buf)
table.SetHeader([]string{"EndPoint", "Url"})
table.SetBorder(true)
for _, endpoint := range ep {
u := endpoint.GetUrl().String()
table.Append([]string{
string(endpoint.GetName()),
u,
})
}
u := ps[endpoint].GetUrl().String()
table.Append([]string{
string(endpoint),
u,
})
table.Render()
ret += fmt.Sprintf("# Implemented endpoints\n")
ret += buf.String()
}
table.Render()
ret += fmt.Sprintf("# Implemented endpoints\n")
ret += buf.String()

buf = new(bytes.Buffer)
table = tablewriter.NewWriter(buf)
table.SetHeader([]string{"EndPoint", "Url"})
table.SetBorder(true)
for _, endpoint := range s {
if ps[endpoint].GetName() != NullEndPoint {
continue

dp := ps.GetDisabled()
if len(dp) > 0 {
buf = new(bytes.Buffer)
table := tablewriter.NewWriter(buf)
table.SetHeader([]string{"EndPoint", "Url"})
table.SetBorder(true)
for _, endpoint := range dp {
u := endpoint.GetUrl().String()
table.Append([]string{
string(endpoint.GetName()),
u,
})
}
table.Append([]string{
string(endpoint),
"",
})
table.Render()
ret += fmt.Sprintf("# Non-implemented endpoints\n")
ret += buf.String()
}
table.Render()
ret += fmt.Sprintf("# Non-implemented endpoints\n")
ret += buf.String()

ret += fmt.Sprintf("\n# Implemented: %d Non-implemented: %d\n", len(ep), len(dp))

}
return ret
}
Expand All @@ -91,8 +91,43 @@ func (ps *TypeEndPoints) SortEndPoints() []EndPointName {
return ret
}

func (ps *TypeEndPoints) CountEndpoints() int {
return len(*ps)
//func (ps *TypeEndPoints) CountEndpoints() int {
// return len(*ps)
//}

func (ps *TypeEndPoints) GetEnabled() TypeEndPoints {
ret := make(TypeEndPoints)
for range Only.Once {
s := ps.SortEndPoints()
if len(s) == 0 {
break
}

for _, endpoint := range s {
if (*ps)[endpoint].IsDisabled() {
continue
}
ret[(*ps)[endpoint].GetName()] = (*ps)[endpoint]
}
}
return ret
}

func (ps *TypeEndPoints) GetDisabled() TypeEndPoints {
ret := make(TypeEndPoints)
for range Only.Once {
s := ps.SortEndPoints()
if len(s) == 0 {
break
}

for _, endpoint := range s {
if (*ps)[endpoint].IsDisabled() {
ret[(*ps)[endpoint].GetName()] = (*ps)[endpoint]
}
}
}
return ret
}

func (ps *TypeEndPoints) GetEndPoint(name EndPointName) EndPoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (e EndPoint) IsError() bool {
}

func (e EndPoint) ReadFile() error {
return e.FileRead("", &e.Response)
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
return e.FileWrite("", e.Response, api.DefaultFileMode)
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
Expand Down
4 changes: 2 additions & 2 deletions iSolarCloud/sungro/AppService/acceptPsSharing/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (e EndPoint) IsError() bool {
}

func (e EndPoint) ReadFile() error {
return e.FileRead("", &e.Response)
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
return e.FileWrite("", e.Response, api.DefaultFileMode)
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
Expand Down
4 changes: 2 additions & 2 deletions iSolarCloud/sungro/AppService/activateEmail/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (e EndPoint) IsError() bool {
}

func (e EndPoint) ReadFile() error {
return e.FileRead("", &e.Response)
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
return e.FileWrite("", e.Response, api.DefaultFileMode)
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
Expand Down
4 changes: 2 additions & 2 deletions iSolarCloud/sungro/AppService/addConfig/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (e EndPoint) IsError() bool {
}

func (e EndPoint) ReadFile() error {
return e.FileRead("", &e.Response)
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
return e.FileWrite("", e.Response, api.DefaultFileMode)
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
Expand Down
4 changes: 2 additions & 2 deletions iSolarCloud/sungro/AppService/addDeviceRepair/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (e EndPoint) IsError() bool {
}

func (e EndPoint) ReadFile() error {
return e.FileRead("", &e.Response)
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
return e.FileWrite("", e.Response, api.DefaultFileMode)
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (e EndPoint) IsError() bool {
}

func (e EndPoint) ReadFile() error {
return e.FileRead("", &e.Response)
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
return e.FileWrite("", e.Response, api.DefaultFileMode)
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (e EndPoint) IsError() bool {
}

func (e EndPoint) ReadFile() error {
return e.FileRead("", &e.Response)
return e.FileRead("", &e.Response.ResultData)
}

func (e EndPoint) WriteFile() error {
return e.FileWrite("", e.Response, api.DefaultFileMode)
return e.FileWrite("", e.Response.ResultData, api.DefaultFileMode)
}

func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
Expand Down

0 comments on commit 3f646bc

Please sign in to comment.