v3.0.1 - fixes

This commit is contained in:
MickMake 2022-12-21 13:39:07 +11:00
parent fd39102b0d
commit cefdc5c7bf
10 changed files with 2023 additions and 1945 deletions

91
.idea/workspace.xml generated
View File

@ -6,14 +6,15 @@
<component name="ChangeListManager">
<list default="true" id="76adadc9-ae71-42a6-82a1-66dbc8ecb14c" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_ha.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_ha.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_mqtt.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_mqtt.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/commands.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/commands.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/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$/mmHa/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/mmHa/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_show_meta.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_show_meta.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$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/WebAppService/getMqttConfigInfoByAppkey/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/WebAppService/getMqttConfigInfoByAppkey/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/highlevel_meta.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/highlevel_meta.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/main.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -87,7 +88,7 @@
<configuration name="GoSungrow" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="GoSungrow" />
<working_directory value="$PROJECT_DIR$" />
<parameters value="ha lovelace" />
<parameters value="api raw queryDeviceRealTimeDataByPsKeys '{&quot;ps_ke_list&quot;:&quot;1171348_14_1_2&quot;,&quot;ps_ke_list&quot;:&quot;1171348_14_1_2&quot;}'" />
<envs>
<env name="GOCACHE" value="/Volumes/Media/GoCache" />
</envs>
@ -124,11 +125,6 @@
<line>190</line>
<option name="timeStamp" value="202" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>350</line>
<option name="timeStamp" value="838" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/../../GoUnify/cmdConfig/commands.go</url>
<line>95</line>
@ -136,22 +132,12 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>39</line>
<line>37</line>
<option name="timeStamp" value="881" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>218</line>
<option name="timeStamp" value="920" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>222</line>
<option name="timeStamp" value="921" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>148</line>
<line>146</line>
<option name="timeStamp" value="1355" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -171,7 +157,7 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel.go</url>
<line>127</line>
<line>125</line>
<option name="timeStamp" value="4110" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -671,24 +657,69 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_ha.go</url>
<line>146</line>
<line>144</line>
<option name="timeStamp" value="8618" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_ha.go</url>
<line>156</line>
<line>154</line>
<option name="timeStamp" value="8619" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_ha.go</url>
<line>166</line>
<line>164</line>
<option name="timeStamp" value="8620" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_ha.go</url>
<line>178</line>
<line>176</line>
<option name="timeStamp" value="8626" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_psid.go</url>
<line>253</line>
<option name="timeStamp" value="8627" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/data.go</url>
<line>434</line>
<option name="timeStamp" value="8629" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_meta.go</url>
<line>46</line>
<option name="timeStamp" value="8630" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_meta.go</url>
<line>47</line>
<option name="timeStamp" value="8631" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_meta.go</url>
<line>118</line>
<option name="timeStamp" value="8636" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/cmd/cmd_show_meta.go</url>
<line>119</line>
<option name="timeStamp" value="8637" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_meta.go</url>
<line>94</line>
<option name="timeStamp" value="8638" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/highlevel_meta.go</url>
<line>98</line>
<option name="timeStamp" value="8639" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys/data.go</url>
<line>22</line>
<option name="timeStamp" value="8641" />
</line-breakpoint>
</breakpoints>
<default-breakpoints>
<breakpoint type="DlvErrorBreakpoint" />

File diff suppressed because it is too large Load Diff

View File

