More Climate Profile changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 23s

This commit is contained in:
2025-05-29 14:15:58 -04:00
parent 2f3840e01b
commit d2baab529c

View File

@ -514,34 +514,36 @@ func (v *Vehicle) GetClimateUserPresets() {
}
v.client.logger.Debug("CLIMATE USER SETTINGS OUTPUT", "body", respParsed)
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPED DATA IN DATA FIELD
for _, child := range respParsed.S("data").Children() {
// logger.Debugf("key: %v, value: %v\n", key, child.Data().(string))
var climateProfile ClimateProfile
json.Unmarshal([]byte(child.Data().(string)), &climateProfile)
// if v.isEV() && climateProfile.VehicleType == "phev" {
// v.ClimateProfiles = append(v.ClimateProfiles, climateProfile)
// }
// if !v.isEV() && climateProfile.VehicleType == "gas" {
// v.ClimateProfiles = append(v.ClimateProfiles, climateProfile)
// }
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPING DATA IN DATA FIELD
data, ok := respParsed.Path("data").Data().(string)
if !ok {
v.client.logger.Error("error while parsing data json", "request", "GetClimateUserPresets", "error", err.Error())
}
v.Updated = time.Now()
// // ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPING DATA IN DATA FIELD
// data, ok := respParsed.Path("data").Data().(string)
// // rawIn := json.RawMessage(in)
// // bytes, err := rawIn.MarshalJSON()
// // if err != nil {
// // panic(err)
// // }
// // value == string, ok == false
// if !ok {
// // TODO: Work with errorCode
// panic(data)
cProfiles := []ClimateProfile{}
err = json.Unmarshal([]byte(data), &cProfiles)
v.client.logger.Debug("climate quick presets", "data", data)
if err != nil {
v.client.logger.Error("error while parsing climate user presets json", "request", "GetClimateUserPresets", "error", err.Error())
}
if len(cProfiles) > 0 {
for _, cp := range cProfiles {
if _, ok := v.ClimateProfiles[cp.PresetType+cp.Name]; ok {
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
} else {
v.ClimateProfiles[cp.PresetType+cp.Name] = cp
}
}
}
// if v.isEV() && climateProfile.VehicleType == "phev" {
// v.ClimateProfiles = append(v.ClimateProfiles, climateProfile)
// }
// logger.Debugf("PRESETS: %+v\n", data)
// if !v.isEV() && climateProfile.VehicleType == "gas" {
// v.ClimateProfiles = append(v.ClimateProfiles, climateProfile)
// }
v.Updated = time.Now()
} else {
v.client.logger.Error("active STARLINK Security Plus subscription required")
}