Skip to content

Instantly share code, notes, and snippets.

View dirkvm's full-sized avatar

Dirk Van Mieghem dirkvm

  • CyberTube
  • Belgium, Liège
View GitHub Profile
@dirkvm
dirkvm / streamws.js
Last active March 11, 2019 21:22
websocket test, copy to examples/streamws.js
#!/usr/bin/env node
const teslams = require('../teslams.js');
const WebSocket = require('ws');
const util = require('util');
var argv = require('optimist')
.usage('Usage: $0 -u <username> -p <password>')
.alias('u', 'username')
.describe('u', 'Teslamotors.com login')
.alias('p', 'password')
@dirkvm
dirkvm / tsla_poll.js
Created March 11, 2019 20:05
Handle Tesla realtime streaming data
/**
* tsla_ws - create websocket connection to Tesla streaming endpoint
*
* @param {number} vid - vehicle_id as returned by /vehicles API call
* @param {string} token - tokens[0] returned by /vehicles API call
*/
var ws, lastToken;
function tsla_ws(vid, token) {
if (lastToken !== token) {
ulog('stream token changed ' + lastToken + ' -> ' + token);
@dirkvm
dirkvm / streamtest.js
Last active November 12, 2020 17:08
websocket based streaming for Tesla
const util = require('util');
const WebSocket = require('ws');
const vehicle_id = ''; // as returned by the /vehicles api call
const auth_token = ''; // tokens as used in the REST API
const stream_columns = [
'speed',
'odometer',
'soc',

Keybase proof

I hereby claim:

  • I am dirkvm on github.
  • I am dirkvm (https://keybase.io/dirkvm) on keybase.
  • I have a public key whose fingerprint is A501 AD9D 4006 DF0E 2E75 513E DCE4 8A65 FAD6 EF4C

To claim this, I am signing this object: