Module: TeslaAPI::PrivateAPI

Included in:
Connection
Defined in:
lib/tesla-api/private_api.rb

Instance Method Summary collapse

Instance Method Details

#api_charge_state_for_vehicle(vehicle) ⇒ Object



112
113
114
115
116
# File 'lib/tesla-api/private_api.rb', line 112

def api_charge_state_for_vehicle(vehicle)
  _, json = get_json(command_url(vehicle, "charge_state"))

  ChargeState.new(json)
end

#api_climate_state_for_vehicle(vehicle) ⇒ Object



106
107
108
109
110
# File 'lib/tesla-api/private_api.rb', line 106

def api_climate_state_for_vehicle(vehicle)
  _, json = get_json(command_url(vehicle, "climate_state"))

  ClimateState.new(json)
end

#api_drive_state_for_vehicle(vehicle) ⇒ Object



100
101
102
103
104
# File 'lib/tesla-api/private_api.rb', line 100

def api_drive_state_for_vehicle(vehicle)
  _, json = get_json(command_url(vehicle, "drive_state"))

  DriveState.new(json)
end

#api_get_vehicle_state_for_vehicle(vehicle) ⇒ Object



88
89
90
91
92
# File 'lib/tesla-api/private_api.rb', line 88

def api_get_vehicle_state_for_vehicle(vehicle)
  _, json = get_json(command_url(vehicle, "vehicle_state"))

  VehicleState.new(json)
end

#api_gui_settings_for_vehicle(vehicle) ⇒ Object



94
95
96
97
98
# File 'lib/tesla-api/private_api.rb', line 94

def api_gui_settings_for_vehicle(vehicle)
  _, json = get_json(command_url(vehicle, "gui_settings"))

  GUISettings.new(json)
end

#api_mobile_access?(vehicle) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
85
86
# File 'lib/tesla-api/private_api.rb', line 82

def api_mobile_access?(vehicle)
  _, json = get_json(command_url(vehicle, "mobile_enabled"))

  json["result"] == true
end

#auto_conditioning_start!(vehicle) ⇒ Object



38
39
40
# File 'lib/tesla-api/private_api.rb', line 38

def auto_conditioning_start!(vehicle)
  command!(vehicle, "auto_conditioning_start")
end

#auto_conditioning_stop!(vehicle) ⇒ Object



34
35
36
# File 'lib/tesla-api/private_api.rb', line 34

def auto_conditioning_stop!(vehicle)
  command!(vehicle, "auto_conditioning_stop")
end

#charge_max_range!(vehicle) ⇒ Object



66
67
68
# File 'lib/tesla-api/private_api.rb', line 66

def charge_max_range!(vehicle)
  command!(vehicle, "charge_max_range")
end

#charge_standard!(vehicle) ⇒ Object



70
71
72
# File 'lib/tesla-api/private_api.rb', line 70

def charge_standard!(vehicle)
  command!(vehicle, "charge_standard")
end

#charge_start!(vehicle) ⇒ Object



62
63
64
# File 'lib/tesla-api/private_api.rb', line 62

def charge_start!(vehicle)
  command!(vehicle, "charge_start")
end

#charge_stop!(vehicle) ⇒ Object



58
59
60
# File 'lib/tesla-api/private_api.rb', line 58

def charge_stop!(vehicle)
  command!(vehicle, "charge_stop")
end

#flash_lights!(vehicle) ⇒ Object



54
55
56
# File 'lib/tesla-api/private_api.rb', line 54

def flash_lights!(vehicle)
  command!(vehicle, "flash_lights")
end

#honk_horn!(vehicle) ⇒ Object



50
51
52
# File 'lib/tesla-api/private_api.rb', line 50

def honk_horn!(vehicle)
  command!(vehicle, "honk_horn")
end

#lock_door!(vehicle) ⇒ Object



42
43
44
# File 'lib/tesla-api/private_api.rb', line 42

def lock_door!(vehicle)
  command!(vehicle, "door_lock")
end

#login(email, password) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/tesla-api/private_api.rb', line 3

def (email, password)
  params = { "user_session[email]"    => email,
             "user_session[password]" => password }

  response = @client.post(Connection::HOST + "/login", params)

  @logged_in = (response.status_code == HTTP::Status::FOUND)
end

#open_charge_port!(vehicle) ⇒ Object



78
79
80
# File 'lib/tesla-api/private_api.rb', line 78

def open_charge_port!(vehicle)
  command!(vehicle, "charge_port_open")
end

#open_roof!(vehicle, state) ⇒ Object



30
31
32
# File 'lib/tesla-api/private_api.rb', line 30

def open_roof!(vehicle, state)
  command!(vehicle, "sun_roof_control", :query => { :state => state })
end

#set_temperature!(vehicle, driver_degrees_celcius, passenger_degrees_celcius) ⇒ Object



25
26
27
28
# File 'lib/tesla-api/private_api.rb', line 25

def set_temperature!(vehicle, driver_degrees_celcius, passenger_degrees_celcius)
  command!(vehicle, "set_temps", :query => { :driver_degrees_celcius    => driver_degrees_celcius,
                                             :passenger_degrees_celcius => passenger_degrees_celcius })
end

#stream(vehicle) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tesla-api/private_api.rb', line 12

def stream(vehicle)
  raise "Doesn't work yet"

  client = HTTPClient.new

  uri = Connection::STREAMING_HOST + "/stream/#{vehicle.vehicle_id}/?values=speed,odometer,soc,elevation,est_heading,est_lat,est_lng,power,shift_state"

  client.set_basic_auth(uri, , vehicle.tokens.first)
  client.get_content(uri) do |chunk|
    p chunk
  end
end

#unlock_door!(vehicle) ⇒ Object



46
47
48
# File 'lib/tesla-api/private_api.rb', line 46

def unlock_door!(vehicle)
  command!(vehicle, "door_unlock")
end

#wake_up!(vehicle) ⇒ Object



74
75
76
# File 'lib/tesla-api/private_api.rb', line 74

def wake_up!(vehicle)
  command!(vehicle, "wake_up")
end