Skip to content

Commit

Permalink
Merge pull request #3 from briangru/master
Browse files Browse the repository at this point in the history
Master
  • Loading branch information
razfriman authored Mar 27, 2017
2 parents dee6180 + fe1074e commit e2b4a81
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 1 deletion.
91 changes: 90 additions & 1 deletion TeslaLib/Models/ChargeStateStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,94 @@

namespace TeslaLib.Models
{
/*
* {"response":
* {"charging_state":"Charging",
* "charge_limit_soc":81,
* "charge_limit_soc_std":90,
* "charge_limit_soc_min":50,
* "charge_limit_soc_max":100,
* "charge_to_max_range":false,
* "battery_heater_on":false,
* "not_enough_power_to_heat":false,
* "max_range_charge_counter":0,
* "fast_charger_present":false,
* "fast_charger_type":"<invalid>",
* "battery_range":212.05,
* "est_battery_range":222.92,
* "ideal_battery_range":245.31,
* "battery_level":80,
* "usable_battery_level":80,
* "battery_current":9.2,
* "charge_energy_added":11.36,
* "charge_miles_added_rated":38.5,
* "charge_miles_added_ideal":44.5,
* "charger_voltage":242,
* "charger_pilot_current":40,
* "charger_actual_current":17,
* "charger_power":4,
* "time_to_full_charge":0.08,
* "trip_charging":false,
* "charge_rate":9.1,
* "charge_port_door_open":true,
* "motorized_charge_port":false,
* "scheduled_charging_start_time":null,
* "scheduled_charging_pending":false,
* "user_charge_enable_request":null,
* "charge_enable_request":true,
* "eu_vehicle":false,
* "charger_phases":1,
* "charge_port_latch":"Engaged",
* "charge_current_request":40,
* "charge_current_request_max":40,
* "managed_charging_active":false,
* "managed_charging_user_canceled":false,
* "managed_charging_start_time":null}}
*
*
* // While SuperCharging
* "charging_state": "Charging",
"battery_current": 206.7,
"battery_heater_on": false,
"battery_level": 47,
"battery_range": 125.08,
"charge_enable_request": true,
"charge_limit_soc": 95,
"charge_limit_soc_max": 100,
"charge_limit_soc_min": 50,
"charge_limit_soc_std": 90,
"charge_port_door_open": true,
"charge_rate": 342.6,
"charge_to_max_range": true,
"charger_actual_current": 0,
"charger_pilot_current": 0,
"charger_power": 78,
"charger_voltage": 377,
"est_battery_range": 117.77,
"fast_charger_present": true,
"ideal_battery_range": 144.71,
"max_range_charge_counter": 0,
"not_enough_power_to_heat": false,
"scheduled_charging_pending": false,
"scheduled_charging_start_time": null,
"time_to_full_charge": 0.83,
"user_charge_enable_request": null,
"trip_charging": false,
"charger_phases": null,
"motorized_charge_port": false,
"fast_charger_type": "Tesla",
"usable_battery_level": 47,
"charge_energy_added": 29.44,
"charge_miles_added_rated": 100.0,
"charge_miles_added_ideal": 115.5,
"eu_vehicle": false,
"charge_port_latch": "Engaged",
"charge_current_request": 80,
"charge_current_request_max": 80,
"managed_charging_active": false,
"managed_charging_user_canceled": false,
"managed_charging_start_time": null
*/
public class ChargeStateStatus
{
[JsonProperty(PropertyName = "charging_state")]
Expand Down Expand Up @@ -84,8 +172,9 @@ public class ChargeStateStatus
[JsonProperty(PropertyName = "scheduled_charging_pending")]
public bool ScheduledChargingPending { get; set; }

// This is a Unix time value in seconds from 1970 in UTC.
[JsonProperty(PropertyName = "scheduled_charging_start_time")]
public DateTime? ScheduledChargingStartTime { get; set; }
public long? ScheduledChargingStartTime { get; set; }

[JsonProperty(PropertyName = "time_to_full_charge")]
public double? TimeUntilFullCharge { get; set; }
Expand Down
14 changes: 14 additions & 0 deletions TeslaLib/Models/VehicleOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public VehicleOptions(string optionCodes)

public int YearModel { get; set; }

public Model Model { get; set; }

public TrimLevel TrimLevel { get; set; }

public DriverSide DriverSide { get; set; }
Expand Down Expand Up @@ -129,6 +131,9 @@ public void ParseOptionCodes(string optionCodes)
case "X025":
HasPerformancePowertrain = false;
break;
case "MDLX":
Model = Model.X;
break;
}

string value2 = option.Substring(2, 2);
Expand All @@ -137,6 +142,7 @@ public void ParseOptionCodes(string optionCodes)
{
case "MS":
YearModel = int.Parse(value2);
Model = Model.S;
break;
case "RE":
Region = Extensions.ToEnum<Region>(value2);
Expand Down Expand Up @@ -316,4 +322,12 @@ public enum DriverSide
[EnumMember(Value = "RH")]
RIGHT_HAND_DRIVE,
}

public enum Model
{
Unknown,
S,
X,
Three
}
}
1 change: 1 addition & 0 deletions TeslaLib/TeslaLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Compile Include="Converters\VehicleOptionsConverter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="ownerapi_endpoints.json" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
Expand Down
167 changes: 167 additions & 0 deletions TeslaLib/ownerapi_endpoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"AUTHENTICATE": {
"TYPE": "POST",
"URI": "oauth/token",
"AUTH": false
},
"REVOKE_AUTH_TOKEN": {
"TYPE": "POST",
"URI": "oauth/revoke",
"AUTH": true
},
"VEHICLE_LIST": {
"TYPE": "GET",
"URI": "api/1/vehicles",
"AUTH": true
},
"VEHICLE_SUMMARY": {
"TYPE": "GET",
"URI": "api/1/vehicles/{vehicle_id}",
"AUTH": true
},
"VEHICLE_DATA": {
"TYPE": "GET",
"URI": "api/1/vehicles/{vehicle_id}/data",
"AUTH": true
},
"WAKE_UP": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/wake_up",
"AUTH": true
},
"UNLOCK": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/door_unlock",
"AUTH": true
},
"LOCK": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/door_lock",
"AUTH": true
},
"HONK_HORN": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/honk_horn",
"AUTH": true
},
"FLASH_LIGHTS": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/flash_lights",
"AUTH": true
},
"CLIMATE_ON": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/auto_conditioning_start",
"AUTH": true
},
"CLIMATE_OFF": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop",
"AUTH": true
},
"CHANGE_CLIMATE_TEMPERATURE_SETTING": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/set_temps",
"AUTH": true
},
"CHANGE_CHARGE_LIMIT": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/set_charge_limit",
"AUTH": true
},
"CHANGE_SUNROOF_STATE": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/sun_roof_control",
"AUTH": true
},
"REMOTE_START": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/remote_start_drive",
"AUTH": true
},
"CHARGE_PORT_DOOR_OPEN": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/charge_port_door_open",
"AUTH": true
},
"CHARGE_PORT_DOOR_CLOSE": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/charge_port_door_close",
"AUTH": true
},
"START_CHARGE": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/charge_start",
"AUTH": true
},
"STOP_CHARGE": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/charge_stop",
"AUTH": true
},
"SEND_LOG": {
"TYPE": "POST",
"URI": "api/1/logs",
"AUTH": true
},
"RETRIEVE_NOTIFICATION_PREFERENCES": {
"TYPE": "GET",
"URI": "api/1/notification_preferences",
"AUTH": true
},
"SEND_NOTIFICATION_PREFERENCES": {
"TYPE": "POST",
"URI": "api/1/notification_preferences",
"AUTH": true
},
"RETRIEVE_NOTIFICATION_SUBSCRIPTION_PREFERENCES": {
"TYPE": "GET",
"URI": "api/1/vehicle_subscriptions",
"AUTH": true
},
"SEND_NOTIFICATION_SUBSCRIPTION_PREFERENCES": {
"TYPE": "POST",
"URI": "api/1/vehicle_subscriptions",
"AUTH": true
},
"DEACTIVATE_DEVICE_TOKEN": {
"TYPE": "POST",
"URI": "api/1/device/{device_token}/deactivate",
"AUTH": true
},
"CALENDAR_SYNC": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/upcoming_calendar_entries",
"AUTH": true
},
"SET_VALET_MODE": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/set_valet_mode",
"AUTH": true
},
"RESET_VALET_PIN": {
"TYPE": "POST",
"URI": "api/1/vehicles/{vehicle_id}/command/reset_valet_pin",
"AUTH": true
},
"REFERRAL_DATA": {
"TYPE": "GET",
"URI": "api/1/users/referral_data",
"AUTH": true
},
"AUTH_COMMAND_TOKEN": {
"TYPE": "POST",
"URI": "api/1/users/command_token",
"AUTH": true
},
"DIAGNOSTICS_ENTITLEMENTS": {
"TYPE": "GET",
"URI": "api/1/diagnostics",
"AUTH": true
},
"SEND_DIAGNOSTICS": {
"TYPE": "POST",
"URI": "api/1/diagnostics",
"AUTH": true
}
}

0 comments on commit e2b4a81

Please sign in to comment.