Class: TeslaAPI::Connection
- Inherits:
-
Object
- Object
- TeslaAPI::Connection
- Includes:
- PrivateAPI
- Defined in:
- lib/tesla-api/connection.rb
Overview
Connection object to the Tesla Model S HTTP API endpoint.
Constant Summary collapse
- HOST =
Host for status/command related API
"https://portal.vn.teslamotors.com"
- STREAMING_HOST =
Host for streaming API
"https://streaming.vn.teslamotors.com"
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
email address of logged in user.
-
#password ⇒ Object
readonly
password of logged in user.
Instance Method Summary collapse
-
#debug! ⇒ Object
Call to see all HTTP traffic to and from the API.
-
#initialize(email, password) ⇒ Connection
constructor
Supply the email and password for login to teslamotors.com.
-
#logged_in? ⇒ Boolean
Logged into the API.
-
#reload! ⇒ Object
Force the vehicles to reload (in case some of the data has changed).
-
#vehicle ⇒ Object
Convenience method to return the first Vehicle.
-
#vehicles ⇒ Object
Returns Vehicle objects for all vehicles the account contains.
Methods included from PrivateAPI
#api_charge_state_for_vehicle, #api_climate_state_for_vehicle, #api_drive_state_for_vehicle, #api_get_vehicle_state_for_vehicle, #api_gui_settings_for_vehicle, #api_mobile_access?, #auto_conditioning_start!, #auto_conditioning_stop!, #charge_max_range!, #charge_standard!, #charge_start!, #charge_stop!, #flash_lights!, #honk_horn!, #lock_door!, #login, #open_charge_port!, #open_roof!, #set_temperature!, #stream, #unlock_door!, #wake_up!
Constructor Details
#initialize(email, password) ⇒ Connection
Supply the email and password for login to teslamotors.com
19 20 21 22 23 24 25 26 27 |
# File 'lib/tesla-api/connection.rb', line 19 def initialize(email, password) @email = email @password = password @client = HTTPClient.new @client.("cookie.dat") login(email, password) end |
Instance Attribute Details
#email ⇒ Object (readonly)
email address of logged in user
7 8 9 |
# File 'lib/tesla-api/connection.rb', line 7 def email @email end |
#password ⇒ Object (readonly)
password of logged in user
10 11 12 |
# File 'lib/tesla-api/connection.rb', line 10 def password @password end |
Instance Method Details
#debug! ⇒ Object
Call to see all HTTP traffic to and from the API
30 31 32 |
# File 'lib/tesla-api/connection.rb', line 30 def debug! @client.debug_dev = STDOUT end |
#logged_in? ⇒ Boolean
Logged into the API
53 54 55 |
# File 'lib/tesla-api/connection.rb', line 53 def logged_in? @logged_in end |
#reload! ⇒ Object
Force the vehicles to reload (in case some of the data has changed)
48 49 50 |
# File 'lib/tesla-api/connection.rb', line 48 def reload! @vehicles = nil end |
#vehicle ⇒ Object
Convenience method to return the first Vehicle
35 36 37 |
# File 'lib/tesla-api/connection.rb', line 35 def vehicle vehicles.first end |