Some changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 24s

This commit is contained in:
2025-05-29 23:54:16 -04:00
parent 2ab1070bce
commit 68866189fb

View File

@ -482,49 +482,49 @@ func (v *Vehicle) GetClimatePresets() {
v.client.logger.Debug("subaru climate presets http output", "body", resp)
tmp1 := strings.ReplaceAll(string(resp), "\\\\\\\"", "\"")
v.client.logger.Debug("subaru climate presets after trimming #1", "body", tmp1)
tmp2 := strings.ReplaceAll(tmp1, `}\",\"{`, `},{`)
v.client.logger.Debug("subaru climate presets after trimming #2", "body", tmp2)
tmp3 := strings.ReplaceAll(tmp2, `[\"{`, `[{`)
v.client.logger.Debug("subaru climate presets after trimming #3", "body", tmp3)
tmp4 := strings.ReplaceAll(tmp3, ` }\"]`, `}]`)
v.client.logger.Debug("subaru climate presets after trimming #4", "body", tmp4)
tmp5 := strings.ReplaceAll(tmp4, `\"`, `"`)
v.client.logger.Debug("subaru climate presets after trimming", "body", tmp5)
respParsed, err := gabs.ParseJSON([]byte(tmp5))
respParsed, err := gabs.ParseJSON([]byte(resp))
if err != nil {
v.client.logger.Error("error while parsing json", "request", "GetClimatePresets", "error", err.Error())
}
v.client.logger.Debug("subaru climate presets parsed http output", "body", respParsed)
// 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", "GetClimatePresets", "error", err.Error())
}
// tmp1 := strings.ReplaceAll(string(resp), "\\\\"", "\"")
// v.client.logger.Debug("subaru climate presets after trimming #1", "body", tmp1)
// tmp2 := strings.ReplaceAll(tmp1, `}\",\"{`, `},{`)
// v.client.logger.Debug("subaru climate presets after trimming #2", "body", tmp2)
// tmp3 := strings.ReplaceAll(tmp2, `[\"{`, `[{`)
// v.client.logger.Debug("subaru climate presets after trimming #3", "body", tmp3)
// tmp4 := strings.ReplaceAll(tmp3, ` }\"]`, `}]`)
// v.client.logger.Debug("subaru climate presets after trimming #4", "body", tmp4)
// tmp5 := strings.ReplaceAll(tmp4, `\"`, `"`)
var cProfiles []ClimateProfile
err = json.Unmarshal([]byte(data), &cProfiles)
if err != nil {
v.client.logger.Error("error while parsing climate subaru presets json", "request", "GetClimatePresets", "error", err.Error())
}
v.client.logger.Debug("climate subaru presets", "data", data)
v.client.logger.Debug("subaru climate presets before trimming", "body", respParsed)
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
}
}
} else {
v.client.logger.Debug("didn't find any climate subaru presets")
}
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)
// if !ok {
// v.client.logger.Error("error while parsing data json", "request", "GetClimatePresets", "error", err.Error())
// }
// var cProfiles []ClimateProfile
// err = json.Unmarshal([]byte(data), &cProfiles)
// if err != nil {
// v.client.logger.Error("error while parsing climate subaru presets json", "request", "GetClimatePresets", "error", err.Error())
// }
// v.client.logger.Debug("climate subaru presets", "data", data)
// 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
// }
// }
// } else {
// v.client.logger.Debug("didn't find any climate subaru presets")
// }
// v.Updated = time.Now()
} else {
v.client.logger.Error("active STARLINK Security Plus subscription required")
}