Skip to content

Commit

Permalink
cli/charger: support mA currents (evcc-io#15341)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Aug 11, 2024
1 parent 260c13e commit 061beab
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmd/charger.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var chargerCmd = &cobra.Command{

func init() {
rootCmd.AddCommand(chargerCmd)
chargerCmd.Flags().IntP(flagCurrent, "i", 0, flagCurrentDescription)
chargerCmd.Flags().Float64P(flagCurrent, "i", 0, flagCurrentDescription)
//lint:ignore SA1019 as Title is safe on ascii
chargerCmd.Flags().BoolP(flagEnable, "e", false, strings.Title(flagEnable))
//lint:ignore SA1019 as Title is safe on ascii
Expand Down Expand Up @@ -60,13 +60,19 @@ func runCharger(cmd *cobra.Command, args []string) {
if flag := cmd.Flags().Lookup(flagCurrent); flag.Changed {
flagUsed = true

current, err := strconv.ParseInt(flag.Value.String(), 10, 64)
current, err := strconv.ParseFloat(flag.Value.String(), 64)
if err != nil {
log.ERROR.Fatalln(err)
}

if err := v.MaxCurrent(current); err != nil {
log.ERROR.Println("set current:", err)
if vv, ok := v.(api.ChargerEx); ok {
if err := vv.MaxCurrentMillis(current); err != nil {
log.ERROR.Println("set current:", err)
}
} else {
if err := v.MaxCurrent(int64(current)); err != nil {
log.ERROR.Println("set current:", err)
}
}
}

Expand Down

0 comments on commit 061beab

Please sign in to comment.