teslamate-org / teslamate

A self-hosted data logger for your Tesla 🚘
https://docs.teslamate.org
MIT License
5.88k stars 736 forks source link

Unexpected car model displayed for Model S Refresh #2494

Closed alsun2001 closed 2 years ago

alsun2001 commented 2 years ago

Is there an existing issue for this?

What happened?

My MS LR is displayed as "Model S 100D". It would be nice to have it display as its marketing name, like was done for M3s in #2030 / 6c0c0ee.

Not sure but additional logic might be needed as 100D is also a valid older Model S trim name.

Expected Behavior

Model S LR displayed as either

Steps To Reproduce

  1. Go to Teslamate front page
  2. Observe vehicle model/trim notation for MSLR

Relevant log output

N/A

Screenshots

No response

Additional data

No response

Type of installation

Docker

Version

1.26.1

natrlhy commented 2 years ago

I suspect the Model X Plaid will be the same. I'm guessing it will show up as Model X P100D. Would like it to display Model X Plaid

cwanja commented 2 years ago

So there is a couple of things here:

  1. First and foremost, Tesla does not provide a public way to identify a Long Range versus a Plaid, etc. Tesla does not even have a "Long Range" designation any more - it is just Dual Motor and Plaid. They stopped identifying the vehicles by battery size with the 100D I believe.
  2. Tesla's app likely uses more internal APIs to give you that "Dual Motor AWD" or "Long Range" as opposed to the Owners API that is not documented and not technically publicly available.
  3. On that same note, in the public API, there is no way for TeslaMate (or TeslaFi, TeslaScope) to identify more of the model via the vehicle_data response. Here is an output for my refreshed Model S.
    {"response":
    {"badge_version":0,
    "can_accept_navigation_requests":true,
    "can_actuate_trunks":true,
    "car_special_type":"base",
    "car_type":"lychee",
    "charge_port_type":"US",
    "dashcam_clip_save_supported":true,
    "default_charge_to_max":false,
    "driver_assist":"TeslaAP3",
    "ece_restrictions":false,
    "efficiency_package":"EfficiencyPackageDefault",
    "eu_vehicle":false,
    "exterior_color":"SolidBlack",
    "has_air_suspension":true,
    "has_ludicrous_mode":false,
    "has_seat_cooling":true,
    "headlamp_type":"HeadlampTypePremium",
    "interior_trim_type":"WalnutWhite",
    "key_version":2,
    "motorized_charge_port":true,
    "paint_color_override":"14,14,14,1,0.04",
    "plg":true,
    "pws":true,
    "rear_drive_unit":"CorianderSingle",
    "rear_seat_heaters":1,
    "rear_seat_type":0,
    "rhd":false,
    "roof_color":"RoofColorGlass",
    "seat_type":null,
    "spoiler_type":"None",
    "steering_wheel_type":1,
    "sun_roof_installed":null,
    "third_row_seats":"None",
    "trim_badging":"100d",
    "use_range_badging":true,
    "utc_offset":-216 

    car_type and trim_badging are what drives TeslaMate to insert the "Model S 100D" below the friendly name of your car. As such, there is no other way (as far as I know) to say it is a "Long Range" or "Plaid". has_ludicrous_mode might be for performance, so you could do P100D. Or say if lychee is true and has_ludicrous_mode is true -> Plaid. But I do not have a Plaid to verify that logic. Other services might be guessing, but I will let @corsair jump in from a TeslaScope perspective.

cwanja commented 2 years ago

So there is a couple of things here:

  1. First and foremost, Tesla does not provide a public way to identify a Long Range versus a Plaid, etc. Tesla does not even have a "Long Range" designation any more - it is just Dual Motor and Plaid. They stopped identifying the vehicles by battery size with the 100D I believe.
  2. Tesla's app likely uses more internal APIs to give you that "Dual Motor AWD" or "Long Range" as opposed to the Owners API that is not documented and not technically publicly available.
  3. On that same note, in the public API, there is no way for TeslaMate (or TeslaFi, TeslaScope) to identify more of the model via the vehicle_data response. Here is an output for my refreshed Model S.
{"response":
{"badge_version":0,
"can_accept_navigation_requests":true,
"can_actuate_trunks":true,
"car_special_type":"base",
"car_type":"lychee",
"charge_port_type":"US",
"dashcam_clip_save_supported":true,
"default_charge_to_max":false,
"driver_assist":"TeslaAP3",
"ece_restrictions":false,
"efficiency_package":"EfficiencyPackageDefault",
"eu_vehicle":false,
"exterior_color":"SolidBlack",
"has_air_suspension":true,
"has_ludicrous_mode":false,
"has_seat_cooling":true,
"headlamp_type":"HeadlampTypePremium",
"interior_trim_type":"WalnutWhite",
"key_version":2,
"motorized_charge_port":true,
"paint_color_override":"14,14,14,1,0.04",
"plg":true,
"pws":true,
"rear_drive_unit":"CorianderSingle",
"rear_seat_heaters":1,
"rear_seat_type":0,
"rhd":false,
"roof_color":"RoofColorGlass",
"seat_type":null,
"spoiler_type":"None",
"steering_wheel_type":1,
"sun_roof_installed":null,
"third_row_seats":"None",
"trim_badging":"100d",
"use_range_badging":true,
"utc_offset":-216 

car_type and trim_badging are what drives TeslaMate to insert the "Model S 100D" below the friendly name of your car. As such, there is no other way (as far as I know) to say it is a "Long Range" or "Plaid". has_ludicrous_mode might be for performance, so you could do P100D. Or say if lychee is true and has_ludicrous_mode is true -> Plaid. But I do not have a Plaid to verify that logic. Other services might be guessing, but I will let @corsair jump in from a TeslaScope perspective.

I will walk back some of these comments. It seems possible that TeslaMate could be updated to handle all the various types of cars, if @adriankumpf wants to build the logic in. But that logic is also going to need to be crowd sourced since Adrian does not have the data for various cars to then update the code. Or a cross collaboration with another service.

Looking through the code, for a refreshed Model S LR you would need: model to match S car_type to be lychee (designates the refreshed Model S) spoiler_type or trim_badging - would need a Model S Plaid output to ensure that if true or P100D (respective) is present to designates a Performance vehicle.

I am all for supporting the effort, there is a large TeslaMate community at TMC we could possibly scrape data from as well.

I would be happy to trial a dev branch with Adrian modifying https://github.com/adriankumpf/teslamate/blob/master/lib/teslamate/vehicles/vehicle/summary.ex - but I do not want to just add car_type to that code as I do not know what downstream effects it has on the Model 3 and Y identification.

cwanja commented 2 years ago

Do either of you have a Model 3 to pull the car_type and share what it reports? I am thinking this:

defp put_friendly_name(%Car{} = car) do
    %Car{car | friendly_name: friendly_name(car.model, car.trim_badging)}
  end

Will need to be updated to:

defp put_friendly_name(%Car{} = car) do
    %Car{car | friendly_name: friendly_name(car.model, car.car_type, car.trim_badging)}
  end

And then this:

        {:ok,
         %{
           model: model,
           name: name,
           trim_badging: trim_badging,
           exterior_color: exterior_color,
           spoiler_type: spoiler_type,
           wheel_type: wheel_type
         }}

Updated to include car_type. But I am no Elixir expert. Or maybe not. I do see car_type above the trim_badging. https://github.com/adriankumpf/teslamate/blob/b209d348f8cebca9dea480537bbd45f97af1d1ae/lib/teslamate/vehicles/vehicle.ex#L37-L45

natrlhy commented 2 years ago

Here's what I see for my Model X Plaid:

        "can_accept_navigation_requests": true,
        "can_actuate_trunks": true,
        "car_special_type": "base",
        "car_type": "tamarind",
        "charge_port_type": "US",
        "dashcam_clip_save_supported": true,
        "default_charge_to_max": false,
        "driver_assist": "TeslaAP3",
        "ece_restrictions": false,
        "efficiency_package": "EfficiencyPackageDefault",
        "eu_vehicle": false,
        "exterior_color": "DeepBlue",
        "has_air_suspension": true,
        "has_ludicrous_mode": false,
        "has_seat_cooling": true,
        "interior_trim_type": "CarbonBlack",
        "key_version": 2,
        "motorized_charge_port": true,
        "plg": true,
        "pws": true,
        "rear_drive_unit": "CorianderDual",
        "rear_seat_heaters": 1,
        "rear_seat_type": 2,
        "rhd": false,
        "roof_color": "RoofColorGlass",
        "seat_type": null,
        "spoiler_type": "None",
        "steering_wheel_type": 2,
        "sun_roof_installed": null,
        "third_row_seats": "FlatFold",
        "timestamp": 1645661963854,
        "trim_badging": "p100d",
        "use_range_badging": true,
        "utc_offset": -28800,
        "webcam_supported": true,
        "wheel_type": "NewTurbine22Black"

For my Model 3 Performance:

    "response": {
        "badge_version": 0,
        "can_accept_navigation_requests": true,
        "can_actuate_trunks": true,
        "car_special_type": "base",
        "car_type": "model3",
        "charge_port_type": "US",
        "dashcam_clip_save_supported": true,
        "default_charge_to_max": false,
        "driver_assist": "TeslaAP3",
        "ece_restrictions": false,
        "efficiency_package": "Default",
        "eu_vehicle": false,
        "exterior_color": "PearlWhite",
        "exterior_trim": "Chrome",
        "exterior_trim_override": "",
        "has_air_suspension": false,
        "has_ludicrous_mode": false,
        "has_seat_cooling": false,
        "headlamp_type": "Premium",
        "interior_trim_type": "White",
        "key_version": 2,
        "motorized_charge_port": true,
        "paint_color_override": "20,20,20,0.01,0.04",
        "performance_package": "Performance",
        "plg": false,
        "pws": false,
        "rear_drive_unit": "PM216MOSFET",
        "rear_seat_heaters": 1,
        "rear_seat_type": 0,
        "rhd": false,
        "roof_color": "RoofColorGlass",
        "seat_type": null,
        "spoiler_type": "Passive",
        "sun_roof_installed": null,
        "third_row_seats": "None",
        "timestamp": 1645662360701,
        "trim_badging": "p74d",
        "use_range_badging": true,
        "utc_offset": -28800,
        "webcam_supported": true,
        "wheel_type": "Stiletto20DarkSquare"
cwanja commented 2 years ago

Super helpful @natrlhy, I appreciate it. Looks like has_ludicrous_mode is not helpful, but inside of trim_badging, there is still a P designation for the Plaid X. Took a stab at it in #2496 - I imagine @adriankumpf is going to have to clean up my mess of coding a bit. But hopefully it gets us started.

I will make a suggestion, if this goes through, we put out a poll or start trying to crowdsource the remaining S and X designations. Again, happy to lead that effort from a TMC perspective. Active in a few TeslaMate threads over there.