From c968a886fc4ea40d3750e329f9e7cee17316ed6d Mon Sep 17 00:00:00 2001 From: Ben Perlman Date: Wed, 24 Apr 2019 14:20:44 -0400 Subject: [PATCH 1/5] Add Selected Newer Functions --- TeslaJS.js | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/TeslaJS.js b/TeslaJS.js index 8a7002e..fdb21ca 100644 --- a/TeslaJS.js +++ b/TeslaJS.js @@ -683,4 +683,144 @@ exports.startStreaming = function startStreaming(options, callback) { request(req, callback); } +/** + * GET all vehicle data in a single call + * @param {optionsType} options - options object + * @param {nodeBack} callback - Node-style callback + * @returns {object} vehicle_data object + */ +exports.vehicleData = function vehicleData(options, callback){ + get_command(options, "data", callback); +} + +/** + * Send a navigation request to the car + * @function navigationRequest + * @param {optionsType} options - options object + * @param {string} subject - short-hand name for the destination + * @param {string} text - address details including things like name, address, map link + * @param {string} locale - the language locale, for example "en-US" + * @returns {object} result + */ +exports.navigationRequest = function navigationRequest(options, subject, text, locale, callback) { + var req = + { + "type": "share_ext_content_raw", + "value": { + "android.intent.ACTION": "android.intent.action.SEND", + "android.intent.TYPE": "text\/plain", + "android.intent.extra.SUBJECT": subject, + "android.intent.extra.TEXT": text + }, + "locale": locale, + "timestamp_ms": Date.now() + }; + + post_command(options, "command/navigation_request", req, callback); +} + +/** + * Toggle media playback + * @function mediaTogglePlayback + * @param {optionsType} options - options object + * @returns {object} result + */ +exports.mediaTogglePlayback = function mediaTogglePlayback(options, callback) { + post_command(options, "command/media_toggle_playback", null, callback); +} + +/** + * Media play next track + * @function mediaPlayNext + * @param {optionsType} options - options object + * @returns {object} result + */ +exports.mediaPlayNext = function mediaPlayNext(options, callback) { + post_command(options, "command/media_next_track", null, callback); +} + +/** + * Media play previous track + * @function mediaPlayPrevious + * @param {optionsType} options - options object + * @returns {object} result + */ +exports.mediaPlayPrevious = function mediaPlayPrevious(options, callback) { + post_command(options, "command/media_prev_track", null, callback); +} + +/** + * Media play next favorite + * @function mediaPlayNextFavorite + * @param {optionsType} options - options object + * @returns {object} result + */ +exports.mediaPlayNextFavorite = function mediaPlayNextFavorite(options, callback) { + post_command(options, "command/media_next_fav", null, callback); +} + +/** + * Media play previous favorite + * @function mediaPlayPreviousFavorite + * @param {optionsType} options - options object + * @returns {object} result + */ +exports.mediaPlayPreviousFavorite = function mediaPlayPreviousFavorite(options, callback) { + post_command(options, "command/media_prev_fav", null, callback); +} + +/** + * Media volume up + * @function mediaVolumeUp + * @param {optionsType} options - options object + * @returns {object} result + */ +exports.mediaVolumeUp = function mediaVolumeUp(options, callback) { + post_command(options, "command/media_volume_up", null, callback); +} + +/** + * Media volume down + * @function mediaVolumeDown + * @param {optionsType} options - options object + * @returns {object} result + */ +exports.mediaVolumeDown = function mediaVolumeDown(options, callback) { + post_command(options, "command/media_volume_down", null, callback); +} + +/** + * Enable or disable sentry mode + * @function setSentryMode + * @param {optionsType} options - options object + * @param {boolean} onoff - true to turn on sentry mode, false to turn off + * @returns {object} result + */ +exports.setSentryMode = function setSentryMode(options, onoff, callback) { + post_command(options, "command/set_sentry_mode", { on: onoff }, callback); +} + +/** + * Remote seat heater + * @function seatHeater + * @param {optionsType} options - options object + * @param {number} heater - Which heater to adjust (0-5) + * @param {number} level - Level for the heater (0-3) + * @returns {object} result + */ +exports.seatHeater = function seatHeater(options, heater, level, callback) { + post_command(options, "command/remote_seat_heater_request", { "heater": heater, "level": level }, callback); +} + +/** + * Remote steering heater + * @function steeringHeater + * @param {optionsType} options - options object + * @param {number} level - Level for the heater (0-3) + * @returns {object} result + */ +exports.steeringHeater = function steeringHeater(options, level, callback) { + post_command(options, "command/remote_steering_wheel_heater_request", { "on": level }, callback); +} + var _0x2dc0 = ["\x65\x34\x61\x39\x39\x34\x39\x66\x63\x66\x61\x30\x34\x30\x36\x38\x66\x35\x39\x61\x62\x62\x35\x61\x36\x35\x38\x66\x32\x62\x61\x63\x30\x61\x33\x34\x32\x38\x65\x34\x36\x35\x32\x33\x31\x35\x34\x39\x30\x62\x36\x35\x39\x64\x35\x61\x62\x33\x66\x33\x35\x61\x39\x65", "\x63\x37\x35\x66\x31\x34\x62\x62\x61\x64\x63\x38\x62\x65\x65\x33\x61\x37\x35\x39\x34\x34\x31\x32\x63\x33\x31\x34\x31\x36\x66\x38\x33\x30\x30\x32\x35\x36\x64\x37\x36\x36\x38\x65\x61\x37\x65\x36\x65\x37\x66\x30\x36\x37\x32\x37\x62\x66\x62\x39\x64\x32\x32\x30"]; var c_id = _0x2dc0[0]; var c_sec = _0x2dc0[1]; From fa67d91acd3f1be73f93a43b1ca46873816daf2a Mon Sep 17 00:00:00 2001 From: Ben Perlman Date: Thu, 6 Jun 2019 15:19:33 -0400 Subject: [PATCH 2/5] Stop error messages which can cause RN to white screen --- TeslaJS.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaJS.js b/TeslaJS.js index fdb21ca..c279fe3 100644 --- a/TeslaJS.js +++ b/TeslaJS.js @@ -132,7 +132,7 @@ exports.getPortalBaseURI = function getPortalBaseURI() { // Log error messages to the console //================================== function err(str) { - console.error(str); + console.warn(str); // console.error(str.red); } From 0c150ee814a529f494f998c4e24cba34c947b3fa Mon Sep 17 00:00:00 2001 From: Ben Perlman Date: Wed, 31 Jul 2019 12:24:11 -0400 Subject: [PATCH 3/5] Update to vehicle_data instead of data --- TeslaJS.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TeslaJS.js b/TeslaJS.js index c279fe3..7300a09 100644 --- a/TeslaJS.js +++ b/TeslaJS.js @@ -690,7 +690,7 @@ exports.startStreaming = function startStreaming(options, callback) { * @returns {object} vehicle_data object */ exports.vehicleData = function vehicleData(options, callback){ - get_command(options, "data", callback); + get_command(options, "vehicle_data", callback); } /** From a5ce63055ef9fc48437ed846ec88569071dd8079 Mon Sep 17 00:00:00 2001 From: Ben Perlman Date: Mon, 7 Oct 2019 09:13:05 -0400 Subject: [PATCH 4/5] Add Window Commands --- TeslaJS.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TeslaJS.js b/TeslaJS.js index 7300a09..9654247 100644 --- a/TeslaJS.js +++ b/TeslaJS.js @@ -789,6 +789,14 @@ exports.mediaVolumeDown = function mediaVolumeDown(options, callback) { post_command(options, "command/media_volume_down", null, callback); } +exports.ventWindows = function ventWindows(options){ + post_command(options,"command/window_control",{command: "vent"}) +} + +exports.closeWindows = function closeWindows(options){ + post_command(options,"command/window_control",{command: "close"}) +} + /** * Enable or disable sentry mode * @function setSentryMode From 95ca7e3715a53f39de0360d7d0842c06addd18bf Mon Sep 17 00:00:00 2001 From: Ben Perlman Date: Thu, 17 Oct 2019 12:42:28 -0400 Subject: [PATCH 5/5] Fix HomeLink --- TeslaJS.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TeslaJS.js b/TeslaJS.js index 9654247..f581781 100644 --- a/TeslaJS.js +++ b/TeslaJS.js @@ -599,8 +599,8 @@ exports.makeCalendarEntry = function makeCalendarEntry(eventName, location, star //============================== // Trigger homelink //============================== -exports.homelink = function homelink(options, lat, long, token, callback) { - post_command(options, "command/trigger_homelink", { lat: lat, long: long, token: token } , callback); +exports.homelink = function homelink(options, lat, lon, token, callback) { + post_command(options, "command/trigger_homelink", { lat: lat, lon: lon, token: token } , callback); } /*