Refactor vehicle climate control methods to improve parameter handling and add new climate preset updates
Some checks failed
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Failing after 24s

This commit is contained in:
2025-07-10 08:36:31 -04:00
parent ebe98e685a
commit 89b3d44d82
3 changed files with 153 additions and 50 deletions

View File

@ -349,38 +349,23 @@ type VehicleCondition struct {
LastUpdatedTime string `json:"lastUpdatedTime"` // "2023-04-10T17:50:54+0000",
}
// ClimateSettings .
// "dataName":null
// type ClimateSettings struct {
// RunTimeMinutes string `json:"runTimeMinutes"`
// StartConfiguration string `json:"startConfiguration"`
// AirConditionOn string `json:"airConditionOn"`
// OuterAirCirculation string `json:"outerAirCirculation"`
// ClimateZoneFrontAirMode string `json:"climateZoneFrontAirMode"`
// ClimateZoneFrontTemp string `json:"climateZoneFrontTemp"`
// ClimateZoneFrontAirVolume string `json:"climateZoneFrontAirVolume"`
// HeatedSeatFrontLeft string `json:"heatedSeatFrontLeft"`
// HeatedSeatFrontRight string `json:"heatedSeatFrontRight"`
// HeatedRearWindowActive string `json:"heatedRearWindowActive"`
// }
// ClimateProfile represents a climate control profile for a Subaru vehicle.
type ClimateProfile struct {
Name string `json:"name,omitempty"`
VehicleType string `json:"vehicleType,omitempty"` // vehicleType [ gas | phev ]
PresetType string `json:"presetType,omitempty"` // presetType [ subaruPreset | userPreset ]
CanEdit bool `json:"canEdit,string,omitempty"` // canEdit [ false | true ]
Disabled bool `json:"disabled,string,omitempty"` // disabled [ false | true ]
RunTimeMinutes int `json:"runTimeMinutes,string"` // runTimeMinutes [ 5 | 10 ]
ClimateZoneFrontTemp int `json:"climateZoneFrontTemp,string"` // climateZoneFrontTemp: [ for _ in range(60, 85 + 1)] // climateZoneFrontTempCelsius: [for _ in range(15, 30 + 1) ]
ClimateZoneFrontAirMode string `json:"climateZoneFrontAirMode"` // climateZoneFrontAirMode: [ WINDOW | FEET_WINDOW | FACE | FEET | FEET_FACE_BALANCED | AUTO ]
ClimateZoneFrontAirVolume string `json:"climateZoneFrontAirVolume"` // climateZoneFrontAirVolume: [ AUTO | 2 | 4 | 7 ]
OuterAirCirculation string `json:"outerAirCirculation"` // outerAirCirculation: [ outsideAir, recirculation ]
HeatedRearWindowActive bool `json:"heatedRearWindowActive,string"` // heatedRearWindowActive: [ false | true ]
AirConditionOn bool `json:"airConditionOn,string"` // airConditionOn: [ false | true ]
HeatedSeatFrontLeft string `json:"heatedSeatFrontLeft"` // heatedSeatFrontLeft: [ OFF | LOW_HEAT | MEDIUM_HEAT | HIGH_HEAT ]
HeatedSeatFrontRight string `json:"heatedSeatFrontRight"` // heatedSeatFrontRight: [ OFF | LOW_HEAT | MEDIUM_HEAT | HIGH_HEAT ]
StartConfiguration string `json:"startConfiguration"` // startConfiguration [ START_ENGINE_ALLOW_KEY_IN_IGNITION (gas) | START_CLIMATE_CONTROL_ONLY_ALLOW_KEY_IN_IGNITION (phev) ]
Name string `json:"name"`
VehicleType string `json:"vehicleType,omitempty"` // vehicleType [ gas | phev ]
PresetType string `json:"presetType"` // presetType [ subaruPreset | userPreset ]
StartConfiguration string `json:"startConfiguration"` // startConfiguration [ START_ENGINE_ALLOW_KEY_IN_IGNITION (gas) | START_CLIMATE_CONTROL_ONLY_ALLOW_KEY_IN_IGNITION (phev) ]
RunTimeMinutes int `json:"runTimeMinutes,string"` // runTimeMinutes [ 5 | 10 ]
HeatedRearWindowActive string `json:"heatedRearWindowActive"` // heatedRearWindowActive: [ false | true ]
HeatedSeatFrontRight string `json:"heatedSeatFrontRight"` // heatedSeatFrontRight: [ OFF | LOW_HEAT | MEDIUM_HEAT | HIGH_HEAT ]
HeatedSeatFrontLeft string `json:"heatedSeatFrontLeft"` // heatedSeatFrontLeft: [ OFF | LOW_HEAT | MEDIUM_HEAT | HIGH_HEAT ]
ClimateZoneFrontTemp int `json:"climateZoneFrontTemp,string"` // climateZoneFrontTemp: [ for _ in range(60, 85 + 1)] // climateZoneFrontTempCelsius: [for _ in range(15, 30 + 1) ]
ClimateZoneFrontAirMode string `json:"climateZoneFrontAirMode"` // climateZoneFrontAirMode: [ WINDOW | FEET_WINDOW | FACE | FEET | FEET_FACE_BALANCED | AUTO ]
ClimateZoneFrontAirVolume int `json:"climateZoneFrontAirVolume,string"` // climateZoneFrontAirVolume: [ AUTO | 2 | 4 | 7 ]
OuterAirCirculation string `json:"outerAirCirculation"` // airConditionOn: [ false | true ]
AirConditionOn bool `json:"airConditionOn"` // airConditionOn: [ false | true ]
CanEdit bool `json:"canEdit"` // canEdit [ false | true ]
Disabled bool `json:"disabled"` // disabled [ false | true ]
}
// GeoLocation represents the geographical location of a Subaru vehicle.
@ -497,7 +482,7 @@ type CustomTime1 struct {
func (ct *CustomTime1) UnmarshalJSON(b []byte) (err error) {
// Use the correct layout string for the desired format
const layout = "2006-01-02T15:04:05"
s := strings.Trim(string(b), "\\\"") // Remove surrounding quotes
s := strings.Trim(string(b), "\\\"") // Remove surrounding escapes and quotes (parsing time \"\\\"2025-07-09T00:23:19\\\"\" as \"2006-01-02T15:04:05\")
if string(b) == "null" {
ct.Time = time.Time{}
return nil
@ -515,7 +500,7 @@ type CustomTime2 struct {
func (ct *CustomTime2) UnmarshalJSON(b []byte) (err error) {
// Use the correct layout string for the desired format
const layout = "2006-01-02T15:04:05-0700"
s := strings.Trim(string(b), "\\\"") // Remove surrounding quotes
s := strings.Trim(string(b), "\\\"") // Remove surrounding escapes and quotes ((parsing time \"\\\"2025-07-09T00:23:19\\\"\" as \"2006-01-02T15:04:05\"))
if string(b) == "null" {
ct.Time = time.Time{}
return nil