Kalud
Active Member
Are there any fields for seat heaters or steering wheel heater?
There are but only to see their status. Unfortunately still nothing to remotely turn them ON...
See: Model S REST API - Page 126
You can install our site as a web app on your iOS device by utilizing the Add to Home Screen feature in Safari. Please see this thread for more details on this.
Note: This feature may not be available in some browsers.
Are there any fields for seat heaters or steering wheel heater?
That's too bad I care far more about turning them on than reading the status.There are but only to see their status. Unfortunately still nothing to remotely turn them ON...
See: Model S REST API - Page 126
'Accept-Encoding': 'gzip,deflate'
Discovered that some of the REST endpoints (like /vehicles/{id}/data_request/charge_state) are returning gzip compressed results as of firmware 2.9.x
I had copied the HTTP header properties from the mobile apps includingbut my client code did not properly handle responses with a compressed (binary) body. It does now. Thought others might want to know as well.Code:'Accept-Encoding': 'gzip,deflate'
So far I only see this on the charge_state endpoint but it might be a sign of things to come.
Not really - it just means that a client that tells the server that it accepts gzip,deflate actually needs to support it if the backend then sends compressed dataPardon my ignorance when it comes to APIs and software development, but is that bad?
Pardon my ignorance when it comes to APIs and software development, but is that bad?
Jeff
I don't think there is currently a way in the API to limit the current draw but given rbergquist's post #1363 it looks as if that may be coming soon. For now you would have to use the car's screen to do that.I'm looking to install this with a solar system. I want to limit the car to only draw excess solar. This will be more important when i get my new charger but at the moment i want to limit the charge current. I can't find that in the documentation. Has anyone found this command?
What would be the reason for doing this? Aren't the results that are returned just a few bytes or so? Why would you care about compressing that?Discovered that some of the REST endpoints (like /vehicles/{id}/data_request/charge_state) are returning gzip compressed results as of firmware 2.9.x
What would be the reason for doing this? Aren't the results that are returned just a few bytes or so? Why would you care about compressing that?
charge_state is 1200 bytes, give or take, in JSON text form. That begins to add up quickly when you consider the number of cars (especially model 3) and what might be interacting with these cars (charging stations, home automation, mobile apps, etc.). Sure, right now it's probably limited if it's only the mobile app interacting with a small segment of 100,000 cars every other day or so - but there are many more applications that haven't been applied yet.
Even so, it's very simple to compress the data, just another line in the code (if accept_encoding includes gzip, compress(body)) - so why not?
Are people using other's libraries (node implementation, for instance), or have you mostly written your own?
I'm considering rewriting pytesla, since that's been abandoned for a while. I use Indigo Domotics for Mac and would like to make it a plugin. If anyone has any python implementations I can work off of, that would be helpful.
Not aware of an API here, but I do know that another user was talking in a thread somewhere about modifying a HPWC to do that automatically by changing how much current it told the car it could supply and doing so on the fly to match his solar output. Maybe try some site searches and see if he ever got anywhere with it.I'm looking to install this with a solar system. I want to limit the car to only draw excess solar. This will be more important when i get my new charger but at the moment i want to limit the charge current. I can't find that in the documentation. Has anyone found this command?
Are people using other's libraries (node implementation, for instance), or have you mostly written your own?
I'm considering rewriting pytesla, since that's been abandoned for a while. I use Indigo Domotics for Mac and would like to make it a plugin. If anyone has any python implementations I can work off of, that would be helpful.
<?php
class SimpleTeslaAPI {
// Quick&Dirty Tesla API
// V1.1
// by [email protected]
var $token;
var $vehicleID;
function SimpleTeslaAPI() {
// !!!!!!!!! set token and vehicle_id (example out of mobile app "Remote S") !!!!!!!!!
$this->token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$this->vehicleID = "xxxxxxxxxx";
}
private function curlexec($command,$mode="GET",$params=array()) {
$url = 'https://owner-api.teslamotors.com/';
$ch = curl_init();
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
$params['vehicle_id']=$this->vehicleID;
if ( $mode == "POST" ) {
if ( $command == "oauth/token" ) {
curl_setopt($ch,CURLOPT_URL, $url.$command);
} else {
if ( $command == "wake_up" ) {
curl_setopt($ch,CURLOPT_URL, $url."api/1/vehicles/".$this->vehicleID."/wake_up");
} else {
curl_setopt($ch,CURLOPT_URL, $url."api/1/vehicles/".$this->vehicleID."/command/".$command);
}
curl_setopt($ch,CURLOPT_HTTPHEADER, array("Authorization:Bearer ".$this->token) );
}
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $params);
} else {
if ( $command == "vehicles" ) {
curl_setopt($ch,CURLOPT_URL, $url."api/1/vehicles");
} else {
curl_setopt($ch,CURLOPT_URL, $url."api/1/vehicles/".$this->vehicleID."/data_request/".$command."?".join("&",$params));
}
curl_setopt($ch,CURLOPT_HTTPHEADER, array("Authorization:Bearer ".$this->token) );
}
$result = curl_exec($ch);
$rc=curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return json_decode($result);
}
//basic functions
function vehicles() {
return $this->curlexec("vehicles","GET");
}
function wake_up() {
return $this->curlexec("wake_up","POST");
}
//data-requests
function charge_state() {
return $this->curlexec("charge_state","GET");
}
function climate_state() {
return $this->curlexec("climate_state","GET");
}
function drive_state() {
return $this->curlexec("drive_state","GET");
}
function gui_settings() {
return $this->curlexec("gui_settings","GET");
}
function vehicle_state() {
return $this->curlexec("vehicle_state","GET");
}
// commands
function charge_port_door_open() {
return $this->curlexec("charge_port_door_open","POST");
}
function charge_standard() {
return $this->curlexec("charge_standard","POST");
}
function charge_max_range() {
return $this->curlexec("charge_max_range","POST");
}
function set_charge_limit($percent) {
return $this->curlexec("set_charge_limit","POST",array("percent" => $percent ));
}
function charge_start() {
return $this->curlexec("charge_start","POST");
}
function charge_stop() {
return $this->curlexec("charge_stop","POST");
}
function flash_lights() {
return $this->curlexec("flash_lights","POST");
}
function honk_horn() {
return $this->curlexec("honk_horn","POST");
}
function door_unlock() {
return $this->curlexec("door_unlock","POST");
}
function door_lock() {
return $this->curlexec("door_lock","POST");
}
function set_temps($tempDriver, $tempPassenger) {
return $this->curlexec("set_temps","POST",array("driver_temp" => $tempDriver,"passenger_temp" => $tempPassenger ));
}
function auto_conditioning_start() {
return $this->curlexec("auto_conditioning_start","POST");
}
function auto_conditioning_stop() {
return $this->curlexec("auto_conditioning_stop","POST");
}
function sun_roof_control_state($state) {
return $this->curlexec("sun_roof_control","POST",array("state" => $state ));
}
function sun_roof_control_percent($percent) {
return $this->curlexec("sun_roof_control","POST",array("state" => "move", "percent" => $percent ));
}
function remote_start_drive($password) {
return $this->curlexec("remote_start_drive","POST",array("password" => $password ));
}
// deprecated
function trunk_open() {
return $this->curlexec("trunk_open","POST",array("which_trunk" => "rear" ));
}
}
// Main
$tesla = new SimpleTeslaAPI();
print_r($tesla->honk_horn());
print_r($tesla->set_temps(22,22));
<?php
class SimpleTeslaAPI {
// Quick&Dirty Tesla API
// V1.1
// by [email protected]
var $token;
var $vehicleID;
function SimpleTeslaAPI() {
// !!!!!!!!! set token and vehicle_id (example out of App "Remote S" !!!!!!!!!
$this->token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$this->vehicleID = "xxxxxxxxxx";
}
private function curlexec($command,$mode="GET",$params=array()) {
$url = 'https://owner-api.teslamotors.com/';
$ch = curl_init();
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
$params['vehicle_id']=$this->vehicleID;
if ( $mode == "POST" ) {
if ( $command == "oauth/token" ) {
curl_setopt($ch,CURLOPT_URL, $url.$command);
} else {
if ( $command == "wake_up" ) {
curl_setopt($ch,CURLOPT_URL, $url."api/1/vehicles/".$this->vehicleID."/wake_up");
} else {
curl_setopt($ch,CURLOPT_URL, $url."api/1/vehicles/".$this->vehicleID."/command/".$command);
}
curl_setopt($ch,CURLOPT_HTTPHEADER, array("Authorization:Bearer ".$this->token) );
}
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $params);
} else {
if ( $command == "vehicles" ) {
curl_setopt($ch,CURLOPT_URL, $url."api/1/vehicles");
} else {
curl_setopt($ch,CURLOPT_URL, $url."api/1/vehicles/".$this->vehicleID."/data_request/".$command."?".join("&",$params));
}
curl_setopt($ch,CURLOPT_HTTPHEADER, array("Authorization:Bearer ".$this->token) );
}
$result = curl_exec($ch);
$rc=curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
return json_decode($result);
}
//basic functions
function vehicles() {
return $this->curlexec("vehicles","GET");
}
function wake_up() {
return $this->curlexec("wake_up","POST");
}
//data-requests
function charge_state() {
return $this->curlexec("charge_state","GET");
}
function climate_state() {
return $this->curlexec("climate_state","GET");
}
function drive_state() {
return $this->curlexec("drive_state","GET");
}
function gui_settings() {
return $this->curlexec("gui_settings","GET");
}
function vehicle_state() {
return $this->curlexec("vehicle_state","GET");
}
// commands
function charge_port_door_open() {
return $this->curlexec("charge_port_door_open","POST");
}
function charge_standard() {
return $this->curlexec("charge_standard","POST");
}
function charge_max_range() {
return $this->curlexec("charge_max_range","POST");
}
function set_charge_limit($percent) {
return $this->curlexec("set_charge_limit","POST",array("percent" => $percent ));
}
function charge_start() {
return $this->curlexec("charge_start","POST");
}
function charge_stop() {
return $this->curlexec("charge_stop","POST");
}
function flash_lights() {
return $this->curlexec("flash_lights","POST");
}
function honk_horn() {
return $this->curlexec("honk_horn","POST");
}
function door_unlock() {
return $this->curlexec("door_unlock","POST");
}
function door_lock() {
return $this->curlexec("door_lock","POST");
}
function set_temps($tempDriver, $tempPassenger) {
return $this->curlexec("set_temps","POST",array("driver_temp" => $tempDriver,"passenger_temp" => $tempPassenger ));
}
function auto_conditioning_start() {
return $this->curlexec("auto_conditioning_start","POST");
}
function auto_conditioning_stop() {
return $this->curlexec("auto_conditioning_stop","POST");
}
function sun_roof_control_state($state) {
return $this->curlexec("sun_roof_control","POST",array("state" => $state ));
}
function sun_roof_control_percent($percent) {
return $this->curlexec("sun_roof_control","POST",array("state" => "move", "percent" => $percent ));
}
function remote_start_drive($password) {
return $this->curlexec("remote_start_drive","POST",array("password" => $password ));
}
// deprecated
function trunk_open() {
return $this->curlexec("trunk_open","POST",array("which_trunk" => "rear" ));
}
}
// Main
$tesla = new SimpleTeslaAPI();
print_r($tesla->honk_horn());
print_r($tesla->set_temps(22,22));