Skip to content

Commit

Permalink
v1.3 interface change
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed Feb 28, 2022
1 parent 5d5fa78 commit c9e6f3b
Show file tree
Hide file tree
Showing 996 changed files with 22,394 additions and 11,016 deletions.
1,099 changes: 1,073 additions & 26 deletions .idea/workspace.xml

Large diffs are not rendered by default.

176 changes: 136 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,45 +55,10 @@ I've planned a number of features, but my main goal is to be able to interface w


## Use case example:
### Fetch PV data from the API.

Get basic inverter information for inverter id 1129147
```
$ ./bin/GoSungrow api get findPsType '{"ps_id":"1129147"}'
```

```
$ ./bin/GoSungrow api get getPsDetailWithPsType '{"ps_id":"1129147"}'
```

Get basic power stats for inverter
```
$ ./bin/GoSungrow api get getPowerStatistics '{"ps_id":"1129147"}'
```

Get point_id to point names for different device types
```
$ ./bin/GoSungrow api get getPowerDevicePointNames '{"device_type":"1"}'
```

```
$ ./bin/GoSungrow api get getPowerDevicePointNames '{"device_type":"2"}'
```
### High level reporting examples.

```
$ ./bin/GoSungrow api get getPowerDevicePointNames '{"device_type":"7"}'
```

Get all inverters
```
$ ./bin/GoSungrow api get getPsList
```

```
$ ./bin/GoSungrow api get WebAppService.showPSView '{"ps_id":"1129147"}'
```

Produce basic real-time stats
Produce point-in-time statistics
```
$ ./bin/GoSungrow data get stats
+---------------------+-----------+---------------------------+---------+------+
Expand Down Expand Up @@ -122,8 +87,26 @@ $ ./bin/GoSungrow data get stats
+---------------------+-----------+---------------------------+---------+------+
```

