@eiannone/tesla-api 1.15.4 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/TeslaApi.js +4 -9
- package/package.json +1 -1
package/TeslaApi.js
CHANGED
|
@@ -44,7 +44,7 @@ class TeslaApi {
|
|
|
44
44
|
case 503: return ApiError.NETWORK; // Service unavailable
|
|
45
45
|
case 504: return ApiError.TIMEOUT;
|
|
46
46
|
case 540: return ApiError.UNAVAILABLE; // TODO: check. Should be system booting
|
|
47
|
-
default:
|
|
47
|
+
default: return ApiError.UNKNOWN;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -81,8 +81,8 @@ class TeslaApi {
|
|
|
81
81
|
// Tries to refresh the tokens
|
|
82
82
|
this.refreshToken(this.refresh_token)
|
|
83
83
|
.then(_ => this.#apiCall(path, method, params))
|
|
84
|
-
.then(
|
|
85
|
-
.catch(
|
|
84
|
+
.then(resolve)
|
|
85
|
+
.catch(reject);
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
let errMsg = res.statusMessage + " ("+res.statusCode+")";
|
|
@@ -115,11 +115,6 @@ class TeslaApi {
|
|
|
115
115
|
return this.#apiCall(vid + "/vehicle_data");
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
async getChargeState(id = null) {
|
|
119
|
-
const vid = (id == null)? this.vid : id;
|
|
120
|
-
return this.#apiCall(vid + "/data_request/charge_state");
|
|
121
|
-
}
|
|
122
|
-
|
|
123
118
|
async wakeUp(id = null) {
|
|
124
119
|
const vid = (id == null)? this.vid : id;
|
|
125
120
|
return this.#apiCall(vid + "/wake_up", "POST");
|
|
@@ -171,7 +166,7 @@ class TeslaApi {
|
|
|
171
166
|
});
|
|
172
167
|
}
|
|
173
168
|
|
|
174
|
-
|
|
169
|
+
onTokenRefresh(callback) {
|
|
175
170
|
this.cb_refreshToken = callback;
|
|
176
171
|
}
|
|
177
172
|
|