More changes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 24s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 24s
This commit is contained in:
21
vehicle.go
21
vehicle.go
@ -486,26 +486,19 @@ 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 json.RawMessage `json:"data"`
|
Data []ClimateProfile `json:"data"`
|
||||||
}{}
|
}{}
|
||||||
err := json.Unmarshal(resp, &tmp)
|
err := json.Unmarshal(resp, &tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.client.logger.Error("error while parsing json", "request", "GetClimatePresets", "error", err.Error())
|
v.client.logger.Error("error while parsing json", "request", "GetClimatePresets", "error", err.Error())
|
||||||
}
|
}
|
||||||
v.client.logger.Debug("subaru climate presets parsed http output", "body", string(tmp.Data))
|
v.client.logger.Debug("subaru climate presets parsed http output", "body", tmp)
|
||||||
|
|
||||||
var cProfiles []ClimateProfile
|
if len(tmp.Data) > 0 {
|
||||||
err = json.Unmarshal([]byte(tmp.Data), &cProfiles)
|
for _, cp := range tmp.Data {
|
||||||
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
|
||||||
|
Reference in New Issue
Block a user