Changed passing way of the logger
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 22s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 22s
This commit is contained in:
60
client.go
60
client.go
@ -24,7 +24,7 @@ type Client struct {
|
|||||||
listOfVins []string
|
listOfVins []string
|
||||||
isAuthenticated bool
|
isAuthenticated bool
|
||||||
isRegistered bool
|
isRegistered bool
|
||||||
log *slog.Logger
|
logger *slog.Logger
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ func (c *Client) auth() []byte {
|
|||||||
reqURL := MOBILE_API_VERSION + apiURLs["API_LOGIN"]
|
reqURL := MOBILE_API_VERSION + apiURLs["API_LOGIN"]
|
||||||
resp := c.execute(reqURL, POST, params, "", false)
|
resp := c.execute(reqURL, POST, params, "", false)
|
||||||
|
|
||||||
c.log.Debug("AUTH HTTP OUTPUT", "body", string([]byte(resp)))
|
c.logger.Debug("AUTH HTTP OUTPUT", "body", string([]byte(resp)))
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
@ -151,14 +151,14 @@ func (c *Client) listDevices() {
|
|||||||
fmt.Println(" RequestAttempt:", ti.RequestAttempt)
|
fmt.Println(" RequestAttempt:", ti.RequestAttempt)
|
||||||
fmt.Println(" RemoteAddr :", ti.RemoteAddr)
|
fmt.Println(" RemoteAddr :", ti.RemoteAddr)
|
||||||
|
|
||||||
// c.log.Debug("LIST DEVICES OUTPUT", "body", string([]byte(resp.Body())))
|
// c.logger.Debug("LIST DEVICES OUTPUT", "body", string([]byte(resp.Body())))
|
||||||
|
|
||||||
// c.httpClient.SetBaseURL(WEB_API_SERVER[c.country]).SetCookies(c.cookies)
|
// c.httpClient.SetBaseURL(WEB_API_SERVER[c.country]).SetCookies(c.cookies)
|
||||||
// reqURL := apiURLs["WEB_API_LIST_DEVICES"]
|
// reqURL := apiURLs["WEB_API_LIST_DEVICES"]
|
||||||
// resp := c.execute(reqURL, GET, map[string]string{}, "", false)
|
// resp := c.execute(reqURL, GET, map[string]string{}, "", false)
|
||||||
|
|
||||||
// if isResponseSuccessfull(resp) {
|
// if isResponseSuccessfull(resp) {
|
||||||
// log.Debugf("LIST DEVICES OUTPUT >> %v\n", string(resp))
|
// logger.Debugf("LIST DEVICES OUTPUT >> %v\n", string(resp))
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,20 +194,20 @@ func (c *Client) validateSession() bool {
|
|||||||
// if await self._select_vehicle(vin):
|
// if await self._select_vehicle(vin):
|
||||||
// result = True
|
// result = True
|
||||||
|
|
||||||
c.log.Debug("session validation", "body", string([]byte(resp)))
|
c.logger.Debug("session validation", "body", string([]byte(resp)))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// New function creates a New MySubaru client
|
// New function creates a New MySubaru client
|
||||||
func New(logger *slog.Logger, config *config.MySubaru) (*Client, error) {
|
func New(config *config.Config) (*Client, error) {
|
||||||
|
|
||||||
client := &Client{
|
client := &Client{
|
||||||
credentials: config.Credentials,
|
credentials: config.MySubaru.Credentials,
|
||||||
country: config.Region,
|
country: config.MySubaru.Region,
|
||||||
updateInterval: 7200,
|
updateInterval: 7200,
|
||||||
fetchInterval: 360,
|
fetchInterval: 360,
|
||||||
log: logger,
|
logger: config.Logger,
|
||||||
}
|
}
|
||||||
|
|
||||||
httpClient := resty.New()
|
httpClient := resty.New()
|
||||||
@ -230,20 +230,20 @@ func New(logger *slog.Logger, config *config.MySubaru) (*Client, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if client.isResponseSuccessfull(resp) {
|
if client.isResponseSuccessfull(resp) {
|
||||||
logger.Debug("Client authentication successful", "isRegistered", respParsed.Path("data.deviceRegistered").Data().(bool))
|
client.logger.Debug("Client authentication successful", "isRegistered", respParsed.Path("data.deviceRegistered").Data().(bool))
|
||||||
client.isAuthenticated = true
|
client.isAuthenticated = true
|
||||||
client.isRegistered = respParsed.Path("data.deviceRegistered").Data().(bool)
|
client.isRegistered = respParsed.Path("data.deviceRegistered").Data().(bool)
|
||||||
} else {
|
} else {
|
||||||
error, _ := respParsed.Path("errorCode").Data().(string)
|
error, _ := respParsed.Path("errorCode").Data().(string)
|
||||||
switch {
|
switch {
|
||||||
case error == apiErrors["ERROR_INVALID_ACCOUNT"]:
|
case error == apiErrors["ERROR_INVALID_ACCOUNT"]:
|
||||||
logger.Debug("Invalid account")
|
client.logger.Debug("Invalid account")
|
||||||
case error == apiErrors["ERROR_INVALID_CREDENTIALS"]:
|
case error == apiErrors["ERROR_INVALID_CREDENTIALS"]:
|
||||||
logger.Debug("Client authentication failed")
|
client.logger.Debug("Client authentication failed")
|
||||||
case error == apiErrors["ERROR_PASSWORD_WARNING"]:
|
case error == apiErrors["ERROR_PASSWORD_WARNING"]:
|
||||||
logger.Debug("Multiple Password Failures.")
|
client.logger.Debug("Multiple Password Failures.")
|
||||||
default:
|
default:
|
||||||
logger.Debug("Uknown error")
|
client.logger.Debug("Uknown error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ func (c *Client) SelectVehicle(vin string) VehicleData {
|
|||||||
json.Unmarshal([]byte(vdString), &vData)
|
json.Unmarshal([]byte(vdString), &vData)
|
||||||
|
|
||||||
// resp := c.execute(reqURL, GET, params, "", false)
|
// resp := c.execute(reqURL, GET, params, "", false)
|
||||||
// log.Debugf("SELECT VEHICLE OUTPUT >> %v\n", string([]byte(resp)))
|
// logger.Debugf("SELECT VEHICLE OUTPUT >> %v\n", string([]byte(resp)))
|
||||||
|
|
||||||
// ERRORS
|
// ERRORS
|
||||||
// {"success":false,"errorCode":"vehicleNotInAccount","dataName":null,"data":null}
|
// {"success":false,"errorCode":"vehicleNotInAccount","dataName":null,"data":null}
|
||||||
@ -323,7 +323,7 @@ func (c *Client) GetVehicles() []*Vehicle {
|
|||||||
|
|
||||||
respParsed, err := gabs.ParseJSON([]byte(resp))
|
respParsed, err := gabs.ParseJSON([]byte(resp))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Error("error which parsing json", "request", "GetVehicles", "error", err.Error())
|
c.logger.Error("error which parsing json", "request", "GetVehicles", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
vData := VehicleData{}
|
vData := VehicleData{}
|
||||||
@ -375,7 +375,7 @@ func (c *Client) GetVehicleByVIN(vin string) *Vehicle {
|
|||||||
|
|
||||||
respParsed, err := gabs.ParseJSON([]byte(resp))
|
respParsed, err := gabs.ParseJSON([]byte(resp))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Error("error which parsing json", "request", "GetVehicleByVIN", "error", err.Error())
|
c.logger.Error("error which parsing json", "request", "GetVehicleByVIN", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
vData := VehicleData{}
|
vData := VehicleData{}
|
||||||
@ -454,9 +454,9 @@ func (c *Client) GetVehicleStatus() {
|
|||||||
|
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Error("error which parsing json", "request", "GetVehicleStatus", "error", err.Error())
|
c.logger.Error("error which parsing json", "request", "GetVehicleStatus", "error", err.Error())
|
||||||
}
|
}
|
||||||
c.log.Debug("GET VEHICLE STATUS OUTPUT", "body", respParsed)
|
c.logger.Debug("GET VEHICLE STATUS OUTPUT", "body", respParsed)
|
||||||
|
|
||||||
success, ok := respParsed.Path("success").Data().(bool)
|
success, ok := respParsed.Path("success").Data().(bool)
|
||||||
// value == string, ok == false
|
// value == string, ok == false
|
||||||
@ -490,9 +490,9 @@ func (c *Client) GetClimateSettings() {
|
|||||||
|
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Error("error which parsing json", "request", "GetClimateSettings", "error", err.Error())
|
c.logger.Error("error which parsing json", "request", "GetClimateSettings", "error", err.Error())
|
||||||
}
|
}
|
||||||
c.log.Debug("CLIMATE SETTINGS OUTPUT", "response", respParsed)
|
c.logger.Debug("CLIMATE SETTINGS OUTPUT", "response", respParsed)
|
||||||
|
|
||||||
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPING DATA IN DATA FIELD
|
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPING DATA IN DATA FIELD
|
||||||
data, ok := respParsed.Path("data").Data().(string)
|
data, ok := respParsed.Path("data").Data().(string)
|
||||||
@ -507,7 +507,7 @@ func (c *Client) GetClimateSettings() {
|
|||||||
// TODO: Work with errorCode
|
// TODO: Work with errorCode
|
||||||
panic(data)
|
panic(data)
|
||||||
}
|
}
|
||||||
c.log.Debug("CLIMATE SETTINGS OUTPUT", "body", data)
|
c.logger.Debug("CLIMATE SETTINGS OUTPUT", "body", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func isPINRequired() {}
|
// func isPINRequired() {}
|
||||||
@ -559,9 +559,9 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
|||||||
// }
|
// }
|
||||||
respParsed, err := gabs.ParseJSON(resBytes)
|
respParsed, err := gabs.ParseJSON(resBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Error("error which parsing json", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
|
c.logger.Error("error which parsing json", "request", "execute", "method", method, "url", requestUrl, "error", err.Error())
|
||||||
}
|
}
|
||||||
c.log.Debug("HTTP OUTPUT", "body", string(resBytes))
|
c.logger.Debug("HTTP OUTPUT", "body", string(resBytes))
|
||||||
|
|
||||||
_, ok := respParsed.Path("success").Data().(bool)
|
_, ok := respParsed.Path("success").Data().(bool)
|
||||||
// value == string, ok == false
|
// value == string, ok == false
|
||||||
@ -587,7 +587,7 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
|||||||
}).
|
}).
|
||||||
Get(pollingUrl)
|
Get(pollingUrl)
|
||||||
resBytes, _ := io.ReadAll(resp.Body)
|
resBytes, _ := io.ReadAll(resp.Body)
|
||||||
c.log.Debug("POLLING HTTP OUTPUT", "body", string(resBytes))
|
c.logger.Debug("POLLING HTTP OUTPUT", "body", string(resBytes))
|
||||||
// {"success":false,"errorCode":"404-soa-unableToParseResponseBody","dataName":"errorResponse","data":{"errorLabel":"404-soa-unableToParseResponseBody","errorDescription":null}}
|
// {"success":false,"errorCode":"404-soa-unableToParseResponseBody","dataName":"errorResponse","data":{"errorLabel":"404-soa-unableToParseResponseBody","errorDescription":null}}
|
||||||
|
|
||||||
respParsed, err := gabs.ParseJSON(resBytes)
|
respParsed, err := gabs.ParseJSON(resBytes)
|
||||||
@ -603,13 +603,13 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
|||||||
status, _ := respParsed.Path("data.remoteServiceState").Data().(string)
|
status, _ := respParsed.Path("data.remoteServiceState").Data().(string)
|
||||||
switch {
|
switch {
|
||||||
case status == "finished":
|
case status == "finished":
|
||||||
c.log.Debug("Remote service request completed successfully", "request id", serviceRequestId)
|
c.logger.Debug("Remote service request completed successfully", "request id", serviceRequestId)
|
||||||
break poolingLoop
|
break poolingLoop
|
||||||
case status == "started":
|
case status == "started":
|
||||||
c.log.Debug("Subaru API reports remote service request is in progress", "request id", serviceRequestId)
|
c.logger.Debug("Subaru API reports remote service request is in progress", "request id", serviceRequestId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.log.Debug("Backend session expired, please try again")
|
c.logger.Debug("Backend session expired, please try again")
|
||||||
break poolingLoop
|
break poolingLoop
|
||||||
}
|
}
|
||||||
attempts--
|
attempts--
|
||||||
@ -625,12 +625,12 @@ func (c *Client) execute(requestUrl string, method string, params map[string]str
|
|||||||
func (c *Client) isResponseSuccessfull(resp []byte) bool {
|
func (c *Client) isResponseSuccessfull(resp []byte) bool {
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Debug("error while parsing json response", "error", err)
|
c.logger.Debug("error while parsing json response", "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
success, ok := respParsed.Path("success").Data().(bool)
|
success, ok := respParsed.Path("success").Data().(bool)
|
||||||
if !ok {
|
if !ok {
|
||||||
c.log.Debug("response is not successful", "error", resp)
|
c.logger.Debug("response is not successful", "error", resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ERRORS FROM CLIENT CREATION AFTER AUTH
|
// ERRORS FROM CLIENT CREATION AFTER AUTH
|
||||||
|
68
vehicle.go
68
vehicle.go
@ -203,7 +203,7 @@ func (v *Vehicle) Lock() {
|
|||||||
pollingURL := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
pollingURL := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
||||||
v.client.execute(reqURL, POST, params, pollingURL, true)
|
v.client.execute(reqURL, POST, params, pollingURL, true)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ func (v *Vehicle) Unlock() {
|
|||||||
pollingURL := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
pollingURL := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
||||||
v.client.execute(reqURL, POST, params, pollingURL, true)
|
v.client.execute(reqURL, POST, params, pollingURL, true)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
// ERROR
|
// ERROR
|
||||||
// {"httpCode":500,"errorCode":"error","errorMessage":"org.springframework.web.HttpMediaTypeNotSupportedException - Content type 'application/x-www-form-urlencoded' not supported"}
|
// {"httpCode":500,"errorCode":"error","errorMessage":"org.springframework.web.HttpMediaTypeNotSupportedException - Content type 'application/x-www-form-urlencoded' not supported"}
|
||||||
@ -277,7 +277,7 @@ func (v *Vehicle) EngineStart() {
|
|||||||
pollingURL := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
pollingURL := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
||||||
v.client.execute(reqURL, POST, params, pollingURL, true)
|
v.client.execute(reqURL, POST, params, pollingURL, true)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ func (v *Vehicle) EngineStop() {
|
|||||||
pollingURL := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
pollingURL := MOBILE_API_VERSION + apiURLs["API_REMOTE_SVC_STATUS"]
|
||||||
v.client.execute(reqURL, POST, params, pollingURL, true)
|
v.client.execute(reqURL, POST, params, pollingURL, true)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("Active STARLINK Security Plus subscription required")
|
v.client.logger.Error("Active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ func (v *Vehicle) LightsStart() {
|
|||||||
}
|
}
|
||||||
v.client.execute(reqURL, POST, params, pollingURL, true)
|
v.client.execute(reqURL, POST, params, pollingURL, true)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ func (v *Vehicle) LightsStop() {
|
|||||||
}
|
}
|
||||||
v.client.execute(reqURL, POST, params, pollingURL, true)
|
v.client.execute(reqURL, POST, params, pollingURL, true)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +354,7 @@ func (v *Vehicle) HornStart() {
|
|||||||
}
|
}
|
||||||
v.client.execute(reqURL, POST, params, pollingURL, true)
|
v.client.execute(reqURL, POST, params, pollingURL, true)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ func (v *Vehicle) HornStop() {
|
|||||||
}
|
}
|
||||||
v.client.execute(reqURL, POST, params, pollingURL, true)
|
v.client.execute(reqURL, POST, params, pollingURL, true)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("Active STARLINK Security Plus subscription required")
|
v.client.logger.Error("Active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,9 +526,9 @@ func (v *Vehicle) GetClimateQuickPresets() {
|
|||||||
|
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.client.log.Error("error which parsing json", "request", "GetClimateQuickPresets", "error", err.Error())
|
v.client.logger.Error("error which parsing json", "request", "GetClimateQuickPresets", "error", err.Error())
|
||||||
}
|
}
|
||||||
v.client.log.Debug("CLIMATE SETTINGS OUTPUT", "body", respParsed)
|
v.client.logger.Debug("CLIMATE SETTINGS OUTPUT", "body", respParsed)
|
||||||
|
|
||||||
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPING DATA IN DATA FIELD
|
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPING DATA IN DATA FIELD
|
||||||
data, ok := respParsed.Path("data").Data().(string)
|
data, ok := respParsed.Path("data").Data().(string)
|
||||||
@ -543,9 +543,9 @@ func (v *Vehicle) GetClimateQuickPresets() {
|
|||||||
// TODO: Work with errorCode
|
// TODO: Work with errorCode
|
||||||
panic(data)
|
panic(data)
|
||||||
}
|
}
|
||||||
v.client.log.Debug("PRESETS", "output", data)
|
v.client.logger.Debug("PRESETS", "output", data)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,12 +558,12 @@ func (v *Vehicle) GetClimatePresets() {
|
|||||||
|
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.client.log.Error("error which parsing json", "request", "GetClimatePresets", "error", err.Error())
|
v.client.logger.Error("error which parsing json", "request", "GetClimatePresets", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPED DATA IN DATA FIELD
|
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPED DATA IN DATA FIELD
|
||||||
for _, child := range respParsed.S("data").Children() {
|
for _, child := range respParsed.S("data").Children() {
|
||||||
// log.Debugf("key: %v, value: %v\n", key, child.Data().(string))
|
// logger.Debugf("key: %v, value: %v\n", key, child.Data().(string))
|
||||||
var climateProfile ClimateProfile
|
var climateProfile ClimateProfile
|
||||||
json.Unmarshal([]byte(child.Data().(string)), &climateProfile)
|
json.Unmarshal([]byte(child.Data().(string)), &climateProfile)
|
||||||
|
|
||||||
@ -576,7 +576,7 @@ func (v *Vehicle) GetClimatePresets() {
|
|||||||
v.Updated = time.Now()
|
v.Updated = time.Now()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,13 +589,13 @@ func (v *Vehicle) GetClimateUserPresets() {
|
|||||||
|
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.client.log.Error("error which parsing json", "request", "GetClimateUserPresets", "error", err.Error())
|
v.client.logger.Error("error which parsing json", "request", "GetClimateUserPresets", "error", err.Error())
|
||||||
}
|
}
|
||||||
v.client.log.Debug("CLIMATE USER SETTINGS OUTPUT", "body", respParsed)
|
v.client.logger.Debug("CLIMATE USER SETTINGS OUTPUT", "body", respParsed)
|
||||||
|
|
||||||
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPED DATA IN DATA FIELD
|
// ONLY FOR THAT REQUEST BECAUSE OF API SENDS BACK ESCAPED DATA IN DATA FIELD
|
||||||
for _, child := range respParsed.S("data").Children() {
|
for _, child := range respParsed.S("data").Children() {
|
||||||
// log.Debugf("key: %v, value: %v\n", key, child.Data().(string))
|
// logger.Debugf("key: %v, value: %v\n", key, child.Data().(string))
|
||||||
var climateProfile ClimateProfile
|
var climateProfile ClimateProfile
|
||||||
json.Unmarshal([]byte(child.Data().(string)), &climateProfile)
|
json.Unmarshal([]byte(child.Data().(string)), &climateProfile)
|
||||||
|
|
||||||
@ -620,9 +620,9 @@ func (v *Vehicle) GetClimateUserPresets() {
|
|||||||
// // TODO: Work with errorCode
|
// // TODO: Work with errorCode
|
||||||
// panic(data)
|
// panic(data)
|
||||||
// }
|
// }
|
||||||
// log.Debugf("PRESETS: %+v\n", data)
|
// logger.Debugf("PRESETS: %+v\n", data)
|
||||||
} else {
|
} else {
|
||||||
v.client.log.Error("active STARLINK Security Plus subscription required")
|
v.client.logger.Error("active STARLINK Security Plus subscription required")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,7 +635,7 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
if v.client.isResponseSuccessfull(resp) {
|
if v.client.isResponseSuccessfull(resp) {
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.client.log.Error("error which parsing json", "request", "GetVehicleStatus", "error", err.Error())
|
v.client.logger.Error("error which parsing json", "request", "GetVehicleStatus", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
vSta := VehicleStatus{}
|
vSta := VehicleStatus{}
|
||||||
@ -667,7 +667,7 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "door") && strings.HasSuffix(key, "Position") {
|
if strings.HasPrefix(key, "door") && strings.HasSuffix(key, "Position") {
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
v.client.log.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||||
for _, element := range submatchall {
|
for _, element := range submatchall {
|
||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
@ -684,7 +684,7 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "door") && strings.HasSuffix(key, "Status") {
|
if strings.HasPrefix(key, "door") && strings.HasSuffix(key, "Status") {
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
v.client.log.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||||
for _, element := range submatchall {
|
for _, element := range submatchall {
|
||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
@ -701,7 +701,7 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
v.client.log.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||||
for _, element := range submatchall {
|
for _, element := range submatchall {
|
||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
@ -717,7 +717,7 @@ func (v *Vehicle) GetVehicleStatus() {
|
|||||||
v.Windows = append(v.Windows, &window)
|
v.Windows = append(v.Windows, &window)
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Psi") {
|
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Psi") {
|
||||||
v.client.log.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
for _, element := range submatchall {
|
for _, element := range submatchall {
|
||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
@ -785,7 +785,7 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
if v.client.isResponseSuccessfull(resp) {
|
if v.client.isResponseSuccessfull(resp) {
|
||||||
respParsed, err := gabs.ParseJSON(resp)
|
respParsed, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.client.log.Error("error which parsing json", "request", "GetVehicleCondition", "error", err.Error())
|
v.client.logger.Error("error which parsing json", "request", "GetVehicleCondition", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
re := regexp.MustCompile(`[A-Z][^A-Z]*`)
|
re := regexp.MustCompile(`[A-Z][^A-Z]*`)
|
||||||
@ -798,7 +798,7 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "door") && strings.HasSuffix(key, "Position") {
|
if strings.HasPrefix(key, "door") && strings.HasSuffix(key, "Position") {
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
v.client.log.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||||
for _, element := range submatchall {
|
for _, element := range submatchall {
|
||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
@ -814,7 +814,7 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
if strings.HasPrefix(key, "window") && strings.HasSuffix(key, "Status") {
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
v.client.log.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data(), "number", len(submatchall))
|
||||||
for _, element := range submatchall {
|
for _, element := range submatchall {
|
||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
}
|
}
|
||||||
@ -828,7 +828,7 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
v.Windows = append(v.Windows, &window)
|
v.Windows = append(v.Windows, &window)
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Unit") {
|
if strings.HasPrefix(key, "tire") && !strings.HasSuffix(key, "Unit") {
|
||||||
v.client.log.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
v.client.logger.Debug("VEHICLE COND", "key", key, "data", child.Data())
|
||||||
submatchall := re.FindAllString(key, -1)
|
submatchall := re.FindAllString(key, -1)
|
||||||
for _, element := range submatchall {
|
for _, element := range submatchall {
|
||||||
fmt.Println(element)
|
fmt.Println(element)
|
||||||
@ -846,7 +846,7 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
// continue
|
// continue
|
||||||
// }
|
// }
|
||||||
// if strings.HasPrefix(elem.Key, "door") {
|
// if strings.HasPrefix(elem.Key, "door") {
|
||||||
// log.Debugf("VEHICLE COND: %v > %v\n", elem.Key, elem.Value)
|
// logger.Debugf("VEHICLE COND: %v > %v\n", elem.Key, elem.Value)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// for _, elem := range vCon.VehicleStatus {
|
// for _, elem := range vCon.VehicleStatus {
|
||||||
@ -854,7 +854,7 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
// continue
|
// continue
|
||||||
// }
|
// }
|
||||||
// if strings.HasPrefix(elem.Key, "window") {
|
// if strings.HasPrefix(elem.Key, "window") {
|
||||||
// log.Debugf("VEHICLE COND: %v > %v\n", elem.Key, elem.Value)
|
// logger.Debugf("VEHICLE COND: %v > %v\n", elem.Key, elem.Value)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// for _, elem := range vCon.VehicleStatus {
|
// for _, elem := range vCon.VehicleStatus {
|
||||||
@ -862,10 +862,10 @@ func (v *Vehicle) GetVehicleCondition() {
|
|||||||
// continue
|
// continue
|
||||||
// }
|
// }
|
||||||
// if strings.HasPrefix(elem.Key, "tire") {
|
// if strings.HasPrefix(elem.Key, "tire") {
|
||||||
// log.Debugf("VEHICLE COND: %v > %v\n", elem.Key, elem.Value)
|
// logger.Debugf("VEHICLE COND: %v > %v\n", elem.Key, elem.Value)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// log.Debugf("VEHICLE COND REQUEST: %+v", vCon)
|
// logger.Debugf("VEHICLE COND REQUEST: %+v", vCon)
|
||||||
}
|
}
|
||||||
|
|
||||||
// VEHICLE_STATE_TYPE >> IGNITION_OFF
|
// VEHICLE_STATE_TYPE >> IGNITION_OFF
|
||||||
@ -895,7 +895,7 @@ func (v *Vehicle) GetVehicleHealth() {
|
|||||||
if v.client.isResponseSuccessfull(resp) {
|
if v.client.isResponseSuccessfull(resp) {
|
||||||
_, err := gabs.ParseJSON(resp)
|
_, err := gabs.ParseJSON(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
v.client.log.Error("error which parsing json", "request", "GetVehicleHealth", "error", err.Error())
|
v.client.logger.Error("error which parsing json", "request", "GetVehicleHealth", "error", err.Error())
|
||||||
}
|
}
|
||||||
// TODO:
|
// TODO:
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user