v3.0.0-alpha - docs

This commit is contained in:
MickMake 2022-12-08 20:43:13 +11:00
parent b847cbbd2c
commit 3b4e391b12
28 changed files with 1289 additions and 1084 deletions

93
.idea/workspace.xml generated
View File

@ -5,9 +5,12 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="76adadc9-ae71-42a6-82a1-66dbc8ecb14c" name="Changes" comment=""> <list default="true" id="76adadc9-ae71-42a6-82a1-66dbc8ecb14c" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_meta.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_api.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/AppService.queryMutiPointDataList.ResultData.Data-Points_p58603.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/AppService.queryMutiPointDataList.ResultData.Data-Points_p58604.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/AppService.queryMutiPointDataList.ResultData.Data-Points_p58605.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/AppService.queryMutiPointDataList.ResultData.Data-Points_p58606.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_data.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_data.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/cmd/cmd_data.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_info.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_info.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/cmd/cmd_info.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_info.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/cmd/cmd_show.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show.go" afterDir="false" />
@ -15,32 +18,11 @@
<change beforePath="$PROJECT_DIR$/cmd/cmd_show_point.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_point.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/cmd/cmd_show_point.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_point.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show_psid.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_psid.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/cmd/cmd_show_psid.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_psid.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show_template.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_template.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/cmd/cmd_show_template.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_template.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/commands.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/commands.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/getDeviceList/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/getDeviceList/data.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_output.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_output.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/getPsList/funcs.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/getPsList/funcs.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfo/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfo/data.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_endpoints.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_endpoints.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfoForApp/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfoForApp/data.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_url.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_url.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceList/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/AppService/queryMutiPointDataList/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryMutiPointDataList/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/Common/images.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/Common/images.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/MttvScreenService/getPsDeviceListValue/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/MttvScreenService/getPsDeviceListValue/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/WebAppService/getDevicePointAttrs/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/WebAppService/getDevicePointAttrs/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/WebAppService/getPsTree/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/WebAppService/getPsTree/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/WebIscmAppService/queryDeviceListForBackSys/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/WebIscmAppService/queryDeviceListForBackSys/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_graph.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_reflect.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/struct_table.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/datetime.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/datetime.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/integers.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/integers.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/point.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/types.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/GoStruct/valueTypes/uv.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/web.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/web.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/data_request.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/data_request.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_device.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_device.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_device.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_device.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_point.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_point.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_point.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_point.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_ps.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_ps.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_ps.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_ps.go" afterDir="false" />
@ -118,7 +100,7 @@
<configuration name="GoSungrow" type="GoApplicationRunConfiguration" factoryName="Go Application"> <configuration name="GoSungrow" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="GoSungrow" /> <module name="GoSungrow" />
<working_directory value="$PROJECT_DIR$" /> <working_directory value="$PROJECT_DIR$" />
<parameters value="show device points 43" /> <parameters value="data md AppService.getPowerDevicePointNames DeviceType:14" />
<envs> <envs>
<env name="GOCACHE" value="/Volumes/Media/GoCache" /> <env name="GOCACHE" value="/Volumes/Media/GoCache" />
</envs> </envs>
@ -224,7 +206,7 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url>
<line>67</line> <line>68</line>
<option name="timeStamp" value="3787" /> <option name="timeStamp" value="3787" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -507,11 +489,6 @@
<line>18</line> <line>18</line>
<option name="timeStamp" value="7467" /> <option name="timeStamp" value="7467" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_template.go</url>
<line>147</line>
<option name="timeStamp" value="7510" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data_request.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/data_request.go</url>
<line>817</line> <line>817</line>
@ -539,7 +516,7 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url>
<line>107</line> <line>108</line>
<option name="timeStamp" value="7740" /> <option name="timeStamp" value="7740" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -567,11 +544,6 @@
<line>594</line> <line>594</line>
<option name="timeStamp" value="7772" /> <option name="timeStamp" value="7772" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_point.go</url>
<line>74</line>
<option name="timeStamp" value="7800" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/WebIscmAppService/queryDeviceListForBackSys/data.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/WebIscmAppService/queryDeviceListForBackSys/data.go</url>
<line>55</line> <line>55</line>
@ -584,12 +556,12 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>665</line> <line>547</line>
<option name="timeStamp" value="7893" /> <option name="timeStamp" value="7893" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>643</line> <line>525</line>
<option name="timeStamp" value="7902" /> <option name="timeStamp" value="7902" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -672,24 +644,19 @@
<line>261</line> <line>261</line>
<option name="timeStamp" value="8015" /> <option name="timeStamp" value="8015" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
<line>318</line>
<option name="timeStamp" value="8028" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url> <url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url>
<line>90</line> <line>96</line>
<option name="timeStamp" value="8032" /> <option name="timeStamp" value="8032" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url> <url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url>
<line>91</line> <line>101</line>
<option name="timeStamp" value="8033" /> <option name="timeStamp" value="8033" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url> <url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url>
<line>59</line> <line>61</line>
<option name="timeStamp" value="8039" /> <option name="timeStamp" value="8039" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -728,24 +695,24 @@
<option name="timeStamp" value="8052" /> <option name="timeStamp" value="8052" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/struct_endpoints.go</url>
<line>206</line> <line>36</line>
<option name="timeStamp" value="8053" /> <option name="timeStamp" value="8063" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/struct_url.go</url>
<line>249</line> <line>52</line>
<option name="timeStamp" value="8054" /> <option name="timeStamp" value="8064" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_output.go</url>
<line>163</line> <line>204</line>
<option name="timeStamp" value="8057" /> <option name="timeStamp" value="8065" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint"> <line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url> <url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_output.go</url>
<line>157</line> <line>230</line>
<option name="timeStamp" value="8058" /> <option name="timeStamp" value="8066" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>
<default-breakpoints> <default-breakpoints>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

501
README.md
View File

