You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.7 KiB
73 lines
2.7 KiB
package main |
|
|
|
import ( |
|
"fmt" |
|
"strconv" |
|
"strings" |
|
"time" |
|
) |
|
|
|
func setValues() { |
|
vehicle = getVehicle(vehicleSearch) |
|
if vehicle == nil { |
|
showDialogue(false, "Unable to get vehicle") |
|
return |
|
} |
|
test, err := vehicle.Data(vehicle.ID) |
|
if err != nil { |
|
showDialogue(false, "Unable to get Vehicle State") |
|
} |
|
vehicleState = test.Response.VehicleState |
|
chargeStats = test.Response.ChargeState |
|
climateState = test.Response.ClimateState |
|
guiSettings = test.Response.GuiSettings |
|
|
|
window.SetWindowTitle(fmt.Sprintf("%+v: %+v", vehicle.DisplayName, vehicle.Vin)) |
|
tempSettingVal := climateState.DriverTempSetting |
|
insideTempVal := climateState.InsideTemp |
|
outsideTempVal := climateState.OutsideTemp |
|
if guiSettings.GuiTemperatureUnits == "F" { |
|
tempSettingVal = (climateState.DriverTempSetting * 1.8) + 32 |
|
insideTempVal = (climateState.InsideTemp * 1.8) + 32 |
|
outsideTempVal = (climateState.OutsideTemp * 1.8) + 32 |
|
} |
|
window.CurrentChargeValue.SetText(fmt.Sprintf("%+v%%", chargeStats.BatteryLevel)) |
|
window.CurrentRangeValue.SetText(fmt.Sprintf("%.2f%+v", chargeStats.BatteryRange, |
|
strings.Replace(guiSettings.GuiDistanceUnits, "/hr", "", -1))) |
|
window.CurrentRangeValue.SetFixedWidth(10 * len(window.CurrentRangeValue.Text())) |
|
window.ChargingStateValue.SetText(chargeStats.ChargingState) |
|
if chargeStats.ChargingState == "Charging" { |
|
chargeTimer := time.Duration(chargeStats.MinutesToFullCharge) * time.Minute |
|
window.TimeToChargeLabel.SetText("Charging Complete In") |
|
window.TimeToChargeVal.SetText(fmt.Sprintf("%+v (%+v)", formatDuration(chargeTimer), time.Now().Add(chargeTimer).Format("15:04"))) |
|
if chargeStats.FastChargerBrand == "Tesla" { |
|
window.ChargingStateValue.SetText("Supercharging") |
|
} |
|
} else { |
|
window.TimeToChargeLabel.SetText("") |
|
window.TimeToChargeVal.SetText("") |
|
} |
|
|
|
if chargeStats.ChargePortDoorOpen { |
|
window.ChargePortValue.SetText("Open") |
|
} else { |
|
window.ChargePortValue.SetText("Closed") |
|
} |
|
window.ChargePercentSlider.SetValue(chargeStats.ChargeLimitSoc) |
|
window.ChargePercentageLabel.SetText(strconv.Itoa(chargeStats.ChargeLimitSoc)) |
|
|
|
window.InsideTempValue.SetText(fmt.Sprintf("%.0f %+v", insideTempVal, guiSettings.GuiTemperatureUnits)) |
|
window.OutsideTempValue.SetText(fmt.Sprintf("%.0f %+v", outsideTempVal, guiSettings.GuiTemperatureUnits)) |
|
window.ClimateOnCheckbox.SetChecked(climateState.IsClimateOn) |
|
window.ClimateSettingSpinbox.SetValue(int(tempSettingVal)) |
|
window.GuiOptionTempValue.SetText(guiSettings.GuiTemperatureUnits) |
|
|
|
if vehicleState.SentryMode { |
|
window.SentryModeValue.SetText("Engaged") |
|
} else { |
|
window.SentryModeValue.SetText("Disengaged") |
|
} |
|
window.ClimateOnCheckbox.SetCheckable(true) |
|
window.ClimateSettingSpinbox.SetReadOnly(false) |
|
fmt.Printf("%+v\n", vehicle.OptionCodes) |
|
}
|
|
|