Beta version
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:
28
client.go
28
client.go
@ -121,31 +121,10 @@ func (c *Client) SelectVehicle(vin string) VehicleData {
|
||||
c.logger.Error("error while parsing json", "request", "SelectVehicle", "error", err.Error())
|
||||
}
|
||||
// c.logger.Debug("http request output", "request", "SelectVehicle", "body", resp)
|
||||
|
||||
return vd
|
||||
} else {
|
||||
return VehicleData{}
|
||||
}
|
||||
|
||||
// ERRORS
|
||||
|
||||
// """Select active vehicle for accounts with multiple VINs."""
|
||||
// params = {"vin": vin, "_": int(time.time())}
|
||||
// js_resp = await self.get(API_SELECT_VEHICLE, params=params)
|
||||
// _LOGGER.debug(pprint.pformat(js_resp))
|
||||
// if js_resp.get("success"):
|
||||
// self._current_vin = vin
|
||||
// _LOGGER.debug("Current vehicle: vin=%s", js_resp["data"]["vin"])
|
||||
// return js_resp["data"]
|
||||
// if not js_resp.get("success") and js_resp.get("errorCode") == "VEHICLESETUPERROR":
|
||||
// # Occasionally happens every few hours. Resetting the session seems to deal with it.
|
||||
// _LOGGER.warning("VEHICLESETUPERROR received. Resetting session.")
|
||||
// self.reset_session()
|
||||
// return False
|
||||
// _LOGGER.debug("Failed to switch vehicle errorCode=%s", js_resp.get("errorCode"))
|
||||
// # Something else is probably wrong with the backend server context - try resetting
|
||||
// self.reset_session()
|
||||
// raise SubaruException("Failed to switch vehicle %s - resetting session." % js_resp.get("errorCode"))
|
||||
}
|
||||
|
||||
// GetVehicles .
|
||||
@ -296,14 +275,15 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
||||
}
|
||||
} else {
|
||||
if r.DataName == "errorResponse" {
|
||||
// {"success":false,"errorCode":"404-soa-unableToParseResponseBody","dataName":"errorResponse","data":{"errorLabel":"404-soa-unableToParseResponseBody","errorDescription":null}}
|
||||
// {"success":false,"errorCode":"vehicleNotInAccount","dataName":null,"data":null}
|
||||
var er ErrorResponse
|
||||
err := json.Unmarshal(r.Data, &er)
|
||||
if err != nil {
|
||||
c.logger.Error("error while parsing json", "request", "errorResponse", "error", err.Error())
|
||||
}
|
||||
c.logger.Error("request is not successfull", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
|
||||
if _, ok := API_ERRORS[er.ErrorLabel]; ok {
|
||||
c.logger.Error("request got an error", "request", "execute", "method", method, "url", requestUrl, "label", er.ErrorLabel, "descrip[tion", er.ErrorDescription)
|
||||
}
|
||||
c.logger.Error("request got an unknown error", "request", "execute", "method", method, "url", requestUrl, "label", er.ErrorLabel, "descrip[tion", er.ErrorDescription)
|
||||
}
|
||||
c.logger.Error("request is not successfull", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
|
||||
}
|
||||
|
18
consts.go
18
consts.go
@ -94,6 +94,24 @@ var apiURLs = map[string]string{
|
||||
// "API_FEATURE_G3_TELEMATICS": "g3",
|
||||
// }
|
||||
|
||||
var API_ERRORS = map[string]string{
|
||||
"403-soa-unableToParseResponseBody": "ERROR_SOA_403", // G2 Error Codes
|
||||
"InvalidCredentials": "ERROR_INVALID_CREDENTIALS",
|
||||
"ServiceAlreadyStarted": "ERROR_SERVICE_ALREADY_STARTED",
|
||||
"invalidAccount": "ERROR_INVALID_ACCOUNT",
|
||||
"passwordWarning": "ERROR_PASSWORD_WARNING",
|
||||
"accountLocked": "ERROR_ACCOUNT_LOCKED",
|
||||
"noVehiclesOnAccount": "ERROR_NO_VEHICLES",
|
||||
"accountNotFound": "ERROR_NO_ACCOUNT",
|
||||
"tooManyAttempts": "ERROR_TOO_MANY_ATTEMPTS",
|
||||
"vehicleNotInAccount": "ERROR_VEHICLE_NOT_IN_ACCOUNT",
|
||||
"SXM40004": "ERROR_G1_NO_SUBSCRIPTION", // G1 Error Codes
|
||||
"SXM40005": "ERROR_G1_STOLEN_VEHICLE",
|
||||
"SXM40006": "ERROR_G1_INVALID_PIN",
|
||||
"SXM40009": "ERROR_G1_SERVICE_ALREADY_STARTED",
|
||||
"SXM40017": "ERROR_G1_PIN_LOCKED",
|
||||
}
|
||||
|
||||
// TODO: Get back and add error wrapper
|
||||
// var apiErrors = map[string]string{
|
||||
// "ERROR_SOA_403": "403-soa-unableToParseResponseBody", // G2 Error Codes
|
||||
|
@ -279,6 +279,8 @@ type ServiceRequest struct {
|
||||
|
||||
// ErrorResponse .
|
||||
// "dataName":"errorResponse"
|
||||
// {"success":false,"errorCode":"404-soa-unableToParseResponseBody","dataName":"errorResponse","data":{"errorLabel":"404-soa-unableToParseResponseBody","errorDescription":null}}
|
||||
// {"success":false,"errorCode":"vehicleNotInAccount","dataName":null,"data":null}
|
||||
type ErrorResponse struct {
|
||||
ErrorLabel string `json:"errorLabel"` // "404-soa-unableToParseResponseBody"
|
||||
ErrorDescription string `json:"errorDescription,omitempty"` // null
|
||||
@ -305,7 +307,7 @@ type VehicleHealthItem struct {
|
||||
B2cCode string `json:"b2cCode"`
|
||||
FeatureCode string `json:"featureCode"`
|
||||
IsTrouble bool `json:"isTrouble"`
|
||||
OnDaiID int `json:"onDaiId"`
|
||||
OnDates []int64 `json:"onDates,omitempty"`
|
||||
OnDaiID int `json:"onDaiId"` // Has a number, probably id, but I couldn't find it purpose
|
||||
OnDates []int64 `json:"onDates,omitempty"` // List of the timestamps
|
||||
WarningCode int `json:"warningCode"`
|
||||
}
|
||||
|
@ -151,8 +151,8 @@ type Tire struct {
|
||||
SubPosition string
|
||||
Pressure int
|
||||
PressurePsi int
|
||||
Status string
|
||||
Updated time.Time
|
||||
// Status string
|
||||
}
|
||||
|
||||
// Warning .
|
||||
@ -677,7 +677,7 @@ func (v *Vehicle) GetVehicleCondition() {
|
||||
|
||||
// for i := 0; i < val.NumField(); i++ {
|
||||
for i := range val.NumField() {
|
||||
v.client.logger.Debug("vehicle condition >> parsing a car part", "field", typeOfS.Field(i).Name, "value", val.Field(i).Interface(), "type", val.Field(i).Type())
|
||||
// v.client.logger.Debug("vehicle condition >> parsing a car part", "field", typeOfS.Field(i).Name, "value", val.Field(i).Interface(), "type", val.Field(i).Type())
|
||||
if slices.Contains(badValues, val.Field(i).Interface()) {
|
||||
continue
|
||||
} else {
|
||||
@ -721,7 +721,8 @@ func (v *Vehicle) GetVehicleHealth() {
|
||||
// v.client.logger.Debug("vehicle health item", "id", i, "item", vhi)
|
||||
if vhi.IsTrouble {
|
||||
if _, ok := troubles[vhi.FeatureCode]; ok {
|
||||
v.client.logger.Debug("found troubled vehicle health item", "id", i, "item", vhi)
|
||||
// TODO: Added a troble to the trouble list
|
||||
v.client.logger.Debug("found troubled vehicle health item", "id", i, "item", vhi.FeatureCode, "description", troubles[vhi.FeatureCode])
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -821,7 +822,7 @@ func (v *Vehicle) parseLock(prefix, suffix, name string, value any) {
|
||||
pos := strings.TrimPrefix(name, prefix)
|
||||
pos = strings.TrimSuffix(pos, suffix)
|
||||
submatchall := re.FindAllString(pos, -1)
|
||||
v.client.logger.Debug("door lock status", "key", name, "value", value, "number", len(submatchall))
|
||||
// v.client.logger.Debug("door lock status", "key", name, "value", value, "number", len(submatchall))
|
||||
|
||||
if d, ok := v.Doors[pos]; ok {
|
||||
d.Lock = value.(string)
|
||||
|
Reference in New Issue
Block a user