cli: add heartbeat option to charger/meter (#22170)
This commit is contained in:
parent
d1a1366232
commit
1be58587b9
3 changed files with 17 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ package cmd
|
|||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/util/config"
|
||||
|
|
@ -27,6 +28,7 @@ func init() {
|
|||
chargerCmd.Flags().Bool(flagDiagnose, false, flagDiagnoseDescription)
|
||||
chargerCmd.Flags().BoolP(flagWakeup, "w", false, flagWakeupDescription)
|
||||
chargerCmd.Flags().IntP(flagPhases, "p", 0, flagPhasesDescription)
|
||||
chargerCmd.Flags().Bool(flagHeartbeat, false, flagHeartbeatDescription)
|
||||
}
|
||||
|
||||
func runCharger(cmd *cobra.Command, args []string) {
|
||||
|
|
@ -117,6 +119,11 @@ func runCharger(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
}
|
||||
|
||||
if ok, _ := cmd.Flags().GetBool(flagHeartbeat); flagUsed && ok {
|
||||
log.INFO.Println("running heartbeat until interrupted (Ctrl-C to stop)")
|
||||
time.Sleep(time.Hour)
|
||||
}
|
||||
|
||||
if !flagUsed {
|
||||
d := dumper{len: len(chargers)}
|
||||
flag := cmd.Flag(flagDiagnose).Changed
|
||||
|
|
@ -129,6 +136,9 @@ func runCharger(cmd *cobra.Command, args []string) {
|
|||
d.DumpDiagnosis(v)
|
||||
}
|
||||
}
|
||||
} else if ok, _ := cmd.Flags().GetBool(flagHeartbeat); ok {
|
||||
log.INFO.Println("running heartbeat (if any) until interrupted (Ctrl-C to stop)")
|
||||
time.Sleep(time.Hour)
|
||||
}
|
||||
|
||||
// wait for shutdown
|
||||
|
|
|
|||
|
|
@ -65,6 +65,9 @@ const (
|
|||
flagRepeatInterval = "repeat-interval"
|
||||
flagRepeatIntervalDescription = "Interval between repetitions"
|
||||
|
||||
flagHeartbeat = "heartbeat"
|
||||
flagHeartbeatDescription = "After command, continue running device heartbeats (if any) until interrupted"
|
||||
|
||||
flagDigits = "digits"
|
||||
flagDelay = "delay"
|
||||
flagForce = "force"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ func init() {
|
|||
meterCmd.Flags().DurationP(flagBatteryModeWait, "w", 0, flagBatteryModeWaitDescription)
|
||||
meterCmd.Flags().BoolP(flagRepeat, "r", false, flagRepeatDescription)
|
||||
meterCmd.Flags().Duration(flagRepeatInterval, 0, flagRepeatIntervalDescription)
|
||||
meterCmd.Flags().Bool(flagHeartbeat, false, flagHeartbeatDescription)
|
||||
}
|
||||
|
||||
func runMeter(cmd *cobra.Command, args []string) {
|
||||
|
|
@ -83,6 +84,9 @@ func runMeter(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
goto REPEAT
|
||||
}
|
||||
} else if ok, _ := cmd.Flags().GetBool(flagHeartbeat); ok {
|
||||
log.INFO.Println("running heartbeat (if any) until interrupted (Ctrl-C to stop)")
|
||||
time.Sleep(time.Hour)
|
||||
}
|
||||
|
||||
// wait for shutdown
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue