diff --git a/src/vehicles.rs b/src/vehicles.rs index 0a690ab..5eda578 100644 --- a/src/vehicles.rs +++ b/src/vehicles.rs @@ -72,6 +72,10 @@ pub struct VehicleData { pub gui_settings: Option, pub vehicle_config: Option, pub vehicle_state: Option, + + pub cached_data: Option, + pub command_signing: Option, + pub release_notes_supported: Option, } #[derive(Debug, Clone, Deserialize)] @@ -171,23 +175,33 @@ pub struct ClimateState { pub supports_fan_only_cabin_overheat_protection: bool, pub timestamp: i64, pub wiper_blade_heater: bool, + + pub auto_steering_wheel_heat: Option, + pub cop_activation_temperature: Option, + pub steering_wheel_heat_level: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct DriveState { - pub gps_as_of: i64, - pub heading: i64, - pub latitude: f64, - pub longitude: f64, - pub native_latitude: f64, - pub native_location_supported: i64, - pub native_longitude: f64, - pub native_type: String, + /// gak: The following fields (up to native_type) suddenly vanished from the API response so + /// I've made them all Option. Maybe API now only returns them when driving? + /// TODO: Check if they come back + pub gps_as_of: Option, + pub heading: Option, + pub latitude: Option, + pub longitude: Option, + pub native_latitude: Option, + pub native_location_supported: Option, + pub native_longitude: Option, + pub native_type: Option, + pub power: i64, pub shift_state: Option, /// gak: I've assumed this to be String. pub speed: Option, pub timestamp: i64, + + pub active_route_traffic_minutes_delay: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -197,6 +211,7 @@ pub struct GuiSettings { pub gui_distance_units: String, pub gui_range_display: String, pub gui_temperature_units: String, + pub gui_tirepressure_units: Option, pub show_range_units: bool, pub timestamp: i64, } @@ -247,6 +262,9 @@ pub struct VehicleConfig { pub utc_offset: i64, pub webcam_supported: Option, pub wheel_type: String, + + pub cop_user_set_temp_supported: Option, + pub webcam_selfie_supported: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -304,6 +322,25 @@ pub struct VehicleState { pub vehicle_self_test_progress: Option, pub vehicle_self_test_requested: Option, pub webcam_available: Option, + + pub media_info: Option, + pub tpms_hard_warning_fl: Option, + pub tpms_hard_warning_fr: Option, + pub tpms_hard_warning_rl: Option, + pub tpms_hard_warning_rr: Option, + + pub tpms_rcp_front_value: Option, + pub tpms_rcp_rear_value: Option, + + pub tpms_last_seen_pressure_time_fl: Option, + pub tpms_last_seen_pressure_time_fr: Option, + pub tpms_last_seen_pressure_time_rl: Option, + pub tpms_last_seen_pressure_time_rr: Option, + + pub tpms_soft_warning_fl: Option, + pub tpms_soft_warning_fr: Option, + pub tpms_soft_warning_rl: Option, + pub tpms_soft_warning_rr: Option, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -311,6 +348,13 @@ pub struct MediaState { pub remote_control_enabled: bool, } +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct MediaInfo { + audio_volume: Option, + audio_volume_increment: Option, + audio_volume_max: Option, +} + #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SoftwareUpdate { pub download_perc: i64, @@ -769,4 +813,13 @@ mod tests { OwnerApi::parse_json::(&request_data, s.to_string(), PrintResponses::Pretty) .unwrap(); } + + #[test] + fn json_vehicle_data_gak_2023_11_11() { + let s = include_str!("../testdata/vehicle_data_gak_2023_11_11.json"); + + let request_data = RequestData::Get { url: "" }; + OwnerApi::parse_json::(&request_data, s.to_string(), PrintResponses::Pretty) + .unwrap(); + } } diff --git a/testdata/vehicle_data_gak_2023_11_11.json b/testdata/vehicle_data_gak_2023_11_11.json new file mode 100644 index 0000000..8345b33 --- /dev/null +++ b/testdata/vehicle_data_gak_2023_11_11.json @@ -0,0 +1,266 @@ +{ + "response": { + "id": 123, + "user_id": 123, + "vehicle_id": 123, + "vin": "XXX", + "color": null, + "access_type": "OWNER", + "granular_access": { + "hide_private": false + }, + "tokens": [ + "123", + "123" + ], + "state": "online", + "in_service": false, + "id_s": "123", + "calendar_enabled": true, + "api_version": 67, + "backseat_token": null, + "backseat_token_updated_at": null, + "ble_autopair_enrolled": false, + "charge_state": { + "battery_heater_on": false, + "battery_level": 80, + "battery_range": 276.41, + "charge_amps": 13, + "charge_current_request": 13, + "charge_current_request_max": 16, + "charge_enable_request": true, + "charge_energy_added": 0.13, + "charge_limit_soc": 80, + "charge_limit_soc_max": 100, + "charge_limit_soc_min": 50, + "charge_limit_soc_std": 80, + "charge_miles_added_ideal": 0.5, + "charge_miles_added_rated": 0.5, + "charge_port_cold_weather_mode": false, + "charge_port_color": "\u003cinvalid\u003e", + "charge_port_door_open": true, + "charge_port_latch": "Engaged", + "charge_rate": 0.0, + "charger_actual_current": 0, + "charger_phases": 2, + "charger_pilot_current": 16, + "charger_power": 0, + "charger_voltage": 2, + "charging_state": "Complete", + "conn_charge_cable": "IEC", + "est_battery_range": 227.57, + "fast_charger_brand": "", + "fast_charger_present": false, + "fast_charger_type": "ACSingleWireCAN", + "ideal_battery_range": 276.41, + "max_range_charge_counter": 0, + "minutes_to_full_charge": 0, + "not_enough_power_to_heat": null, + "off_peak_charging_enabled": false, + "off_peak_charging_times": "all_week", + "off_peak_hours_end_time": 800, + "preconditioning_enabled": false, + "preconditioning_times": "all_week", + "scheduled_charging_mode": "Off", + "scheduled_charging_pending": false, + "scheduled_charging_start_time": null, + "scheduled_charging_start_time_app": 0, + "scheduled_departure_time": 1693404000, + "scheduled_departure_time_minutes": 0, + "supercharger_session_trip_planner": false, + "time_to_full_charge": 0.0, + "timestamp": 1699653893260, + "trip_charging": false, + "usable_battery_level": 80, + "user_charge_enable_request": null + }, + "climate_state": { + "allow_cabin_overheat_protection": true, + "auto_seat_climate_left": true, + "auto_seat_climate_right": false, + "auto_steering_wheel_heat": true, + "battery_heater": false, + "battery_heater_no_power": null, + "cabin_overheat_protection": "On", + "cabin_overheat_protection_actively_cooling": false, + "climate_keeper_mode": "off", + "cop_activation_temperature": "High", + "defrost_mode": 0, + "driver_temp_setting": 22.0, + "fan_status": 0, + "hvac_auto_request": "On", + "inside_temp": 24.2, + "is_auto_conditioning_on": false, + "is_climate_on": false, + "is_front_defroster_on": false, + "is_preconditioning": false, + "is_rear_defroster_on": false, + "left_temp_direction": 428, + "max_avail_temp": 28.0, + "min_avail_temp": 15.0, + "outside_temp": 21.5, + "passenger_temp_setting": 22.0, + "remote_heater_control_enabled": false, + "right_temp_direction": 428, + "seat_heater_left": 0, + "seat_heater_rear_center": 0, + "seat_heater_rear_left": 0, + "seat_heater_rear_right": 0, + "seat_heater_right": 0, + "side_mirror_heaters": false, + "steering_wheel_heat_level": 0, + "steering_wheel_heater": false, + "supports_fan_only_cabin_overheat_protection": true, + "timestamp": 1699653893260, + "wiper_blade_heater": false + }, + "drive_state": { + "active_route_traffic_minutes_delay": 0.0, + "power": 0, + "shift_state": null, + "speed": null, + "timestamp": 1699653893260 + }, + "gui_settings": { + "gui_24_hour_time": false, + "gui_charge_rate_units": "kW", + "gui_distance_units": "km/hr", + "gui_range_display": "Rated", + "gui_temperature_units": "C", + "gui_tirepressure_units": "Psi", + "show_range_units": false, + "timestamp": 1699653893260 + }, + "vehicle_config": { + "aux_park_lamps": "Eu", + "badge_version": 0, + "can_accept_navigation_requests": true, + "can_actuate_trunks": true, + "car_special_type": "base", + "car_type": "model3", + "charge_port_type": "CCS", + "cop_user_set_temp_supported": false, + "dashcam_clip_save_supported": true, + "default_charge_to_max": false, + "driver_assist": "TeslaAP3", + "ece_restrictions": false, + "efficiency_package": "M32021", + "eu_vehicle": true, + "exterior_color": "MidnightSilver", + "exterior_trim": "Black", + "exterior_trim_override": "", + "has_air_suspension": false, + "has_ludicrous_mode": false, + "has_seat_cooling": false, + "headlamp_type": "Global", + "interior_trim_type": "Black2", + "key_version": 2, + "motorized_charge_port": true, + "paint_color_override": "24,24,27,0.9,0.3", + "performance_package": "Base", + "plg": true, + "pws": false, + "rear_drive_unit": "PM216MOSFET", + "rear_seat_heaters": 1, + "rear_seat_type": 0, + "rhd": true, + "roof_color": "RoofColorGlass", + "seat_type": null, + "spoiler_type": "None", + "sun_roof_installed": null, + "supports_qr_pairing": false, + "third_row_seats": "None", + "timestamp": 1699653893260, + "trim_badging": "74d", + "use_range_badging": true, + "utc_offset": 36000, + "webcam_selfie_supported": true, + "webcam_supported": true, + "wheel_type": "StilettoRefresh19" + }, + "vehicle_state": { + "api_version": 67, + "autopark_state_v2": "disabled", + "autopark_style": "dead_man", + "calendar_supported": true, + "car_version": "2023.38.6 c1f85ddb415f", + "center_display_state": 0, + "dashcam_clip_save_available": true, + "dashcam_state": "Recording", + "df": 0, + "dr": 0, + "fd_window": 0, + "feature_bitmask": "fbdffbff,7f", + "fp_window": 0, + "ft": 0, + "is_user_present": false, + "last_autopark_error": "no_error", + "locked": true, + "media_info": { + "audio_volume": 2.0, + "audio_volume_increment": 0.333333, + "audio_volume_max": 10.333333 + }, + "media_state": { + "remote_control_enabled": true + }, + "notifications_supported": true, + "odometer": 11643.048901, + "parsed_calendar_supported": true, + "pf": 0, + "pr": 0, + "rd_window": 0, + "remote_start": false, + "remote_start_enabled": true, + "remote_start_supported": true, + "rp_window": 0, + "rt": 0, + "santa_mode": 0, + "sentry_mode": true, + "sentry_mode_available": true, + "service_mode": false, + "service_mode_plus": false, + "smart_summon_available": true, + "software_update": { + "download_perc": 0, + "expected_duration_sec": 2700, + "install_perc": 1, + "status": "", + "version": " " + }, + "speed_limit_mode": { + "active": false, + "current_limit_mph": 50.0, + "max_limit_mph": 120, + "min_limit_mph": 50.0, + "pin_code_set": true + }, + "summon_standby_mode_enabled": false, + "timestamp": 1699653893260, + "tpms_hard_warning_fl": false, + "tpms_hard_warning_fr": false, + "tpms_hard_warning_rl": false, + "tpms_hard_warning_rr": false, + "tpms_last_seen_pressure_time_fl": 1699595745, + "tpms_last_seen_pressure_time_fr": 1699595714, + "tpms_last_seen_pressure_time_rl": 1699595714, + "tpms_last_seen_pressure_time_rr": 1699595715, + "tpms_pressure_fl": 2.925, + "tpms_pressure_fr": 2.925, + "tpms_pressure_rl": 2.9, + "tpms_pressure_rr": 2.9, + "tpms_rcp_front_value": 2.9, + "tpms_rcp_rear_value": 2.9, + "tpms_soft_warning_fl": false, + "tpms_soft_warning_fr": false, + "tpms_soft_warning_rl": false, + "tpms_soft_warning_rr": false, + "valet_mode": false, + "valet_pin_needed": false, + "vehicle_name": "xxx", + "vehicle_self_test_progress": 0, + "vehicle_self_test_requested": false, + "webcam_available": false + } + } +} \ No newline at end of file