Class: TeslaApi::Vehicle
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Autopark
#start_autopark
Methods included from Stream
#stream, streaming_endpoint, streaming_endpoint_url
Constructor Details
#initialize(client, email, id, vehicle) ⇒ Vehicle
Returns a new instance of Vehicle.
7
8
9
10
11
12
|
# File 'lib/tesla_api/vehicle.rb', line 7
def initialize(client, email, id, vehicle)
@client = client
@email = email
@id = id
@vehicle = vehicle
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/tesla_api/vehicle.rb', line 20
def method_missing(name)
if vehicle.keys.include?(name.to_s)
vehicle[name.to_s]
else
raise NoMethodError.new("Vehicle does not have property `#{name}`", name)
end
end
|
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
5
6
7
|
# File 'lib/tesla_api/vehicle.rb', line 5
def api
@api
end
|
#client ⇒ Object
Returns the value of attribute client.
5
6
7
|
# File 'lib/tesla_api/vehicle.rb', line 5
def client
@client
end
|
#email ⇒ Object
Returns the value of attribute email.
5
6
7
|
# File 'lib/tesla_api/vehicle.rb', line 5
def email
@email
end
|
#id ⇒ Object
Returns the value of attribute id.
5
6
7
|
# File 'lib/tesla_api/vehicle.rb', line 5
def id
@id
end
|
#vehicle ⇒ Object
Returns the value of attribute vehicle.
5
6
7
|
# File 'lib/tesla_api/vehicle.rb', line 5
def vehicle
@vehicle
end
|
Instance Method Details
#[](key) ⇒ Object
16
17
18
|
# File 'lib/tesla_api/vehicle.rb', line 16
def [](key)
vehicle[key]
end
|
#activate_speed_limit(pin) ⇒ Object
168
169
170
|
# File 'lib/tesla_api/vehicle.rb', line 168
def activate_speed_limit(pin)
command('speed_limit_activate', body: {pin: pin})['response']
end
|
#auto_conditioning_start ⇒ Object
136
137
138
|
# File 'lib/tesla_api/vehicle.rb', line 136
def auto_conditioning_start
command('auto_conditioning_start')['response']
end
|
#auto_conditioning_stop ⇒ Object
140
141
142
|
# File 'lib/tesla_api/vehicle.rb', line 140
def auto_conditioning_stop
command('auto_conditioning_stop')['response']
end
|
#cancel_software_update ⇒ Object
201
202
203
|
# File 'lib/tesla_api/vehicle.rb', line 201
def cancel_software_update
command('cancel_software_update')['response']
end
|
#charge_max_range ⇒ Object
96
97
98
|
# File 'lib/tesla_api/vehicle.rb', line 96
def charge_max_range
command('charge_max_range')['response']
end
|
#charge_port_door_close ⇒ Object
88
89
90
|
# File 'lib/tesla_api/vehicle.rb', line 88
def charge_port_door_close
command('charge_port_door_close')['response']
end
|
#charge_port_door_open ⇒ Object
84
85
86
|
# File 'lib/tesla_api/vehicle.rb', line 84
def charge_port_door_open
command('charge_port_door_open')['response']
end
|
#charge_standard ⇒ Object
92
93
94
|
# File 'lib/tesla_api/vehicle.rb', line 92
def charge_standard
command('charge_standard')['response']
end
|
#charge_start ⇒ Object
104
105
106
|
# File 'lib/tesla_api/vehicle.rb', line 104
def charge_start
command('charge_start')['response']
end
|
#charge_state ⇒ Object
50
51
52
|
# File 'lib/tesla_api/vehicle.rb', line 50
def charge_state
data_request('charge_state')['response']
end
|
#charge_stop ⇒ Object
108
109
110
|
# File 'lib/tesla_api/vehicle.rb', line 108
def charge_stop
command('charge_stop')['response']
end
|
#clear_speed_limit_pin(pin) ⇒ Object
180
181
182
|
# File 'lib/tesla_api/vehicle.rb', line 180
def clear_speed_limit_pin(pin)
command('speed_limit_clear_pin', body: {pin: pin})['response']
end
|
#climate_state ⇒ Object
54
55
56
|
# File 'lib/tesla_api/vehicle.rb', line 54
def climate_state
data_request('climate_state')['response']
end
|
#data ⇒ Object
34
35
36
|
# File 'lib/tesla_api/vehicle.rb', line 34
def data
client.get("/vehicles/#{id}/data")['response']
end
|
#deactivate_speed_limit(pin) ⇒ Object
172
173
174
|
# File 'lib/tesla_api/vehicle.rb', line 172
def deactivate_speed_limit(pin)
command('speed_limit_deactivate', body: {pin: pin})['response']
end
|
#door_lock ⇒ Object
124
125
126
|
# File 'lib/tesla_api/vehicle.rb', line 124
def door_lock
command('door_lock')['response']
end
|
#door_unlock ⇒ Object
120
121
122
|
# File 'lib/tesla_api/vehicle.rb', line 120
def door_unlock
command('door_unlock')['response']
end
|
#drive_state ⇒ Object
58
59
60
|
# File 'lib/tesla_api/vehicle.rb', line 58
def drive_state
data_request('drive_state')['response']
end
|
#flash_lights ⇒ Object
112
113
114
|
# File 'lib/tesla_api/vehicle.rb', line 112
def flash_lights
command('flash_lights')['response']
end
|
#gui_settings ⇒ Object
46
47
48
|
# File 'lib/tesla_api/vehicle.rb', line 46
def gui_settings
data_request('gui_settings')['response']
end
|
#honk_horn ⇒ Object
116
117
118
|
# File 'lib/tesla_api/vehicle.rb', line 116
def honk_horn
command('honk_horn')['response']
end
|
233
234
235
|
# File 'lib/tesla_api/vehicle.rb', line 233
def media_next_fav
command('media_next_fav')['response']
end
|
225
226
227
|
# File 'lib/tesla_api/vehicle.rb', line 225
def media_next_track
command('media_next_track')['response']
end
|
237
238
239
|
# File 'lib/tesla_api/vehicle.rb', line 237
def media_prev_fav
command('media_prev_fav')['response']
end
|
229
230
231
|
# File 'lib/tesla_api/vehicle.rb', line 229
def media_prev_track
command('media_prev_track')['response']
end
|
221
222
223
|
# File 'lib/tesla_api/vehicle.rb', line 221
def media_toggle_playback
command('media_toggle_playback')['response']
end
|
245
246
247
|
# File 'lib/tesla_api/vehicle.rb', line 245
def media_volume_down
command('media_volume_down')['response']
end
|
241
242
243
|
# File 'lib/tesla_api/vehicle.rb', line 241
def media_volume_up
command('media_volume_up')['response']
end
|
#mobile_enabled ⇒ Object
38
39
40
|
# File 'lib/tesla_api/vehicle.rb', line 38
def mobile_enabled
client.get("/vehicles/#{id}/mobile_enabled")['response']
end
|
#navigation_request(address) ⇒ Object
184
185
186
187
188
189
190
191
|
# File 'lib/tesla_api/vehicle.rb', line 184
def navigation_request(address)
command('navigation_request', body: {
type: 'share_ext_content_raw',
locale: 'en-US',
timestamp_ms: Time.now.to_i,
value: {'android.intent.extra.TEXT' => address}
})['response']
end
|
#nearby_charging_sites ⇒ Object
42
43
44
|
# File 'lib/tesla_api/vehicle.rb', line 42
def nearby_charging_sites
client.get("/vehicles/#{id}/nearby_charging_sites")['response']
end
|
#open_frunk ⇒ Object
164
165
166
|
# File 'lib/tesla_api/vehicle.rb', line 164
def open_frunk
command('actuate_trunk', body: {which_trunk: 'front'})['response']
end
|
#open_trunk ⇒ Object
160
161
162
|
# File 'lib/tesla_api/vehicle.rb', line 160
def open_trunk
command('actuate_trunk', body: {which_trunk: 'rear'})['response']
end
|
#remote_start_drive(password) ⇒ Object
156
157
158
|
# File 'lib/tesla_api/vehicle.rb', line 156
def remote_start_drive(password)
command('remote_start_drive', body: {password: password})['response']
end
|
#reset_valet_pin ⇒ Object
80
81
82
|
# File 'lib/tesla_api/vehicle.rb', line 80
def reset_valet_pin
command('reset_valet_pin')['response']
end
|
#schedule_software_update(offset_sec = 0) ⇒ Object
197
198
199
|
# File 'lib/tesla_api/vehicle.rb', line 197
def schedule_software_update(offset_sec = 0)
command('schedule_software_update', body: {offset_sec: offset_sec})['response']
end
|
#set_charge_limit(percent) ⇒ Object
100
101
102
|
# File 'lib/tesla_api/vehicle.rb', line 100
def set_charge_limit(percent)
command('set_charge_limit', body: {percent: percent.to_i})['response']
end
|
#set_preconditioning_max(on) ⇒ Object
132
133
134
|
# File 'lib/tesla_api/vehicle.rb', line 132
def set_preconditioning_max(on)
command('set_preconditioning_max', body: {on: on})['response']
end
|
#set_seat_heater(heater, level) ⇒ Object
205
206
207
|
# File 'lib/tesla_api/vehicle.rb', line 205
def set_seat_heater(heater, level)
command('remote_seat_heater_request', body: {heater: heater, level: level})['response']
end
|
#set_sentry_mode(on) ⇒ Object
213
214
215
|
# File 'lib/tesla_api/vehicle.rb', line 213
def set_sentry_mode(on)
command('set_sentry_mode', body: {on: on})['response']
end
|
#set_speed_limit(limit_mph) ⇒ Object
176
177
178
|
# File 'lib/tesla_api/vehicle.rb', line 176
def set_speed_limit(limit_mph)
command('speed_limit_set_limit', body: {limit_mph: limit_mph})['response']
end
|
#set_steering_wheel_heater(on) ⇒ Object
209
210
211
|
# File 'lib/tesla_api/vehicle.rb', line 209
def set_steering_wheel_heater(on)
command('remote_steering_wheel_heater_request', body: {on: on})['response']
end
|
#set_temps(driver_temp, passenger_temp) ⇒ Object
128
129
130
|
# File 'lib/tesla_api/vehicle.rb', line 128
def set_temps(driver_temp, passenger_temp)
command('set_temps', body: {driver_temp: driver_temp, passenger_temp: passenger_temp})['response']
end
|
#set_valet_mode(on, password = nil) ⇒ Object
76
77
78
|
# File 'lib/tesla_api/vehicle.rb', line 76
def set_valet_mode(on, password=nil)
command('set_valet_mode', body: {on: on, password: password})['response']
end
|
#share(text) ⇒ Object
193
194
195
|
# File 'lib/tesla_api/vehicle.rb', line 193
def share(text)
navigation_request(text)
end
|
#sun_roof_control(state) ⇒ Object
144
145
146
|
# File 'lib/tesla_api/vehicle.rb', line 144
def sun_roof_control(state)
command('sun_roof_control', body: {state: state})['response']
end
|
#sun_roof_move(percent) ⇒ Object
148
149
150
|
# File 'lib/tesla_api/vehicle.rb', line 148
def sun_roof_move(percent)
command('sun_roof_control', body: {state: 'move', percent: percent})['response']
end
|
#trigger_homelink(lat, lon) ⇒ Object
217
218
219
|
# File 'lib/tesla_api/vehicle.rb', line 217
def trigger_homelink(lat, lon)
command('trigger_homelink', body: {lat: lat, lon: lon})['response']
end
|
#vehicle_config ⇒ Object
66
67
68
|
# File 'lib/tesla_api/vehicle.rb', line 66
def vehicle_config
data_request('vehicle_config')['response']
end
|
#vehicle_data ⇒ Object
30
31
32
|
# File 'lib/tesla_api/vehicle.rb', line 30
def vehicle_data
client.get("/vehicles/#{id}/vehicle_data")['response']
end
|
#vehicle_state ⇒ Object
62
63
64
|
# File 'lib/tesla_api/vehicle.rb', line 62
def vehicle_state
data_request('vehicle_state')['response']
end
|
#wake_up ⇒ Object
72
73
74
|
# File 'lib/tesla_api/vehicle.rb', line 72
def wake_up
@vehicle = client.post("/vehicles/#{id}/wake_up")['response']
end
|
#window_control(command) ⇒ Object
152
153
154
|
# File 'lib/tesla_api/vehicle.rb', line 152
def window_control(command)
command('window_control', body: {command: command, lat: 0, lon: 0})['response']
end
|