Skip to content

Commit

Permalink
v3.0.6 - small fixups.
Browse files Browse the repository at this point in the history
  • Loading branch information
MickMake committed May 15, 2023
1 parent 42d5353 commit 23f00cf
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 235 deletions.
66 changes: 27 additions & 39 deletions .idea/workspace.xml

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

174 changes: 1 addition & 173 deletions cmd/cmd_mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (c *CmdMqtt) MqttArgs(_ *cobra.Command, _ []string) error {
break
}

c.points, c.Error = cmds.Api.SunGrow.DevicePointAttrsMap(nil, "")
c.points, c.Error = cmds.Api.SunGrow.DevicePointAttrsMap("")
if c.Error != nil {
break
}
Expand Down Expand Up @@ -626,178 +626,6 @@ func (c *CmdMqtt) UpdatePoint(entry *api.DataEntry) error {
return c.Error
}

// func FixConfig(config *mmHa.EntityConfig) {
//
// for range Only.Once {
// // mdi:power-socket-au
// // mdi:solar-power
// // mdi:home-lightning-bolt-outline
// // mdi:transmission-tower
// // mdi:transmission-tower-export
// // mdi:transmission-tower-import
// // mdi:transmission-tower-off
// // mdi:home-battery-outline
// // mdi:lightning-bolt
// // mdi:check-circle-outline | mdi:arrow-right-bold
//
// // Set ValueTemplate
// switch config.Units {
// case "MW":
// fallthrough
// case "kW":
// fallthrough
// case "W":
// fallthrough
// case "MWh":
// fallthrough
// case "kWh":
// fallthrough
// case "Wh":
// fallthrough
// case "kvar":
// fallthrough
// case "Hz":
// fallthrough
// case "V":
// fallthrough
// case "A":
// fallthrough
// case "°F":
// fallthrough
// case "F":
// fallthrough
// case "℉":
// fallthrough
// case "°C":
// fallthrough
// case "C":
// fallthrough
// case "℃":
// fallthrough
// case "%":
// if !config.Value.Valid {
// config.IgnoreUpdate = true
// }
// cnv := "| float"
// if config.Value.String() == "" {
// cnv = ""
// }
// if config.ValueName == "" {
// config.ValueTemplate = SetDefault(config.ValueTemplate, fmt.Sprintf("{{ value_json.value %s }}", cnv))
// } else {
// config.ValueTemplate = SetDefault(config.ValueTemplate, fmt.Sprintf("{{ value_json.%s %s }}", config.ValueName, cnv))
// }
//
// case "Bool":
// fallthrough
// case LabelBinarySensor:
// config.ValueTemplate = SetDefault(config.ValueTemplate, "{{ value_json.value }}")
//
// default:
// config.ValueTemplate = SetDefault(config.ValueTemplate, "{{ value_json.value }}")
// }
//
// // Set DeviceClass & Icon
// switch config.Units {
// case "Bool":
// fallthrough
// case LabelBinarySensor:
// config.DeviceClass = SetDefault(config.DeviceClass, "power")
// config.Icon = SetDefault(config.Icon, "mdi:check-circle-outline")
// // if !config.Value.Valid {
// // config.Value = "false"
// // }
//
// case "MW":
// fallthrough
// case "kW":
// fallthrough
// case "W":
// config.DeviceClass = SetDefault(config.DeviceClass, "power")
// config.Icon = SetDefault(config.Icon, "mdi:lightning-bolt")
//
// case "MWh":
// fallthrough
// case "kWh":
// fallthrough
// case "Wh":
// config.DeviceClass = SetDefault(config.DeviceClass, "energy")
// config.Icon = SetDefault(config.Icon, "mdi:lightning-bolt")
//
// case "kvar":
// config.DeviceClass = SetDefault(config.DeviceClass, "reactive_power")
// config.Icon = SetDefault(config.Icon, "mdi:lightning-bolt")
//
// case "Hz":
// config.DeviceClass = SetDefault(config.DeviceClass, "frequency")
// config.Icon = SetDefault(config.Icon, "mdi:sine-wave")
//
// case "V":
// config.DeviceClass = SetDefault(config.DeviceClass, "voltage")
// config.Icon = SetDefault(config.Icon, "mdi:current-dc")
//
// case "A":
// config.DeviceClass = SetDefault(config.DeviceClass, "current")
// config.Icon = SetDefault(config.Icon, "mdi:current-ac")
//
// case "°F":
// fallthrough
// case "F":
// fallthrough
// case "℉":
// config.DeviceClass = SetDefault(config.DeviceClass, "temperature")
// config.Units = "℉"
// config.Icon = SetDefault(config.Icon, "mdi:thermometer")
//
// case "°C":
// fallthrough
// case "C":
// fallthrough
// case "℃":
// config.DeviceClass = SetDefault(config.DeviceClass, "temperature")
// config.Units = "°C"
// config.Icon = SetDefault(config.Icon, "mdi:thermometer")
//
// case "%":
// config.DeviceClass = SetDefault(config.DeviceClass, "battery")
// config.Icon = SetDefault(config.Icon, "mdi:home-battery-outline")
//
// default:
// config.DeviceClass = SetDefault(config.DeviceClass, "")
// config.Icon = SetDefault(config.Icon, "")
// }
//
// if config.LastReset != "" {
// break
// }
//
// // pt := api.GetDevicePoint(config.FullId)
// // if !pt.Valid {
// // break
// // }
//
// if config.StateClass == "instant" {
// config.StateClass = "measurement"
// break
// }
//
// if config.StateClass == "" {
// config.StateClass = "measurement"
// break
// }
//
// // config.LastReset = pt.WhenReset()
// config.LastResetValueTemplate = SetDefault(config.LastResetValueTemplate, "{{ value_json.last_reset | as_datetime() }}")
// // config.LastResetValueTemplate = SetDefault(config.LastResetValueTemplate, "{{ value_json.last_reset | int | timestamp_local | as_datetime }}")
//
// if config.LastReset == "" {
// config.StateClass = "measurement"
// break
// }
// config.StateClass = "total"
// }
// }


