v3.0.0-alpha - docs
93
.idea/workspace.xml
generated
@ -5,9 +5,12 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<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$/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_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" />
|
||||
@ -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_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/commands.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/commands.go" 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/AppService/getPsList/funcs.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/getPsList/funcs.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/AppService/queryDeviceInfoForApp/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceInfoForApp/data.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$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" 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/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/api/struct_endpoints.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_endpoints.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/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_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">
|
||||
<module name="GoSungrow" />
|
||||
<working_directory value="$PROJECT_DIR$" />
|
||||
<parameters value="show device points 43" />
|
||||
<parameters value="data md AppService.getPowerDevicePointNames DeviceType:14" />
|
||||
<envs>
|
||||
<env name="GOCACHE" value="/Volumes/Media/GoCache" />
|
||||
</envs>
|
||||
@ -224,7 +206,7 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url>
|
||||
<line>67</line>
|
||||
<line>68</line>
|
||||
<option name="timeStamp" value="3787" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
@ -507,11 +489,6 @@
|
||||
<line>18</line>
|
||||
<option name="timeStamp" value="7467" />
|
||||
</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">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/data_request.go</url>
|
||||
<line>817</line>
|
||||
@ -539,7 +516,7 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_table.go</url>
|
||||
<line>107</line>
|
||||
<line>108</line>
|
||||
<option name="timeStamp" value="7740" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
@ -567,11 +544,6 @@
|
||||
<line>594</line>
|
||||
<option name="timeStamp" value="7772" />
|
||||
</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">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/WebIscmAppService/queryDeviceListForBackSys/data.go</url>
|
||||
<line>55</line>
|
||||
@ -584,12 +556,12 @@
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
|
||||
<line>665</line>
|
||||
<line>547</line>
|
||||
<option name="timeStamp" value="7893" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_point.go</url>
|
||||
<line>643</line>
|
||||
<line>525</line>
|
||||
<option name="timeStamp" value="7902" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
@ -672,24 +644,19 @@
|
||||
<line>261</line>
|
||||
<option name="timeStamp" value="8015" />
|
||||
</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">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url>
|
||||
<line>90</line>
|
||||
<line>96</line>
|
||||
<option name="timeStamp" value="8032" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url>
|
||||
<line>91</line>
|
||||
<line>101</line>
|
||||
<option name="timeStamp" value="8033" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/cmd/cmd_show_device.go</url>
|
||||
<line>59</line>
|
||||
<line>61</line>
|
||||
<option name="timeStamp" value="8039" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
@ -728,24 +695,24 @@
|
||||
<option name="timeStamp" value="8052" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url>
|
||||
<line>206</line>
|
||||
<option name="timeStamp" value="8053" />
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_endpoints.go</url>
|
||||
<line>36</line>
|
||||
<option name="timeStamp" value="8063" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url>
|
||||
<line>249</line>
|
||||
<option name="timeStamp" value="8054" />
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/struct_url.go</url>
|
||||
<line>52</line>
|
||||
<option name="timeStamp" value="8064" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url>
|
||||
<line>163</line>
|
||||
<option name="timeStamp" value="8057" />
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_output.go</url>
|
||||
<line>204</line>
|
||||
<option name="timeStamp" value="8065" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_device.go</url>
|
||||
<line>157</line>
|
||||
<option name="timeStamp" value="8058" />
|
||||
<url>file://$PROJECT_DIR$/iSolarCloud/api/GoStruct/output/struct_output.go</url>
|
||||
<line>230</line>
|
||||
<option name="timeStamp" value="8066" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
<default-breakpoints>
|
||||
|
Before Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 122 KiB |
Before Width: | Height: | Size: 90 KiB |
Before Width: | Height: | Size: 134 KiB |
501
README.md
@ -1,11 +1,6 @@
|
||||
# GoSungrow - iSolarCloud API written in GoLang.
|
||||
|
||||
Note: I'm currently going through a big refactor. The next major release, (v3.0.0), will:
|
||||
- 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. :-).
|
||||
Note: I'm currently going through a big refactor. The next major release, (v3.0.0).
|
||||
|
||||
[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?
|
||||
|
||||
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.
|
||||
|
||||
Note:
|
||||
- [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.
|
||||
- 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.
|
||||
|
||||

|
||||
|
||||
@ -50,25 +46,35 @@ I'm currently using it in my [HomeAssistant](https://www.home-assistant.io/) ins
|
||||
|
||||
## 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 % |
|
||||
+-------------------+-------------------+--------------------+------------+
|
||||
| AliSmsService | 0 | 1 | 0.0 % |
|
||||
| AppService | 52 | 522 | 10.0 % |
|
||||
| MttvScreenService | 0 | 30 | 0.0 % |
|
||||
| PowerPointService | 0 | 1 | 0.0 % |
|
||||
| WebAppService | 4 | 186 | 2.2 % |
|
||||
| WebIscmAppService | 0 | 184 | 0.0 % |
|
||||
| AliSmsService | 1 | 0 | 100 % |
|
||||
| AppService | 574 | 0 | 100 % |
|
||||
| MttvScreenService | 30 | 0 | 100 % |
|
||||
| NullArea | 1 | 0 | 100 % |
|
||||
| PowerPointService | 1 | 0 | 100 % |
|
||||
| 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:
|
||||
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/).
|
||||
3. Graphing any points data, (over daily, monthly and yearly).
|
||||
4. Update a GitHub repo with SunGrow PV data, (provide full revision history for any changes made to the SunGrow PV).
|
||||
5. Update a Google sheet with SunGrow PV data.
|
||||
3. Graphing any data points, over daily, monthly and yearly with 5 to hour time granularity.
|
||||
4. Output data to various formats - JSON, CSV, raw, Graphing, XML, XLSX, Markdown, and GoLang structures.
|
||||
|
||||
|
||||
## 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...
|
||||
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:
|
||||
|
||||
### Config and login.
|
||||
|
||||
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
|
||||
Using config file '/Users/mick/.GoSungrow/config.json'
|
||||
@ -117,204 +125,305 @@ Token File: /Users/mick/.GoSungrow/AppService_login.json
|
||||
|
||||
### High level reporting examples.
|
||||
|
||||
Produce point-in-time statistics
|
||||
Show all devices on your iSolarCloud account.
|
||||
```
|
||||
$ ./bin/GoSungrow data get stats
|
||||
+---------------------+-----------+---------------------------+---------+------+
|
||||
| Date | Point Id | Point Name | Value | Unit |
|
||||
+---------------------+-----------+---------------------------+---------+------+
|
||||
| 2022-02-28 11:05:00 | 1129147.0 | Co2 Reduce | 3.589 | kg |
|
||||
| 2022-02-28 11:05:00 | 1129147.0 | Co2 Reduce Total | 1047 | kg |
|
||||
| 2022-02-28 11:05:00 | 1129147.0 | Curr Power | 641 | W |
|
||||
| 2022-02-28 11:05:00 | 1129147.0 | Daily Irradiation | -- | |
|
||||
| 2022-02-28 11:05:00 | 1129147.0 | Equivalent Hour | 0.36 | Hour |
|
||||
| 2022-02-28 11:05:00 | 1129147.0 | Es Discharge Energy | 4.8 | kWh |
|
||||
| 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 |
|
||||
+---------------------+-----------+---------------------------+---------+------+
|
||||
./bin/GoSungrow show ps list
|
||||
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
|
||||
┃ Ps Key ┃ Ps Id ┃ Device Type ┃ Device Code ┃ Channel Id ┃ Serial # ┃ Factory Name ┃ Device Model ┃
|
||||
┣━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┫
|
||||
┃ 1129147_14_1_1 │ 1129147 │ 14 │ 1 │ 1 │ B2192301528 │ SUNGROW │ SH10RT ┃
|
||||
┃ 1129147_22_247_1 │ 1129147 │ 22 │ 247 │ 1 │ B2192301528 │ SUNGROW │ WiNet-S ┃
|
||||
┃ 1129147_43_2_1 │ 1129147 │ 43 │ 2 │ 1 │ B2192301528 │ SUNGROW │ SBR096 ┃
|
||||
┃ 1171348_14_1_2 │ 1171348 │ 14 │ 1 │ 2 │ B2281302388 │ SUNGROW │ SH10RT-V112 ┃
|
||||
┃ 1171348_22_247_2 │ 1171348 │ 22 │ 247 │ 2 │ B2281302388 │ SUNGROW │ WiNet-S ┃
|
||||
┃ 1171348_43_2_2 │ 1171348 │ 43 │ 2 │ 2 │ B2281302388 │ SUNGROW │ SBR096 ┃
|
||||
┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┛
|
||||
```
|
||||
|
||||
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'
|
||||
```
|
||||

|
||||
|
||||
|
||||
Get all defined report templates.
|
||||
```
|
||||
./bin/GoSungrow data get templates
|
||||
+-------------+---------------+---------------------+
|
||||
| Template Id | Template Name | Update On |
|
||||
+-------------+---------------+---------------------+
|
||||
| 8042 | Critical | 2022-02-15 13:00:28 |
|
||||
| 8041 | extras | 2022-02-15 09:40:04 |
|
||||
| 8036 | C | 2022-02-15 09:31:35 |
|
||||
| 8039 | v | 2022-02-15 09:31:10 |
|
||||
| 8040 | A | 2022-02-15 09:30:56 |
|
||||
| 8034 | Percent | 2022-02-15 09:30:41 |
|
||||
| 8038 | MWh | 2022-02-15 09:09:22 |
|
||||
| 8037 | MW | 2022-02-15 09:03:22 |
|
||||
| 8033 | kW | 2022-02-15 09:01:19 |
|
||||
| 8035 | Hours | 2022-02-15 08:55:56 |
|
||||
| 8031 | kWh | 2022-02-15 07:57:36 |
|
||||
| 7981 | Power | 2022-02-09 10:03:40 |
|
||||
+-------------+---------------+---------------------+
|
||||
./bin/GoSungrow show template list
|
||||
|
||||
# DataTable AppService.getTemplateList.ResultData.PageList - DataTable AppService.getTemplateList.ResultData.PageList
|
||||
---------------- ------------------ ------------------------
|
||||
Template Id Template Name Update Time
|
||||
---------------- ------------------ ------------------------
|
||||
7981 Power 2022-02-09 10:03:40
|
||||
8031 kWh 2022-02-15 07:57:36
|
||||
8035 Hours 2022-02-15 08:55:56
|
||||
8033 kW 2022-02-15 09:01:19
|
||||
8037 MW 2022-02-15 09:03:22
|
||||
8038 MWh 2022-02-15 09:09:22
|
||||
8034 Percent 2022-02-15 09:30:41
|
||||
8040 A 2022-02-15 09:30:56
|
||||
8039 v 2022-02-15 09:31:10
|
||||
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.
|
||||
```
|
||||
$ ./bin/GoSungrow data get template-points 8040
|
||||
+---------+----------------------------+------+
|
||||
| PointId | Description | Unit |
|
||||
+---------+----------------------------+------+
|
||||
| p83106 | Load Power | kW |
|
||||
| p13003 | Total DC Power | kW |
|
||||
| p13019 | Internal Air Temperature | ℃ |
|
||||
| p13142 | Battery Health (SOH) | % |
|
||||
| p13149 | Purchased Power | kW |
|
||||
| p13150 | Battery Discharging Power | kW |
|
||||
| p13121 | Total Export Active Power | kW |
|
||||
| p13126 | Battery Charging Power | kW |
|
||||
| p13141 | Battery Level (SOC) | % |
|
||||
| p13143 | Battery Temperature | ℃ |
|
||||
+---------+----------------------------+------+
|
||||
./bin/GoSungrow show template points 8040
|
||||
|
||||
# DataTable WebAppService.queryUserCurveTemplateData.8040.ResultData.PointsData.Devices.[1129147_14_1_1].Points - TemplateId:8040
|
||||
------------- ----------------------------------- ------------ ------------------- ------------ -------------- ------------- --------------- ---------- --------- --------------
|
||||
Point Id Point Name Ps Id Ps Key Color Detail Id Ps Name Statistics Style Unit Data List
|
||||
------------- ----------------------------------- ------------ ------------------- ------------ -------------- ------------- --------------- ---------- --------- --------------
|
||||
p13002 MPPT1 Current 1129147 1129147_14_1_1 #FFFF00 123808 MickMake 5 1 A
|
||||
p13008 Phase A Current 1129147 1129147_14_1_1 #FF0000 123814 MickMake 5 1 A
|
||||
p13009 Phase B Current 1129147 1129147_14_1_1 #00FF00 123813 MickMake 5 1 A
|
||||
p13010 Phase C Current 1129147 1129147_14_1_1 #0000FF 123812 MickMake 5 1 A
|
||||
p13106 MPPT2 Current 1129147 1129147_14_1_1 #70DB93 123807 MickMake 5 1 A
|
||||
p13139 Battery Current 1129147 1129147_14_1_1 #CD7F32 123806 MickMake 5 1 A
|
||||
p13162 Max. Charging Current (BMS) 1129147 1129147_14_1_1 #C0C0C0 123805 MickMake 5 1 A
|
||||
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.
|
||||
```
|
||||
$ ./bin/GoSungrow data get template 8040 20220224
|
||||
+---------------------+-----------------------+----------------------------+-------------+-------+
|
||||
| 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 |
|
||||
./bin/GoSungrow show template data 8040 20220204 20220205 120
|
||||
|
||||
...
|
||||
|
||||
+---------------------+-----------------------+----------------------------+-------------+-------+
|
||||
# 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'
|
||||
```
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
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
|
||||
+---------+----------------------------+------+
|
||||
| PointId | Description | Unit |
|
||||
+---------+----------------------------+------+
|
||||
| p83106 | Load Power | kW |
|
||||
| p13003 | Total DC Power | kW |
|
||||
| p13121 | Total Export Active Power | kW |
|
||||
| p13142 | Battery Health (SOH) | % |
|
||||
| p13150 | Battery Discharging Power | kW |
|
||||
| p13019 | Internal Air Temperature | ℃ |
|
||||
| p13126 | Battery Charging Power | kW |
|
||||
| p13141 | Battery Level (SOC) | % |
|
||||
| p13143 | Battery Temperature | ℃ |
|
||||
| p13149 | Purchased Power | kW |
|
||||
+---------+----------------------------+------+
|
||||
|
||||
$ ./bin/GoSungrow data graph template 8042 20220224 '{"search_string":"p13019"}'
|
||||
```
|
||||

|
||||
|
||||
Produce graphs of all points from template 8042 for date 2022/02/28 with a different width and height.
|
||||
```
|
||||
$ ./bin/GoSungrow data graph template 8042 20220228 '{"width":2400,"height":500}'
|
||||
```
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
Produce daily report for point_id p83106 for date 2022/02/24.
|
||||
```
|
||||
$ ./bin/GoSungrow data get points 20220224 1129147_11_0_0.p83106
|
||||
+---------------------+-----------------------+------------+--------+-------+
|
||||
| Date/Time | Point Id | Point Name | Value | Units |
|
||||
+---------------------+-----------------------+------------+--------+-------+
|
||||
| 2022-02-24 00:00:00 | 1129147_11_0_0.p83106 | | 818.0 | |
|
||||
| 2022-02-24 00:05:00 | 1129147_11_0_0.p83106 | | 756.0 | |
|
||||
| 2022-02-24 00:10:00 | 1129147_11_0_0.p83106 | | 571.0 | |
|
||||
| 2022-02-24 00:15:00 | 1129147_11_0_0.p83106 | | 557.0 | |
|
||||
| 2022-02-24 00:20:00 | 1129147_11_0_0.p83106 | | 553.0 | |
|
||||
| 2022-02-24 00:25:00 | 1129147_11_0_0.p83106 | | 558.0 | |
|
||||
| 2022-02-24 00:30:00 | 1129147_11_0_0.p83106 | | 562.0 | |
|
||||
| 2022-02-24 00:35:00 | 1129147_11_0_0.p83106 | | 561.0 | |
|
||||
|
||||
...
|
||||
|
||||
+---------------------+-----------------------+------------+--------+-------+
|
||||
```
|
||||
|
||||
Get all point ids by device_type.
|
||||
```
|
||||
+-------------+------------+----------+----------------------------------------+
|
||||
| Device Type | Point Type | Point Id | Point Name |
|
||||
+-------------+------------+----------+----------------------------------------+
|
||||
| 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 |
|
||||
|
||||
...
|
||||
|
||||
+-------------+------------+----------+----------------------------------------+
|
||||
./bin/GoSungrow show device list
|
||||
# Available points:
|
||||
┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
||||
┃ Device Type ┃ Name ┃
|
||||
┣━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
|
||||
┃ 1 │ Inverter ┃
|
||||
┃ 10 │ String ┃
|
||||
┃ 11 │ Plant ┃
|
||||
┃ 12 │ Circuit Protection ┃
|
||||
┃ 13 │ Splitting Device ┃
|
||||
┃ 14 │ Energy Storage System ┃
|
||||
┃ 15 │ Sampling Device ┃
|
||||
┃ 16 │ EMU ┃
|
||||
┃ 17 │ Unit ┃
|
||||
┃ 18 │ Temperature and Humidity Sensor ┃
|
||||
┃ 19 │ Intelligent Power Distribution Cabinet ┃
|
||||
┃ 20 │ Display Device ┃
|
||||
┃ 21 │ AC Power Distributed Cabinet ┃
|
||||
┃ 22 │ Communication Module ┃
|
||||
┃ 23 │ System-BMS ┃
|
||||
┃ 24 │ RackBMS ┃
|
||||
┃ 25 │ DC-DC ┃
|
||||
┃ 26 │ Energy Management System ┃
|
||||
┃ 28 │ Wind Energy Converter ┃
|
||||
┃ 29 │ SVG ┃
|
||||
┃ 3 │ Grid-connection Point ┃
|
||||
┃ 30 │ PT Cabinet ┃
|
||||
┃ 31 │ Bus Protection ┃
|
||||
┃ 32 │ Cleaning Robot ┃
|
||||
┃ 33 │ Direct Current Cabinet ┃
|
||||
┃ 34 │ Public Measurement and Control ┃
|
||||
┃ 35 │ Anti-islanding Protection Device ┃
|
||||
┃ 36 │ Frequency and Voltage Emergency Control Device ┃
|
||||
┃ 37 │ PCS ┃
|
||||
┃ 38 │ Cell BMS ┃
|
||||
┃ 39 │ Power Quality ┃
|
||||
┃ 4 │ Combiner Box ┃
|
||||
┃ 40 │ Shuttle ┃
|
||||
┃ 41 │ Optimizer ┃
|
||||
┃ 42 │ Tracking axis communication box ┃
|
||||
┃ 43 │ Battery ┃
|
||||
┃ 44 │ Battery Cluster Management Unit ┃
|
||||
┃ 45 │ Local Controller ┃
|
||||
┃ 46 │ Networking Devices ┃
|
||||
┃ 47 │ Energy Storage Unit ┃
|
||||
┃ 48 │ DC Container ┃
|
||||
┃ 5 │ Meteo Station ┃
|
||||
┃ 50 │ IO Module ┃
|
||||
┃ 51 │ Charger ┃
|
||||
┃ 52 │ Battery System Controller ┃
|
||||
┃ 6 │ Transformer ┃
|
||||
┃ 7 │ Meter ┃
|
||||
┃ 8 │ UPS ┃
|
||||
┃ 9 │ Data Logger ┃
|
||||
┃ 99 │ Others ┃
|
||||
┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
||||
```
|
||||
|
||||
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'
|
||||
```
|
||||

|
||||

|
||||
|
||||
|
||||
### Using the API instead.
|
||||
|
@ -180,6 +180,22 @@ func (c *CmdData) AttachCommand(cmd *cobra.Command) *cobra.Command {
|
||||
c.SelfCmd.AddCommand(cmdApiXLSX)
|
||||
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{
|
||||
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 {
|
||||
cmds.Api.SaveFile = true
|
||||
}
|
||||
if cmd.Name() == output.StringTypeGraph {
|
||||
cmds.Api.SaveFile = true
|
||||
}
|
||||
|
||||
args = MinimumArraySize(2, args)
|
||||
eps := iSolarCloud.SplitArg(args[0])
|
||||
|
@ -127,6 +127,25 @@ func (c *CmdInfo) AttachCommand(cmd *cobra.Command) *cobra.Command {
|
||||
cmdInfoCsv.Example = cmdHelp.PrintExamples(cmdInfoCsv, "[area.]<endpoint>")
|
||||
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{
|
||||
// Use: "put",
|
||||
|
@ -26,13 +26,12 @@ func (c *CmdShow) AttachCommand(cmd *cobra.Command) *cobra.Command {
|
||||
}
|
||||
c.cmd = cmd
|
||||
|
||||
// ******************************************************************************** //
|
||||
c.SelfCmd = &cobra.Command{
|
||||
Use: "show",
|
||||
Aliases: []string{},
|
||||
Annotations: map[string]string{"group": "Show"},
|
||||
Short: fmt.Sprintf("Helpful Sungrow functions."),
|
||||
Long: fmt.Sprintf("Helpful Sungrow functions."),
|
||||
Short: fmt.Sprintf("High-level Sungrow commands."),
|
||||
Long: fmt.Sprintf("High-level Sungrow commands."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
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.AttachDevice(c.SelfCmd)
|
||||
c.AttachPoint(c.SelfCmd)
|
||||
c.AttachTemplate(c.SelfCmd)
|
||||
c.AttachPoint(c.SelfCmd)
|
||||
}
|
||||
return c.SelfCmd
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ func (c *CmdShow) AttachDevice(cmd *cobra.Command) *cobra.Command {
|
||||
Use: "device",
|
||||
Aliases: []string{},
|
||||
Annotations: map[string]string{"group": "Device"},
|
||||
Short: fmt.Sprintf("Sungrow devices."),
|
||||
Long: fmt.Sprintf("Sungrow devices."),
|
||||
Short: fmt.Sprintf("Device related Sungrow commands."),
|
||||
Long: fmt.Sprintf("Device related Sungrow commands."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
@ -29,6 +29,8 @@ func (c *CmdShow) AttachDevice(cmd *cobra.Command) *cobra.Command {
|
||||
|
||||
c.AttachDeviceList(self)
|
||||
c.AttachDevicePoints(self)
|
||||
c.AttachDeviceData(self)
|
||||
c.AttachDeviceGraph(self)
|
||||
c.AttachDeviceModels(self)
|
||||
}
|
||||
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 {
|
||||
// ********************************************************************************
|
||||
var c2 = &cobra.Command{
|
||||
var self = &cobra.Command{
|
||||
Use: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Annotations: map[string]string{"group": "Device"},
|
||||
@ -49,36 +50,40 @@ func (c *CmdShow) AttachDeviceList(cmd *cobra.Command) *cobra.Command {
|
||||
RunE: c.funcDeviceTypeList,
|
||||
Args: cobra.MinimumNArgs(0),
|
||||
}
|
||||
cmd.AddCommand(c2)
|
||||
c2.Example = cmdHelp.PrintExamples(c2, "")
|
||||
cmd.AddCommand(self)
|
||||
self.Example = cmdHelp.PrintExamples(self, "")
|
||||
|
||||
return cmd
|
||||
}
|
||||
func (c *CmdShow) funcDeviceTypeList(_ *cobra.Command, args []string) error {
|
||||
for range Only.Once {
|
||||
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)
|
||||
}
|
||||
return c.Error
|
||||
}
|
||||
|
||||
func (c *CmdShow) AttachDevicePoints(cmd *cobra.Command) *cobra.Command {
|
||||
// ********************************************************************************
|
||||
var c2 = &cobra.Command{
|
||||
var self = &cobra.Command{
|
||||
Use: "points <device_type ...>",
|
||||
Aliases: []string{"point"},
|
||||
Annotations: map[string]string{"group": "Device"},
|
||||
Short: fmt.Sprintf("List data points used by a device."),
|
||||
Long: fmt.Sprintf("List data points used by a device."),
|
||||
Short: fmt.Sprintf("List points used for a given device_type."),
|
||||
Long: fmt.Sprintf("List points used for a given device_type."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
RunE: c.funcDevicePoints,
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
}
|
||||
cmd.AddCommand(c2)
|
||||
c2.Example = cmdHelp.PrintExamples(c2,
|
||||
cmd.AddCommand(self)
|
||||
self.Example = cmdHelp.PrintExamples(self,
|
||||
"1",
|
||||
"11",
|
||||
)
|
||||
@ -88,19 +93,24 @@ func (c *CmdShow) AttachDevicePoints(cmd *cobra.Command) *cobra.Command {
|
||||
func (c *CmdShow) funcDevicePoints(_ *cobra.Command, args []string) error {
|
||||
for range Only.Once {
|
||||
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)
|
||||
}
|
||||
return c.Error
|
||||
}
|
||||
|
||||
func (c *CmdShow) AttachDeviceData(cmd *cobra.Command) *cobra.Command {
|
||||
// ********************************************************************************
|
||||
var self = &cobra.Command{
|
||||
Use: "data <device_type> [start date] [end date] [interval]",
|
||||
Aliases: []string{},
|
||||
Annotations: map[string]string{"group": "Device"},
|
||||
Short: fmt.Sprintf("Get data from report template."),
|
||||
Long: fmt.Sprintf("Get data from report template."),
|
||||
Short: fmt.Sprintf("Generate points table for a given device_type."),
|
||||
Long: fmt.Sprintf("Generate points table for a given device_type."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
@ -122,22 +132,22 @@ func (c *CmdShow) funcDeviceData(_ *cobra.Command, args []string) error {
|
||||
for range Only.Once {
|
||||
cmds.Api.SunGrow.OutputType.SetTable()
|
||||
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
|
||||
}
|
||||
|
||||
func (c *CmdShow) AttachDeviceDataGraph(cmd *cobra.Command) *cobra.Command {
|
||||
// ********************************************************************************
|
||||
func (c *CmdShow) AttachDeviceGraph(cmd *cobra.Command) *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"},
|
||||
Short: fmt.Sprintf("Get data from report template."),
|
||||
Long: fmt.Sprintf("Get data from report template."),
|
||||
Short: fmt.Sprintf("Generate graphs of points for a given device_type."),
|
||||
Long: fmt.Sprintf("Generate graphs of points for a given device_type."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
RunE: c.funcDeviceDataGraph,
|
||||
RunE: c.funcDeviceGraph,
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
}
|
||||
cmd.AddCommand(self)
|
||||
@ -151,18 +161,17 @@ func (c *CmdShow) AttachDeviceDataGraph(cmd *cobra.Command) *cobra.Command {
|
||||
|
||||
return cmd
|
||||
}
|
||||
func (c *CmdShow) funcDeviceDataGraph(_ *cobra.Command, args []string) error {
|
||||
func (c *CmdShow) funcDeviceGraph(_ *cobra.Command, args []string) error {
|
||||
for range Only.Once {
|
||||
cmds.Api.SunGrow.OutputType.SetGraph()
|
||||
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
|
||||
}
|
||||
|
||||
func (c *CmdShow) AttachDeviceModels(cmd *cobra.Command) *cobra.Command {
|
||||
// ********************************************************************************
|
||||
var c2 = &cobra.Command{
|
||||
var self = &cobra.Command{
|
||||
Use: "models",
|
||||
Aliases: []string{"model"},
|
||||
Annotations: map[string]string{"group": "Device"},
|
||||
@ -174,14 +183,14 @@ func (c *CmdShow) AttachDeviceModels(cmd *cobra.Command) *cobra.Command {
|
||||
RunE: c.funcDeviceModels,
|
||||
Args: cobra.MinimumNArgs(0),
|
||||
}
|
||||
cmd.AddCommand(c2)
|
||||
c2.Example = cmdHelp.PrintExamples(c2, "")
|
||||
cmd.AddCommand(self)
|
||||
self.Example = cmdHelp.PrintExamples(self, "")
|
||||
|
||||
return cmd
|
||||
}
|
||||
func (c *CmdShow) funcDeviceModels(_ *cobra.Command, _ []string) error {
|
||||
for range Only.Once {
|
||||
// _ = cmds.SetOutputType(cmd)
|
||||
cmds.Api.SunGrow.OutputType.SetTable()
|
||||
c.Error = cmds.Api.SunGrow.DeviceModelInfoList()
|
||||
}
|
||||
return c.Error
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"github.com/MickMake/GoUnify/cmdHelp"
|
||||
"github.com/spf13/cobra"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
||||
@ -15,8 +14,8 @@ func (c *CmdShow) AttachPoint(cmd *cobra.Command) *cobra.Command {
|
||||
Use: "point",
|
||||
Aliases: []string{},
|
||||
Annotations: map[string]string{"group": "Point"},
|
||||
Short: fmt.Sprintf("General iSolarCloud functions."),
|
||||
Long: fmt.Sprintf("General iSolarCloud functions."),
|
||||
Short: fmt.Sprintf("Point related Sungrow commands."),
|
||||
Long: fmt.Sprintf("Point related Sungrow commands."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
@ -41,7 +40,7 @@ func (c *CmdShow) AttachPoint(cmd *cobra.Command) *cobra.Command {
|
||||
c.AttachPointTemplateGraph(self)
|
||||
|
||||
c.AttachPointData(self)
|
||||
c.AttachPointDataGraph(self)
|
||||
c.AttachPointGraph(self)
|
||||
|
||||
c.AttachPointScan(self)
|
||||
}
|
||||
@ -59,7 +58,7 @@ func (c *CmdShow) AttachPointPs(cmd *cobra.Command) *cobra.Command {
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
RunE: c.funcPointPs,
|
||||
RunE: c.funcAttachPsPoints,
|
||||
Args: cobra.MinimumNArgs(0),
|
||||
}
|
||||
cmd.AddCommand(self)
|
||||
@ -67,22 +66,10 @@ func (c *CmdShow) AttachPointPs(cmd *cobra.Command) *cobra.Command {
|
||||
|
||||
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 {
|
||||
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{},
|
||||
Annotations: map[string]string{"group": "Point"},
|
||||
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,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
RunE: c.funcPointPsTable,
|
||||
RunE: c.funcAttachPsData,
|
||||
Args: cobra.MinimumNArgs(0),
|
||||
}
|
||||
cmd.AddCommand(self)
|
||||
@ -103,17 +90,6 @@ func (c *CmdShow) AttachPointPsTable(cmd *cobra.Command) *cobra.Command {
|
||||
|
||||
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 {
|
||||
var self = &cobra.Command{
|
||||
@ -125,7 +101,7 @@ func (c *CmdShow) AttachPointPsGraph(cmd *cobra.Command) *cobra.Command {
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
RunE: c.funcPointPsGraph,
|
||||
RunE: c.funcAttachPsGraph,
|
||||
Args: cobra.MinimumNArgs(0),
|
||||
}
|
||||
cmd.AddCommand(self)
|
||||
@ -138,96 +114,10 @@ func (c *CmdShow) AttachPointPsGraph(cmd *cobra.Command) *cobra.Command {
|
||||
|
||||
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 {
|
||||
// ********************************************************************************
|
||||
var c2 = &cobra.Command{
|
||||
var self = &cobra.Command{
|
||||
Use: "device <device_type ...>",
|
||||
Aliases: []string{"devices"},
|
||||
Annotations: map[string]string{"group": "Point"},
|
||||
@ -239,8 +129,8 @@ func (c *CmdShow) AttachPointDevice(cmd *cobra.Command) *cobra.Command {
|
||||
RunE: c.funcDevicePoints,
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
cmd.AddCommand(c2)
|
||||
c2.Example = cmdHelp.PrintExamples(c2,
|
||||
cmd.AddCommand(self)
|
||||
self.Example = cmdHelp.PrintExamples(self,
|
||||
"1",
|
||||
"11",
|
||||
)
|
||||
@ -249,10 +139,9 @@ func (c *CmdShow) AttachPointDevice(cmd *cobra.Command) *cobra.Command {
|
||||
}
|
||||
|
||||
func (c *CmdShow) AttachPointDeviceTable(cmd *cobra.Command) *cobra.Command {
|
||||
// ********************************************************************************
|
||||
var self = &cobra.Command{
|
||||
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."),
|
||||
Long: fmt.Sprintf("Generate points table for a given device."),
|
||||
DisableFlagParsing: false,
|
||||
@ -274,10 +163,9 @@ func (c *CmdShow) AttachPointDeviceTable(cmd *cobra.Command) *cobra.Command {
|
||||
}
|
||||
|
||||
func (c *CmdShow) AttachPointDeviceGraph(cmd *cobra.Command) *cobra.Command {
|
||||
// ********************************************************************************
|
||||
var self = &cobra.Command{
|
||||
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."),
|
||||
Long: fmt.Sprintf("Generate graphs of points for a given device."),
|
||||
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{
|
||||
Use: "scan [min] [max]",
|
||||
Use: "template <template_id>",
|
||||
Aliases: []string{},
|
||||
Annotations: map[string]string{"group": "Point"},
|
||||
Short: fmt.Sprintf("Scan full list of points."),
|
||||
Long: fmt.Sprintf("Scan full list of points."),
|
||||
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.funcPointScan,
|
||||
Args: cobra.MinimumNArgs(2),
|
||||
RunE: c.funcTemplatePoints,
|
||||
Args: cobra.ExactArgs(1),
|
||||
}
|
||||
cmd.AddCommand(self)
|
||||
self.Example = cmdHelp.PrintExamples(self,
|
||||
"1 1000",
|
||||
)
|
||||
"8042",
|
||||
"8040",
|
||||
)
|
||||
|
||||
return cmd
|
||||
}
|
||||
func (c *CmdShow) funcPointScan(_ *cobra.Command, args []string) error {
|
||||
for range Only.Once {
|
||||
cmds.Api.SunGrow.OutputType.SetTable()
|
||||
args = MinimumArraySize(2, args)
|
||||
points := cmds.Api.SunGrow.PointScan(args[0], args[1])
|
||||
if c.Error != nil {
|
||||
break
|
||||
}
|
||||
fmt.Printf("%s\n", points)
|
||||
|
||||
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": "Point"},
|
||||
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),
|
||||
}
|
||||
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 {
|
||||
cmds.Api.SunGrow.OutputType.SetTable()
|
||||
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 {
|
||||
break
|
||||
}
|
||||
@ -366,17 +291,17 @@ func (c *CmdShow) funcPointData(_ *cobra.Command, args []string) 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{
|
||||
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{},
|
||||
Annotations: map[string]string{"group": "Point"},
|
||||
Short: fmt.Sprintf("Get data points."),
|
||||
Long: fmt.Sprintf("Get data points."),
|
||||
Short: fmt.Sprintf("Graph data points."),
|
||||
Long: fmt.Sprintf("Graph data points."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
RunE: c.funcPointDataGraph,
|
||||
RunE: c.funcPointGraph,
|
||||
Args: cobra.MinimumNArgs(4),
|
||||
}
|
||||
cmd.AddCommand(self)
|
||||
@ -387,14 +312,50 @@ func (c *CmdShow) AttachPointDataGraph(cmd *cobra.Command) *cobra.Command {
|
||||
|
||||
return cmd
|
||||
}
|
||||
func (c *CmdShow) funcPointDataGraph(_ *cobra.Command, args []string) error {
|
||||
func (c *CmdShow) funcPointGraph(_ *cobra.Command, args []string) error {
|
||||
for range Only.Once {
|
||||
cmds.Api.SunGrow.OutputType.SetGraph()
|
||||
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 {
|
||||
break
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ func (c *CmdShow) AttachPsId(cmd *cobra.Command) *cobra.Command {
|
||||
Use: "ps",
|
||||
Aliases: []string{},
|
||||
Annotations: map[string]string{"group": "PsId"},
|
||||
Short: fmt.Sprintf("General iSolarCloud functions."),
|
||||
Long: fmt.Sprintf("General iSolarCloud functions."),
|
||||
Short: fmt.Sprintf("Ps related Sungrow commands."),
|
||||
Long: fmt.Sprintf("Ps related Sungrow commands."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
@ -29,24 +29,27 @@ func (c *CmdShow) AttachPsId(cmd *cobra.Command) *cobra.Command {
|
||||
cmd.AddCommand(self)
|
||||
self.Example = cmdHelp.PrintExamples(self, "")
|
||||
|
||||
c.AttachPsIdList(self)
|
||||
c.AttachPsList(self)
|
||||
c.AttachPsTree(self)
|
||||
c.AttachPsPoints(self)
|
||||
c.AttachPsData(self)
|
||||
c.AttachPsGraph(self)
|
||||
}
|
||||
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{
|
||||
Use: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Annotations: map[string]string{"group": "Device"},
|
||||
Annotations: map[string]string{"group": "PsId"},
|
||||
Short: fmt.Sprintf("Show all devices on account."),
|
||||
Long: fmt.Sprintf("Show all devices on account."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
RunE: c.funcPsIdListList,
|
||||
RunE: c.funcPsList,
|
||||
Args: cobra.MinimumNArgs(0),
|
||||
}
|
||||
cmd.AddCommand(self)
|
||||
@ -54,13 +57,14 @@ func (c *CmdShow) AttachPsIdList(cmd *cobra.Command) *cobra.Command {
|
||||
|
||||
return cmd
|
||||
}
|
||||
func (c *CmdShow) funcPsIdListList(_ *cobra.Command, args []string) error {
|
||||
func (c *CmdShow) funcPsList(_ *cobra.Command, args []string) error {
|
||||
for range Only.Once {
|
||||
var devices string
|
||||
devices, c.Error = cmds.Api.SunGrow.Devices(args...)
|
||||
devices, c.Error = cmds.Api.SunGrow.PsList(args...)
|
||||
if c.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", devices)
|
||||
}
|
||||
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 {
|
||||
var self = &cobra.Command{
|
||||
Use: "list",
|
||||
Use: "list2",
|
||||
Aliases: []string{"ls"},
|
||||
Annotations: map[string]string{"group": "PsId"},
|
||||
Short: fmt.Sprintf("Show all available PS."),
|
||||
@ -90,6 +94,7 @@ func (c *CmdShow) funcAttachPsIdList2(_ *cobra.Command, args []string) error {
|
||||
if c.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", pids)
|
||||
}
|
||||
return c.Error
|
||||
@ -120,6 +125,7 @@ func (c *CmdShow) funcAttachPsTree(_ *cobra.Command, args []string) error {
|
||||
if c.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", pids)
|
||||
}
|
||||
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 {
|
||||
var self = &cobra.Command{
|
||||
Use: "points <ps_ids | .> [device_type]",
|
||||
Use: "points [ps_ids | .] [device_type]",
|
||||
Aliases: []string{"point"},
|
||||
Annotations: map[string]string{"group": "PsId"},
|
||||
Short: fmt.Sprintf("Show available PS points."),
|
||||
Long: fmt.Sprintf("Show available PS points."),
|
||||
Short: fmt.Sprintf("List points used for a given ps_id."),
|
||||
Long: fmt.Sprintf("List points used for a given ps_id."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
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 {
|
||||
for range Only.Once {
|
||||
args = MinimumArraySize(2, args)
|
||||
points := cmds.Api.SunGrow.PointNames(strings.Split(args[0], ","), args[1])
|
||||
if cmds.Api.SunGrow.Error != nil {
|
||||
c.Error = cmds.Api.SunGrow.Error
|
||||
var points string
|
||||
points, c.Error = cmds.Api.SunGrow.PsPoints(strings.Split(args[0], ","), args[1])
|
||||
if c.Error != nil {
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Printf("%s\n", points)
|
||||
}
|
||||
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
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ func (c *CmdShow) AttachTemplate(cmd *cobra.Command) *cobra.Command {
|
||||
Use: "template",
|
||||
Aliases: []string{},
|
||||
Annotations: map[string]string{"group": "Template"},
|
||||
Short: fmt.Sprintf("General iSolarCloud functions."),
|
||||
Long: fmt.Sprintf("General iSolarCloud functions."),
|
||||
Short: fmt.Sprintf("Template related Sungrow commands."),
|
||||
Long: fmt.Sprintf("Template related Sungrow commands."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
@ -30,16 +30,16 @@ func (c *CmdShow) AttachTemplate(cmd *cobra.Command) *cobra.Command {
|
||||
c.AttachTemplateList(self)
|
||||
c.AttachTemplatePoints(self)
|
||||
c.AttachTemplateData(self)
|
||||
c.AttachTemplateDataGraph(self)
|
||||
c.AttachTemplateGraph(self)
|
||||
}
|
||||
return c.SelfCmd
|
||||
}
|
||||
|
||||
|
||||
func (c *CmdShow) AttachTemplateList(cmd *cobra.Command) *cobra.Command {
|
||||
// ********************************************************************************
|
||||
var self = &cobra.Command{
|
||||
Use: "list",
|
||||
Aliases: []string{},
|
||||
Aliases: []string{"ls"},
|
||||
Annotations: map[string]string{"group": "Template"},
|
||||
Short: 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 {
|
||||
// ********************************************************************************
|
||||
var self = &cobra.Command{
|
||||
Use: "points <template id>",
|
||||
Aliases: []string{"point"},
|
||||
Annotations: map[string]string{"group": "Template"},
|
||||
Short: fmt.Sprintf("Get all points defined within a template."),
|
||||
Long: fmt.Sprintf("Get all points defined within a template."),
|
||||
Short: fmt.Sprintf("List points used for a given template_id."),
|
||||
Long: fmt.Sprintf("List points used for a given template_id."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
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 {
|
||||
// ********************************************************************************
|
||||
var self = &cobra.Command{
|
||||
Use: "data <template_id> [start date] [end date] [interval]",
|
||||
Aliases: []string{},
|
||||
Annotations: map[string]string{"group": "Template"},
|
||||
Short: fmt.Sprintf("Get data from report template."),
|
||||
Long: fmt.Sprintf("Get data from report template."),
|
||||
Short: fmt.Sprintf("Generate points table for a given template_id."),
|
||||
Long: fmt.Sprintf("Generate points table for a given template_id."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
@ -122,17 +121,17 @@ func (c *CmdShow) funcTemplateData(_ *cobra.Command, args []string) 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{
|
||||
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"},
|
||||
Short: fmt.Sprintf("Get data from report template."),
|
||||
Long: fmt.Sprintf("Get data from report template."),
|
||||
Short: fmt.Sprintf("Generate graphs of points for a given template_id."),
|
||||
Long: fmt.Sprintf("Generate graphs of points for a given template_id."),
|
||||
DisableFlagParsing: false,
|
||||
DisableFlagsInUseLine: false,
|
||||
PreRunE: cmds.SunGrowArgs,
|
||||
RunE: c.funcTemplateDataGraph,
|
||||
RunE: c.funcTemplateGraph,
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
}
|
||||
cmd.AddCommand(self)
|
||||
@ -146,7 +145,7 @@ func (c *CmdShow) AttachTemplateDataGraph(cmd *cobra.Command) *cobra.Command {
|
||||
|
||||
return cmd
|
||||
}
|
||||
func (c *CmdShow) funcTemplateDataGraph(_ *cobra.Command, args []string) error {
|
||||
func (c *CmdShow) funcTemplateGraph(_ *cobra.Command, args []string) error {
|
||||
for range Only.Once {
|
||||
cmds.Api.SunGrow.OutputType.SetGraph()
|
||||
args = MinimumArraySize(4, args)
|
||||
|
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 43 KiB |
23
go.mod
@ -3,41 +3,18 @@ module GoSungrow
|
||||
go 1.19
|
||||
|
||||
//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/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/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/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/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/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/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/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/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/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/cmdPath => ../../GoUnify/cmdPath
|
||||
|
||||
//require github.com/MickMake/GoUnify/Only v0.0.0-20221125013232-022ba4a63055 // indirect
|
||||
|
||||
require (
|
||||
github.com/MickMake/GoUnify/Only v0.0.0-20221125023651-ff4a37b1928a
|
||||
github.com/MickMake/GoUnify/Unify v0.0.0-20221125023651-ff4a37b1928a
|
||||
|
@ -7,27 +7,29 @@ import (
|
||||
|
||||
|
||||
const (
|
||||
TypeNone = iota
|
||||
TypeJson = iota
|
||||
TypeCsv = iota
|
||||
TypeList = iota
|
||||
TypeTable = iota
|
||||
TypeRaw = iota
|
||||
TypeGraph = iota
|
||||
TypeStruct = iota
|
||||
TypeXML = iota
|
||||
TypeXLSX = iota
|
||||
TypeNone = iota
|
||||
TypeJson = iota
|
||||
TypeCsv = iota
|
||||
TypeList = iota
|
||||
TypeTable = iota
|
||||
TypeRaw = iota
|
||||
TypeGraph = iota
|
||||
TypeStruct = iota
|
||||
TypeXML = iota
|
||||
TypeXLSX = iota
|
||||
TypeMarkDown = iota
|
||||
|
||||
StringTypeNone = ""
|
||||
StringTypeJson = "json"
|
||||
StringTypeCsv = "csv"
|
||||
StringTypeList = "list"
|
||||
StringTypeTable = "table"
|
||||
StringTypeRaw = "raw"
|
||||
StringTypeGraph = "graph"
|
||||
StringTypeStruct = "struct"
|
||||
StringTypeXML = "xml"
|
||||
StringTypeXLSX = "xlsx"
|
||||
StringTypeNone = ""
|
||||
StringTypeJson = "json"
|
||||
StringTypeCsv = "csv"
|
||||
StringTypeList = "list"
|
||||
StringTypeTable = "table"
|
||||
StringTypeRaw = "raw"
|
||||
StringTypeGraph = "graph"
|
||||
StringTypeStruct = "struct"
|
||||
StringTypeXML = "xml"
|
||||
StringTypeXLSX = "xlsx"
|
||||
StringTypeMarkDown = "md"
|
||||
)
|
||||
|
||||
//goland:noinspection GoNameStartsWithPackageName
|
||||
@ -64,6 +66,9 @@ func (out *OutputType) SetXML() {
|
||||
func (out *OutputType) SetXLSX() {
|
||||
*out = TypeXLSX
|
||||
}
|
||||
func (out *OutputType) SetMarkDown() {
|
||||
*out = TypeMarkDown
|
||||
}
|
||||
|
||||
|
||||
func (out *OutputType) IsNone() bool {
|
||||
@ -126,6 +131,12 @@ func (out *OutputType) IsXLSX() bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (out *OutputType) IsMarkDown() bool {
|
||||
if *out == TypeMarkDown {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
func (out *OutputType) IsStrNone(t string) bool {
|
||||
@ -182,6 +193,12 @@ func (out *OutputType) IsStrXLSX(t string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (out *OutputType) IsStrMarkDown(t string) bool {
|
||||
if t == StringTypeMarkDown {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
func (out *OutputType) Set(outputType string) {
|
||||
@ -210,6 +227,8 @@ func (out *OutputType) Set(outputType string) {
|
||||
out.SetXML()
|
||||
case StringTypeXLSX:
|
||||
out.SetXLSX()
|
||||
case StringTypeMarkDown:
|
||||
out.SetMarkDown()
|
||||
case StringTypeList:
|
||||
fallthrough
|
||||
default:
|
||||
|
@ -11,8 +11,9 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
// "go.pennock.tech/tabular/auto"
|
||||
// "github.com/olekukonko/tablewriter"
|
||||
// "github.com/agrison/go-tablib"
|
||||
// "go.pennock.tech/tabular"
|
||||
// "github.com/jbub/tabular"
|
||||
|
||||
|
||||
@ -279,10 +280,14 @@ func (t *Table) Output() error {
|
||||
case t.OutputType.IsGraph():
|
||||
t.Error = t.CreateGraph()
|
||||
|
||||
case t.OutputType.IsMarkDown():
|
||||
t.Error = t.WriteMarkDown()
|
||||
|
||||
case t.OutputType.IsStruct():
|
||||
t.Error = t.WriteStruct()
|
||||
|
||||
default:
|
||||
t.Error = t.WriteTable()
|
||||
}
|
||||
}
|
||||
|
||||
@ -548,3 +553,45 @@ func (t *Table) WriteStruct() 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
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"sort"
|
||||
)
|
||||
@ -64,7 +64,7 @@ func (ps TypeEndPoints) String() 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
|
||||
|
@ -1,10 +1,10 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
@ -35,6 +35,10 @@ func (u *EndPointUrl) IsValid() error {
|
||||
err = errors.New("empty url")
|
||||
break
|
||||
}
|
||||
if u.EndPoint == nil {
|
||||
err = errors.New("empty url")
|
||||
break
|
||||
}
|
||||
if u.EndPoint.String() == "" {
|
||||
err = errors.New("empty url")
|
||||
break
|
||||
@ -45,6 +49,9 @@ func (u *EndPointUrl) IsValid() error {
|
||||
}
|
||||
|
||||
func (u EndPointUrl) String() string {
|
||||
if u.EndPoint == nil {
|
||||
return ""
|
||||
}
|
||||
return u.EndPoint.String()
|
||||
}
|
||||
|
||||
|
@ -11,191 +11,12 @@ import (
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
datatable "go.pennock.tech/tabular/auto"
|
||||
"sort"
|
||||
"strings"
|
||||
"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.
|
||||
func (sg *SunGrow) DeviceTypeList(psIds ...string) string {
|
||||
func (sg *SunGrow) DeviceTypeList(psIds ...string) (string, error) {
|
||||
var ret string
|
||||
|
||||
for range Only.Once {
|
||||
@ -256,7 +77,156 @@ func (sg *SunGrow) DeviceTypeList(psIds ...string) string {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,10 +16,8 @@ import (
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
datatable "go.pennock.tech/tabular/auto"
|
||||
"math"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -259,122 +257,8 @@ func (sg *SunGrow) GetAllPointsData(psIds ...string) error {
|
||||
}
|
||||
|
||||
|
||||
// PointNamesData - 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 {
|
||||
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 {
|
||||
// DevicePointAttrs - Return all points associated with psIds and device_type filter.
|
||||
func (sg *SunGrow) DevicePointAttrs(psIds []string, deviceType string) ([]getDevicePointAttrs.Point, error) {
|
||||
var points []getDevicePointAttrs.Point
|
||||
|
||||
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
|
||||
@ -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 {
|
||||
var ret string
|
||||
|
||||
func (sg *SunGrow) PointData(startDate string, endDate string, interval string, points ...string) error {
|
||||
for range Only.Once {
|
||||
// _, _ = sg.QueryMultiPointDataList(
|
||||
// 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
|
||||
|
||||
for range Only.Once {
|
||||
@ -561,7 +443,7 @@ func (sg *SunGrow) PointScan(min string, max string) string {
|
||||
ret = table.String()
|
||||
}
|
||||
|
||||
return ret
|
||||
return ret, sg.Error
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ package iSolarCloud
|
||||
import (
|
||||
"GoSungrow/iSolarCloud/AppService/findPsType"
|
||||
"GoSungrow/iSolarCloud/AppService/getChnnlListByPsId"
|
||||
"GoSungrow/iSolarCloud/AppService/getDeviceList"
|
||||
"GoSungrow/iSolarCloud/AppService/getHouseholdStoragePsReport"
|
||||
"GoSungrow/iSolarCloud/AppService/getIncomeSettingInfos"
|
||||
"GoSungrow/iSolarCloud/AppService/getPListinfoFromMysql"
|
||||
@ -20,6 +21,7 @@ import (
|
||||
"GoSungrow/iSolarCloud/AppService/getPsInstallerOrgInfoByPsId"
|
||||
"GoSungrow/iSolarCloud/AppService/getPsList"
|
||||
"GoSungrow/iSolarCloud/AppService/getPsWeatherList"
|
||||
"GoSungrow/iSolarCloud/AppService/getRemoteUpgradeTaskList"
|
||||
"GoSungrow/iSolarCloud/AppService/getReportData"
|
||||
"GoSungrow/iSolarCloud/AppService/psForcastInfo"
|
||||
"GoSungrow/iSolarCloud/AppService/psHourPointsValue"
|
||||
@ -34,6 +36,7 @@ import (
|
||||
"GoSungrow/iSolarCloud/Common"
|
||||
"GoSungrow/iSolarCloud/MttvScreenService/getPsDeviceListValue"
|
||||
"GoSungrow/iSolarCloud/MttvScreenService/getPsKpiForHoursByPsId"
|
||||
"GoSungrow/iSolarCloud/WebAppService/getDevicePointAttrs"
|
||||
"GoSungrow/iSolarCloud/WebAppService/getPsIdState"
|
||||
"GoSungrow/iSolarCloud/WebAppService/getReportPsTree"
|
||||
"GoSungrow/iSolarCloud/WebAppService/showPSView"
|
||||
@ -43,11 +46,162 @@ import (
|
||||
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
|
||||
"fmt"
|
||||
"github.com/MickMake/GoUnify/Only"
|
||||
datatable "go.pennock.tech/tabular/auto"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"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 {
|
||||
var ret valueTypes.PsKeys
|
||||
|
||||
@ -123,34 +277,6 @@ func (sg *SunGrow) GetPsKeys() valueTypes.PsKeys {
|
||||
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 {
|
||||
var ret []queryDeviceListForBackSys.Device
|
||||
for range Only.Once {
|
||||
@ -205,6 +331,32 @@ func (sg *SunGrow) GetPsIds() (valueTypes.PsIds, 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) {
|
||||
// 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
|
||||
func (sg *SunGrow) PsTreeMenu(psIds ...string) (PsTree, error) {
|
||||
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
|
||||
func (sg *SunGrow) QueryPowerStationInfo(psId valueTypes.PsId, sn valueTypes.String) (queryPowerStationInfo.ResultData, error) {
|
||||
var ret queryPowerStationInfo.ResultData
|
||||
@ -474,26 +624,26 @@ func (sg *SunGrow) QueryAllPsIdAndName() (queryAllPsIdAndName.ResultData, error)
|
||||
return ret, sg.Error
|
||||
}
|
||||
|
||||
// // GetRemoteUpgradeTaskList - AppService.getRemoteUpgradeTaskList
|
||||
// func (sg *SunGrow) getRemoteUpgradeTaskList(psId valueTypes.PsIds) (getRemoteUpgradeTaskList.ResultData, error) {
|
||||
// var ret getRemoteUpgradeTaskList.ResultData
|
||||
// for range Only.Once {
|
||||
// ep := sg.GetByStruct(
|
||||
// "WebAppService.getRemoteUpgradeTaskList",
|
||||
// getRemoteUpgradeTaskList.RequestData {
|
||||
// PsIdList: psId,
|
||||
// },
|
||||
// time.Hour * 24,
|
||||
// )
|
||||
// if sg.IsError() {
|
||||
// break
|
||||
// }
|
||||
//
|
||||
// data := getRemoteUpgradeTaskList.Assert(ep)
|
||||
// ret = data.Response.ResultData
|
||||
// }
|
||||
// return ret, sg.Error
|
||||
// }
|
||||
// GetRemoteUpgradeTaskList - AppService.getRemoteUpgradeTaskList
|
||||
func (sg *SunGrow) getRemoteUpgradeTaskList(psId valueTypes.PsIds) (getRemoteUpgradeTaskList.ResultData, error) {
|
||||
var ret getRemoteUpgradeTaskList.ResultData
|
||||
for range Only.Once {
|
||||
ep := sg.GetByStruct(
|
||||
"WebAppService.getRemoteUpgradeTaskList",
|
||||
getRemoteUpgradeTaskList.RequestData {
|
||||
PsIdList: psId,
|
||||
},
|
||||
time.Hour * 24,
|
||||
)
|
||||
if sg.IsError() {
|
||||
break
|
||||
}
|
||||
|
||||
data := getRemoteUpgradeTaskList.Assert(ep)
|
||||
ret = data.Response.ResultData
|
||||
}
|
||||
return ret, sg.Error
|
||||
}
|
||||
|
||||
// QuerySysAdvancedParam - AppService.querySysAdvancedParam
|
||||
func (sg *SunGrow) QuerySysAdvancedParam(psId valueTypes.PsId, curPage valueTypes.Integer, size valueTypes.Integer) (querySysAdvancedParam.ResultData, error) {
|
||||
|
@ -10,158 +10,46 @@ import (
|
||||
)
|
||||
|
||||
|
||||
// GetTemplateList - AppService.getTemplateList
|
||||
func (sg *SunGrow) GetTemplateList() (getTemplateList.ResultData, error) {
|
||||
var ret getTemplateList.ResultData
|
||||
// TemplateList - Return all templates.
|
||||
func (sg *SunGrow) TemplateList() error {
|
||||
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 {
|
||||
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...)
|
||||
data := sg.NewSunGrowData()
|
||||
data.SetEndpoints(getTemplateList.EndPointName)
|
||||
data.SetArgs()
|
||||
sg.Error = data.GetData()
|
||||
if sg.Error != nil {
|
||||
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
|
||||
}
|
||||
|
||||
// TemplatePoints - Return all points associated a template_id.
|
||||
func (sg *SunGrow) TemplatePoints(template string) error {
|
||||
for range Only.Once {
|
||||
if template == "" {
|
||||
@ -233,40 +121,156 @@ func (sg *SunGrow) TemplatePoints(template string) 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 {
|
||||
data := sg.NewSunGrowData()
|
||||
data.SetEndpoints(getTemplateList.EndPointName)
|
||||
data.SetArgs()
|
||||
sg.Error = data.GetData()
|
||||
if sg.Error != nil {
|
||||
if template == "" {
|
||||
sg.Error = errors.New("no template defined")
|
||||
break
|
||||
}
|
||||
|
||||
sg.Error = data.OutputDataTables()
|
||||
if sg.Error != nil {
|
||||
var data queryUserCurveTemplateData.ResultData
|
||||
data, sg.Error = sg.QueryUserCurveTemplateData(template)
|
||||
if sg.IsError() {
|
||||
break
|
||||
}
|
||||
|
||||
// var data getTemplateList.ResultData
|
||||
// data, sg.Error = sg.GetTemplateList()
|
||||
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)
|
||||
//
|
||||
// table := data.GetEndPointResultTable()
|
||||
// if table.Error != nil {
|
||||
// sg.Error = table.Error
|
||||
// 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
|
||||
// }
|
||||
//
|
||||
// table.SetTitle("getTemplateList")
|
||||
// table.SetFilePrefix(data.SetFilenamePrefix(""))
|
||||
// table.SetGraphFilter("")
|
||||
// table.SetSaveFile(sg.SaveAsFile)
|
||||
// table.OutputType = sg.OutputType
|
||||
// sg.Error = table.Output()
|
||||
// if sg.IsError() {
|
||||
// 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.Error = sg.PointData(startDate, endDate, interval, points...)
|
||||
if sg.Error != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|