cli: support heating
This commit is contained in:
parent
0a8c2cdd15
commit
5f88ab408a
1 changed files with 28 additions and 6 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
|
@ -36,6 +37,11 @@ func (d *dumper) DumpWithHeader(name string, device interface{}) {
|
|||
func (d *dumper) Dump(name string, v interface{}) {
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
var isHeating bool
|
||||
if fd, ok := v.(api.FeatureDescriber); ok {
|
||||
isHeating = slices.Contains(fd.Features(), api.Heating)
|
||||
}
|
||||
|
||||
// meter
|
||||
|
||||
if v, ok := v.(api.Meter); ok {
|
||||
|
|
@ -95,10 +101,18 @@ func (d *dumper) Dump(name string, v interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "Soc:\t%v\n", err)
|
||||
if isHeating {
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "Temp:\t%v\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(w, "Temp:\t%.0f°C\n", soc)
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintf(w, "Soc:\t%.0f%%\n", soc)
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "Soc:\t%v\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(w, "Soc:\t%.0f%%\n", soc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -204,10 +218,18 @@ func (d *dumper) Dump(name string, v interface{}) {
|
|||
}
|
||||
|
||||
if v, ok := v.(api.SocLimiter); ok {
|
||||
if limitSoc, err := v.GetLimitSoc(); err != nil {
|
||||
fmt.Fprintf(w, "Limit Soc:\t%v\n", err)
|
||||
if isHeating {
|
||||
if limitSoc, err := v.GetLimitSoc(); err != nil {
|
||||
fmt.Fprintf(w, "Max Temp:\t%v\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(w, "Max Temp:\t%d°C\n", limitSoc)
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintf(w, "Limit Soc:\t%d%%\n", limitSoc)
|
||||
if limitSoc, err := v.GetLimitSoc(); err != nil {
|
||||
fmt.Fprintf(w, "Limit Soc:\t%v\n", err)
|
||||
} else {
|
||||
fmt.Fprintf(w, "Limit Soc:\t%d%%\n", limitSoc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue