Fix dumping ActionConfig structure (#2029)

This commit is contained in:
rivengh 2021-12-11 23:07:17 +01:00 • committed by GitHub
parent 8323f2f100
commit 05e3eed893
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -60,8 +60,9 @@ type ActionConfig struct {
func (a ActionConfig) String() string {
var s []string
for k, v := range structs.Map(a) {
if v != nil && !reflect.ValueOf(v).IsNil() {
s = append(s, fmt.Sprintf("%s:%v", k, v))
val := reflect.ValueOf(v)
if v != nil && !val.IsNil() {
s = append(s, fmt.Sprintf("%s:%v", k, val.Elem()))
}
}
return strings.Join(s, ", ")

View file

@ -10,6 +10,7 @@ import (
"time"
"github.com/evcc-io/evcc/api"
"github.com/fatih/structs"
)
var truefalse = map[bool]string{false: "false", true: "true"}
@ -174,6 +175,8 @@ func (d *dumper) Dump(name string, v interface{}) {
fmt.Fprintf(w, "Capacity:\t%dkWh\n", v.Capacity())
if len(v.Identifiers()) > 0 {
fmt.Fprintf(w, "Identifiers:\t%v\n", v.Identifiers())
}
if !structs.IsZero(v.OnIdentified()) {
fmt.Fprintf(w, "OnIdentified:\t%s\n", v.OnIdentified())
}
}