// -------------------------------------------------------------------------------- //

Expand Down
8 changes: 8 additions & 0 deletions iSolarCloud/api/GoStruct/valueTypes/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,14 @@ func (t *PsKeys) Strings() []string {
return ret
}

func (t *PsKeys) PsIds() []string {
var ret []string
for _, pskey := range t.PsKeys {
ret = append(ret, pskey.PsId)
}
return ret
}

func (t *PsKeys) Set(values ...string) PsKeys {
for _, value := range values {
for _, v := range strings.Split(value, ",") {
Expand Down
6 changes: 3 additions & 3 deletions iSolarCloud/highlevel_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (sg *SunGrow) GetAllPointsData(psIds ...string) error {


// DevicePointAttrs - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) DevicePointAttrs(psIds []string, deviceType string) (getDevicePointAttrs.Points, error) {
func (sg *SunGrow) DevicePointAttrs(deviceType string, psIds ...string) (getDevicePointAttrs.Points, error) {
var points getDevicePointAttrs.Points

for range Only.Once {
Expand Down Expand Up @@ -304,12 +304,12 @@ func (sg *SunGrow) DevicePointAttrs(psIds []string, deviceType string) (getDevic
}

// DevicePointAttrsMap - Return all points associated with psIds and device_type filter.
func (sg *SunGrow) DevicePointAttrsMap(psIds []string, deviceType string) (getDevicePointAttrs.PointsMap, error) {
func (sg *SunGrow) DevicePointAttrsMap(deviceType string, psIds ...string) (getDevicePointAttrs.PointsMap, error) {
points := make(getDevicePointAttrs.PointsMap)

for range Only.Once {
var pa getDevicePointAttrs.Points
pa, sg.Error = sg.DevicePointAttrs(psIds, deviceType)
pa, sg.Error = sg.DevicePointAttrs(deviceType, psIds...)
if sg.Error != nil {
break
}
Expand Down

0 comments on commit 23f00cf

Please sign in to comment.