@ -1,11 +1,6 @@
# GoSungrow - iSolarCloud API written in GoLang. # GoSungrow - iSolarCloud API written in GoLang.
Note: I'm currently going through a big refactor. The next major release, (v3.0.0), will: Note: I'm currently going through a big refactor. The next major release, (v3.0.0).
- support better api changes. This allows a much quicker change in my code when the api changes.
- support multiple devices. Previous versions only allowed query of one device.
- improve cli for queries. Now can fetch endpoints in either "list" or "table" formats, the latter showing point data in a similar fashion to pivot tables in spreadsheets.
- multiple output formats supported - not only csv, png and ascii, but markdown, xml, HTML, sql and plain MQTT.
- lots of bug fixes. :-).
[Latest releases here](https://github.com/MickMake/GoSungrow/releases) [Latest releases here](https://github.com/MickMake/GoSungrow/releases)
@ -14,13 +9,14 @@ Note: I'm currently going through a big refactor. The next major release, (v3.0.
## What is it? ## What is it?
This GoLang package has a complete, (almost complete), implementation of the iSolarCloud API. This GoLang package has a complete implementation of the iSolarCloud API.
There's been no published specs on this, so I've had to figure it all out based on the [Android app](https://play.google.com/store/apps/details?id=com.isolarcloud.manager), using javascript IDEs and various other means. There's been no published specs on this, so I've had to figure it all out based on the [Android app](https://play.google.com/store/apps/details?id=com.isolarcloud.manager), using javascript IDEs and various other means.
Note: Note:
- [iSolarCloud](https://isolarcloud.com) has no interest in developing a public API. - [iSolarCloud](https://isolarcloud.com) has no interest in developing a public API.
- Their "API" implementation is so broken with security and coding issues, I'm surprised it hasn't been exploited yet. - Their "API" implementation is so broken with security and coding issues, I'm surprised it hasn't been exploited yet.
- iSolarCloud reached out to me, (based off this GitHub page), to see what can be done about these security issues. So that's a very good thing. - iSolarCloud reached out to me, (based off this GitHub page), to see what can be done about these security issues. So that's a very good thing.
- As of 1st August 2022 I discovered a number of security holes. At which point I notified AusCert, the vendor and a number of other security companies - hopefully they will get patched because my tool makes it very easy.
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/iSolarCloudLogin.png?raw=true) ![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/iSolarCloudLogin.png?raw=true)
@ -50,25 +46,35 @@ I'm currently using it in my [HomeAssistant](https://www.home-assistant.io/) ins
## What state is it in? ## What state is it in?
This is currently usable for my needs, (seeing all data in [HomeAssistant](https://www.home-assistant.io/)), but there's quite a few API endpoints that need to be implemented for completeness. It was originally intended for my needs, (seeing all data in [HomeAssistant](https://www.home-assistant.io/)), but there seems to be a big interest in this tool.
So I've spent some time working on the v3.0.0 release.
So far I have mapped out all the API calls. It's tricky as their "API" changes regularly. v3.0.0 changelog:
- Support better api changes. This allows a much quicker change in my code when the api changes.
- Support multiple devices. Previous versions only allowed query of one device.
- Improve cli for queries. Now can fetch endpoints in either "list" or "table" formats, the latter showing point data in a similar fashion to pivot tables in spreadsheets.
- Multiple output formats supported - not only csv, png and ascii, but markdown, xml, HTML, sql and plain MQTT.
- Lots of bug fixes. :-).
I have now mapped out all the API calls. All the read-only endpoints are mapped out and fully tested. The write-only calls haven't been tested fully.
It's tricky as their "API" changes regularly; however I've accommodated for quick changes in the v3.0.0 release.
Most endpoints contain repeated data. The main endpoints that house most of the data I've provided easy commands to access.
Of course, all endpoints are accessible. So go for your life.
I've currently mapped out these API EndPoints. All of the critical read only endpoints are mapped out, with none of the write endpoints.
Most endpoints are a repeat and a lot of the data contained is repeated.
So, in reality 50% of all endpoints are implemented.
``` ```
+-------------------+-------------------+--------------------+------------+ +-------------------+-------------------+--------------------+------------+
| AREAS | ENABLED ENDPOINTS | DISABLED ENDPOINTS | COVERAGE % | | AREAS | ENABLED ENDPOINTS | DISABLED ENDPOINTS | COVERAGE % |
+-------------------+-------------------+--------------------+------------+ +-------------------+-------------------+--------------------+------------+
| AliSmsService | 0 | 1 | 0.0 % | | AliSmsService | 1 | 0 | 100 % |
| AppService | 52 | 522 | 10.0 % | | AppService | 574 | 0 | 100 % |
| MttvScreenService | 0 | 30 | 0.0 % | | MttvScreenService | 30 | 0 | 100 % |
| PowerPointService | 0 | 1 | 0.0 % | | NullArea | 1 | 0 | 100 % |
| WebAppService | 4 | 186 | 2.2 % | | PowerPointService | 1 | 0 | 100 % |
| WebIscmAppService | 0 | 184 | 0.0 % | | WebAppService | 190 | 0 | 100 % |
| WebIscmAppService | 184 | 0 | 100 % |
| ---------------- | ---------------- | ----------------- | --------- | | ---------------- | ---------------- | ----------------- | --------- |
| Total | 56 | 924 | 6.1 % | | Total | 981 | 0 | 100 % |
+-------------------+-------------------+--------------------+------------+ +-------------------+-------------------+--------------------+------------+
``` ```
@ -78,9 +84,8 @@ So, in reality 50% of all endpoints are implemented.
This GoLang package does several things: This GoLang package does several things:
1. 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. MQTT client to push to [HomeAssistant](https://www.home-assistant.io/). 2. MQTT client to push to [HomeAssistant](https://www.home-assistant.io/).
3. Graphing any points data, (over daily, monthly and yearly). 3. Graphing any data points, over daily, monthly and yearly with 5 to hour time granularity.
4. Update a GitHub repo with SunGrow PV data, (provide full revision history for any changes made to the SunGrow PV). 4. Output data to various formats - JSON, CSV, raw, Graphing, XML, XLSX, Markdown, and GoLang structures.
5. Update a Google sheet with SunGrow PV data.
## What is the roadmap? ## What is the roadmap?
@ -88,12 +93,15 @@ This GoLang package does several things:
I've implemented most of the features I've wanted to, except for... I've implemented most of the features I've wanted to, except for...
1. IFTTT support. 1. IFTTT support.
The most recent version has changed the code-base substantially, making it a lot more robust to changes in the API JSON schema.
## Using GoSungrow: ## Using GoSungrow:
### Config and login. ### Config and login.
Add your username and password to the config. (See [the website](https://portalau.isolarcloud.com/)) Add your username and password to the config. (See [the website](https://portalau.isolarcloud.com/))
Once done, it's a case of set and forget. GoSungrow will handle the re-authentication for you.
``` ```
$ ./bin/GoSungrow config write --user=USERNAME --password=PASSWORD $ ./bin/GoSungrow config write --user=USERNAME --password=PASSWORD
Using config file '/Users/mick/.GoSungrow/config.json' Using config file '/Users/mick/.GoSungrow/config.json'
@ -117,204 +125,305 @@ Token File: /Users/mick/.GoSungrow/AppService_login.json
### High level reporting examples. ### High level reporting examples.
Produce point-in-time statistics Show all devices on your iSolarCloud account.
``` ```
$ ./bin/GoSungrow data get stats ./bin/GoSungrow show ps list
+---------------------+-----------+---------------------------+---------+------+ ┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
| Date | Point Id | Point Name | Value | Unit | ┃ Ps Key ┃ Ps Id ┃ Device Type ┃ Device Code ┃ Channel Id ┃ Serial # ┃ Factory Name ┃ Device Model ┃
+---------------------+-----------+---------------------------+---------+------+ ┣━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┫
| 2022-02-28 11:05:00 | 1129147.0 | Co2 Reduce | 3.589 | kg | ┃ 1129147_14_1_1 │ 1129147 │ 14 │ 1 │ 1 │ B2192301528 │ SUNGROW │ SH10RT ┃
| 2022-02-28 11:05:00 | 1129147.0 | Co2 Reduce Total | 1047 | kg | ┃ 1129147_22_247_1 │ 1129147 │ 22 │ 247 │ 1 │ B2192301528 │ SUNGROW │ WiNet-S ┃
| 2022-02-28 11:05:00 | 1129147.0 | Curr Power | 641 | W | ┃ 1129147_43_2_1 │ 1129147 │ 43 │ 2 │ 1 │ B2192301528 │ SUNGROW │ SBR096 ┃
| 2022-02-28 11:05:00 | 1129147.0 | Daily Irradiation | -- | | ┃ 1171348_14_1_2 │ 1171348 │ 14 │ 1 │ 2 │ B2281302388 │ SUNGROW │ SH10RT-V112 ┃
| 2022-02-28 11:05:00 | 1129147.0 | Equivalent Hour | 0.36 | Hour | ┃ 1171348_22_247_2 │ 1171348 │ 22 │ 247 │ 2 │ B2281302388 │ SUNGROW │ WiNet-S ┃
| 2022-02-28 11:05:00 | 1129147.0 | Es Discharge Energy | 4.8 | kWh | ┃ 1171348_43_2_2 │ 1171348 │ 43 │ 2 │ 2 │ B2281302388 │ SUNGROW │ SBR096 ┃
| 2022-02-28 11:05:00 | 1129147.0 | Es Energy | 1.6 | kWh | ┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┛
| 2022-02-28 11:05:00 | 1129147.0 | Es Power | 641 | W |
| 2022-02-28 11:05:00 | 1129147.0 | Es Total Discharge Energy | 109.9 | kWh |
| 2022-02-28 11:05:00 | 1129147.0 | Es Total Energy | 106.2 | kWh |
| 2022-02-28 11:05:00 | 1129147.0 | Installed Power Map | 10 | kWp |
| 2022-02-28 11:05:00 | 1129147.0 | Pv Energy | 3.6 | kWh |
| 2022-02-28 11:05:00 | 1129147.0 | Pv Power | 2.291 | kW |
| 2022-02-28 11:05:00 | 1129147.0 | Radiation | -- | |
| 2022-02-28 11:05:00 | 1129147.0 | Today Energy | 3.6 | kWh |
| 2022-02-28 11:05:00 | 1129147.0 | Today Income | 1.346 | AUD |
| 2022-02-28 11:05:00 | 1129147.0 | Total Capacity | 10 | kWp |
| 2022-02-28 11:05:00 | 1129147.0 | Total Energy | 1.05 | MWh |
| 2022-02-28 11:05:00 | 1129147.0 | Total Income | 302.074 | AUD |
| 2022-02-28 11:05:00 | 1129147.0 | Use Energy | 7.6 | kWh |
+---------------------+-----------+---------------------------+---------+------+
``` ```
Show the device tree on your iSolarCloud account.
```
./bin/GoSungrow show ps tree
+ PsId:1129147 PsName:MickMake PsKey:1129147_11_0_0 DeviceName:MickMake Uuid:844763
+ PsId:1129147 PsName:MickMake PsKey:1129147_11_0_0 DeviceName:MickMake Uuid:844763
+-- PsId:1129147 PsName:MickMake PsKey:1129147_14_1_1 DeviceName:SH10RT Uuid:844775
+---- PsId:1129147 PsName:MickMake PsKey:1129147_43_2_1 DeviceName:Battery_001_002 Uuid:1155386
+ PsId:1129147 PsName:MickMake PsKey:1129147_11_0_0 DeviceName:MickMake Uuid:844763
+-- PsId:1129147 PsName:MickMake PsKey:1129147_14_1_1 DeviceName:SH10RT Uuid:844775
+---- PsId:1129147 PsName:MickMake PsKey:1129147_43_2_1 DeviceName:Battery_001_002 Uuid:1155386
+-- PsId:1129147 PsName:MickMake PsKey:1129147_22_247_1 DeviceName:WiNet-S Uuid:844774
+ PsId:1171348 PsName:MickMake42 PsKey:1171348_11_0_0 DeviceName:MickMake42 Uuid:1179860
+-- PsId:1171348 PsName:MickMake42 PsKey:1171348_22_247_2 DeviceName:Communication Module 02_247 Uuid:1179877
+-- PsId:1171348 PsName:MickMake42 PsKey:1171348_14_1_2 DeviceName:Energy Storage System 02_01 Uuid:1179878
+---- PsId:1171348 PsName:MickMake42 PsKey:1171348_43_2_2 DeviceName:Battery 02_02 Uuid:1179879
```
List all known data points for all PS on your account.
```
./bin/GoSungrow show ps points
# Available points:
# Available points:
┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Id ┃ Name ┃ Unit ┃ Unit Type ┃ Ps Id ┃ Device Type ┃ Device Name ┃
┣━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ p83001 │ Inverter AC Power Normalization │ kW/kWp │ 43 │ 1129147 │ 11 │ MickMake ┃
┃ p83002 │ Inverter AC Power │ kW │ 3 │ 1129147 │ 11 │ MickMake ┃
┃ p83004 │ Inverter Total Yield │ kWh │ 7 │ 1129147 │ 11 │ MickMake ┃
┃ p83005 │ Daily Equivalent Hours of Meter │ h │ 15 │ 1129147 │ 11 │ MickMake ┃
┃ p83006 │ Meter Daily Yield │ kWh │ 7 │ 1129147 │ 11 │ MickMake ┃
┃ p83007 │ Meter PR │ % │ 10 │ 1129147 │ 11 │ MickMake ┃
┃ p83008 │ Daily Equivalent Hours of Inverter │ h │ 15 │ 1129147 │ 11 │ MickMake ┃
┃ p83009 │ Daily Yield by Inverter │ kWh │ 7 │ 1129147 │ 11 │ MickMake ┃
┃ p83010 │ Inverter PR │ % │ 10 │ 1129147 │ 11 │ MickMake ┃
┃ p83011 │ Meter E-daily Consumption │ kWh │ 7 │ 1129147 │ 11 │ MickMake ┃
...
┃ p58630 │ Min. Cell Voltage of Module 5 │ mV │ 31 │ 1171348 │ 43 │ Battery 02_02 ┃
┃ p58631 │ Min. Cell Voltage of Module 6 │ mV │ 31 │ 1171348 │ 43 │ Battery 02_02 ┃
┃ p58632 │ Min. Cell Voltage of Module 7 │ mV │ 31 │ 1171348 │ 43 │ Battery 02_02 ┃
┃ p58633 │ Min. Cell Voltage of Module 8 │ mV │ 31 │ 1171348 │ 43 │ Battery 02_02 ┃
┃ p58635 │ DC Contactor State │ │ 999 │ 1171348 │ 43 │ Battery 02_02 ┃
┃ p58636 │ Fault Module ID │ │ 999 │ 1171348 │ 43 │ Battery 02_02 ┃
┗━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
```
Produce data table of device_type 22 on ps_id 1171348 between 20221001 and 20221002 at 60 minute increments.
```
./bin/GoSungrow show ps data 11713482 22 20221001 20221002 60
------------------------ --------------------- ----------------------------
Timestamp Ps Key 1171348_22_247_2.p23014
------------------------ --------------------- ----------------------------
2022-10-01 00:00:00 1171348_22_247_2 --
2022-10-01 01:00:00 1171348_22_247_2 --
2022-10-01 02:00:00 1171348_22_247_2 --
2022-10-01 03:00:00 1171348_22_247_2 --
2022-10-01 04:00:00 1171348_22_247_2 --
2022-10-01 05:00:00 1171348_22_247_2 --
2022-10-01 06:00:00 1171348_22_247_2 --
2022-10-01 07:00:00 1171348_22_247_2 --
2022-10-01 08:00:00 1171348_22_247_2 --
2022-10-01 09:00:00 1171348_22_247_2 --
2022-10-01 10:00:00 1171348_22_247_2 --
2022-10-01 11:00:00 1171348_22_247_2 --
2022-10-01 12:00:00 1171348_22_247_2 --
2022-10-01 13:00:00 1171348_22_247_2 --
2022-10-01 14:00:00 1171348_22_247_2 -68
2022-10-01 15:00:00 1171348_22_247_2 -82
2022-10-01 16:00:00 1171348_22_247_2 -81
2022-10-01 17:00:00 1171348_22_247_2 -81
2022-10-01 18:00:00 1171348_22_247_2 -86
2022-10-01 19:00:00 1171348_22_247_2 -82
2022-10-01 20:00:00 1171348_22_247_2 -90
2022-10-01 21:00:00 1171348_22_247_2 -89
2022-10-01 22:00:00 1171348_22_247_2 -88
2022-10-01 23:00:00 1171348_22_247_2 -86
2022-10-02 00:00:00 1171348_22_247_2 -83
------------------------ --------------------- ----------------------------
```
Do the same, but with a graph!
```
./bin/GoSungrow show ps graph 1171348 22 20221001 20221002 60
Found ps_keys: 1129147_14_1_1,1129147_22_247_1,1129147_43_2_1,1171348_14_1_2,1171348_22_247_2,1171348_43_2_2
Finding points to graph...
Table Headers: Timestamp, Ps Key, 1171348_22_247_2.p23014
Table rows: 25
Found 1 points.
Creating graph file 'AppService.queryMutiPointDataList.ResultData.Data-1171348-1171348_22_247_2.p23014.png'
```
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService.queryMutiPointDataList.ResultData.Data-1171348-1171348_22_247_2.p23014.png?raw=true)
Get all defined report templates. Get all defined report templates.
``` ```
./bin/GoSungrow data get templates ./bin/GoSungrow show template list
+-------------+---------------+---------------------+
| Template Id | Template Name | Update On | # DataTable AppService.getTemplateList.ResultData.PageList - DataTable AppService.getTemplateList.ResultData.PageList
+-------------+---------------+---------------------+ ---------------- ------------------ ------------------------
| 8042 | Critical | 2022-02-15 13:00:28 | Template Id Template Name Update Time
| 8041 | extras | 2022-02-15 09:40:04 | ---------------- ------------------ ------------------------
| 8036 | C | 2022-02-15 09:31:35 | 7981 Power 2022-02-09 10:03:40
| 8039 | v | 2022-02-15 09:31:10 | 8031 kWh 2022-02-15 07:57:36
| 8040 | A | 2022-02-15 09:30:56 | 8035 Hours 2022-02-15 08:55:56
| 8034 | Percent | 2022-02-15 09:30:41 | 8033 kW 2022-02-15 09:01:19
| 8038 | MWh | 2022-02-15 09:09:22 | 8037 MW 2022-02-15 09:03:22
| 8037 | MW | 2022-02-15 09:03:22 | 8038 MWh 2022-02-15 09:09:22
| 8033 | kW | 2022-02-15 09:01:19 | 8034 Percent 2022-02-15 09:30:41
| 8035 | Hours | 2022-02-15 08:55:56 | 8040 A 2022-02-15 09:30:56
| 8031 | kWh | 2022-02-15 07:57:36 | 8039 v 2022-02-15 09:31:10
| 7981 | Power | 2022-02-09 10:03:40 | 8036 C 2022-02-15 09:31:35
+-------------+---------------+---------------------+ 8041 extras 2022-02-15 09:40:04
8042 Critical 2022-02-15 13:00:28
8092 ALL1 2022-03-09 17:18:21
8093 ALL2 2022-03-09 17:20:42
8094 ALL3 2022-03-09 17:36:20
8095 ALL4 2022-03-09 17:37:56
8652 NewAll1 2022-10-04 12:27:00
8653 NewAll2 2022-10-04 12:28:58
8654 NewAll03 2022-10-04 12:31:39
8655 NewAll04 2022-10-04 12:34:51
8656 NewAll05 2022-10-04 12:37:34
8657 NewAll06 2022-10-04 12:38:27
---------------- ------------------ ------------------------
``` ```
Show all data points used in a report template. Show all data points used in a report template.
``` ```
$ ./bin/GoSungrow data get template-points 8040 ./bin/GoSungrow show template points 8040
+---------+----------------------------+------+
| PointId | Description | Unit | # DataTable WebAppService.queryUserCurveTemplateData.8040.ResultData.PointsData.Devices.[1129147_14_1_1].Points - TemplateId:8040
+---------+----------------------------+------+ ------------- ----------------------------------- ------------ ------------------- ------------ -------------- ------------- --------------- ---------- --------- --------------
| p83106 | Load Power | kW | Point Id Point Name Ps Id Ps Key Color Detail Id Ps Name Statistics Style Unit Data List
| p13003 | Total DC Power | kW | ------------- ----------------------------------- ------------ ------------------- ------------ -------------- ------------- --------------- ---------- --------- --------------
| p13019 | Internal Air Temperature | ℃ | p13002 MPPT1 Current 1129147 1129147_14_1_1 #FFFF00 123808 MickMake 5 1 A
| p13142 | Battery Health (SOH) | % | p13008 Phase A Current 1129147 1129147_14_1_1 #FF0000 123814 MickMake 5 1 A
| p13149 | Purchased Power | kW | p13009 Phase B Current 1129147 1129147_14_1_1 #00FF00 123813 MickMake 5 1 A
| p13150 | Battery Discharging Power | kW | p13010 Phase C Current 1129147 1129147_14_1_1 #0000FF 123812 MickMake 5 1 A
| p13121 | Total Export Active Power | kW | p13106 MPPT2 Current 1129147 1129147_14_1_1 #70DB93 123807 MickMake 5 1 A
| p13126 | Battery Charging Power | kW | p13139 Battery Current 1129147 1129147_14_1_1 #CD7F32 123806 MickMake 5 1 A
| p13141 | Battery Level (SOC) | % | p13162 Max. Charging Current (BMS) 1129147 1129147_14_1_1 #C0C0C0 123805 MickMake 5 1 A
| p13143 | Battery Temperature | ℃ | p13163 Max. Discharging Current (BMS) 1129147 1129147_14_1_1 #9F9F9F 123804 MickMake 5 1 A
+---------+----------------------------+------+ p18062 Phase A Backup Current 1129147 1129147_14_1_1 #FF00FF 123811 MickMake 5 1 A
p18063 Phase B Backup Current 1129147 1129147_14_1_1 #00FFFF 123810 MickMake 5 1 A
p18064 Phase C Backup Current 1129147 1129147_14_1_1 #000000 123809 MickMake 5 1 A
------------- ----------------------------------- ------------ ------------------- ------------ -------------- ------------- --------------- ---------- --------- --------------
``` ```
Produce daily report for template 8040 for date 2022/02/24 display on STDOUT. Produce daily report for template 8040 for date 2022/02/24 display on STDOUT.
``` ```
$ ./bin/GoSungrow data get template 8040 20220224 ./bin/GoSungrow show template data 8040 20220204 20220205 120
+---------------------+-----------------------+----------------------------+-------------+-------+
| Date/Time | Point Id | Point Name | Value | Units |
+---------------------+-----------------------+----------------------------+-------------+-------+
| 2022-02-24 00:00:00 | 1129147_11_0_0.p83106 | Load Power | 818.0 | kW |
| 2022-02-24 00:05:00 | 1129147_11_0_0.p83106 | Load Power | 756.0 | kW |
| 2022-02-24 00:10:00 | 1129147_11_0_0.p83106 | Load Power | 571.0 | kW |
| 2022-02-24 00:15:00 | 1129147_11_0_0.p83106 | Load Power | 557.0 | kW |
| 2022-02-24 00:20:00 | 1129147_11_0_0.p83106 | Load Power | 553.0 | kW |
| 2022-02-24 00:25:00 | 1129147_11_0_0.p83106 | Load Power | 558.0 | kW |
| 2022-02-24 00:30:00 | 1129147_11_0_0.p83106 | Load Power | 562.0 | kW |
... # DataTable AppService.queryMutiPointDataList.ResultData.Data - PsId:1129147 StartTimeStamp:20220204000000 EndTimeStamp:20220205000000 MinuteInterval:120 PsKeys:1129147_14_1_1,1129147_14_1_1,1129147_14_1_1,1129147_14_1_1,1129147_14_1_1,1129147_14_1_1,1129147_14_1_1,1129147_14_1_1,1129147_14_1_1,1129147_14_1_1,1129147_14_1_1 Points:p13002,p13008,p13162,p18062,p18064,p13009,p13010,p13106,p13139,p13163,p18063
------------------------ ------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- --------------------------
+---------------------+-----------------------+----------------------------+-------------+-------+ Timestamp Ps Key 1129147_14_1_1.p13002 1129147_14_1_1.p13008 1129147_14_1_1.p13009 1129147_14_1_1.p13010 1129147_14_1_1.p13106 1129147_14_1_1.p13139 1129147_14_1_1.p13162 1129147_14_1_1.p13163 1129147_14_1_1.p18062 1129147_14_1_1.p18063 1129147_14_1_1.p18064
------------------------ ------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- --------------------------
2022-02-04 00:00:00 1129147_14_1_1 0 0 0 0 0 0 30 30 0 0.1 0
2022-02-04 02:00:00 1129147_14_1_1 0 0 0 0 0 0 30 30 0 0.1 0
2022-02-04 04:00:00 1129147_14_1_1 0 0 0 0 0 0 30 30 0 0.1 0
2022-02-04 06:00:00 1129147_14_1_1 0 1.38 1.38 1.29 0 4.6 30 28 0 0.1 0
2022-02-04 08:00:00 1129147_14_1_1 2.39 3.31 3.31 3.31 6.1 0 30 29 0 0.1 0
2022-02-04 10:00:00 1129147_14_1_1 6.35 1.75 1.75 1.75 15.4 24.5 30 30 0 0.1 0
2022-02-04 12:00:00 1129147_14_1_1 6.99 9.84 9.94 9.84 19.5 0 0 30 0 0.2 0
2022-02-04 14:00:00 1129147_14_1_1 0.64 0.83 0.83 0.83 1.4 0 0 30 0 0.1 0
2022-02-04 16:00:00 1129147_14_1_1 0.37 3.13 3.13 3.13 0.8 10.1 20 30 0 0.1 0
2022-02-04 18:00:00 1129147_14_1_1 0 1.01 0.92 1.01 0 3.8 30 30 0 0.1 0
2022-02-04 20:00:00 1129147_14_1_1 0 1.38 1.47 1.47 0 5.5 30 30 0 0.1 0
2022-02-04 22:00:00 1129147_14_1_1 0 0 0 0 0 0 30 30 0 0.1 0
2022-02-05 00:00:00 1129147_14_1_1 0 0 0 0 0 0 30 30 0 0.1 0
------------------------ ------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- -------------------------- --------------------------
``` ```
Produce daily report for template 8042 for date 2022/02/24 and save as a JSON file. And now graph it!
``` ```
$ ./bin/GoSungrow data save template 8042 20220224 ./bin/GoSungrow show template graph 8040 20220204 20220205 120
Finding points to graph...
Table Headers: Timestamp, Ps Key, 1129147_14_1_1.p13002, 1129147_14_1_1.p13008, 1129147_14_1_1.p13009, 1129147_14_1_1.p13010, 1129147_14_1_1.p13106, 1129147_14_1_1.p13139, 1129147_14_1_1.p13162, 1129147_14_1_1.p13163, 1129147_14_1_1.p18062, 1129147_14_1_1.p18063, 1129147_14_1_1.p18064
Table rows: 13
Found 11 points.
Creating graph file 'AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13002.png'
Creating graph file 'AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13008.png'
Creating graph file 'AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13009.png'
Creating graph file 'AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13010.png'
Creating graph file 'AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13106.png'
``` ```
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService.queryMutiPointDataList.ResultData.Data-1171348-1171348_22_247_2.p23014.png?raw=true)
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13002.png?raw=true)
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13008.png?raw=true)
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13139.png?raw=true)
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13162.png?raw=true)
Produce graph of daily report for template 8040 for date 2022/02/24 and point_id P13019.
List all possible devices
``` ```
$ ./bin/GoSungrow data get template-points 8040 ./bin/GoSungrow show device list
+---------+----------------------------+------+ # Available points:
| PointId | Description | Unit | ┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+---------+----------------------------+------+ ┃ Device Type ┃ Name ┃
| p83106 | Load Power | kW | ┣━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
| p13003 | Total DC Power | kW | ┃ 1 │ Inverter ┃
| p13121 | Total Export Active Power | kW | ┃ 10 │ String ┃
| p13142 | Battery Health (SOH) | % | ┃ 11 │ Plant ┃
| p13150 | Battery Discharging Power | kW | ┃ 12 │ Circuit Protection ┃
| p13019 | Internal Air Temperature | ℃ | ┃ 13 │ Splitting Device ┃
| p13126 | Battery Charging Power | kW | ┃ 14 │ Energy Storage System ┃
| p13141 | Battery Level (SOC) | % | ┃ 15 │ Sampling Device ┃
| p13143 | Battery Temperature | ℃ | ┃ 16 │ EMU ┃
| p13149 | Purchased Power | kW | ┃ 17 │ Unit ┃
+---------+----------------------------+------+ ┃ 18 │ Temperature and Humidity Sensor ┃
┃ 19 │ Intelligent Power Distribution Cabinet ┃
$ ./bin/GoSungrow data graph template 8042 20220224 '{"search_string":"p13019"}' ┃ 20 │ Display Device ┃
``` ┃ 21 │ AC Power Distributed Cabinet ┃
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220224-8042-InternalAirTemperature.png?raw=true) ┃ 22 │ Communication Module ┃
┃ 23 │ System-BMS ┃
Produce graphs of all points from template 8042 for date 2022/02/28 with a different width and height. ┃ 24 │ RackBMS ┃
``` ┃ 25 │ DC-DC ┃
$ ./bin/GoSungrow data graph template 8042 20220228 '{"width":2400,"height":500}' ┃ 26 │ Energy Management System ┃
``` ┃ 28 │ Wind Energy Converter ┃
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8042-PurchasedPower.png?raw=true) ┃ 29 │ SVG ┃
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8042-LoadPower.png?raw=true) ┃ 3 │ Grid-connection Point ┃
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8042-BatteryTemperature.png?raw=true) ┃ 30 │ PT Cabinet ┃
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8042-InternalAirTemperature.png?raw=true) ┃ 31 │ Bus Protection ┃
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8042-BatteryChargingPower.png?raw=true) ┃ 32 │ Cleaning Robot ┃
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8042-BatteryDischargingPower.png?raw=true) ┃ 33 │ Direct Current Cabinet ┃
┃ 34 │ Public Measurement and Control ┃
Produce daily report for point_id p83106 for date 2022/02/24. ┃ 35 │ Anti-islanding Protection Device ┃
``` ┃ 36 │ Frequency and Voltage Emergency Control Device ┃
$ ./bin/GoSungrow data get points 20220224 1129147_11_0_0.p83106 ┃ 37 │ PCS ┃
+---------------------+-----------------------+------------+--------+-------+ ┃ 38 │ Cell BMS ┃
| Date/Time | Point Id | Point Name | Value | Units | ┃ 39 │ Power Quality ┃
+---------------------+-----------------------+------------+--------+-------+ ┃ 4 │ Combiner Box ┃
| 2022-02-24 00:00:00 | 1129147_11_0_0.p83106 | | 818.0 | | ┃ 40 │ Shuttle ┃
| 2022-02-24 00:05:00 | 1129147_11_0_0.p83106 | | 756.0 | | ┃ 41 │ Optimizer ┃
| 2022-02-24 00:10:00 | 1129147_11_0_0.p83106 | | 571.0 | | ┃ 42 │ Tracking axis communication box ┃
| 2022-02-24 00:15:00 | 1129147_11_0_0.p83106 | | 557.0 | | ┃ 43 │ Battery ┃
| 2022-02-24 00:20:00 | 1129147_11_0_0.p83106 | | 553.0 | | ┃ 44 │ Battery Cluster Management Unit ┃
| 2022-02-24 00:25:00 | 1129147_11_0_0.p83106 | | 558.0 | | ┃ 45 │ Local Controller ┃
| 2022-02-24 00:30:00 | 1129147_11_0_0.p83106 | | 562.0 | | ┃ 46 │ Networking Devices ┃
| 2022-02-24 00:35:00 | 1129147_11_0_0.p83106 | | 561.0 | | ┃ 47 │ Energy Storage Unit ┃
┃ 48 │ DC Container ┃
... ┃ 5 │ Meteo Station ┃
┃ 50 │ IO Module ┃
+---------------------+-----------------------+------------+--------+-------+ ┃ 51 │ Charger ┃
``` ┃ 52 │ Battery System Controller ┃
┃ 6 │ Transformer ┃
Get all point ids by device_type. ┃ 7 │ Meter ┃
``` ┃ 8 │ UPS ┃
+-------------+------------+----------+----------------------------------------+ ┃ 9 │ Data Logger ┃
| Device Type | Point Type | Point Id | Point Name | ┃ 99 │ Others ┃
+-------------+------------+----------+----------------------------------------+ ┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
| 1 | 2 | 1 | Daily Yield |
| 1 | 1 | 24 | Total Active Power |
| 1 | 1 | 2 | Total Yield |
| 1 | 1 | 14 | Total DC Power |
| 1 | 1 | 18 | Phase A Voltage |
| 1 | 1 | 19 | Phase B Voltage |
| 1 | 1 | 20 | Phase C Voltage |
| 1 | 1 | 21 | Phase A Current |
| 1 | 1 | 22 | Phase B Current |
| 1 | 1 | 23 | Phase C Current |
| 1 | 1 | 25 | Total Reactive Power |
| 1 | 1 | 27 | Grid Frequency |
| 1 | 1 | 15 | A-B Line Voltage |
| 1 | 1 | 16 | B-C Line Voltage |
| 1 | 1 | 17 | C-A Line Voltage |
| 1 | 1 | 4 | Internal Air Temperature |
| 1 | 1 | 26 | Total Power Factor |
| 1 | 1 | 90 | Negative Voltage to Ground |
| 1 | 1 | 43 | Total Apparent Power |
| 1 | 1 | 33 | Module 1 Temperature |
| 1 | 1 | 34 | Module 2 Temperature |
| 1 | 1 | 39 | Positive Impedance to Ground |
| 1 | 1 | 40 | Negative Impedance to Ground |
| 1 | 1 | 41 | P-limit-actual |
| 1 | 1 | 42 | Reactive Power Regulation Actual Value |
| 1 | 2 | 67 | Daily Yield (Theoretical) |
| 1 | 1 | 5 | MPPT1 Voltage |
| 1 | 1 | 6 | MPPT1 Current |
| 1 | 1 | 7 | MPPT2 Voltage |
| 1 | 1 | 8 | MPPT2 Current |
| 1 | 1 | 70 | String 1 Current |
| 1 | 1 | 71 | String 2 Current |
| 1 | 1 | 72 | String 3 Current |
| 1 | 1 | 73 | String 4 Current |
| 1 | 1 | 74 | String 5 Current |
| 1 | 1 | 75 | String 6 Current |
| 1 | 1 | 76 | String 7 Current |
...
+-------------+------------+----------+----------------------------------------+
``` ```
Get mains power frequency variation graph from template id 8041 on date 2022/02/28 Get mains power frequency variation graph from template id 8041 on date 2022/02/28
``` ```
./bin/GoSungrow data graph template 8041 20220228 '{"search_string":"p13007","min_left_axis":49,"max_left_axis":51}' ./bin/GoSungrow show point data 20220301 20220302 120 1129147_14_1_1.p13007
# DataTable AppService.queryMutiPointDataList.ResultData.Data - PsKeys:1129147_14_1_1 Points:p13007 PsId:1129147 StartTimeStamp:20220301000000 EndTimeStamp:20220302000000 MinuteInterval:120
------------------------ ------------------- --------------------------
Timestamp Ps Key 1129147_14_1_1.p13007
------------------------ ------------------- --------------------------
2022-03-01 00:00:00 1129147_14_1_1 49.969997
2022-03-01 02:00:00 1129147_14_1_1 49.98
2022-03-01 04:00:00 1129147_14_1_1 50.01
2022-03-01 06:00:00 1129147_14_1_1 49.98
2022-03-01 08:00:00 1129147_14_1_1 49.98
2022-03-01 10:00:00 1129147_14_1_1 50.01
2022-03-01 12:00:00 1129147_14_1_1 50
2022-03-01 14:00:00 1129147_14_1_1 50.02
2022-03-01 16:00:00 1129147_14_1_1 49.96
2022-03-01 18:00:00 1129147_14_1_1 50.01
2022-03-01 20:00:00 1129147_14_1_1 50
2022-03-01 22:00:00 1129147_14_1_1 49.969997
2022-03-02 00:00:00 1129147_14_1_1 50.01
------------------------ ------------------- --------------------------
./bin/GoSungrow show point graph 20220301 20220302 120 1129147_14_1_1.p13007
Finding points to graph...
Table Headers: Timestamp, Ps Key, 1129147_14_1_1.p13007
Table rows: 13
Found 1 points.
Creating graph file 'AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13007.png'
``` ```
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8041-GridFrequency.png?raw=true) ![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService.queryMutiPointDataList.ResultData.Data-1129147-1129147_14_1_1.p13007.png?raw=true)
### Using the API instead. ### Using the API instead.

