From 15a792ac9bc6cc2fc1a571de6618996d849cf711 Mon Sep 17 00:00:00 2001 From: Alex Savin Date: Thu, 5 Jun 2025 10:58:30 -0400 Subject: [PATCH] Changed the way of naming climate profiles --- vehicle.go | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/vehicle.go b/vehicle.go index 48cf87f..481d409 100644 --- a/vehicle.go +++ b/vehicle.go @@ -458,11 +458,6 @@ func (v *Vehicle) GetClimatePresets() { reqURL := MOBILE_API_VERSION + apiURLs["API_G2_FETCH_RES_SUBARU_PRESETS"] resp := v.client.execute(reqURL, GET, map[string]string{}, "", false) - // var r Response - // err := json.Unmarshal(resp, &r) - // if err != nil { - // v.client.logger.Error("error while parsing json", "request", "GetClimatePresets", "error", err.Error()) - // } if r, ok := v.client.parseResponse(resp); ok { re1 := regexp.MustCompile(`\"`) @@ -479,7 +474,7 @@ func (v *Vehicle) GetClimatePresets() { if len(cProfiles) > 0 { for _, cp := range cProfiles { re := regexp.MustCompile(`([A-Z])`) - cpn := re.ReplaceAllString(cp.PresetType, "_$1") + "_" + strings.ReplaceAll(cp.Name, " ", "_") + cpn := strings.ToLower(re.ReplaceAllString(cp.PresetType, "_$1") + "_" + strings.ReplaceAll(cp.Name, " ", "_")) if v.isEV() && cp.VehicleType == "phev" { if _, ok := v.ClimateProfiles[cpn]; ok { @@ -523,11 +518,6 @@ func (v *Vehicle) GetClimateQuickPresets() { resp := v.client.execute(reqURL, GET, map[string]string{}, "", false) // v.client.logger.Debug("http request output", "request", "GetClimateQuickPresets", "body", resp) - // var r Response - // err := json.Unmarshal(resp, &r) - // if err != nil { - // v.client.logger.Error("error while parsing json", "request", "GetClimateQuickPresets", "error", err.Error()) - // } if r, ok := v.client.parseResponse(resp); ok { re1 := regexp.MustCompile(`\"`) @@ -542,7 +532,7 @@ func (v *Vehicle) GetClimateQuickPresets() { } re := regexp.MustCompile(`([A-Z])`) - cpn := re.ReplaceAllString(cp.PresetType, "_$1") + "_quick_" + strings.ReplaceAll(cp.Name, " ", "_") + cpn := strings.ToLower("quick_" + re.ReplaceAllString(cp.PresetType, "_$1") + "_" + strings.ReplaceAll(cp.Name, " ", "_")) if _, ok := v.ClimateProfiles[cpn]; ok { v.ClimateProfiles[cpn] = cp @@ -563,11 +553,6 @@ func (v *Vehicle) GetClimateUserPresets() { reqURL := MOBILE_API_VERSION + apiURLs["API_G2_FETCH_RES_USER_PRESETS"] resp := v.client.execute(reqURL, GET, map[string]string{}, "", false) - // var r Response - // err := json.Unmarshal(resp, &r) - // if err != nil { - // v.client.logger.Error("error while parsing json", "request", "GetClimateUserPresets", "error", err.Error()) - // } if r, ok := v.client.parseResponse(resp); ok { re1 := regexp.MustCompile(`\"`) @@ -584,7 +569,7 @@ func (v *Vehicle) GetClimateUserPresets() { if len(cProfiles) > 0 { for _, cp := range cProfiles { re := regexp.MustCompile(`([A-Z])`) - cpn := re.ReplaceAllString(cp.PresetType, "_$1") + "_" + strings.ReplaceAll(cp.Name, " ", "_") + cpn := strings.ToLower(re.ReplaceAllString(cp.PresetType, "_$1") + "_" + strings.ReplaceAll(cp.Name, " ", "_")) if _, ok := v.ClimateProfiles[cpn]; ok { v.ClimateProfiles[cpn] = cp