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

This commit is contained in:
2025-05-30 12:52:02 -04:00
parent 193a60d1f1
commit 3b7c350826

View File

@ -486,10 +486,10 @@ func (v *Vehicle) GetClimatePresets() {
v.client.logger.Debug("subaru climate presets http output", "body", resp) v.client.logger.Debug("subaru climate presets http output", "body", resp)
tmp := struct { tmp := struct {
Success bool `json:"success"` Success bool `json:"success"`
ErrorCode string `json:"errorCode"` ErrorCode string `json:"errorCode"`
DataName string `json:"dataName"` DataName string `json:"dataName"`
Data []ClimateProfile `json:"data"` Data json.RawMessage `json:"data"`
}{} }{}
err := json.Unmarshal(resp, &tmp) err := json.Unmarshal(resp, &tmp)
if err != nil { if err != nil {
@ -497,8 +497,21 @@ func (v *Vehicle) GetClimatePresets() {
} }
v.client.logger.Debug("subaru climate presets parsed http output", "body", tmp) v.client.logger.Debug("subaru climate presets parsed http output", "body", tmp)
if len(tmp.Data) > 0 { unescapedJSON, err := strconv.Unquote(string(tmp.Data))
for _, cp := range tmp.Data { if err != nil {
fmt.Println("Error unquoting:", err)
return
}
var cProfiles []ClimateProfile
err = json.Unmarshal([]byte(unescapedJSON), &cProfiles)
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", cProfiles)
if len(cProfiles) > 0 {
for _, cp := range cProfiles {
if v.isEV() && cp.VehicleType == "phev" { if v.isEV() && cp.VehicleType == "phev" {
if _, ok := v.ClimateProfiles[cp.PresetType+cp.Name]; ok { if _, ok := v.ClimateProfiles[cp.PresetType+cp.Name]; ok {
v.ClimateProfiles[cp.PresetType+cp.Name] = cp v.ClimateProfiles[cp.PresetType+cp.Name] = cp