### Reporting examples.

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 |
+-------------+---------------+---------------------+
```
Show all data points used in a report template.
```
$ ./bin/GoSungrow data get template-points 8040
Expand All @@ -143,7 +126,7 @@ $ ./bin/GoSungrow data get template-points 8040
+---------+----------------------------+------+
```

Produce daily report for template 8040 for date 2022/02/24 spit out CSV to STDOUT.
Produce daily report for template 8040 for date 2022/02/24 display on STDOUT.
```
$ ./bin/GoSungrow data get template 8040 20220224
+---------------------+-----------------------+----------------------------+-------------+-------+
Expand Down Expand Up @@ -189,6 +172,119 @@ $ ./bin/GoSungrow data graph template 8042 20220224 '{"search_string":"p13019"}'
```
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220224-8042.png?raw=true)


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 |
...
+-------------+------------+----------+----------------------------------------+
```

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}'
![alt text](https://github.com/MickMake/GoSungrow/blob/master/docs/AppService_queryMutiPointDataList-20220228-8041.png?raw=true)
```
### Using the API instead.

Get basic inverter information for inverter id 1129147
```
$ ./bin/GoSungrow api get findPsType '{"ps_id":"1129147"}'
```

```
$ ./bin/GoSungrow api get getPsDetailWithPsType '{"ps_id":"1129147"}'
```

Get basic power stats for inverter
```
$ ./bin/GoSungrow api get getPowerStatistics '{"ps_id":"1129147"}'
```

Get point_id to point names for different device types
```
$ ./bin/GoSungrow api get getPowerDevicePointNames '{"device_type":"1"}'
```

```
$ ./bin/GoSungrow api get getPowerDevicePointNames '{"device_type":"2"}'
```

```
$ ./bin/GoSungrow api get getPowerDevicePointNames '{"device_type":"7"}'
```

Get all inverters
```
$ ./bin/GoSungrow api get getPsList
```

```
$ ./bin/GoSungrow api get WebAppService.showPSView '{"ps_id":"1129147"}'
```

Produce basic storage report
```
$ ./bin/GoSungrow api get queryMutiPointDataList '{"ps_key":"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_11_0_0","points":"p13150,p13126,p13142,p13143,p13019,p13141,p13121,p13003,p13149,p83106","minute_interval":"5","start_time_stamp":"20220215000000","end_time_stamp":"20220215235900", "ps_id":"1129147"}'
Expand Down
3 changes: 3 additions & 0 deletions cmd/cmd_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func AttachCmdData(cmd *cobra.Command) *cobra.Command {
AttachCmdDataTemplate(cmdDataGet)
AttachCmdDataTemplatePoints(cmdDataGet)
AttachCmdDataPoints(cmdDataGet)
AttachCmdDataPointNames(cmdDataGet)

// ********************************************************************************
var cmdDataRaw = &cobra.Command{
Expand All @@ -96,6 +97,7 @@ func AttachCmdData(cmd *cobra.Command) *cobra.Command {
AttachCmdDataStats(cmdDataRaw)
AttachCmdDataTemplate(cmdDataRaw)
AttachCmdDataPoints(cmdDataRaw)
AttachCmdDataPointNames(cmdDataRaw)

// ********************************************************************************
var cmdDataSave = &cobra.Command{
Expand All @@ -116,6 +118,7 @@ func AttachCmdData(cmd *cobra.Command) *cobra.Command {
AttachCmdDataStats(cmdDataSave)
AttachCmdDataTemplate(cmdDataSave)
AttachCmdDataPoints(cmdDataSave)
AttachCmdDataPointNames(cmdDataSave)

// ********************************************************************************
var cmdDataGraph = &cobra.Command{
Expand Down
46 changes: 34 additions & 12 deletions cmd/cmd_data_sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func AttachCmdDataTemplatePoints(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var cmdDataTemplatePoints = &cobra.Command{
var c = &cobra.Command{
Use: "template-points <template_id>",
Aliases: []string{""},
Short: fmt.Sprintf("List data points used in report template."),
Expand All @@ -23,15 +23,15 @@ func AttachCmdDataTemplatePoints(cmd *cobra.Command) *cobra.Command {
},
Args: cobra.ExactArgs(1),
}
cmd.AddCommand(cmdDataTemplatePoints)
cmdDataTemplatePoints.Example = PrintExamples(cmdDataTemplatePoints, "8042", "8040")
cmd.AddCommand(c)
c.Example = PrintExamples(c, "8042", "8040")

return cmd
}

func AttachCmdDataTemplate(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var cmdDataGetTemplate = &cobra.Command{
var c = &cobra.Command{
Use: "template <template_id> <date> [filter]",
Short: fmt.Sprintf("Get data from report template."),
Long: fmt.Sprintf("Get data from report template."),
Expand All @@ -45,15 +45,15 @@ func AttachCmdDataTemplate(cmd *cobra.Command) *cobra.Command {
},
Args: cobra.RangeArgs(2, 3),
}
cmd.AddCommand(cmdDataGetTemplate)
cmdDataGetTemplate.Example = PrintExamples(cmdDataGetTemplate, "8042 20220212", "8042 20220212 '{\"search_string\":\"p83106\",\"min_left_axis\":-6000,\"max_left_axis\":12000}'")
cmd.AddCommand(c)
c.Example = PrintExamples(c, "8042 20220212", "8042 20220212 '{\"search_string\":\"p83106\",\"min_left_axis\":-6000,\"max_left_axis\":12000}'")

return cmd
}

func AttachCmdDataStats(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var cmdDataStats = &cobra.Command{
var c = &cobra.Command{
Use: "stats",
Aliases: []string{""},
Short: fmt.Sprintf("Get current inverter stats, (last 5 minutes)."),
Expand All @@ -67,15 +67,15 @@ func AttachCmdDataStats(cmd *cobra.Command) *cobra.Command {
},
Args: cobra.ExactArgs(0),
}
cmd.AddCommand(cmdDataStats)
cmdDataStats.Example = PrintExamples(cmdDataStats, "")
cmd.AddCommand(c)
c.Example = PrintExamples(c, "")

return cmd
}

func AttachCmdDataPoints(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var cmdDataStats = &cobra.Command{
var cmdDataPoints = &cobra.Command{
Use: "points <date> <device_id.point_id> ...",
Aliases: []string{""},
Short: fmt.Sprintf("Get points data for a specific date."),
Expand All @@ -89,8 +89,30 @@ func AttachCmdDataPoints(cmd *cobra.Command) *cobra.Command {
},
Args: cobra.MinimumNArgs(2),
}
cmd.AddCommand(cmdDataStats)
cmdDataStats.Example = PrintExamples(cmdDataStats, "20220202 1129147.p13019 1129147.p83106")
cmd.AddCommand(cmdDataPoints)
cmdDataPoints.Example = PrintExamples(cmdDataPoints, "20220202 1129147.p13019 1129147.p83106")

return cmd
}

func AttachCmdDataPointNames(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var c = &cobra.Command{
Use: "templates",
Aliases: []string{""},
Short: fmt.Sprintf("Get all defined templates."),
Long: fmt.Sprintf("Get all defined templates."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: Cmd.SunGrowArgs,
RunE: func(cmd *cobra.Command, args []string) error {
_ = SwitchOutput(cmd)
return Cmd.SunGrow.GetTemplates()
},
Args: cobra.ExactArgs(0),
}
cmd.AddCommand(c)
c.Example = PrintExamples(c, "")

return cmd
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 21 additions & 11 deletions iSolarCloud/AliSmsService/msgDownwardStatusReceipt/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,21 +322,31 @@ func (e EndPoint) MarshalJSON() ([]byte, error) {

// ********************************************************************************

// CheckCacheFile - Check if a cache file exists for this EndPoint.
func (e EndPoint) CheckCache() bool {
return e.ApiCheckCache(e.Request.RequestData)
// RequestFingerprint - Check if a cache file exists for this EndPoint.
func (e EndPoint) RequestFingerprint() string {
return e.ApiFingerprint(e.Request.RequestData)
}

// ReadCacheFile - Read a cache file and return it as an EndPoint structure.
func (e EndPoint) ReadCache() api.EndPoint {
e.Error = e.ApiReadCache(e.Request.RequestData, &e)
return e
// CacheFilename - Check if a cache file exists for this EndPoint.
func (e EndPoint) CacheFilename() string {
return e.ApiCacheFilename(e.Request.RequestData)
}

// WriteCacheFile - Write this EndPoint structure out to a cache file.
func (e EndPoint) WriteCache() error {
return e.ApiWriteCache(e.Request.RequestData, e)
}
// // CheckCache - Check if a cache file exists for this EndPoint.
// func (e EndPoint) CheckCache() bool {
// return e.ApiCheckCache(e.Request.RequestData)
// }
//
// // ReadCache - Read a cache file and return it as an EndPoint structure.
// func (e EndPoint) ReadCache() api.EndPoint {
// e.Error = e.ApiReadCache(e.Request.RequestData, &e)
// return e
// }
//
// // WriteCache - Write this EndPoint structure out to a cache file.
// func (e EndPoint) WriteCache() error {
// return e.ApiWriteCache(e.Request.RequestData, e)
// }

// SetCacheTimeout - Set the cache timeout for this EndPoint. (Defaults to 1 hour.)
func (e EndPoint) SetCacheTimeout(duration time.Duration) api.EndPoint {
Expand Down

0 comments on commit c9e6f3b

Please sign in to comment.