Skip to content

Commit

Permalink
Vehicle: add cloud switch
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Sep 17, 2023
1 parent dd668c3 commit 33fc5d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
3 changes: 1 addition & 2 deletions cmd/charger.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ func init() {
chargerCmd.Flags().BoolP(flagEnable, "e", false, strings.Title(flagEnable))
//lint:ignore SA1019 as Title is safe on ascii
chargerCmd.Flags().BoolP(flagDisable, "d", false, strings.Title(flagDisable))
//lint:ignore SA1019 as Title is safe on ascii
chargerCmd.Flags().Bool(flagDiagnose, false, strings.Title(flagDiagnose))
chargerCmd.Flags().Bool(flagDiagnose, false, flagDiagnoseDescription)
chargerCmd.Flags().BoolP(flagWakeup, "w", false, flagWakeupDescription)
chargerCmd.Flags().IntP(flagPhases, "p", 0, flagPhasesDescription)
}
Expand Down
11 changes: 8 additions & 3 deletions cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ const (
flagPhases = "phases"
flagPhasesDescription = "Set usable phases (1 or 3)"

flagEnable = "enable"
flagDisable = "disable"
flagDiagnose = "diagnose"
flagCloud = "cloud"
flagCloudDescription = "Use cloud service (requires sponsor token)"

flagEnable = "enable"
flagDisable = "disable"

flagDiagnose = "diagnose"
flagDiagnoseDescription = "Diagnose"

flagWakeup = "wakeup"
flagWakeupDescription = "Wake up"
Expand Down
13 changes: 9 additions & 4 deletions cmd/vehicle.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cmd

import (
"strings"

"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util/config"
"github.com/spf13/cobra"
Expand All @@ -21,8 +19,8 @@ func init() {
vehicleCmd.Flags().BoolP(flagStart, "a", false, flagStartDescription)
vehicleCmd.Flags().BoolP(flagStop, "o", false, flagStopDescription)
vehicleCmd.Flags().BoolP(flagWakeup, "w", false, flagWakeupDescription)
//lint:ignore SA1019 as Title is safe on ascii
vehicleCmd.Flags().Bool(flagDiagnose, false, strings.Title(flagDiagnose))
vehicleCmd.Flags().Bool(flagDiagnose, false, flagDiagnoseDescription)
vehicleCmd.Flags().Bool(flagCloud, false, flagCloudDescription)
}

func runVehicle(cmd *cobra.Command, args []string) {
Expand All @@ -41,6 +39,13 @@ func runVehicle(cmd *cobra.Command, args []string) {
fatal(err)
}

// use cloud
if cmd.Flags().Lookup(flagCloud).Changed {
for _, conf := range conf.Vehicles {
conf.Other["cloud"] = "true"
}
}

if err := configureVehicles(conf.Vehicles); err != nil {
fatal(err)
}
Expand Down

0 comments on commit 33fc5d6

Please sign in to comment.