@eiannone/tesla-api 1.8.0 → 1.8.1

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.
Files changed (2) hide show
  1. package/TeslaStream.js +3 -8
  2. package/package.json +1 -1
package/TeslaStream.js CHANGED
@@ -138,15 +138,10 @@ export default class TeslaStream extends EventEmitter {
138
138
  this.log("Websocket open.");
139
139
  this.#subscribe(this.tag, token);
140
140
  });
141
- this.ws.on('message', (data, isBinary) => {
142
- if (isBinary) {
143
- this.log("Binary data received. Ignored.");
144
- return;
145
- }
141
+ this.ws.on('message', (message) => {
146
142
  if (this.checkTimeout != null) clearTimeout(this.checkTimeout);
147
143
  this.checkTimeout = setTimeout(this.#timeout.bind(this), 15000);
148
-
149
- const message = data.toString();
144
+
150
145
  let d = JSON.parse(message);
151
146
  if (d.msg_type == 'control:hello') {
152
147
  this.log("Hello response received.");
@@ -184,7 +179,7 @@ export default class TeslaStream extends EventEmitter {
184
179
  this.log("Websocket error: " + errMsg, "error");
185
180
  });
186
181
  this.ws.on('close', (code, reason) => {
187
- this.log("Websocket closed ("+ code + (reason? ': ' + reason.toString() : '') + ").");
182
+ this.log("Websocket closed ("+ code + (reason? ': ' + reason : '') + ").");
188
183
  if (code == 1006 && this.state != CLOSING) this.reconnect = true; // Abnormal close
189
184
  if (this.checkTimeout != null) clearTimeout(this.checkTimeout);
190
185
  this.ws = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eiannone/tesla-api",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Nodejs Tesla API",
5
5
  "type": "module",
6
6
  "main": "index.js",