Class: TeslaAPI::ChargeState

Inherits:
Data
  • Object
show all
Defined in:
lib/tesla-api/charge_state.rb

Overview

Defines the current charge state of the vehicle

Instance Method Summary collapse

Methods inherited from Data

#inspect, #ivar_from_data, #method_missing, #respond_to_missing?

Constructor Details

#initialize(data) ⇒ Boolean

Returns charging via a Tesla SuperCharger.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/tesla-api/charge_state.rb', line 65

def initialize(data)
  ivar_from_data("charging_state",               "charging_state",         data)
  ivar_from_data("charging_to_max",              "charge_to_max_range",    data)
  ivar_from_data("battery_range_miles",          "battery_range",          data)
  ivar_from_data("estimated_battry_range_miles", "est_battery_range",      data)
  ivar_from_data("ideal_battery_range_miles",    "ideal_battery_range",    data)
  ivar_from_data("battery_percentage",           "battery_level",          data)
  ivar_from_data("battery_current_flow",         "battery_current",        data)
  ivar_from_data("charger_voltage",              "charger_voltage",        data)
  ivar_from_data("charger_pilot_amperage",       "charger_pilot_current",  data)
  ivar_from_data("charger_actual_amperage",      "charger_actual_current", data)
  ivar_from_data("charger_power",                "charger_power",          data)
  ivar_from_data("hours_to_full_charge",         "time_to_full_charge",    data)
  ivar_from_data("charge_rate_miles_per_hour",   "charge_rate",            data)
  ivar_from_data("charge_port_open",             "charge_port_door_open",  data)
  ivar_from_data("supercharging",                "fast_charger_present",   data)

  @charging        = charging_state == "Charging"
  @charge_complete = charging_state == "Complete"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TeslaAPI::Data

Instance Method Details

#battery_current_flowFloat

Returns Current flowing into the battery.

Returns:

  • (Float)

    Current flowing into the battery



# File 'lib/tesla-api/charge_state.rb', line 29

#battery_percentageInteger

Returns Percentage of battery charge.

Returns:

  • (Integer)

    Percentage of battery charge



# File 'lib/tesla-api/charge_state.rb', line 25

#battery_range_milesFloat

Returns Rated miles for the current charge.

Returns:

  • (Float)

    Rated miles for the current charge



# File 'lib/tesla-api/charge_state.rb', line 13

#charge_port_open?Boolean

Returns charge port open state.

Returns:

  • (Boolean)

    charge port open state



# File 'lib/tesla-api/charge_state.rb', line 57

#charge_rate_miles_per_hourFloat

Returns Miles of range being added per hour.

Returns:

  • (Float)

    Miles of range being added per hour



# File 'lib/tesla-api/charge_state.rb', line 53

#charger_actual_amperageInteger

Returns Current amperage being drawn into battery.

Returns:

  • (Integer)

    Current amperage being drawn into battery



# File 'lib/tesla-api/charge_state.rb', line 41

#charger_pilot_amperageInteger

Returns Max amperage allowed by the charger.

Returns:

  • (Integer)

    Max amperage allowed by the charger



# File 'lib/tesla-api/charge_state.rb', line 37

#charger_powerInteger

Returns Kilowatt of charger (rounded down).

Returns:

  • (Integer)

    Kilowatt of charger (rounded down)



# File 'lib/tesla-api/charge_state.rb', line 45

#charger_voltageFloat

Returns Current voltage being used to charge battery.

Returns:

  • (Float)

    Current voltage being used to charge battery



# File 'lib/tesla-api/charge_state.rb', line 33

#charging_stateObject

Returns Charging state (“Complete”, “Charging”).

Returns:

  • Charging state (“Complete”, “Charging”)



# File 'lib/tesla-api/charge_state.rb', line 5

#charging_to_max?Boolean

Returns true if currently performing a range charge.

Returns:

  • (Boolean)

    true if currently performing a range charge



# File 'lib/tesla-api/charge_state.rb', line 9

#estimated_battry_range_milesFloat

Returns Range estimated from current driving.

Returns:

  • (Float)

    Range estimated from current driving



# File 'lib/tesla-api/charge_state.rb', line 17

#hours_to_full_chargeFloat

Returns Hours remaining until the vehicle is fully charged.

Returns:

  • (Float)

    Hours remaining until the vehicle is fully charged



# File 'lib/tesla-api/charge_state.rb', line 49

#ideal_battery_range_milesFloat

Returns Ideal range for the current charge.

Returns:

  • (Float)

    Ideal range for the current charge



# File 'lib/tesla-api/charge_state.rb', line 21

#supercharging?Boolean

Returns charging via a Tesla SuperCharger.

Returns:

  • (Boolean)

    charging via a Tesla SuperCharger



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/tesla-api/charge_state.rb', line 65

def initialize(data)
  ivar_from_data("charging_state",               "charging_state",         data)
  ivar_from_data("charging_to_max",              "charge_to_max_range",    data)
  ivar_from_data("battery_range_miles",          "battery_range",          data)
  ivar_from_data("estimated_battry_range_miles", "est_battery_range",      data)
  ivar_from_data("ideal_battery_range_miles",    "ideal_battery_range",    data)
  ivar_from_data("battery_percentage",           "battery_level",          data)
  ivar_from_data("battery_current_flow",         "battery_current",        data)
  ivar_from_data("charger_voltage",              "charger_voltage",        data)
  ivar_from_data("charger_pilot_amperage",       "charger_pilot_current",  data)
  ivar_from_data("charger_actual_amperage",      "charger_actual_current", data)
  ivar_from_data("charger_power",                "charger_power",          data)
  ivar_from_data("hours_to_full_charge",         "time_to_full_charge",    data)
  ivar_from_data("charge_rate_miles_per_hour",   "charge_rate",            data)
  ivar_from_data("charge_port_open",             "charge_port_door_open",  data)
  ivar_from_data("supercharging",                "fast_charger_present",   data)

  @charging        = charging_state == "Charging"
  @charge_complete = charging_state == "Complete"
end