diff --git a/main.go b/main.go index 382e1ce..40a1170 100644 --- a/main.go +++ b/main.go @@ -52,7 +52,7 @@ var ( func init() { flag.StringVar(&vehicleSearch, "v", "", "Vehicle Identifier") - flag.IntVar(&refresh, "r", -1, "Auto-refresh (every \"r\" minutes)") + flag.IntVar(&refresh, "r", -1, "Auto-refresh (every \"r\" minutes) WARNING: Vehicle can not sleep while refreshing.") flag.Parse() } func main() { @@ -117,14 +117,15 @@ func main() { centralWidget := widgets.NewQWidget(window, 0) // Set Values for everything - setValues() if refresh >= 1{ go func() { for { - time.Sleep(time.Duration(refresh) * time.Minute) setValues() + time.Sleep(time.Duration(refresh) * time.Minute) } }() + } else { + setValues() } // Some adjustments @@ -236,28 +237,19 @@ func main() { func setValues() { vehicle = getVehicle(vehicleSearch) - var err error if vehicle == nil { showDialogue(false, "Unable to get vehicle") return } - vehicleState, err = vehicle.VehicleState() + test, err := vehicle.Data(vehicle.ID) if err != nil { showDialogue(false, "Unable to get Vehicle State") } - chargeStats, err = vehicle.ChargeState() - if err != nil { + vehicleState = test.Response.VehicleState + chargeStats = test.Response.ChargeState + climateState = test.Response.ClimateState + guiSettings = test.Response.GuiSettings - showDialogue(false, "Unable to get Vehicle Charge State") - } - climateState, err = vehicle.ClimateState() - if err != nil { - showDialogue(false, "Unable to get Vehicle Climate") - } - guiSettings, err = vehicle.GuiSettings() - if err != nil { - showDialogue(false, "Unable to get Gui Settings") - } window.SetWindowTitle(fmt.Sprintf("%+v: %+v", vehicle.DisplayName, vehicle.Vin)) tempSettingVal := climateState.DriverTempSetting insideTempVal := climateState.InsideTemp