@ -173,204 +173,13 @@ func (c *CmdInfo) AttachCmdInfo(cmd *cobra.Command) *cobra.Command {
break
}
// c.AttachCmdInfoPointNames(cmd)
c.AttachCmdInfoMqtt(cmd)
// c.AttachCmdInfoSearchPointInfo(cmd)
// c.AttachCmdInfoDevices(cmd)
// c.AttachCmdInfoDeviceModels(cmd)
// c.AttachCmdInfoTemplates(cmd)
// c.AttachCmdInfoTemplatePoints(cmd)
// c.AttachCmdInfoGetDevicePoints(cmd)
c.AttachCmdInfoStats(cmd)
// c.AttachCmdInfoTemplate(cmd)
// c.AttachCmdInfoPoints(cmd)
c.AttachCmdInfoRealTime(cmd)
c.AttachCmdInfoPsDetails(cmd)
}
return cmd
}
// func (ca *Cmds) CmdInfoPut(_ *cobra.Command, _ []string) {
// for range Only.Once {
// fmt.Println("Not yet implemented.")
// // ca.Api.SunGrow.OutputType.SetFile()
// // args = MinimumArraySize(2, args)
// // c.Error = SunGrow.PutHighLevel(args[0], args[1])
// }
// }
func (c *CmdInfo) AttachCmdInfoMqtt(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var c2 = &cobra.Command{
Use: "mqtt",
Aliases: []string{"mqtt-server"},
Annotations: map[string]string{"group": "Info"},
Short: fmt.Sprintf("Get iSolarCloud MQTT service login details."),
Long: fmt.Sprintf("Get iSolarCloud MQTT service login details."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: func(cmd *cobra.Command, args []string) error {
_ = cmds.SetOutputType(cmd)
args = MinimumArraySize(1, args)
return cmds.Api.SunGrow.GetIsolarcloudMqtt(args[0])
},
Args: cobra.RangeArgs(0, 1),
}
cmd.AddCommand(c2)
c2.Example = cmdHelp.PrintExamples(c2, "")
return cmd
}
// "point-names" -> Alias AppService.getPowerDevicePointNames
// func (c *CmdInfo) AttachCmdInfoPointNames(cmd *cobra.Command) *cobra.Command {
// // ********************************************************************************
// var c2 = &cobra.Command{
// Use: "point-names",
// Aliases: []string{"names"},
// Annotations: map[string]string{"group": "Info"},
// Short: fmt.Sprintf("Get iSolarCloud point names."),
// Long: fmt.Sprintf("Get iSolarCloud point names."),
// DisableFlagParsing: false,
// DisableFlagsInUseLine: false,
// PreRunE: func(cmd *cobra.Command, args []string) error {
// cmds.Error = cmds.ProcessArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// cmds.Error = cmds.SunGrowArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// return nil
// },
// RunE: func(cmd *cobra.Command, args []string) error {
// _ = cmds.SetOutputType(cmd)
// return cmds.Api.SunGrow.GetPointNames(args...)
// },
// Args: cobra.MinimumNArgs(0),
// }
// cmd.AddCommand(c2)
// c2.Example = cmdHelp.PrintExamples(c2, "")
//
// return cmd
// }
// func (c *CmdInfo) AttachCmdInfoSearchPointInfo(cmd *cobra.Command) *cobra.Command {
// // ********************************************************************************
// var c2 = &cobra.Command{
// Use: "search-point-names",
// Aliases: []string{"names"},
// Annotations: map[string]string{"group": "Info"},
// Short: fmt.Sprintf("Get iSolarCloud search point names."),
// Long: fmt.Sprintf("Get iSolarCloud search point names."),
// DisableFlagParsing: false,
// DisableFlagsInUseLine: false,
// PreRunE: func(cmd *cobra.Command, args []string) error {
// cmds.Error = cmds.ProcessArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// cmds.Error = cmds.SunGrowArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// return nil
// },
// RunE: func(cmd *cobra.Command, args []string) error {
// _ = cmds.SetOutputType(cmd)
// return cmds.Api.SunGrow.SearchPointNames(args...)
// },
// Args: cobra.MinimumNArgs(0),
// }
// cmd.AddCommand(c2)
// c2.Example = cmdHelp.PrintExamples(c2, "")
//
// return cmd
// }
// func (c *CmdInfo) AttachCmdInfoDevices(cmd *cobra.Command) *cobra.Command {
// // ********************************************************************************
// var c2 = &cobra.Command{
// Use: "devices",
// Aliases: []string{"device"},
// Annotations: map[string]string{"group": "Info"},
// Short: fmt.Sprintf("Get iSolarCloud devices."),
// Long: fmt.Sprintf("Get iSolarCloud devices."),
// DisableFlagParsing: false,
// DisableFlagsInUseLine: false,
// PreRunE: func(cmd *cobra.Command, args []string) error {
// cmds.Error = cmds.ProcessArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// cmds.Error = cmds.SunGrowArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// return nil
// },
// RunE: func(cmd *cobra.Command, args []string) error {
// _ = cmds.SetOutputType(cmd)
// // pids, err := cmds.Api.SunGrow.StringToPids(args...)
// // if err != nil {
// // return err
// // }
// return cmds.Api.SunGrow.GetDeviceList(args...)
// },
// Args: cobra.MinimumNArgs(0),
// }
// cmd.AddCommand(c2)
// c2.Example = cmdHelp.PrintExamples(c2, "")
//
// return cmd
// }
// func (c *CmdInfo) AttachCmdInfoGetDevicePoints(cmd *cobra.Command) *cobra.Command {
// // ********************************************************************************
// var c2 = &cobra.Command{
// Use: "device-points [ps_id]",
// Aliases: []string{},
// Annotations: map[string]string{"group": "Info"},
// Short: fmt.Sprintf("List all available device data points."),
// Long: fmt.Sprintf("List all available device data points."),
// DisableFlagParsing: false,
// DisableFlagsInUseLine: false,
// PreRunE: func(cmd *cobra.Command, args []string) error {
// cmds.Error = cmds.ProcessArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// cmds.Error = cmds.SunGrowArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// return nil
// },
// RunE: func(cmd *cobra.Command, args []string) error {
// _ = cmds.SetOutputType(cmd)
// pids, err := cmds.Api.SunGrow.StringToPids(args...)
// if err != nil {
// return err
// }
// return cmds.Api.SunGrow.GetDevicePoints(pids...)
// },
// Args: cobra.MinimumNArgs(0),
// }
// cmd.AddCommand(c2)
// c2.Example = cmdHelp.PrintExamples(c2, "", "1129147")
//
// return cmd
// }
func (c *CmdInfo) AttachCmdInfoStats(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var c2 = &cobra.Command{
@ -394,39 +203,6 @@ func (c *CmdInfo) AttachCmdInfoStats(cmd *cobra.Command) *cobra.Command {
return cmd
}
// func (c *CmdInfo) AttachCmdInfoPoints(cmd *cobra.Command) *cobra.Command {
// // ********************************************************************************
// var cmdDataPoints = &cobra.Command{
// Use: "points <date> <device_id.point_id> ...",
// Aliases: []string{},
// Annotations: map[string]string{"group": "Data"},
// Short: fmt.Sprintf("Get points data for a specific date."),
// Long: fmt.Sprintf("Get points data for a specific date."),
// DisableFlagParsing: false,
// DisableFlagsInUseLine: false,
// PreRunE: func(cmd *cobra.Command, args []string) error {
// cmds.Error = cmds.ProcessArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// cmds.Error = cmds.SunGrowArgs(cmd, args)
// if cmds.Error != nil {
// return cmds.Error
// }
// return nil
// },
// RunE: func(cmd *cobra.Command, args []string) error {
// _ = cmds.SetOutputType(cmd)
// return cmds.Api.SunGrow.GetPointData(args[0], api.CreatePoints(args[1:]))
// },
// Args: cobra.MinimumNArgs(2),
// }
// cmd.AddCommand(cmdDataPoints)
// cmdDataPoints.Example = cmdHelp.PrintExamples(cmdDataPoints, "20220202 1129147.p13019 1129147.p83106")
//
// return cmd
// }
func (c *CmdInfo) AttachCmdInfoRealTime(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var c2 = &cobra.Command{
@ -450,30 +226,3 @@ func (c *CmdInfo) AttachCmdInfoRealTime(cmd *cobra.Command) *cobra.Command {
return cmd
}
func (c *CmdInfo) AttachCmdInfoPsDetails(cmd *cobra.Command) *cobra.Command {
// ********************************************************************************
var c2 = &cobra.Command{
Use: "psdetails",
Aliases: []string{"ps-details"},
Annotations: map[string]string{"group": "Data"},
Short: fmt.Sprintf("Get iSolarCloud ps details."),
Long: fmt.Sprintf("Get iSolarCloud ps details."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: func(cmd *cobra.Command, args []string) error {
_ = cmds.SetOutputType(cmd)
// pids, err := cmds.Api.SunGrow.StringToPids(args...)
// if err != nil {
// return err
// }
return cmds.Api.SunGrow.CmdDataPsDetail(args...)
},
Args: cobra.MinimumNArgs(0),
}
cmd.AddCommand(c2)
c2.Example = cmdHelp.PrintExamples(c2, "")
return cmd
}

View File

@ -1,6 +1,7 @@
package cmd
import (
"GoSungrow/iSolarCloud/api/GoStruct/output"
"fmt"
"github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/cmdHelp"
@ -27,17 +28,15 @@ func (c *CmdShow) AttachMeta(cmd *cobra.Command) *cobra.Command {
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "")
c.AttachMetaList(self)
// c.AttachMetaTree(self)
// c.AttachMetaPoints(self)
// c.AttachMetaData(self)
// c.AttachMetaGraph(self)
c.AttachMetaUnitList(self)
c.AttachMetaMqtt(self)
c.AttachMetaRealTime(self)
}
return c.SelfCmd
}
func (c *CmdShow) AttachMetaList(cmd *cobra.Command) *cobra.Command {
func (c *CmdShow) AttachMetaUnitList(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "unit-list",
Aliases: []string{},
@ -47,7 +46,7 @@ func (c *CmdShow) AttachMetaList(cmd *cobra.Command) *cobra.Command {
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcMetaList,
RunE: c.funcMetaUnitList,
Args: cobra.MinimumNArgs(0),
}
cmd.AddCommand(self)
@ -55,7 +54,7 @@ func (c *CmdShow) AttachMetaList(cmd *cobra.Command) *cobra.Command {
return cmd
}
func (c *CmdShow) funcMetaList(_ *cobra.Command, _ []string) error {
func (c *CmdShow) funcMetaUnitList(_ *cobra.Command, _ []string) error {
for range Only.Once {
c.Error = cmds.Api.SunGrow.MetaUnitList()
if c.Error != nil {
@ -64,3 +63,63 @@ func (c *CmdShow) funcMetaList(_ *cobra.Command, _ []string) error {
}
return c.Error
}
func (c *CmdShow) AttachMetaMqtt(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "mqtt",
Aliases: []string{},
Annotations: map[string]string{"group": "Meta"},
Short: fmt.Sprintf("Show iSolarCloud mqtt info."),
Long: fmt.Sprintf("Show iSolarCloud mqtt info."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcMetaMqtt,
Args: cobra.MinimumNArgs(0),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "")
return cmd
}
func (c *CmdShow) funcMetaMqtt(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.SetOutputType(output.StringTypeTable)
args = MinimumArraySize(1, args)
c.Error = cmds.Api.SunGrow.GetIsolarcloudMqtt(args[0])
if c.Error != nil {
break
}
}
return c.Error
}
func (c *CmdShow) AttachMetaRealTime(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "real-time",
Aliases: []string{},
Annotations: map[string]string{"group": "Meta"},
Short: fmt.Sprintf("Show iSolarCloud real-time info."),
Long: fmt.Sprintf("Show iSolarCloud real-time info."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcMetaRealTime,
Args: cobra.MinimumNArgs(0),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "")
return cmd
}
func (c *CmdShow) funcMetaRealTime(_ *cobra.Command, args []string) error {
for range Only.Once {
cmds.Api.SunGrow.SetOutputType(output.StringTypeTable)
args = MinimumArraySize(1, args)
c.Error = cmds.Api.SunGrow.GetRealTimeData(args[0])
if c.Error != nil {
break
}
}
return c.Error
}

View File

@ -2,6 +2,8 @@ package cmd
import (
"GoSungrow/iSolarCloud"
"GoSungrow/iSolarCloud/AppService/getPsDetail"
"GoSungrow/iSolarCloud/AppService/getPsDetailWithPsType"
"fmt"
"github.com/MickMake/GoUnify/Only"
"github.com/MickMake/GoUnify/cmdHelp"
@ -31,6 +33,7 @@ func (c *CmdShow) AttachPs(cmd *cobra.Command) *cobra.Command {
c.AttachPsList(self)
c.AttachPsTree(self)
c.AttachPsDetail(self)
c.AttachPsPoints(self)
c.AttachPsData(self)
c.AttachPsGraph(self)
@ -222,3 +225,45 @@ func (c *CmdShow) funcPsGraph(_ *cobra.Command, args []string) error {
}
return c.Error
}
func (c *CmdShow) AttachPsDetail(cmd *cobra.Command) *cobra.Command {
var self = &cobra.Command{
Use: "detail [ps_id ...]",
Aliases: []string{},
Annotations: map[string]string{"group": "PsId"},
Short: fmt.Sprintf("Show detailed info on PS."),
Long: fmt.Sprintf("Show detailed info on PS."),
DisableFlagParsing: false,
DisableFlagsInUseLine: false,
PreRunE: cmds.SunGrowArgs,
RunE: c.funcPsDetail,
Args: cobra.MinimumNArgs(0),
}
cmd.AddCommand(self)
self.Example = cmdHelp.PrintExamples(self, "")
return cmd
}
func (c *CmdShow) funcPsDetail(_ *cobra.Command, args []string) error {
for range Only.Once {
pids := cmds.Api.SunGrow.SetPsIds(args...)
if c.Error != nil {
break
}
data := cmds.Api.SunGrow.NewSunGrowData()
data.SetPsIds(pids.Strings()...)
data.SetEndpoints(getPsDetail.EndPointName, getPsDetailWithPsType.EndPointName)
c.Error = data.GetData()
if c.Error != nil {
break
}
c.Error = data.Output()
if c.Error != nil {
break
}
}
return c.Error
}

View File

@ -6,7 +6,6 @@ import (
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
"fmt"
"github.com/MickMake/GoUnify/Only"
)
const Url = "/v1/devService/queryDeviceRealTimeDataByPsKeys"
@ -15,10 +14,12 @@ const EndPointName = "AppService.queryDeviceRealTimeDataByPsKeys"
type RequestData struct {
PsKeyList valueTypes.String `json:"ps_key_list" required:"true"`
PsKeyList2 valueTypes.String `json:"ps_ke_list" required:"true"`
}
func (rd *RequestData) IsValid() error {
rd.PsKeyList = valueTypes.SetStringValue("1171348_11_0_0")
rd.PsKeyList = valueTypes.SetStringValue("1171348_14_1_2")
rd.PsKeyList2 = valueTypes.SetStringValue("1171348_14_1_2")
return GoStruct.VerifyOptionsRequired(*rd)
}
@ -29,7 +30,6 @@ func (rd RequestData) Help() string {
type ResultData struct {
// Dummy valueTypes.String `json:"dummy"`
}
func (e *ResultData) IsValid() error {
@ -39,10 +39,6 @@ func (e *ResultData) IsValid() error {
func (e *EndPoint) GetData() api.DataMap {
entries := api.NewDataMap()
for range Only.Once {
entries.StructToDataMap(*e, "", GoStruct.EndPointPath{})
}
entries.StructToDataMap(*e, "", GoStruct.EndPointPath{})
return entries
}

View File

@ -4,8 +4,6 @@ import (
"GoSungrow/iSolarCloud/api"
"GoSungrow/iSolarCloud/api/GoStruct"
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
"github.com/MickMake/GoUnify/Only"
"fmt"
)
@ -15,7 +13,8 @@ const Disabled = false
const EndPointName = "WebAppService.getMqttConfigInfoByAppkey"
const (
WebAppKey = "B0455FBE7AA0328DB57B59AA729F05D8"
AppKey = "93D72E60331ABDCDC7B39ADC2D1F32B3"
WebAppKey = "B0455FBE7AA0328DB57B59AA729F05D8"
LoginAppKey = "93D72E60331ABDCDC7B39ADC2D1F32B3"
)
@ -48,72 +47,11 @@ type ResultData struct {
// IsValid Checks for validity of results data.
func (e *ResultData) IsValid() error {
var err error
// switch {
// case e.Dummy == "":
// break
// default:
// err = errors.New(fmt.Sprintf("unknown error '%s'", e.Dummy))
// }
return err
}
// type DecodeResultData ResultData
//
// func (e *ResultData) UnmarshalJSON(data []byte) error {
// var err error
//
// for range Only.Once {
// if len(data) == 0 {
// break
// }
// var pd DecodeResultData
//
// // Store ResultData
// _ = json.Unmarshal(data, &pd)
// e.Dummy = pd.Dummy
// }
//
// return err
// }
// func (e *EndPoint) GetDataTable() output.Table {
// var table output.Table
//
// for range Only.Once {
// table = output.NewTable()
// table.SetTitle("")
// table.SetJson([]byte(e.GetJsonData(false)))
// table.SetRaw([]byte(e.GetJsonData(true)))
//
// e.Error = table.SetHeader(
// "AppKey",
// "Name",
// "Value",
// )
// if e.Error != nil {
// break
// }
//
// // @TODO - Think about providing an GoStruct function that does this automatically.
// _ = table.AddRow(e.Request.AppKey, "Code", e.Response.ResultData.Code)
// _ = table.AddRow(e.Request.AppKey, "Mqtt Username", e.Response.ResultData.MqttUsername)
// _ = table.AddRow(e.Request.AppKey, "Mqtt Password", e.Response.ResultData.MqttPassword)
// _ = table.AddRow(e.Request.AppKey, "Mqtt Rsa Public Key", e.Response.ResultData.MqttRsaPublicKey)
// _ = table.AddRow(e.Request.AppKey, "Mqtt Type", e.Response.ResultData.MqttType)
// _ = table.AddRow(e.Request.AppKey, "Mqtt URL List", e.Response.ResultData.MqttURLList)
// _ = table.AddRow(e.Request.AppKey, "Mqtt URL List Lan", e.Response.ResultData.MqttURLListLan)
//
// }
//
// return table
// }
func (e *EndPoint) GetData() api.DataMap {
entries := api.NewDataMap()
for range Only.Once {
entries.StructToDataMap(*e, "", GoStruct.EndPointPath{})
}
entries.StructToDataMap(*e, "", GoStruct.EndPointPath{})
return entries
}

View File

@ -11,8 +11,6 @@ import (
"GoSungrow/iSolarCloud/AppService/powerDevicePointList"
"GoSungrow/iSolarCloud/AppService/queryDeviceList"
"GoSungrow/iSolarCloud/AppService/queryDeviceListForApp"
"GoSungrow/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys"
"GoSungrow/iSolarCloud/WebAppService/getMqttConfigInfoByAppkey"
"GoSungrow/iSolarCloud/WebAppService/showPSView"
"GoSungrow/iSolarCloud/api"
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
@ -167,308 +165,6 @@ func (sg *SunGrow) PrintCurrentStats() error {
return sg.Error
}
func (sg *SunGrow) GetIsolarcloudMqtt(appKey string) error {
for range Only.Once {
if appKey == "" {
appKey = sg.GetAppKey()
}
ep := sg.GetByStruct(getMqttConfigInfoByAppkey.EndPointName,
getMqttConfigInfoByAppkey.RequestData{AppKey: valueTypes.SetStringValue(appKey)},
DefaultCacheTimeout,
)
if sg.IsError() {
break
}
data := getMqttConfigInfoByAppkey.Assert(ep)
table := data.GetEndPointResultTable()
if table.Error != nil {
sg.Error = table.Error
break
}
table.SetTitle("MQTT info")
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
}
func (sg *SunGrow) GetRealTimeData(psKey string) error {
for range Only.Once {
if psKey == "" {
// var psKeys []string
// psKeys, sg.Error = sg.GetPsKeys()
// if sg.IsError() {
// break
// }
// fmt.Printf("psKeys: %v\n", psKeys)
// psKey = strings.Join(psKeys, ",")
}
fmt.Println("TO FIX")
break
ep := sg.GetByStruct(queryDeviceRealTimeDataByPsKeys.EndPointName,
queryDeviceRealTimeDataByPsKeys.RequestData{PsKeyList: valueTypes.SetStringValue(psKey)},
DefaultCacheTimeout,
)
if sg.IsError() {
break
}
data := queryDeviceRealTimeDataByPsKeys.Assert(ep)
table := data.GetEndPointResultTable()
if table.Error != nil {
sg.Error = table.Error
break
}
table.SetTitle("Real Time Data %s", psKey)
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
}
func (sg *SunGrow) CmdDataPsDetail(psIds ...string) error {
for range Only.Once {
data := sg.NewSunGrowData()
data.SetPsIds(psIds...)
data.SetEndpoints(getPsDetail.EndPointName, getPsDetailWithPsType.EndPointName)
sg.Error = data.GetData()
if sg.IsError() {
break
}
sg.Error = data.Output()
if sg.IsError() {
break
}
}
return sg.Error
}
// func (sg *SunGrow) GetPointData(date string, pointNames api.TemplatePoints, psIds ...valueTypes.PsId) error {
// for range Only.Once {
// if len(pointNames) == 0 {
// sg.Error = errors.New("no points defined")
// break
// }
//
// if date == "" {
// date = valueTypes.NewDateTime("").String()
// }
// when := valueTypes.NewDateTime(date)
//
// if len(psIds) == 0 {
// psIds, sg.Error = sg.StringToPids()
// if sg.IsError() {
// break
// }
// }
//
// for _, psId := range psIds {
// ep := sg.GetByStruct(
// "AppService.queryMutiPointDataList",
// queryMutiPointDataList.RequestData{
// PsId: psId,
// PsKeys: valueTypes.SetPsKeyString(pointNames.PrintKeys()), // @TODO - Fixup!
// Points: valueTypes.SetPointIdsString(pointNames.PrintPoints()), // @TODO - Fixup!
// MinuteInterval: valueTypes.SetIntegerValue(5), // @TODO - Fixup!
// StartTimeStamp: valueTypes.SetDateTimeString(when.GetDayStartTimestamp()), // @TODO - Fixup!
// EndTimeStamp: valueTypes.SetDateTimeString(when.GetDayEndTimestamp()), // @TODO - Fixup!
// },
// DefaultCacheTimeout,
// )
// if sg.IsError() {
// break
// }
// if ep == nil {
// break
// }
//
// // data := queryMutiPointDataList.Assert(ep)
// // table := data.GetPointDataTable(pointNames)
// // if table.Error != nil {
// // sg.Error = table.Error
// // break
// // }
// //
// // table.SetTitle("Point Data %s", psId)
// // table.SetFilePrefix(data.SetFilenamePrefix("%d", psId))
// // table.SetGraphFilter("")
// // table.SetSaveFile(sg.SaveAsFile)
// // table.OutputType = sg.OutputType
// // sg.Error = table.Output()
// // if sg.IsError() {
// // break
// // }
// }
// }
//
// return sg.Error
// }
// func (sg *SunGrow) SearchPointNames(pns ...string) error {
// for range Only.Once {
// table := output.NewTable(
// "DeviceType",
// "Id",
// "Period",
// "Point Id",
// "Point Name",
// "Show Point Name",
// "Translation Id",
// )
//
// // _ = table.SetHeader(
// // "DeviceType",
// // "Id",
// // "Period",
// // "Point Id",
// // "Point Name",
// // "Show Point Name",
// // "Translation Id",
// // )
//
// if len(pns) == 0 {
// fmt.Println("Searching up to id 1000 within getPowerDevicePointInfo")
// for pni := 0; pni < 1000; pni++ {
// PrintPause(pni, 20)
//
// ep := sg.GetByStruct(
// "AppService.getPowerDevicePointInfo",
// // getPowerDevicePointInfo.RequestData{Id: strconv.FormatInt(int64(pni), 10)},
// getPowerDevicePointInfo.RequestData{Id: valueTypes.SetIntegerValue(int64(pni)) },
// DefaultCacheTimeout,
// )
// if sg.IsError() {
// break
// }
//
// data := getPowerDevicePointInfo.Assert(ep)
// table = data.AddDataTable(table)
// if table.Error != nil {
// sg.Error = table.Error
// break
// }
// }
// fmt.Println("")
// } else {
// fmt.Printf("Searching for %v within getPowerDevicePointInfo\n", pns)
// for _, pn := range pns {
// ep := sg.GetByStruct(
// "AppService.getPowerDevicePointInfo",
// getPowerDevicePointInfo.RequestData{Id: valueTypes.SetIntegerString(pn)},
// DefaultCacheTimeout,
// )
// if sg.IsError() {
// break
// }
//
// data := getPowerDevicePointInfo.Assert(ep)
// table = data.GetPointDataTable()
// if table.Error != nil {
// sg.Error = table.Error
// break
// }
// }
// fmt.Println("")
// }
//
// table.SetTitle("Point Names")
// table.SetFilePrefix("AppService.getPowerDevicePointInfo")
// table.SetGraphFilter("")
// table.SetSaveFile(sg.SaveAsFile)
// table.OutputType = sg.OutputType
// sg.Error = table.Output()
// if sg.IsError() {
// break
// }
// }
//
// return sg.Error
// }
// func (sg *SunGrow) GetPointName(id valueTypes.Integer) error {
// for range Only.Once {
// ep := sg.GetByStruct(
// "AppService.getPowerDevicePointInfo",
// getPowerDevicePointInfo.RequestData{Id: id},
// DefaultCacheTimeout,
// )
// if sg.IsError() {
// break
// }
//
// data := getPowerDevicePointInfo.Assert(ep)
// table := data.GetPointDataTable()
// if table.Error != nil {
// sg.Error = table.Error
// break
// }
//
// // table2 := data.GetEndPointData()
// // fmt.Printf("%v\n", table2)
//
// table.SetTitle("Point Id %s", id)
// 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
// }
// func (sg *SunGrow) StringToPids(pids ...string) ([]valueTypes.PsId, error) {
// var psIds []valueTypes.PsId
// for range Only.Once {
// var psids valueTypes.PsIds
// psids = sg.SetPsIds(pids...)
// if sg.Error != nil {
// break
// }
//
// // for _, pid := range pids {
// // // p, err := strconv.ParseInt(pid, 10, 64)
// // // if err != nil {
// // // continue
// // // }
// // psIds = append(psIds, valueTypes.SetPsIdString(pid))
// // }
// // if len(psIds) == 0 {
// // psIds, sg.Error = sg.PsIds()
// // if sg.IsError() {
// // break
// // }
// // }
// }
//
// return psIds, sg.Error
// }
func (sg *SunGrow) GetPsNames() ([]string, error) {
var ret []string

View File

@ -1,7 +1,10 @@
package iSolarCloud
import (
"GoSungrow/iSolarCloud/AppService/queryDeviceRealTimeDataByPsKeys"
"GoSungrow/iSolarCloud/AppService/queryUnitList"
"GoSungrow/iSolarCloud/WebAppService/getMqttConfigInfoByAppkey"
"GoSungrow/iSolarCloud/api/GoStruct/valueTypes"
"github.com/MickMake/GoUnify/Only"
)
@ -25,3 +28,95 @@ func (sg *SunGrow) MetaUnitList() error {
return sg.Error
}
func (sg *SunGrow) GetIsolarcloudMqtt(appKey string) error {
for range Only.Once {
if appKey == "" {
appKey = sg.GetAppKey()
}
data := sg.NewSunGrowData()
data.SetArgs("AppKey:" + appKey)
data.SetEndpoints(getMqttConfigInfoByAppkey.EndPointName)
sg.Error = data.GetData()
if sg.Error != nil {
break
}
sg.Error = data.Output()
if sg.Error != nil {
break
}
// ep := sg.GetByStruct(getMqttConfigInfoByAppkey.EndPointName,
// getMqttConfigInfoByAppkey.RequestData{AppKey: valueTypes.SetStringValue(appKey)},
// DefaultCacheTimeout,
// )
// if sg.IsError() {
// break
// }
//
// data := getMqttConfigInfoByAppkey.Assert(ep)
// table := data.GetEndPointResultTable()
// if table.Error != nil {
// sg.Error = table.Error
// break
// }
//
// table.SetTitle("MQTT info")
// 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
}
func (sg *SunGrow) GetRealTimeData(psKey string) error {
for range Only.Once {
if psKey == "" {
// var psKeys []string
// psKeys, sg.Error = sg.GetPsKeys()
// if sg.IsError() {
// break
// }
// fmt.Printf("psKeys: %v\n", psKeys)
// psKey = strings.Join(psKeys, ",")
}
// fmt.Println("TO FIX")
// break
ep := sg.GetByStruct(queryDeviceRealTimeDataByPsKeys.EndPointName,
queryDeviceRealTimeDataByPsKeys.RequestData{PsKeyList: valueTypes.SetStringValue(psKey)},
DefaultCacheTimeout,
)
if sg.IsError() {
break
}
data := queryDeviceRealTimeDataByPsKeys.Assert(ep)
table := data.GetEndPointResultTable()
if table.Error != nil {
sg.Error = table.Error
break
}
table.SetTitle("Real Time Data %s", psKey)
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
}

View File

@ -7,9 +7,6 @@ import (
)
// https://augateway.isolarcloud.com/v1/
func main() {
err := cmd.Execute()
if err != nil {