More Climate Profile changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 23s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 23s
This commit is contained in:
52
vehicle.go
52
vehicle.go
@ -514,34 +514,36 @@ func (v *Vehicle) GetClimateUserPresets() {
|
|||||||
}
|
}
|
||||||
v.client.logger.Debug("CLIMATE USER SETTINGS OUTPUT", "body", respParsed)
|
v.client.logger.Debug("CLIMATE USER SETTINGS OUTPUT", "body", respParsed)
|
||||||
|
|
||||||
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPED DATA IN DATA FIELD
|
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPING DATA IN DATA FIELD
|
||||||
for _, child := range respParsed.S("data").Children() {
|
data, ok := respParsed.Path("data").Data().(string)
|
||||||
// logger.Debugf("key: %v, value: %v\n", key, child.Data().(string))
|
if !ok {
|
||||||
var climateProfile ClimateProfile
|
v.client.logger.Error("error while parsing data json", "request", "GetClimateUserPresets", "error", err.Error())
|
||||||
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)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
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
|
cProfiles := []ClimateProfile{}
|
||||||
// if !ok {
|
err = json.Unmarshal([]byte(data), &cProfiles)
|
||||||
// // TODO: Work with errorCode
|
v.client.logger.Debug("climate quick presets", "data", data)
|
||||||
// panic(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 {
|
} else {
|
||||||
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user