Some json parsing 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:
14
vehicle.go
14
vehicle.go
@ -473,7 +473,11 @@ func (v *Vehicle) GetClimateQuickPresets() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetClimatePresets .
|
// GetClimatePresets connects to the MySubaru API to download available climate presets.
|
||||||
|
// It first attempts to establish a connection with the MySubaru API.
|
||||||
|
// If successful and climate presets are found for the user's vehicle,
|
||||||
|
// it downloads them. If no presets are available, or if the connection fails,
|
||||||
|
// appropriate handling should be implemented within the function.
|
||||||
func (v *Vehicle) GetClimatePresets() {
|
func (v *Vehicle) GetClimatePresets() {
|
||||||
if v.getRemoteOptionsStatus() {
|
if v.getRemoteOptionsStatus() {
|
||||||
v.selectVehicle()
|
v.selectVehicle()
|
||||||
@ -486,7 +490,7 @@ func (v *Vehicle) GetClimatePresets() {
|
|||||||
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 any `json:"data"`
|
Data json.RawMessage `json:"data"`
|
||||||
}{}
|
}{}
|
||||||
err := json.Unmarshal(resp, &tmp)
|
err := json.Unmarshal(resp, &tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -494,6 +498,12 @@ 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)
|
||||||
|
|
||||||
|
var cProfiles []ClimateProfile
|
||||||
|
err = json.Unmarshal([]byte(tmp.Data), &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)
|
||||||
// respParsed, err := gabs.ParseJSON([]byte(resp))
|
// respParsed, err := gabs.ParseJSON([]byte(resp))
|
||||||
// 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())
|
||||||
|
Reference in New Issue
Block a user