Class: TeslaApi::Vehicle
- Inherits:
-
Object
show all
- Includes:
- Stream
- Defined in:
- lib/tesla_api/vehicle.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Stream
#stream
Constructor Details
#initialize(api, email, id, vehicle) ⇒ Vehicle
Returns a new instance of Vehicle.
6
7
8
9
10
11
|
# File 'lib/tesla_api/vehicle.rb', line 6
def initialize(api, email, id, vehicle)
@api = api
@email = email
@id = id
@vehicle = vehicle
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/tesla_api/vehicle.rb', line 19
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.
4
5
6
|
# File 'lib/tesla_api/vehicle.rb', line 4
def api
@api
end
|
#email ⇒ Object
Returns the value of attribute email.
4
5
6
|
# File 'lib/tesla_api/vehicle.rb', line 4
def email
@email
end
|
#id ⇒ Object
Returns the value of attribute id.
4
5
6
|
# File 'lib/tesla_api/vehicle.rb', line 4
def id
@id
end
|
#vehicle ⇒ Object
Returns the value of attribute vehicle.
4
5
6
|
# File 'lib/tesla_api/vehicle.rb', line 4
def vehicle
@vehicle
end
|
Instance Method Details
#[](key) ⇒ Object
15
16
17
|
# File 'lib/tesla_api/vehicle.rb', line 15
def [](key)
vehicle[key]
end
|
#auto_conditioning_start ⇒ Object
111
112
113
|
# File 'lib/tesla_api/vehicle.rb', line 111
def auto_conditioning_start
command("auto_conditioning_start")["response"]
end
|
#auto_conditioning_stop ⇒ Object
115
116
117
|
# File 'lib/tesla_api/vehicle.rb', line 115
def auto_conditioning_stop
command("auto_conditioning_stop")["response"]
end
|
#charge_max_range ⇒ Object
75
76
77
|
# File 'lib/tesla_api/vehicle.rb', line 75
def charge_max_range
command("charge_max_range")["response"]
end
|
#charge_port_door_open ⇒ Object
67
68
69
|
# File 'lib/tesla_api/vehicle.rb', line 67
def charge_port_door_open
command("charge_port_door_open")["response"]
end
|
#charge_standard ⇒ Object
71
72
73
|
# File 'lib/tesla_api/vehicle.rb', line 71
def charge_standard
command("charge_standard")["response"]
end
|
#charge_start ⇒ Object
83
84
85
|
# File 'lib/tesla_api/vehicle.rb', line 83
def charge_start
command("charge_start")["response"]
end
|
#charge_state ⇒ Object
37
38
39
|
# File 'lib/tesla_api/vehicle.rb', line 37
def charge_state
data_request("charge_state")["response"]
end
|
#charge_stop ⇒ Object
87
88
89
|
# File 'lib/tesla_api/vehicle.rb', line 87
def charge_stop
command("charge_stop")["response"]
end
|
#climate_state ⇒ Object
41
42
43
|
# File 'lib/tesla_api/vehicle.rb', line 41
def climate_state
data_request("climate_state")["response"]
end
|
#door_lock ⇒ Object
103
104
105
|
# File 'lib/tesla_api/vehicle.rb', line 103
def door_lock
command("door_lock")["response"]
end
|
#door_unlock ⇒ Object
99
100
101
|
# File 'lib/tesla_api/vehicle.rb', line 99
def door_unlock
command("door_unlock")["response"]
end
|
#drive_state ⇒ Object
45
46
47
|
# File 'lib/tesla_api/vehicle.rb', line 45
def drive_state
data_request("drive_state")["response"]
end
|
#flash_lights ⇒ Object
91
92
93
|
# File 'lib/tesla_api/vehicle.rb', line 91
def flash_lights
command("flash_lights")["response"]
end
|
#gui_settings ⇒ Object
33
34
35
|
# File 'lib/tesla_api/vehicle.rb', line 33
def gui_settings
data_request("gui_settings")["response"]
end
|
#honk_horn ⇒ Object
95
96
97
|
# File 'lib/tesla_api/vehicle.rb', line 95
def honk_horn
command("honk_horn")["response"]
end
|
#mobile_enabled ⇒ Object
29
30
31
|
# File 'lib/tesla_api/vehicle.rb', line 29
def mobile_enabled
api.get("/vehicles/#{id}/mobile_enabled")["response"]
end
|
#open_frunk ⇒ Object
135
136
137
|
# File 'lib/tesla_api/vehicle.rb', line 135
def open_frunk
command("trunk_open", body: {which_trunk: "rear"})
end
|
#open_trunk ⇒ Object
131
132
133
|
# File 'lib/tesla_api/vehicle.rb', line 131
def open_trunk
command("trunk_open", body: {which_trunk: "rear"})
end
|
#remote_start_drive(password) ⇒ Object
127
128
129
|
# File 'lib/tesla_api/vehicle.rb', line 127
def remote_start_drive(password)
command("remote_start_drive", body: {password: password})["response"]
end
|
#reset_valet_pin ⇒ Object
63
64
65
|
# File 'lib/tesla_api/vehicle.rb', line 63
def reset_valet_pin
command("reset_valet_pin")["response"]
end
|
#set_charge_limit(percent) ⇒ Object
79
80
81
|
# File 'lib/tesla_api/vehicle.rb', line 79
def set_charge_limit(percent)
command("set_charge_limit", body: {percent: percent})["response"]
end
|
#set_temps(driver_temp, passenger_temp) ⇒ Object
107
108
109
|
# File 'lib/tesla_api/vehicle.rb', line 107
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
59
60
61
|
# File 'lib/tesla_api/vehicle.rb', line 59
def set_valet_mode(on, password=nil)
command("set_valet_mode", body: {on: on, password: password})["response"]
end
|
#sun_roof_control(state) ⇒ Object
119
120
121
|
# File 'lib/tesla_api/vehicle.rb', line 119
def sun_roof_control(state)
command("sun_roof_control", body: {state: state})["response"]
end
|
#sun_roof_move(percent) ⇒ Object
123
124
125
|
# File 'lib/tesla_api/vehicle.rb', line 123
def sun_roof_move(percent)
command("sun_roof_control", body: {state: "move", percent: percent})["response"]
end
|
#vehicle_state ⇒ Object
49
50
51
|
# File 'lib/tesla_api/vehicle.rb', line 49
def vehicle_state
data_request("vehicle_state")["response"]
end
|
#wake_up ⇒ Object
55
56
57
|
# File 'lib/tesla_api/vehicle.rb', line 55
def wake_up
@vehicle = api.post("/vehicles/#{id}/wake_up")["response"]
end
|