View File

@ -180,6 +180,22 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command {
c.SelfCmd.AddCommand(cmdApiXLSX) c.SelfCmd.AddCommand(cmdApiXLSX)
cmdApiXLSX.Example = cmdHelp.PrintExamples(cmdApiXLSX, "queryDeviceList", "WebAppService.showPSView") cmdApiXLSX.Example = cmdHelp.PrintExamples(cmdApiXLSX, "queryDeviceList", "WebAppService.showPSView")
// ******************************************************************************** //
var cmdApiMarkDown = &cobra.Command{
Use: output.StringTypeMarkDown + " <[area.]endpoint> [endpoint args ...]",
Aliases: []string{},
Annotations: map[string]string{"group": "Data"},
Short: fmt.Sprintf("Get data from the Sungrow api (MarkDown)"),
Long: fmt.Sprintf("Get data from the Sungrow api (MarkDown)"),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.GetEndpoints,
Args: cobra.MinimumNArgs(0),
}
c.SelfCmd.AddCommand(cmdApiMarkDown)
cmdApiMarkDown.Example = cmdHelp.PrintExamples(cmdApiMarkDown, "queryDeviceList", "WebAppService.showPSView")
// ******************************************************************************** // // ******************************************************************************** //
var cmdApiStruct = &cobra.Command{ var cmdApiStruct = &cobra.Command{
Use: output.StringTypeStruct + " <[area.]endpoint> [endpoint args ...]", Use: output.StringTypeStruct + " <[area.]endpoint> [endpoint args ...]",
@ -207,6 +223,9 @@ func (c *CmdData) GetEndpoints(cmd *cobra.Command, args []string) error {
if cmd.Name() == output.StringTypeXLSX { if cmd.Name() == output.StringTypeXLSX {
cmds.Api.SaveFile = true cmds.Api.SaveFile = true
} }
if cmd.Name() == output.StringTypeGraph {
cmds.Api.SaveFile = true
}
args = MinimumArraySize(2, args) args = MinimumArraySize(2, args)
eps := iSolarCloud.SplitArg(args[0]) eps := iSolarCloud.SplitArg(args[0])

View File

@ -127,6 +127,25 @@ func (c *CmdInfo) AttachCommand(cmd *cobra.Command) *cobra.Command {
cmdInfoCsv.Example = cmdHelp.PrintExamples(cmdInfoCsv, "[area.]<endpoint>") cmdInfoCsv.Example = cmdHelp.PrintExamples(cmdInfoCsv, "[area.]<endpoint>")
c.AttachCmdInfo(cmdInfoCsv) c.AttachCmdInfo(cmdInfoCsv)
// ********************************************************************************
var cmdInfoMarkDown = &cobra.Command{
Use: output.StringTypeMarkDown,
Aliases: []string{},
Annotations: map[string]string{"group": "Info"},
Short: fmt.Sprintf("Get info from iSolarCloud (MarkDown)"),
Long: fmt.Sprintf("Get info from iSolarCloud (MarkDown)"),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
Args: cobra.MinimumNArgs(1),
}
c.SelfCmd.AddCommand(cmdInfoMarkDown)
cmdInfoMarkDown.Example = cmdHelp.PrintExamples(cmdInfoMarkDown, "[area.]<endpoint>")
c.AttachCmdInfo(cmdInfoMarkDown)
// // ******************************************************************************** // // ********************************************************************************
// var cmdInfoPut = &cobra.Command{ // var cmdInfoPut = &cobra.Command{
// Use: "put", // Use: "put",

View File

@ -26,13 +26,12 @@ func (c *CmdShow) AttachCommand(cmd *cobra.Command) *cobra.Command {
} }
c.cmd = cmd c.cmd = cmd
// ******************************************************************************** //
c.SelfCmd = &cobra.Command{ c.SelfCmd = &cobra.Command{
Use: "show", Use: "show",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Show"}, Annotations: map[string]string{"group": "Show"},
Short: fmt.Sprintf("Helpful Sungrow functions."), Short: fmt.Sprintf("High-level Sungrow commands."),
Long: fmt.Sprintf("Helpful Sungrow functions."), Long: fmt.Sprintf("High-level Sungrow commands."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: func(cmd *cobra.Command, args []string) error { PreRunE: func(cmd *cobra.Command, args []string) error {
@ -56,8 +55,8 @@ func (c *CmdShow) AttachCommand(cmd *cobra.Command) *cobra.Command {
c.AttachPsId(c.SelfCmd) c.AttachPsId(c.SelfCmd)
c.AttachDevice(c.SelfCmd) c.AttachDevice(c.SelfCmd)
c.AttachPoint(c.SelfCmd)
c.AttachTemplate(c.SelfCmd) c.AttachTemplate(c.SelfCmd)
c.AttachPoint(c.SelfCmd)
} }
return c.SelfCmd return c.SelfCmd
} }

View File

@ -14,8 +14,8 @@ func (c *CmdShow) AttachDevice(cmd *cobra.Command) *cobra.Command {
Use: "device", Use: "device",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Device"}, Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("Sungrow devices."), Short: fmt.Sprintf("Device related Sungrow commands."),
Long: fmt.Sprintf("Sungrow devices."), Long: fmt.Sprintf("Device related Sungrow commands."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
@ -29,6 +29,8 @@ func (c *CmdShow) AttachDevice(cmd *cobra.Command) *cobra.Command {
c.AttachDeviceList(self) c.AttachDeviceList(self)
c.AttachDevicePoints(self) c.AttachDevicePoints(self)
c.AttachDeviceData(self)
c.AttachDeviceGraph(self)
c.AttachDeviceModels(self) c.AttachDeviceModels(self)
} }
return c.SelfCmd return c.SelfCmd
@ -36,8 +38,7 @@ func (c *CmdShow) AttachDevice(cmd *cobra.Command) *cobra.Command {
func (c *CmdShow) AttachDeviceList(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachDeviceList(cmd *cobra.Command) *cobra.Command {
// ******************************************************************************** var self = &cobra.Command{
var c2 = &cobra.Command{
Use: "list", Use: "list",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Annotations: map[string]string{"group": "Device"}, Annotations: map[string]string{"group": "Device"},
@ -49,36 +50,40 @@ func (c *CmdShow) AttachDeviceList(cmd *cobra.Command) *cobra.Command {
RunE: c.funcDeviceTypeList, RunE: c.funcDeviceTypeList,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(c2) cmd.AddCommand(self)
c2.Example = cmdHelp.PrintExamples(c2, "") self.Example = cmdHelp.PrintExamples(self, "")
return cmd return cmd
} }
func (c *CmdShow) funcDeviceTypeList(_ *cobra.Command, args []string) error { func (c *CmdShow) funcDeviceTypeList(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable() cmds.Api.SunGrow.OutputType.SetTable()
ret := cmds.Api.SunGrow.DeviceTypeList() var ret string
ret, c.Error = cmds.Api.SunGrow.DeviceTypeList()
if c.Error != nil {
break
}
fmt.Println(ret) fmt.Println(ret)
} }
return c.Error return c.Error
} }
func (c *CmdShow) AttachDevicePoints(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachDevicePoints(cmd *cobra.Command) *cobra.Command {
// ******************************************************************************** var self = &cobra.Command{
var c2 = &cobra.Command{
Use: "points <device_type ...>", Use: "points <device_type ...>",
Aliases: []string{"point"}, Aliases: []string{"point"},
Annotations: map[string]string{"group": "Device"}, Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("List data points used by a device."), Short: fmt.Sprintf("List points used for a given device_type."),
Long: fmt.Sprintf("List data points used by a device."), Long: fmt.Sprintf("List points used for a given device_type."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcDevicePoints, RunE: c.funcDevicePoints,
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
} }
cmd.AddCommand(c2) cmd.AddCommand(self)
c2.Example = cmdHelp.PrintExamples(c2, self.Example = cmdHelp.PrintExamples(self,
"1", "1",
"11", "11",
) )
@ -88,19 +93,24 @@ func (c *CmdShow) AttachDevicePoints(cmd *cobra.Command) *cobra.Command {
func (c *CmdShow) funcDevicePoints(_ *cobra.Command, args []string) error { func (c *CmdShow) funcDevicePoints(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable() cmds.Api.SunGrow.OutputType.SetTable()
ret := cmds.Api.SunGrow.DevicePoints(args...) var ret string
ret, c.Error = cmds.Api.SunGrow.DeviceTypePoints(args...)
if c.Error != nil {
break
}
fmt.Println(ret) fmt.Println(ret)
} }
return c.Error return c.Error
} }
func (c *CmdShow) AttachDeviceData(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachDeviceData(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{ var self = &cobra.Command{
Use: "data <device_type> [start date] [end date] [interval]", Use: "data <device_type> [start date] [end date] [interval]",
Aliases: []string{},
Annotations: map[string]string{"group": "Device"}, Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("Get data from report template."), Short: fmt.Sprintf("Generate points table for a given device_type."),
Long: fmt.Sprintf("Get data from report template."), Long: fmt.Sprintf("Generate points table for a given device_type."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
@ -122,22 +132,22 @@ func (c *CmdShow) funcDeviceData(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable() cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(4, args) args = MinimumArraySize(4, args)
c.Error = cmds.Api.SunGrow.DeviceData(args[0], args[1], args[2], args[3]) c.Error = cmds.Api.SunGrow.DeviceTypeData(args[0], args[1], args[2], args[3])
} }
return c.Error return c.Error
} }
func (c *CmdShow) AttachDeviceDataGraph(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachDeviceGraph(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{ var self = &cobra.Command{
Use: "data-graph <device_type> [start date] [end date] [interval]", Use: "graph <device_type> [start date] [end date] [interval]",
Aliases: []string{},
Annotations: map[string]string{"group": "Device"}, Annotations: map[string]string{"group": "Device"},
Short: fmt.Sprintf("Get data from report template."), Short: fmt.Sprintf("Generate graphs of points for a given device_type."),
Long: fmt.Sprintf("Get data from report template."), Long: fmt.Sprintf("Generate graphs of points for a given device_type."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcDeviceDataGraph, RunE: c.funcDeviceGraph,
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
@ -151,18 +161,17 @@ func (c *CmdShow) AttachDeviceDataGraph(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcDeviceDataGraph(_ *cobra.Command, args []string) error { func (c *CmdShow) funcDeviceGraph(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
cmds.Api.SunGrow.OutputType.SetGraph() cmds.Api.SunGrow.OutputType.SetGraph()
args = MinimumArraySize(4, args) args = MinimumArraySize(4, args)
c.Error = cmds.Api.SunGrow.DeviceData(args[0], args[1], args[2], args[3]) c.Error = cmds.Api.SunGrow.DeviceTypeData(args[0], args[1], args[2], args[3])
} }
return c.Error return c.Error
} }
func (c *CmdShow) AttachDeviceModels(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachDeviceModels(cmd *cobra.Command) *cobra.Command {
// ******************************************************************************** var self = &cobra.Command{
var c2 = &cobra.Command{
Use: "models", Use: "models",
Aliases: []string{"model"}, Aliases: []string{"model"},
Annotations: map[string]string{"group": "Device"}, Annotations: map[string]string{"group": "Device"},
@ -174,14 +183,14 @@ func (c *CmdShow) AttachDeviceModels(cmd *cobra.Command) *cobra.Command {
RunE: c.funcDeviceModels, RunE: c.funcDeviceModels,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(c2) cmd.AddCommand(self)
c2.Example = cmdHelp.PrintExamples(c2, "") self.Example = cmdHelp.PrintExamples(self, "")
return cmd return cmd
} }
func (c *CmdShow) funcDeviceModels(_ *cobra.Command, _ []string) error { func (c *CmdShow) funcDeviceModels(_ *cobra.Command, _ []string) error {
for range Only.Once { for range Only.Once {
// _ = cmds.SetOutputType(cmd) cmds.Api.SunGrow.OutputType.SetTable()
c.Error = cmds.Api.SunGrow.DeviceModelInfoList() c.Error = cmds.Api.SunGrow.DeviceModelInfoList()
} }
return c.Error return c.Error

View File

@ -5,7 +5,6 @@ import (
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/cmdHelp" "github.com/MickMake/GoUnify/cmdHelp"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"strings"
) )
@ -15,8 +14,8 @@ func (c *CmdShow) AttachPoint(cmd *cobra.Command) *cobra.Command {
Use: "point", Use: "point",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Point"}, Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("General iSolarCloud functions."), Short: fmt.Sprintf("Point related Sungrow commands."),
Long: fmt.Sprintf("General iSolarCloud functions."), Long: fmt.Sprintf("Point related Sungrow commands."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
@ -41,7 +40,7 @@ func (c *CmdShow) AttachPoint(cmd *cobra.Command) *cobra.Command {
c.AttachPointTemplateGraph(self) c.AttachPointTemplateGraph(self)
c.AttachPointData(self) c.AttachPointData(self)
c.AttachPointDataGraph(self) c.AttachPointGraph(self)
c.AttachPointScan(self) c.AttachPointScan(self)
} }
@ -59,7 +58,7 @@ func (c *CmdShow) AttachPointPs(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcPointPs, RunE: c.funcAttachPsPoints,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
@ -67,22 +66,10 @@ func (c *CmdShow) AttachPointPs(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcPointPs(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(2, args)
points := cmds.Api.SunGrow.PointNames(strings.Split(args[0], ","), args[1])
if c.Error != nil {
break
}
fmt.Printf("%s\n", points)
}
return c.Error
}
func (c *CmdShow) AttachPointPsTable(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointPsTable(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "ps-table <ps_ids | .> <device_type | .> (start)<YYYYmmdd[HHMMSS]> (end)<YYYYmmdd[HHMMSS]> <interval_minutes | .>", Use: "ps-data <ps_ids | .> <device_type | .> (start)<YYYYmmdd[HHMMSS]> (end)<YYYYmmdd[HHMMSS]> <interval_minutes | .>",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Point"}, Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Generate points table for a given ps_id."), Short: fmt.Sprintf("Generate points table for a given ps_id."),
@ -90,7 +77,7 @@ func (c *CmdShow) AttachPointPsTable(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcPointPsTable, RunE: c.funcAttachPsData,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
@ -103,17 +90,6 @@ func (c *CmdShow) AttachPointPsTable(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcPointPsTable(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(5, args)
_ = cmds.Api.SunGrow.PointNamesData(strings.Split(args[0], ","), args[1], args[2], args[3], args[4])
if c.Error != nil {
break
}
}
return c.Error
}
func (c *CmdShow) AttachPointPsGraph(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointPsGraph(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
@ -125,7 +101,7 @@ func (c *CmdShow) AttachPointPsGraph(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcPointPsGraph, RunE: c.funcAttachPsGraph,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
@ -138,96 +114,10 @@ func (c *CmdShow) AttachPointPsGraph(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcPointPsGraph(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetGraph()
args = MinimumArraySize(5, args)
_ = cmds.Api.SunGrow.PointNamesData(strings.Split(args[0], ","), args[1], args[2], args[3], args[4])
if c.Error != nil {
break
}
}
return c.Error
}
func (c *CmdShow) AttachPointTemplate(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var c2 = &cobra.Command{
Use: "template <template_id>",
Aliases: []string{},
Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("List data points used by a report template."),
Long: fmt.Sprintf("List data points used by a report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplatePoints,
Args: cobra.ExactArgs(1),
}
cmd.AddCommand(c2)
c2.Example = cmdHelp.PrintExamples(c2,
"8042",
"8040",
)
return cmd
}
func (c *CmdShow) AttachPointTemplateTable(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{
Use: "template-data <template_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Generate points table for a given report template."),
Long: fmt.Sprintf("Generate points table for a given report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplateData,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd
}
func (c *CmdShow) AttachPointTemplateGraph(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{
Use: "template-graph <template_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Generate graphs of points for a given report template."),
Long: fmt.Sprintf("Generate graphs of points for a given report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplateData,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd
}
func (c *CmdShow) AttachPointDevice(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointDevice(cmd *cobra.Command) *cobra.Command {
// ******************************************************************************** var self = &cobra.Command{
var c2 = &cobra.Command{
Use: "device <device_type ...>", Use: "device <device_type ...>",
Aliases: []string{"devices"}, Aliases: []string{"devices"},
Annotations: map[string]string{"group": "Point"}, Annotations: map[string]string{"group": "Point"},
@ -239,8 +129,8 @@ func (c *CmdShow) AttachPointDevice(cmd *cobra.Command) *cobra.Command {
RunE: c.funcDevicePoints, RunE: c.funcDevicePoints,
Args: cobra.ExactArgs(1), Args: cobra.ExactArgs(1),
} }
cmd.AddCommand(c2) cmd.AddCommand(self)
c2.Example = cmdHelp.PrintExamples(c2, self.Example = cmdHelp.PrintExamples(self,
"1", "1",
"11", "11",
) )
@ -249,10 +139,9 @@ func (c *CmdShow) AttachPointDevice(cmd *cobra.Command) *cobra.Command {
} }
func (c *CmdShow) AttachPointDeviceTable(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointDeviceTable(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{ var self = &cobra.Command{
Use: "device-data <device_id> [start date] [end date] [interval]", Use: "device-data <device_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Template"}, Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Generate points table for a given device."), Short: fmt.Sprintf("Generate points table for a given device."),
Long: fmt.Sprintf("Generate points table for a given device."), Long: fmt.Sprintf("Generate points table for a given device."),
DisableFlagParsing: false, DisableFlagParsing: false,
@ -274,10 +163,9 @@ func (c *CmdShow) AttachPointDeviceTable(cmd *cobra.Command) *cobra.Command {
} }
func (c *CmdShow) AttachPointDeviceGraph(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointDeviceGraph(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{ var self = &cobra.Command{
Use: "device-graph <template_id> [start date] [end date] [interval]", Use: "device-graph <template_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Template"}, Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Generate graphs of points for a given device."), Short: fmt.Sprintf("Generate graphs of points for a given device."),
Long: fmt.Sprintf("Generate graphs of points for a given device."), Long: fmt.Sprintf("Generate graphs of points for a given device."),
DisableFlagParsing: false, DisableFlagParsing: false,
@ -299,37 +187,74 @@ func (c *CmdShow) AttachPointDeviceGraph(cmd *cobra.Command) *cobra.Command {
} }
func (c *CmdShow) AttachPointScan(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointTemplate(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "scan [min] [max]", Use: "template <template_id>",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Point"}, Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Scan full list of points."), Short: fmt.Sprintf("List data points used by a report template."),
Long: fmt.Sprintf("Scan full list of points."), Long: fmt.Sprintf("List data points used by a report template."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcPointScan, RunE: c.funcTemplatePoints,
Args: cobra.MinimumNArgs(2), Args: cobra.ExactArgs(1),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, self.Example = cmdHelp.PrintExamples(self,
"1 1000", "8042",
) "8040",
)
return cmd return cmd
} }
func (c *CmdShow) funcPointScan(_ *cobra.Command, args []string) error {
for range Only.Once { func (c *CmdShow) AttachPointTemplateTable(cmd *cobra.Command) *cobra.Command {
cmds.Api.SunGrow.OutputType.SetTable() var self = &cobra.Command{
args = MinimumArraySize(2, args) Use: "template-data <template_id> [start date] [end date] [interval]",
points := cmds.Api.SunGrow.PointScan(args[0], args[1]) Annotations: map[string]string{"group": "Point"},
if c.Error != nil { Short: fmt.Sprintf("Generate points table for a given report template."),
break Long: fmt.Sprintf("Generate points table for a given report template."),
} DisableFlagParsing: false,
fmt.Printf("%s\n", points) DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplateData,
Args: cobra.MinimumNArgs(1),
} }
return c.Error cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd
}
func (c *CmdShow) AttachPointTemplateGraph(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "template-graph <template_id> [start date] [end date] [interval]",
Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Generate graphs of points for a given report template."),
Long: fmt.Sprintf("Generate graphs of points for a given report template."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplateData,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"8092 20221201 20221202 30",
"8092 20221201 20221202 5",
"8092 20221201 20221202",
"8092 20221201",
"8092",
)
return cmd
} }
@ -358,7 +283,7 @@ func (c *CmdShow) funcPointData(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable() cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(4, args) args = MinimumArraySize(4, args)
cmds.Api.SunGrow.PointData(args[0], args[1], args[2], args[3:]...) c.Error = cmds.Api.SunGrow.PointData(args[0], args[1], args[2], args[3:]...)
if c.Error != nil { if c.Error != nil {
break break
} }
@ -366,17 +291,17 @@ func (c *CmdShow) funcPointData(_ *cobra.Command, args []string) error {
return c.Error return c.Error
} }
func (c *CmdShow) AttachPointDataGraph(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPointGraph(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "data-graph (start)<YYYYmmdd[HHMMSS]> (end)<YYYYmmdd[HHMMSS]> <interval_minutes | .> <points ...>", Use: "graph (start)<YYYYmmdd[HHMMSS]> (end)<YYYYmmdd[HHMMSS]> <interval_minutes | .> <points ...>",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Point"}, Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Get data points."), Short: fmt.Sprintf("Graph data points."),
Long: fmt.Sprintf("Get data points."), Long: fmt.Sprintf("Graph data points."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcPointDataGraph, RunE: c.funcPointGraph,
Args: cobra.MinimumNArgs(4), Args: cobra.MinimumNArgs(4),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
@ -387,14 +312,50 @@ func (c *CmdShow) AttachPointDataGraph(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcPointDataGraph(_ *cobra.Command, args []string) error { func (c *CmdShow) funcPointGraph(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
cmds.Api.SunGrow.OutputType.SetGraph() cmds.Api.SunGrow.OutputType.SetGraph()
args = MinimumArraySize(4, args) args = MinimumArraySize(4, args)
cmds.Api.SunGrow.PointData(args[0], args[1], args[2], args[3:]...) c.Error = cmds.Api.SunGrow.PointData(args[0], args[1], args[2], args[3:]...)
if c.Error != nil { if c.Error != nil {
break break
} }
} }
return c.Error return c.Error
} }
func (c *CmdShow) AttachPointScan(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "scan [min] [max]",
Aliases: []string{},
Annotations: map[string]string{"group": "Point"},
Short: fmt.Sprintf("Scan full list of points."),
Long: fmt.Sprintf("Scan full list of points."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcPointScan,
Args: cobra.MinimumNArgs(2),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self,
"1 1000",
)
return cmd
}
func (c *CmdShow) funcPointScan(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(2, args)
var points string
points, c.Error = cmds.Api.SunGrow.PointScan(args[0], args[1])
if c.Error != nil {
break
}
fmt.Printf("%s\n", points)
}
return c.Error
}

View File

@ -16,8 +16,8 @@ func (c *CmdShow) AttachPsId(cmd *cobra.Command) *cobra.Command {
Use: "ps", Use: "ps",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "PsId"}, Annotations: map[string]string{"group": "PsId"},
Short: fmt.Sprintf("General iSolarCloud functions."), Short: fmt.Sprintf("Ps related Sungrow commands."),
Long: fmt.Sprintf("General iSolarCloud functions."), Long: fmt.Sprintf("Ps related Sungrow commands."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
@ -29,24 +29,27 @@ func (c *CmdShow) AttachPsId(cmd *cobra.Command) *cobra.Command {
cmd.AddCommand(self) cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "") self.Example = cmdHelp.PrintExamples(self, "")
c.AttachPsIdList(self) c.AttachPsList(self)
c.AttachPsTree(self) c.AttachPsTree(self)
c.AttachPsPoints(self) c.AttachPsPoints(self)
c.AttachPsData(self)
c.AttachPsGraph(self)
} }
return c.SelfCmd return c.SelfCmd
} }
func (c *CmdShow) AttachPsIdList(cmd *cobra.Command) *cobra.Command {
func (c *CmdShow) AttachPsList(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "list", Use: "list",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Annotations: map[string]string{"group": "Device"}, Annotations: map[string]string{"group": "PsId"},
Short: fmt.Sprintf("Show all devices on account."), Short: fmt.Sprintf("Show all devices on account."),
Long: fmt.Sprintf("Show all devices on account."), Long: fmt.Sprintf("Show all devices on account."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcPsIdListList, RunE: c.funcPsList,
Args: cobra.MinimumNArgs(0), Args: cobra.MinimumNArgs(0),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
@ -54,13 +57,14 @@ func (c *CmdShow) AttachPsIdList(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcPsIdListList(_ *cobra.Command, args []string) error { func (c *CmdShow) funcPsList(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
var devices string var devices string
devices, c.Error = cmds.Api.SunGrow.Devices(args...) devices, c.Error = cmds.Api.SunGrow.PsList(args...)
if c.Error != nil { if c.Error != nil {
break break
} }
fmt.Printf("%s\n", devices) fmt.Printf("%s\n", devices)
} }
return c.Error return c.Error
@ -68,7 +72,7 @@ func (c *CmdShow) funcPsIdListList(_ *cobra.Command, args []string) error {
func (c *CmdShow) AttachPsIdList2(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPsIdList2(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "list", Use: "list2",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Annotations: map[string]string{"group": "PsId"}, Annotations: map[string]string{"group": "PsId"},
Short: fmt.Sprintf("Show all available PS."), Short: fmt.Sprintf("Show all available PS."),
@ -90,6 +94,7 @@ func (c *CmdShow) funcAttachPsIdList2(_ *cobra.Command, args []string) error {
if c.Error != nil { if c.Error != nil {
break break
} }
fmt.Printf("%s\n", pids) fmt.Printf("%s\n", pids)
} }
return c.Error return c.Error
@ -120,6 +125,7 @@ func (c *CmdShow) funcAttachPsTree(_ *cobra.Command, args []string) error {
if c.Error != nil { if c.Error != nil {
break break
} }
fmt.Printf("%s\n", pids) fmt.Printf("%s\n", pids)
} }
return c.Error return c.Error
@ -127,11 +133,11 @@ func (c *CmdShow) funcAttachPsTree(_ *cobra.Command, args []string) error {
func (c *CmdShow) AttachPsPoints(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachPsPoints(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{ var self = &cobra.Command{
Use: "points <ps_ids | .> [device_type]", Use: "points [ps_ids | .] [device_type]",
Aliases: []string{"point"}, Aliases: []string{"point"},
Annotations: map[string]string{"group": "PsId"}, Annotations: map[string]string{"group": "PsId"},
Short: fmt.Sprintf("Show available PS points."), Short: fmt.Sprintf("List points used for a given ps_id."),
Long: fmt.Sprintf("Show available PS points."), Long: fmt.Sprintf("List points used for a given ps_id."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
@ -146,12 +152,73 @@ func (c *CmdShow) AttachPsPoints(cmd *cobra.Command) *cobra.Command {
func (c *CmdShow) funcAttachPsPoints(_ *cobra.Command, args []string) error { func (c *CmdShow) funcAttachPsPoints(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
args = MinimumArraySize(2, args) args = MinimumArraySize(2, args)
points := cmds.Api.SunGrow.PointNames(strings.Split(args[0], ","), args[1]) var points string
if cmds.Api.SunGrow.Error != nil { points, c.Error = cmds.Api.SunGrow.PsPoints(strings.Split(args[0], ","), args[1])
c.Error = cmds.Api.SunGrow.Error if c.Error != nil {
break break
} }
fmt.Printf("%s\n", points) fmt.Printf("%s\n", points)
} }
return c.Error return c.Error
} }
func (c *CmdShow) AttachPsData(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "data <ps_ids | .> [device_type | .] [start date] [end date] [interval]",
Aliases: []string{"point"},
Annotations: map[string]string{"group": "PsId"},
Short: fmt.Sprintf("Generate points table for a given ps_id."),
Long: fmt.Sprintf("Generate points table for a given ps_id."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachPsData,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "")
return cmd
}
func (c *CmdShow) funcAttachPsData(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetTable()
args = MinimumArraySize(5, args)
c.Error = cmds.Api.SunGrow.PsPointsData(strings.Split(args[0], ","), args[1], args[2], args[3], args[4])
if c.Error != nil {
break
}
}
return c.Error
}
func (c *CmdShow) AttachPsGraph(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "graph <ps_ids | .> [device_type]",
Aliases: []string{},
Annotations: map[string]string{"group": "PsId"},
Short: fmt.Sprintf("Generate graphs of points for a given ps_id."),
Long: fmt.Sprintf("Generate graphs of points for a given ps_id."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcAttachPsGraph,
Args: cobra.MinimumNArgs(1),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "")
return cmd
}
func (c *CmdShow) funcAttachPsGraph(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.OutputType.SetGraph()
args = MinimumArraySize(5, args)
c.Error = cmds.Api.SunGrow.PsPointsData(strings.Split(args[0], ","), args[1], args[2], args[3], args[4])
if c.Error != nil {
break
}
}
return c.Error
}

View File

@ -14,8 +14,8 @@ func (c *CmdShow) AttachTemplate(cmd *cobra.Command) *cobra.Command {
Use: "template", Use: "template",
Aliases: []string{}, Aliases: []string{},
Annotations: map[string]string{"group": "Template"}, Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("General iSolarCloud functions."), Short: fmt.Sprintf("Template related Sungrow commands."),
Long: fmt.Sprintf("General iSolarCloud functions."), Long: fmt.Sprintf("Template related Sungrow commands."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
@ -30,16 +30,16 @@ func (c *CmdShow) AttachTemplate(cmd *cobra.Command) *cobra.Command {
c.AttachTemplateList(self) c.AttachTemplateList(self)
c.AttachTemplatePoints(self) c.AttachTemplatePoints(self)
c.AttachTemplateData(self) c.AttachTemplateData(self)
c.AttachTemplateDataGraph(self) c.AttachTemplateGraph(self)
} }
return c.SelfCmd return c.SelfCmd
} }
func (c *CmdShow) AttachTemplateList(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachTemplateList(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{ var self = &cobra.Command{
Use: "list", Use: "list",
Aliases: []string{}, Aliases: []string{"ls"},
Annotations: map[string]string{"group": "Template"}, Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Get all defined templates."), Short: fmt.Sprintf("Get all defined templates."),
Long: fmt.Sprintf("Get all defined templates."), Long: fmt.Sprintf("Get all defined templates."),
@ -63,13 +63,12 @@ func (c *CmdShow) funcTemplateList(_ *cobra.Command, _ []string) error {
} }
func (c *CmdShow) AttachTemplatePoints(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachTemplatePoints(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{ var self = &cobra.Command{
Use: "points <template id>", Use: "points <template id>",
Aliases: []string{"point"}, Aliases: []string{"point"},
Annotations: map[string]string{"group": "Template"}, Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Get all points defined within a template."), Short: fmt.Sprintf("List points used for a given template_id."),
Long: fmt.Sprintf("Get all points defined within a template."), Long: fmt.Sprintf("List points used for a given template_id."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
@ -90,12 +89,12 @@ func (c *CmdShow) funcTemplatePoints(_ *cobra.Command, args []string) error {
} }
func (c *CmdShow) AttachTemplateData(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachTemplateData(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{ var self = &cobra.Command{
Use: "data <template_id> [start date] [end date] [interval]", Use: "data <template_id> [start date] [end date] [interval]",
Aliases: []string{},
Annotations: map[string]string{"group": "Template"}, Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Get data from report template."), Short: fmt.Sprintf("Generate points table for a given template_id."),
Long: fmt.Sprintf("Get data from report template."), Long: fmt.Sprintf("Generate points table for a given template_id."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
@ -122,17 +121,17 @@ func (c *CmdShow) funcTemplateData(_ *cobra.Command, args []string) error {
return c.Error return c.Error
} }
func (c *CmdShow) AttachTemplateDataGraph(cmd *cobra.Command) *cobra.Command { func (c *CmdShow) AttachTemplateGraph(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var self = &cobra.Command{ var self = &cobra.Command{
Use: "data-graph <template_id> [start date] [end date] [interval]", Use: "graph <template_id> [start date] [end date] [interval]",
Aliases: []string{},
Annotations: map[string]string{"group": "Template"}, Annotations: map[string]string{"group": "Template"},
Short: fmt.Sprintf("Get data from report template."), Short: fmt.Sprintf("Generate graphs of points for a given template_id."),
Long: fmt.Sprintf("Get data from report template."), Long: fmt.Sprintf("Generate graphs of points for a given template_id."),
DisableFlagParsing: false, DisableFlagParsing: false,
DisableFlagsInUseLine: false, DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs, PreRunE: cmds.SunGrowArgs,
RunE: c.funcTemplateDataGraph, RunE: c.funcTemplateGraph,
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
} }
cmd.AddCommand(self) cmd.AddCommand(self)
@ -146,7 +145,7 @@ func (c *CmdShow) AttachTemplateDataGraph(cmd *cobra.Command) *cobra.Command {
return cmd return cmd
} }
func (c *CmdShow) funcTemplateDataGraph(_ *cobra.Command, args []string) error { func (c *CmdShow) funcTemplateGraph(_ *cobra.Command, args []string) error {
for range Only.Once { for range Only.Once {
cmds.Api.SunGrow.OutputType.SetGraph() cmds.Api.SunGrow.OutputType.SetGraph()
args = MinimumArraySize(4, args) args = MinimumArraySize(4, args)

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

23
go.mod
View File

@ -3,41 +3,18 @@ module GoSungrow
go 1.19 go 1.19
//replace github.com/MickMake/GoUnify => ../../GoUnify //replace github.com/MickMake/GoUnify => ../../GoUnify
//replace github.com/MickMake/GoUnify/cmdConfig v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/cmdConfig v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/cmdConfig => ../../GoUnify/cmdConfig //replace github.com/MickMake/GoUnify/cmdConfig => ../../GoUnify/cmdConfig
//replace github.com/MickMake/GoUnify/cmdLog v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/cmdLog v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/cmdLog => ../../GoUnify/cmdLog //replace github.com/MickMake/GoUnify/cmdLog => ../../GoUnify/cmdLog
//replace github.com/MickMake/GoUnify/cmdHelp v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/cmdHelp v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/cmdHelp => ../../GoUnify/cmdHelp //replace github.com/MickMake/GoUnify/cmdHelp => ../../GoUnify/cmdHelp
//replace github.com/MickMake/GoUnify/Unify v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/Unify v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/Unify => ../../GoUnify/Unify //replace github.com/MickMake/GoUnify/Unify => ../../GoUnify/Unify
//replace github.com/MickMake/GoUnify/Only v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/Only v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/Only => ../../GoUnify/Only //replace github.com/MickMake/GoUnify/Only => ../../GoUnify/Only
//replace github.com/MickMake/GoUnify/cmdCron v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/cmdCron v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/cmdCron => ../../GoUnify/cmdCron //replace github.com/MickMake/GoUnify/cmdCron => ../../GoUnify/cmdCron
//replace github.com/MickMake/GoUnify/cmdDaemon v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/cmdDaemon v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/cmdDaemon => ../../GoUnify/cmdDaemon //replace github.com/MickMake/GoUnify/cmdDaemon => ../../GoUnify/cmdDaemon
//replace github.com/MickMake/GoUnify/cmdShell v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/cmdShell v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/cmdShell => ../../GoUnify/cmdShell //replace github.com/MickMake/GoUnify/cmdShell => ../../GoUnify/cmdShell
//replace github.com/MickMake/GoUnify/cmdVersion v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/cmdVersion v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/cmdVersion => ../../GoUnify/cmdVersion //replace github.com/MickMake/GoUnify/cmdVersion => ../../GoUnify/cmdVersion
//replace github.com/MickMake/GoUnify/cmdExec v0.0.0-00010101000000-000000000000 => github.com/MickMake/GoUnify/cmdExec v0.0.0-20220923023100-6cf4e624a412
//replace github.com/MickMake/GoUnify/cmdExec => ../../GoUnify/cmdExec //replace github.com/MickMake/GoUnify/cmdExec => ../../GoUnify/cmdExec
//replace github.com/MickMake/GoUnify/cmdPath => ../../GoUnify/cmdPath //replace github.com/MickMake/GoUnify/cmdPath => ../../GoUnify/cmdPath
//require github.com/MickMake/GoUnify/Only v0.0.0-20221125013232-022ba4a63055 // indirect
require ( require (
github.com/MickMake/GoUnify/Only v0.0.0-20221125023651-ff4a37b1928a github.com/MickMake/GoUnify/Only v0.0.0-20221125023651-ff4a37b1928a
github.com/MickMake/GoUnify/Unify v0.0.0-20221125023651-ff4a37b1928a github.com/MickMake/GoUnify/Unify v0.0.0-20221125023651-ff4a37b1928a

View File

@ -7,27 +7,29 @@ import (
const ( const (
TypeNone = iota TypeNone = iota
TypeJson = iota TypeJson = iota
TypeCsv = iota TypeCsv = iota
TypeList = iota TypeList = iota
TypeTable = iota TypeTable = iota
TypeRaw = iota TypeRaw = iota
TypeGraph = iota TypeGraph = iota
TypeStruct = iota TypeStruct = iota
TypeXML = iota TypeXML = iota
TypeXLSX = iota TypeXLSX = iota
TypeMarkDown = iota
StringTypeNone = "" StringTypeNone = ""
StringTypeJson = "json" StringTypeJson = "json"
StringTypeCsv = "csv" StringTypeCsv = "csv"
StringTypeList = "list" StringTypeList = "list"
StringTypeTable = "table" StringTypeTable = "table"
StringTypeRaw = "raw" StringTypeRaw = "raw"
StringTypeGraph = "graph" StringTypeGraph = "graph"
StringTypeStruct = "struct" StringTypeStruct = "struct"
StringTypeXML = "xml" StringTypeXML = "xml"
StringTypeXLSX = "xlsx" StringTypeXLSX = "xlsx"
StringTypeMarkDown = "md"
) )
//goland:noinspection GoNameStartsWithPackageName //goland:noinspection GoNameStartsWithPackageName
@ -64,6 +66,9 @@ func (out *OutputType) SetXML() {
func (out *OutputType) SetXLSX() { func (out *OutputType) SetXLSX() {
*out = TypeXLSX *out = TypeXLSX
} }
func (out *OutputType) SetMarkDown() {
*out = TypeMarkDown
}
func (out *OutputType) IsNone() bool { func (out *OutputType) IsNone() bool {
@ -126,6 +131,12 @@ func (out *OutputType) IsXLSX() bool {
} }
return false return false
} }
func (out *OutputType) IsMarkDown() bool {
if *out == TypeMarkDown {
return true
}
return false
}
func (out *OutputType) IsStrNone(t string) bool { func (out *OutputType) IsStrNone(t string) bool {
@ -182,6 +193,12 @@ func (out *OutputType) IsStrXLSX(t string) bool {
} }
return false return false
} }
func (out *OutputType) IsStrMarkDown(t string) bool {
if t == StringTypeMarkDown {
return true
}
return false
}
func (out *OutputType) Set(outputType string) { func (out *OutputType) Set(outputType string) {
@ -210,6 +227,8 @@ func (out *OutputType) Set(outputType string) {
out.SetXML() out.SetXML()
case StringTypeXLSX: case StringTypeXLSX:
out.SetXLSX() out.SetXLSX()
case StringTypeMarkDown:
out.SetMarkDown()
case StringTypeList: case StringTypeList:
fallthrough fallthrough
default: default:

View File

@ -11,8 +11,9 @@ import (
"sort" "sort"
"strings" "strings"
) )
// "go.pennock.tech/tabular/auto"
// "github.com/olekukonko/tablewriter"
// "github.com/agrison/go-tablib" // "github.com/agrison/go-tablib"
// "go.pennock.tech/tabular"
// "github.com/jbub/tabular" // "github.com/jbub/tabular"
@ -279,10 +280,14 @@ func (t *Table) Output() error {
case t.OutputType.IsGraph(): case t.OutputType.IsGraph():
t.Error = t.CreateGraph() t.Error = t.CreateGraph()
case t.OutputType.IsMarkDown():
t.Error = t.WriteMarkDown()
case t.OutputType.IsStruct(): case t.OutputType.IsStruct():
t.Error = t.WriteStruct() t.Error = t.WriteStruct()
default: default:
t.Error = t.WriteTable()
} }
} }
@ -548,3 +553,45 @@ func (t *Table) WriteStruct() error {
} }
return t.Error return t.Error
} }
func (t *Table) AsMarkDown() string {
var ret string
for range Only.Once {
if t.IsNotValid() {
break
}
var result *tabular.Exportable
result = t.table.Markdown()
if t.Error != nil {
break
}
ret = result.String()
}
return ret
}
func (t *Table) WriteMarkDown() error {
for range Only.Once {
if t.IsNotValid() {
msg := fmt.Sprintf("# %s - has no data.", t.name)
if t.saveAsFile {
fmt.Println(msg)
} else {
_, _ = fmt.Fprintln(os.Stderr, msg)
}
break
}
if t.saveAsFile {
_, _ = fmt.Fprintf(os.Stderr,"# %s\n", t.title)
t.filePrefix += "." + StringTypeMarkDown
t.Error = t.writeFile(t.AsMarkDown(), DefaultFileMode)
break
}
fmt.Print(t.AsMarkDown())
}
return t.Error
}

View File

@ -1,10 +1,10 @@
package api package api
import ( import (
"github.com/MickMake/GoUnify/Only"
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only"
"github.com/olekukonko/tablewriter" "github.com/olekukonko/tablewriter"
"sort" "sort"
) )
@ -64,7 +64,7 @@ func (ps TypeEndPoints) String() string {
ret += buf.String() ret += buf.String()
} }
ret += fmt.Sprintf("\n# Implemented: %d Non-implemented: %d\n", len(ep), len(dp)) ret += fmt.Sprintf("\n# Implemented: %d Non-implemented: %d\n\n", len(ep), len(dp))
} }
return ret return ret

View File

@ -1,10 +1,10 @@
package api package api
import ( import (
"github.com/MickMake/GoUnify/Only"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only"
"net/url" "net/url"
) )
@ -35,6 +35,10 @@ func (u *EndPointUrl) IsValid() error {
err = errors.New("empty url") err = errors.New("empty url")
break break
} }
if u.EndPoint == nil {
err = errors.New("empty url")
break
}
if u.EndPoint.String() == "" { if u.EndPoint.String() == "" {
err = errors.New("empty url") err = errors.New("empty url")
break break
@ -45,6 +49,9 @@ func (u *EndPointUrl) IsValid() error {
} }
func (u EndPointUrl) String() string { func (u EndPointUrl) String() string {
if u.EndPoint == nil {
return ""
}
return u.EndPoint.String() return u.EndPoint.String()
} }

View File

@ -11,191 +11,12 @@ import (
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
datatable "go.pennock.tech/tabular/auto" datatable "go.pennock.tech/tabular/auto"
"sort" "sort"
"strings"
"time" "time"
) )
// GetDeviceList - AppService.getDeviceList
func (sg *SunGrow) GetDeviceList(psIds ...string) ([]getDeviceList.Device, error) {
var ret []getDeviceList.Device
for range Only.Once {
pids := sg.SetPsIds(psIds...)
if sg.Error != nil {
break
}
for _, psId := range pids {
ep := sg.GetByStruct(getDeviceList.EndPointName,
getDeviceList.RequestData {
PsId: psId,
},
time.Hour * 24,
)
if sg.IsError() {
break
}
data := getDeviceList.Assert(ep)
ret = append(ret, data.Response.ResultData.PageList...)
}
}
return ret, sg.Error
}
// QueryDeviceList - AppService.queryDeviceList
func (sg *SunGrow) QueryDeviceList(psIds ...string) ([]queryDeviceList.Device, error) {
var ret []queryDeviceList.Device
for range Only.Once {
pids := sg.SetPsIds(psIds...)
if sg.Error != nil {
break
}
for _, psId := range pids {
ep := sg.GetByStruct(queryDeviceList.EndPointName,
queryDeviceList.RequestData {
PsId: psId,
},
time.Hour*24,
)
if sg.IsError() {
break
}
data := queryDeviceList.Assert(ep)
ret = append(ret, data.Response.ResultData.PageList...)
}
}
return ret, sg.Error
}
func (sg *SunGrow) Devices(psIds ...string) (string, error) {
var ret string
for range Only.Once {
var devices getDeviceList.Devices
devices, sg.Error = sg.GetDeviceList()
if sg.Error != nil {
break
}
ret += fmt.Sprintf("# Devices on ps_id %s:\n", strings.Join(psIds, ", "))
table := datatable.New("utf8-heavy")
table.AddHeaders("Ps Key", "Ps Id", "Device Type", "Device Code", "Channel Id", "Serial #", "Factory Name", "Device Model")
for _, device := range devices {
table.AddRowItems(device.PsKey, device.PsId, device.DeviceType, device.DeviceCode, device.ChannelId, device.Sn, device.FactoryName, device.DeviceModel)
}
ret, sg.Error = table.Render()
if sg.Error != nil {
break
}
}
return ret, sg.Error
}
// DeviceData -
func (sg *SunGrow) DeviceData(deviceType string, startDate string, endDate string, interval string) error {
for range Only.Once {
if deviceType == "" {
sg.Error = errors.New("no template defined")
break
}
fmt.Println("NOT YET IMPLEMENTED.")
// data := sg.QueryUserCurveDeviceData(deviceType)
// if sg.IsError() {
// break
// }
//
// var points []string
// for an := range data.PointsData.Devices {
// // fmt.Println(an)
// for _, b := range data.PointsData.Devices[an].Points {
// points = append(points, b.PointId.Full())
// // fmt.Println(bn)
// // fmt.Printf("%v\n", b)
// }
// }
//
// sg.PointData(startDate, endDate, interval, points...)
// if sg.Error != nil {
// break
// }
}
return sg.Error
}
// DevicePoints - Return all points associated a device_type.
func (sg *SunGrow) DevicePoints(deviceTypes ...string) string {
var ret string
for range Only.Once {
if len(deviceTypes) == 0 {
break
}
table := datatable.New("utf8-heavy")
table.AddHeaders("Device Type", "Point Id", "Name", "Cal Type")
var points []getPowerDevicePointNames.Point
for _, deviceType := range deviceTypes {
ep := sg.GetByStruct(getPowerDevicePointNames.EndPointName,
getPowerDevicePointNames.RequestData{ DeviceType: valueTypes.SetIntegerString(deviceType) },
DefaultCacheTimeout,
)
if sg.IsError() {
break
}
data := getPowerDevicePointNames.Assert(ep)
points = append(points, data.Response.ResultData...)
// Sort table based on PointId
pn := map[string]int{}
for index, point := range points {
pn[point.PointId.String()] = index
}
var names []string
for point := range pn {
names = append(names, point)
}
sort.Strings(names)
for _, name := range names {
index := pn[name]
point := points[index]
table.AddRowItems(deviceType, point.PointId, point.PointName, point.PointCalType)
}
}
if sg.IsError() {
break
}
var r string
r, sg.Error = table.Render()
if sg.Error != nil {
break
}
ret += fmt.Sprintln("# Available points:")
ret += r
}
return ret
}
// DeviceTypeList - Return all device_types. // DeviceTypeList - Return all device_types.
func (sg *SunGrow) DeviceTypeList(psIds ...string) string { func (sg *SunGrow) DeviceTypeList(psIds ...string) (string, error) {
var ret string var ret string
for range Only.Once { for range Only.Once {
@ -256,7 +77,156 @@ func (sg *SunGrow) DeviceTypeList(psIds ...string) string {
ret += r ret += r
} }
return ret return ret, sg.Error
}
// DeviceTypePoints - Return all points associated a device_type.
func (sg *SunGrow) DeviceTypePoints(deviceTypes ...string) (string, error) {
var ret string
for range Only.Once {
if len(deviceTypes) == 0 {
break
}
table := datatable.New("utf8-heavy")
table.AddHeaders("Device Type", "Point Id", "Name", "Cal Type")
var points []getPowerDevicePointNames.Point
for _, deviceType := range deviceTypes {
ep := sg.GetByStruct(getPowerDevicePointNames.EndPointName,
getPowerDevicePointNames.RequestData{ DeviceType: valueTypes.SetIntegerString(deviceType) },
DefaultCacheTimeout,
)
if sg.IsError() {
break
}
data := getPowerDevicePointNames.Assert(ep)
points = append(points, data.Response.ResultData...)
// Sort table based on PointId
pn := map[string]int{}
for index, point := range points {
pn[point.PointId.String()] = index
}
var names []string
for point := range pn {
names = append(names, point)
}
sort.Strings(names)
for _, name := range names {
index := pn[name]
point := points[index]
table.AddRowItems(deviceType, point.PointId, point.PointName, point.PointCalType)
}
}
if sg.IsError() {
break
}
var r string
r, sg.Error = table.Render()
if sg.Error != nil {
break
}
ret += fmt.Sprintln("# Available points:")
ret += r
}
return ret, sg.Error
}
// DeviceTypeData - Return all point data associated a device_type.
func (sg *SunGrow) DeviceTypeData(deviceType string, startDate string, endDate string, interval string) error {
for range Only.Once {
if deviceType == "" {
sg.Error = errors.New("no template defined")
break
}
fmt.Println("NOT YET IMPLEMENTED.")
// data := sg.QueryUserCurveDeviceData(deviceType)
// if sg.IsError() {
// break
// }
//
// var points []string
// for an := range data.PointsData.Devices {
// // fmt.Println(an)
// for _, b := range data.PointsData.Devices[an].Points {
// points = append(points, b.PointId.Full())
// // fmt.Println(bn)
// // fmt.Printf("%v\n", b)
// }
// }
//
// sg.PointData(startDate, endDate, interval, points...)
// if sg.Error != nil {
// break
// }
}
return sg.Error
}
// GetDeviceList - AppService.getDeviceList
func (sg *SunGrow) GetDeviceList(psIds ...string) ([]getDeviceList.Device, error) {
var ret []getDeviceList.Device
for range Only.Once {
pids := sg.SetPsIds(psIds...)
if sg.Error != nil {
break
}
for _, psId := range pids {
ep := sg.GetByStruct(getDeviceList.EndPointName,
getDeviceList.RequestData {
PsId: psId,
},
time.Hour * 24,
)
if sg.IsError() {
break
}
data := getDeviceList.Assert(ep)
ret = append(ret, data.Response.ResultData.PageList...)
}
}
return ret, sg.Error
}
// QueryDeviceList - AppService.queryDeviceList
func (sg *SunGrow) QueryDeviceList(psIds ...string) ([]queryDeviceList.Device, error) {
var ret []queryDeviceList.Device
for range Only.Once {
pids := sg.SetPsIds(psIds...)
if sg.Error != nil {
break
}
for _, psId := range pids {
ep := sg.GetByStruct(queryDeviceList.EndPointName,
queryDeviceList.RequestData {
PsId: psId,
},
time.Hour*24,
)
if sg.IsError() {
break
}
data := queryDeviceList.Assert(ep)
ret = append(ret, data.Response.ResultData.PageList...)
}
}
return ret, sg.Error
} }

View File

@ -16,10 +16,8 @@ import (
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes" "GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
datatable "go.pennock.tech/tabular/auto"
"math" "math"
"os" "os"
"sort"
"strings" "strings"
"time" "time"
) )
@ -259,122 +257,8 @@ func (sg *SunGrow) GetAllPointsData(psIds ...string) error {
} }
// PointNamesData - Return all points associated with psIds and device_type filter. // DevicePointAttrs - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) PointNamesData(psIds []string, deviceType string, startDate string, endDate string, interval string) string { func (sg *SunGrow) DevicePointAttrs(psIds []string, deviceType string) ([]getDevicePointAttrs.Point, error) {
var ret string
for range Only.Once {
pskeys := sg.GetPsKeys()
_, _ = fmt.Fprintf(os.Stderr, "Found ps_keys: %s\n", pskeys)
points := sg.PsPointNames(psIds, deviceType)
var ps []string
for _, pid := range points {
match := pskeys.MatchPsIdDeviceType(pid.PsId.String(), pid.DeviceType.String())
if match.Valid {
ps = append(ps, fmt.Sprintf("%s.%s", match, pid.Id))
}
}
// _, _ = fmt.Fprintf(os.Stderr, "Found points: %s\n", strings.Join(ps, " "))
sg.PointData(startDate, endDate, interval, ps...)
}
return ret
}
// PointNames - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) PointNames(psIds []string, deviceType string) string {
var ret string
for range Only.Once {
points := sg.PsPointNames(psIds, deviceType)
// Sort table based on PsId + DeviceType + Id
pn := map[string]int{}
for index, point := range points {
pn[point.PsId.String()+"."+point.DeviceType.String()+"."+point.Id.String()] = index
}
var names []string
for point := range pn {
names = append(names, point)
}
sort.Strings(names)
table := datatable.New("utf8-heavy")
table.AddHeaders("Id", "Name", "Unit", "Unit Type", "Ps Id", "Device Type", "Device Name")
for _, name := range names {
index := pn[name]
point := points[index]
table.AddRowItems(point.Id, point.Name, point.Unit, point.UnitType, point.PsId, point.DeviceType, point.DeviceName)
}
// PsKey
// PsId
// DeviceType
// DeviceCode
// ChannelId
var r string
r, sg.Error = table.Render()
if sg.Error != nil {
break
}
ret += fmt.Sprintln("# Available points:")
ret += r
// var pids valueTypes.PsIds
// pids = sg.SetPsIds(psIds...)
// if sg.Error != nil {
// break
// }
//
// for _, pid := range pids {
// var points []getDevicePointAttrs.Points
// points, sg.Error = sg.GetDevicePointAttrs(pid)
// if sg.Error != nil {
// break
// }
//
// if len(points) == 0 {
// continue
// }
//
// ret += fmt.Sprintf("# Available points for ps_id %s:\n", pid.String())
// table := datatable.New("utf8-heavy")
// table.AddHeaders("Id", "Name", "Unit", "UnitType", "PsId", "DeviceType", "DeviceName")
// for _, point := range points {
// if (deviceType != "") && point.DeviceType.MatchString(deviceType) {
// continue
// }
// table.AddRowItems(point.Id, point.Name, point.Unit, point.UnitType, point.PsId, point.DeviceType, point.DeviceName)
// }
//
// var r string
// r, sg.Error = table.Render()
// if sg.Error != nil {
// break
// }
// ret += r
//
// // @TODO - Include AppService.getPowerDevicePointNames
// // points2 := cmds.Api.SunGrow.GetDevicePointNames(pid)
// // if c.Error != nil {
// // break
// // }
// // if len(points) == 0 {
// // continue
// // }
//
// }
}
return ret
}
// PsPointNames - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) PsPointNames(psIds []string, deviceType string) []getDevicePointAttrs.Point {
var points []getDevicePointAttrs.Point var points []getDevicePointAttrs.Point
for range Only.Once { for range Only.Once {
@ -416,7 +300,7 @@ func (sg *SunGrow) PsPointNames(psIds []string, deviceType string) []getDevicePo
} }
} }
return points return points, sg.Error
} }
// GetDevicePointAttrs - WebAppService.getDevicePointAttrs Uuid: PsId: DeviceType // GetDevicePointAttrs - WebAppService.getDevicePointAttrs Uuid: PsId: DeviceType
@ -453,9 +337,7 @@ func (sg *SunGrow) GetDevicePointAttrs(psId valueTypes.PsId) ([]getDevicePointAt
} }
func (sg *SunGrow) PointData(startDate string, endDate string, interval string, points ...string) string { func (sg *SunGrow) PointData(startDate string, endDate string, interval string, points ...string) error {
var ret string
for range Only.Once { for range Only.Once {
// _, _ = sg.QueryMultiPointDataList( // _, _ = sg.QueryMultiPointDataList(
// valueTypes.SetDateTimeString(startDate), // valueTypes.SetDateTimeString(startDate),
@ -501,10 +383,10 @@ func (sg *SunGrow) PointData(startDate string, endDate string, interval string,
} }
} }
return ret return sg.Error
} }
func (sg *SunGrow) PointScan(min string, max string) string { func (sg *SunGrow) PointScan(min string, max string) (string, error) {
var ret string var ret string
for range Only.Once { for range Only.Once {
@ -561,7 +443,7 @@ func (sg *SunGrow) PointScan(min string, max string) string {
ret = table.String() ret = table.String()
} }
return ret return ret, sg.Error
} }

View File

@ -3,6 +3,7 @@ package iSolarCloud
import ( import (
"GoSungrow/iSolarCloud/AppService/findPsType" "GoSungrow/iSolarCloud/AppService/findPsType"
"GoSungrow/iSolarCloud/AppService/getChnnlListByPsId" "GoSungrow/iSolarCloud/AppService/getChnnlListByPsId"
"GoSungrow/iSolarCloud/AppService/getDeviceList"
"GoSungrow/iSolarCloud/AppService/getHouseholdStoragePsReport" "GoSungrow/iSolarCloud/AppService/getHouseholdStoragePsReport"
"GoSungrow/iSolarCloud/AppService/getIncomeSettingInfos" "GoSungrow/iSolarCloud/AppService/getIncomeSettingInfos"
"GoSungrow/iSolarCloud/AppService/getPListinfoFromMysql" "GoSungrow/iSolarCloud/AppService/getPListinfoFromMysql"
@ -20,6 +21,7 @@ import (
"GoSungrow/iSolarCloud/AppService/getPsInstallerOrgInfoByPsId" "GoSungrow/iSolarCloud/AppService/getPsInstallerOrgInfoByPsId"
"GoSungrow/iSolarCloud/AppService/getPsList" "GoSungrow/iSolarCloud/AppService/getPsList"
"GoSungrow/iSolarCloud/AppService/getPsWeatherList" "GoSungrow/iSolarCloud/AppService/getPsWeatherList"
"GoSungrow/iSolarCloud/AppService/getRemoteUpgradeTaskList"
"GoSungrow/iSolarCloud/AppService/getReportData" "GoSungrow/iSolarCloud/AppService/getReportData"
"GoSungrow/iSolarCloud/AppService/psForcastInfo" "GoSungrow/iSolarCloud/AppService/psForcastInfo"
"GoSungrow/iSolarCloud/AppService/psHourPointsValue" "GoSungrow/iSolarCloud/AppService/psHourPointsValue"
@ -34,6 +36,7 @@ import (
"GoSungrow/iSolarCloud/Common" "GoSungrow/iSolarCloud/Common"
"GoSungrow/iSolarCloud/MttvScreenService/getPsDeviceListValue" "GoSungrow/iSolarCloud/MttvScreenService/getPsDeviceListValue"
"GoSungrow/iSolarCloud/MttvScreenService/getPsKpiForHoursByPsId" "GoSungrow/iSolarCloud/MttvScreenService/getPsKpiForHoursByPsId"
"GoSungrow/iSolarCloud/WebAppService/getDevicePointAttrs"
"GoSungrow/iSolarCloud/WebAppService/getPsIdState" "GoSungrow/iSolarCloud/WebAppService/getPsIdState"
"GoSungrow/iSolarCloud/WebAppService/getReportPsTree" "GoSungrow/iSolarCloud/WebAppService/getReportPsTree"
"GoSungrow/iSolarCloud/WebAppService/showPSView" "GoSungrow/iSolarCloud/WebAppService/showPSView"
@ -43,11 +46,162 @@ import (
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes" "GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
"fmt" "fmt"
"github.com/MickMake/GoUnify/Only" "github.com/MickMake/GoUnify/Only"
datatable "go.pennock.tech/tabular/auto"
"os"
"sort"
"strings" "strings"
"time" "time"
) )
// PsList - Return all ps_ids.
func (sg *SunGrow) PsList(psIds ...string) (string, error) {
var ret string
for range Only.Once {
var devices getDeviceList.Devices
devices, sg.Error = sg.GetDeviceList()
if sg.Error != nil {
break
}
ret += fmt.Sprintf("# Devices on ps_id %s:\n", strings.Join(psIds, ", "))
table := datatable.New("utf8-heavy")
table.AddHeaders("Ps Key", "Ps Id", "Device Type", "Device Code", "Channel Id", "Serial #", "Factory Name", "Device Model")
for _, device := range devices {
table.AddRowItems(device.PsKey, device.PsId, device.DeviceType, device.DeviceCode, device.ChannelId, device.Sn, device.FactoryName, device.DeviceModel)
}
ret, sg.Error = table.Render()
if sg.Error != nil {
break
}
}
return ret, sg.Error
}
// PsPoints - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) PsPoints(psIds []string, deviceType string) (string, error) {
var ret string
for range Only.Once {
var points []getDevicePointAttrs.Point
points, sg.Error = sg.DevicePointAttrs(psIds, deviceType)
if sg.Error != nil {
break
}
// Sort table based on PsId + DeviceType + Id
pn := map[string]int{}
for index, point := range points {
pn[point.PsId.String()+"."+point.DeviceType.String()+"."+point.Id.String()] = index
}
var names []string
for point := range pn {
names = append(names, point)
}
sort.Strings(names)
table := datatable.New("utf8-heavy")
table.AddHeaders("Id", "Name", "Unit", "Unit Type", "Ps Id", "Device Type", "Device Name")
for _, name := range names {
index := pn[name]
point := points[index]
table.AddRowItems(point.Id, point.Name, point.Unit, point.UnitType, point.PsId, point.DeviceType, point.DeviceName)
}
// PsKey
// PsId
// DeviceType
// DeviceCode
// ChannelId
var r string
r, sg.Error = table.Render()
if sg.Error != nil {
break
}
ret += fmt.Sprintln("# Available points:")
ret += r
// var pids valueTypes.PsIds
// pids = sg.SetPsIds(psIds...)
// if sg.Error != nil {
// break
// }
//
// for _, pid := range pids {
// var points []getDevicePointAttrs.Points
// points, sg.Error = sg.GetDevicePointAttrs(pid)
// if sg.Error != nil {
// break
// }
//
// if len(points) == 0 {
// continue
// }
//
// ret += fmt.Sprintf("# Available points for ps_id %s:\n", pid.String())
// table := datatable.New("utf8-heavy")
// table.AddHeaders("Id", "Name", "Unit", "UnitType", "PsId", "DeviceType", "DeviceName")
// for _, point := range points {
// if (deviceType != "") && point.DeviceType.MatchString(deviceType) {
// continue
// }
// table.AddRowItems(point.Id, point.Name, point.Unit, point.UnitType, point.PsId, point.DeviceType, point.DeviceName)
// }
//
// var r string
// r, sg.Error = table.Render()
// if sg.Error != nil {
// break
// }
// ret += r
//
// // @TODO - Include AppService.getPowerDevicePointNames
// // points2 := cmds.Api.SunGrow.GetDevicePointNames(pid)
// // if c.Error != nil {
// // break
// // }
// // if len(points) == 0 {
// // continue
// // }
//
// }
}
return ret, sg.Error
}
// PsPointsData - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) PsPointsData(psIds []string, deviceType string, startDate string, endDate string, interval string) error {
for range Only.Once {
pskeys := sg.GetPsKeys()
_, _ = fmt.Fprintf(os.Stderr, "Found ps_keys: %s\n", pskeys)
var points []getDevicePointAttrs.Point
points, sg.Error = sg.DevicePointAttrs(psIds, deviceType)
if sg.Error != nil {
break
}
var ps []string
for _, pid := range points {
match := pskeys.MatchPsIdDeviceType(pid.PsId.String(), pid.DeviceType.String())
if match.Valid {
ps = append(ps, fmt.Sprintf("%s.%s", match, pid.Id))
}
}
// _, _ = fmt.Fprintf(os.Stderr, "Found points: %s\n", strings.Join(ps, " "))
sg.Error = sg.PointData(startDate, endDate, interval, ps...)
}
return sg.Error
}
func (sg *SunGrow) GetPsKeys() valueTypes.PsKeys { func (sg *SunGrow) GetPsKeys() valueTypes.PsKeys {
var ret valueTypes.PsKeys var ret valueTypes.PsKeys
@ -123,34 +277,6 @@ func (sg *SunGrow) GetPsKeys() valueTypes.PsKeys {
return ret return ret
} }
// func (sg *SunGrow) GetPsKeys() ([]string, error) {
// var ret []string
//
// for range Only.Once {
// var psIds valueTypes.PsIds
// psIds, sg.Error = sg.GetPsIds()
// if sg.Error != nil {
// break
// }
//
// for _, psId := range psIds {
// ep := sg.GetByStruct(getPsDetailWithPsType.EndPointName,
// // getPsDetailWithPsType.RequestData{PsId: strconv.FormatInt(psId, 10)},
// getPsDetailWithPsType.RequestData{PsId: psId},
// DefaultCacheTimeout)
// if sg.IsError() {
// break
// }
//
// data := getPsDetailWithPsType.Assert(ep)
// ret = append(ret, data.GetPsKeys()...)
// }
// }
//
// return ret, sg.Error
// }
func (sg *SunGrow) GetDevices() []queryDeviceListForBackSys.Device { func (sg *SunGrow) GetDevices() []queryDeviceListForBackSys.Device {
var ret []queryDeviceListForBackSys.Device var ret []queryDeviceListForBackSys.Device
for range Only.Once { for range Only.Once {
@ -205,6 +331,32 @@ func (sg *SunGrow) GetPsIds() (valueTypes.PsIds, error) {
return ret, sg.Error return ret, sg.Error
} }
// func (sg *SunGrow) GetPsKeys() ([]string, error) {
// var ret []string
//
// for range Only.Once {
// var psIds valueTypes.PsIds
// psIds, sg.Error = sg.GetPsIds()
// if sg.Error != nil {
// break
// }
//
// for _, psId := range psIds {
// ep := sg.GetByStruct(getPsDetailWithPsType.EndPointName,
// // getPsDetailWithPsType.RequestData{PsId: strconv.FormatInt(psId, 10)},
// getPsDetailWithPsType.RequestData{PsId: psId},
// DefaultCacheTimeout)
// if sg.IsError() {
// break
// }
//
// data := getPsDetailWithPsType.Assert(ep)
// ret = append(ret, data.GetPsKeys()...)
// }
// }
//
// return ret, sg.Error
// }
// func (sg *SunGrow) GetPsId() (valueTypes.PsId, error) { // func (sg *SunGrow) GetPsId() (valueTypes.PsId, error) {
// var ret valueTypes.PsId // var ret valueTypes.PsId
@ -229,49 +381,6 @@ func (sg *SunGrow) GetPsIds() (valueTypes.PsIds, error) {
// } // }
// QueryDeviceListForBackSys - WebIscmAppService.queryDeviceListForBackSys
func (sg *SunGrow) QueryDeviceListForBackSys(psId string) ([]queryDeviceListForBackSys.Device, error) {
var ret []queryDeviceListForBackSys.Device
for range Only.Once {
pid := valueTypes.SetPsIdString(psId)
if !pid.Valid {
sg.Error = pid.Error
break
}
ep := sg.GetByStruct(queryDeviceListForBackSys.EndPointName,
queryDeviceListForBackSys.RequestData{ PsId: pid },
DefaultCacheTimeout)
if sg.IsError() {
break
}
ret = queryDeviceListForBackSys.AssertResultData(ep)
}
return ret, sg.Error
}
// GetPsList - AppService.getPsList
func (sg *SunGrow) GetPsList() ([]Common.Device, error) {
var ret []Common.Device
for range Only.Once {
ep := sg.GetByStruct(getPsList.EndPointName, nil, DefaultCacheTimeout)
if sg.IsError() {
break
}
data := getPsList.AssertResultData(ep)
ret = data.PageList
}
return ret, sg.Error
}
// PsTreeMenu - WebIscmAppService.getPsTreeMenu // PsTreeMenu - WebIscmAppService.getPsTreeMenu
func (sg *SunGrow) PsTreeMenu(psIds ...string) (PsTree, error) { func (sg *SunGrow) PsTreeMenu(psIds ...string) (PsTree, error) {
var ret PsTree var ret PsTree
@ -377,6 +486,47 @@ func (p *PsTree) loop(current string, count int, depth int) {
} }
// QueryDeviceListForBackSys - WebIscmAppService.queryDeviceListForBackSys
func (sg *SunGrow) QueryDeviceListForBackSys(psId string) ([]queryDeviceListForBackSys.Device, error) {
var ret []queryDeviceListForBackSys.Device
for range Only.Once {
pid := valueTypes.SetPsIdString(psId)
if !pid.Valid {
sg.Error = pid.Error
break
}
ep := sg.GetByStruct(queryDeviceListForBackSys.EndPointName,
queryDeviceListForBackSys.RequestData{ PsId: pid },
DefaultCacheTimeout)
if sg.IsError() {
break
}
ret = queryDeviceListForBackSys.AssertResultData(ep)
}
return ret, sg.Error
}
// GetPsList - AppService.getPsList
func (sg *SunGrow) GetPsList() ([]Common.Device, error) {
var ret []Common.Device
for range Only.Once {
ep := sg.GetByStruct(getPsList.EndPointName, nil, DefaultCacheTimeout)
if sg.IsError() {
break
}
data := getPsList.AssertResultData(ep)
ret = data.PageList
}
return ret, sg.Error
}
// QueryPowerStationInfo - AppService.queryPowerStationInfo // QueryPowerStationInfo - AppService.queryPowerStationInfo
func (sg *SunGrow) QueryPowerStationInfo(psId valueTypes.PsId, sn valueTypes.String) (queryPowerStationInfo.ResultData, error) { func (sg *SunGrow) QueryPowerStationInfo(psId valueTypes.PsId, sn valueTypes.String) (queryPowerStationInfo.ResultData, error) {
var ret queryPowerStationInfo.ResultData var ret queryPowerStationInfo.ResultData
@ -474,26 +624,26 @@ func (sg *SunGrow) QueryAllPsIdAndName() (queryAllPsIdAndName.ResultData, error)
return ret, sg.Error return ret, sg.Error
} }
// // GetRemoteUpgradeTaskList - AppService.getRemoteUpgradeTaskList // GetRemoteUpgradeTaskList - AppService.getRemoteUpgradeTaskList
// func (sg *SunGrow) getRemoteUpgradeTaskList(psId valueTypes.PsIds) (getRemoteUpgradeTaskList.ResultData, error) { func (sg *SunGrow) getRemoteUpgradeTaskList(psId valueTypes.PsIds) (getRemoteUpgradeTaskList.ResultData, error) {
// var ret getRemoteUpgradeTaskList.ResultData var ret getRemoteUpgradeTaskList.ResultData
// for range Only.Once { for range Only.Once {
// ep := sg.GetByStruct( ep := sg.GetByStruct(
// "WebAppService.getRemoteUpgradeTaskList", "WebAppService.getRemoteUpgradeTaskList",
// getRemoteUpgradeTaskList.RequestData { getRemoteUpgradeTaskList.RequestData {
// PsIdList: psId, PsIdList: psId,
// }, },
// time.Hour * 24, time.Hour * 24,
// ) )
// if sg.IsError() { if sg.IsError() {
// break break
// } }
//
// data := getRemoteUpgradeTaskList.Assert(ep) data := getRemoteUpgradeTaskList.Assert(ep)
// ret = data.Response.ResultData ret = data.Response.ResultData
// } }
// return ret, sg.Error return ret, sg.Error
// } }
// QuerySysAdvancedParam - AppService.querySysAdvancedParam // QuerySysAdvancedParam - AppService.querySysAdvancedParam
func (sg *SunGrow) QuerySysAdvancedParam(psId valueTypes.PsId, curPage valueTypes.Integer, size valueTypes.Integer) (querySysAdvancedParam.ResultData, error) { func (sg *SunGrow) QuerySysAdvancedParam(psId valueTypes.PsId, curPage valueTypes.Integer, size valueTypes.Integer) (querySysAdvancedParam.ResultData, error) {

View File

@ -10,158 +10,46 @@ import (
) )
// GetTemplateList - AppService.getTemplateList // TemplateList - Return all templates.
func (sg *SunGrow) GetTemplateList() (getTemplateList.ResultData, error) { func (sg *SunGrow) TemplateList() error {
var ret getTemplateList.ResultData
for range Only.Once { for range Only.Once {
ep := sg.GetByStruct(getTemplateList.EndPointName, data := sg.NewSunGrowData()
getTemplateList.RequestData{}, data.SetEndpoints(getTemplateList.EndPointName)
DefaultCacheTimeout, data.SetArgs()
) sg.Error = data.GetData()
if sg.IsError() {
break
}
data := getTemplateList.Assert(ep)
ret = data.Response.ResultData
}
return ret, sg.Error
}
// QueryUserCurveTemplateData - WebAppService.queryUserCurveTemplateData
func (sg *SunGrow) QueryUserCurveTemplateData(template string) queryUserCurveTemplateData.ResultData {
var ret queryUserCurveTemplateData.ResultData
for range Only.Once {
if template == "" {
sg.Error = errors.New("no template defined")
break
}
ep := sg.GetByStruct(queryUserCurveTemplateData.EndPointName,
queryUserCurveTemplateData.RequestData{TemplateId: valueTypes.SetStringValue(template)},
time.Hour,
)
if sg.IsError() {
break
}
data := queryUserCurveTemplateData.Assert(ep)
ret = data.Response.ResultData
// foo := data.GetData()
// fmt.Printf("%v\n", foo)
// tables := foo.CreateDataTables()
//
// for _, table := range tables {
// table.SetOutputType(output.StringTypeTable)
// table.Output()
// }
// for an, a := range ret.PointsData.Devices {
// fmt.Println(an)
// for bn, b := range ret.PointsData.Devices[an].Points {
// fmt.Println(bn)
// fmt.Print("%v\n", b)
// }
// }
// data := queryUserCurveTemplateData.AssertResultData(ep)
//
// for dn, dr := range data.PointsData.Devices {
// for _, pr := range dr.Points {
// if pr.Unit.String() == "null" {
// pr.Unit.SetString("")
// }
// ret = append(ret, api.TemplatePoint {
// PsKey: dn,
// PointId: pr.PointId,
// Name: pr.PointName.String(),
// Unit: pr.Unit.String(),
// })
// }
// }
}
return ret
}
// TemplateData -
func (sg *SunGrow) TemplateData(template string, startDate string, endDate string, interval string) error {
for range Only.Once {
if template == "" {
sg.Error = errors.New("no template defined")
break
}
data := sg.QueryUserCurveTemplateData(template)
if sg.IsError() {
break
}
var points []string
for an := range data.PointsData.Devices {
// fmt.Println(an)
for _, b := range data.PointsData.Devices[an].Points {
points = append(points, b.PointId.Full())
// fmt.Println(bn)
// fmt.Printf("%v\n", b)
}
}
// data2 := sg.NewSunGrowData()
// data2.SetEndpoints(queryMutiPointDataList.EndPointName)
// // req := iSolarCloud.RequestArgs{
// // StartTimeStamp: startDate,
// // EndTimeStamp: endDate,
// // }
// // var req iSolarCloud.RequestArgs
// // data.Request.SetPoints(points)
//
// startDate = valueTypes.NewDateTime(startDate).Format(valueTypes.DateTimeLayoutSecond)
// endDate = valueTypes.NewDateTime(endDate).Format(valueTypes.DateTimeLayoutSecond)
//
// data2.SetArgs(
// "StartTimeStamp:" + startDate,
// "EndTimeStamp:" + endDate,
// "MinuteInterval:" + interval,
// "Points:" + strings.Join(points, ","),
// )
//
// sg.Error = data2.GetData()
// if sg.Error != nil {
// break
// }
//
// sg.Error = data2.Process()
// if sg.Error != nil {
// break
// }
//
// // @TODO - Figure out a way to push the Unit values from QueryUserCurveTemplateData to this table.
// // result := queryMutiPointDataList.Assert(data2.Results["queryMutiPointDataList/1129147"].EndPoint)
// // for nr, r := range result.Response.ResultData.Data {
// // for nr2, r2 := range r.Points {
// // result.Response.ResultData.Data[nr].Points[r2].
// // }
// // }
// sg.Error = data2.OutputDataTables()
// if sg.Error != nil {
// break
// }
// @TODO - Figure out a way to push the Unit values from QueryUserCurveTemplateData to this table.
// @TODO - Maybe use a point cache?!
// sg.OutputType.SetTable()
sg.PointData(startDate, endDate, interval, points...)
if sg.Error != nil { if sg.Error != nil {
break break
} }
sg.Error = data.OutputDataTables()
if sg.Error != nil {
break
}
// var data getTemplateList.ResultData
// data, sg.Error = sg.GetTemplateList()
//
// table := data.GetEndPointResultTable()
// if table.Error != nil {
// sg.Error = table.Error
// break
// }
//
// table.SetTitle("getTemplateList")
// table.SetFilePrefix(data.SetFilenamePrefix(""))
// table.SetGraphFilter("")
// table.SetSaveFile(sg.SaveAsFile)
// table.OutputType = sg.OutputType
// sg.Error = table.Output()
// if sg.IsError() {
// break
// }
} }
return sg.Error return sg.Error
} }
// TemplatePoints - Return all points associated a template_id.
func (sg *SunGrow) TemplatePoints(template string) error { func (sg *SunGrow) TemplatePoints(template string) error {
for range Only.Once { for range Only.Once {
if template == "" { if template == "" {
@ -233,40 +121,156 @@ func (sg *SunGrow) TemplatePoints(template string) error {
return sg.Error return sg.Error
} }
func (sg *SunGrow) TemplateList() error { // TemplateData - Return all point data associated a template_id.
func (sg *SunGrow) TemplateData(template string, startDate string, endDate string, interval string) error {
for range Only.Once { for range Only.Once {
data := sg.NewSunGrowData() if template == "" {
data.SetEndpoints(getTemplateList.EndPointName) sg.Error = errors.New("no template defined")
data.SetArgs()
sg.Error = data.GetData()
if sg.Error != nil {
break break
} }
sg.Error = data.OutputDataTables() var data queryUserCurveTemplateData.ResultData
if sg.Error != nil { data, sg.Error = sg.QueryUserCurveTemplateData(template)
if sg.IsError() {
break break
} }
// var data getTemplateList.ResultData var points []string
// data, sg.Error = sg.GetTemplateList() for an := range data.PointsData.Devices {
// fmt.Println(an)
for _, b := range data.PointsData.Devices[an].Points {
points = append(points, b.PointId.Full())
// fmt.Println(bn)
// fmt.Printf("%v\n", b)
}
}
// data2 := sg.NewSunGrowData()
// data2.SetEndpoints(queryMutiPointDataList.EndPointName)
// // req := iSolarCloud.RequestArgs{
// // StartTimeStamp: startDate,
// // EndTimeStamp: endDate,
// // }
// // var req iSolarCloud.RequestArgs
// // data.Request.SetPoints(points)
// //
// table := data.GetEndPointResultTable() // startDate = valueTypes.NewDateTime(startDate).Format(valueTypes.DateTimeLayoutSecond)
// if table.Error != nil { // endDate = valueTypes.NewDateTime(endDate).Format(valueTypes.DateTimeLayoutSecond)
// sg.Error = table.Error //
// data2.SetArgs(
// "StartTimeStamp:" + startDate,
// "EndTimeStamp:" + endDate,
// "MinuteInterval:" + interval,
// "Points:" + strings.Join(points, ","),
// )
//
// sg.Error = data2.GetData()
// if sg.Error != nil {
// break // break
// } // }
// //
// table.SetTitle("getTemplateList") // sg.Error = data2.Process()
// table.SetFilePrefix(data.SetFilenamePrefix("")) // if sg.Error != nil {
// table.SetGraphFilter("")
// table.SetSaveFile(sg.SaveAsFile)
// table.OutputType = sg.OutputType
// sg.Error = table.Output()
// if sg.IsError() {
// break // break
// } // }
//
// // @TODO - Figure out a way to push the Unit values from QueryUserCurveTemplateData to this table.
// // result := queryMutiPointDataList.Assert(data2.Results["queryMutiPointDataList/1129147"].EndPoint)
// // for nr, r := range result.Response.ResultData.Data {
// // for nr2, r2 := range r.Points {
// // result.Response.ResultData.Data[nr].Points[r2].
// // }
// // }
// sg.Error = data2.OutputDataTables()
// if sg.Error != nil {
// break
// }
// @TODO - Figure out a way to push the Unit values from QueryUserCurveTemplateData to this table.
// @TODO - Maybe use a point cache?!
sg.Error = sg.PointData(startDate, endDate, interval, points...)
if sg.Error != nil {
break
}
} }
return sg.Error return sg.Error
} }
// GetTemplateList - AppService.getTemplateList
func (sg *SunGrow) GetTemplateList() (getTemplateList.ResultData, error) {
var ret getTemplateList.ResultData
for range Only.Once {
ep := sg.GetByStruct(getTemplateList.EndPointName,
getTemplateList.RequestData{},
DefaultCacheTimeout,
)
if sg.IsError() {
break
}
data := getTemplateList.Assert(ep)
ret = data.Response.ResultData
}
return ret, sg.Error
}
// QueryUserCurveTemplateData - WebAppService.queryUserCurveTemplateData
func (sg *SunGrow) QueryUserCurveTemplateData(template string) (queryUserCurveTemplateData.ResultData, error) {
var ret queryUserCurveTemplateData.ResultData
for range Only.Once {
if template == "" {
sg.Error = errors.New("no template defined")
break
}
ep := sg.GetByStruct(queryUserCurveTemplateData.EndPointName,
queryUserCurveTemplateData.RequestData{TemplateId: valueTypes.SetStringValue(template)},
time.Hour,
)
if sg.IsError() {
break
}
data := queryUserCurveTemplateData.Assert(ep)
ret = data.Response.ResultData
// foo := data.GetData()
// fmt.Printf("%v\n", foo)
// tables := foo.CreateDataTables()
//
// for _, table := range tables {
// table.SetOutputType(output.StringTypeTable)
// table.Output()
// }
// for an, a := range ret.PointsData.Devices {
// fmt.Println(an)
// for bn, b := range ret.PointsData.Devices[an].Points {
// fmt.Println(bn)
// fmt.Print("%v\n", b)
// }
// }
// data := queryUserCurveTemplateData.AssertResultData(ep)
//
// for dn, dr := range data.PointsData.Devices {
// for _, pr := range dr.Points {
// if pr.Unit.String() == "null" {
// pr.Unit.SetString("")
// }
// ret = append(ret, api.TemplatePoint {
// PsKey: dn,
// PointId: pr.PointId,
// Name: pr.PointName.String(),
// Unit: pr.Unit.String(),
// })
// }
// }
}
return ret, sg.Error
}