teslamate-org / teslamate

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

'Model' and 'Efficiency' data missing from new Model S LR (2021.5+) #2193

Closed cwanja closed 2 years ago

cwanja commented 2 years ago

Is there an existing issue for this?

What happened?

When reviewing the grafana dashboards for a new Tesla Model S, the kWh and Consumption data is missing. Not sure if this is due to too little data in the database to compute. Or if there is an issue scrapping this off new models. This is a refreshed Model S. However, I only have 27 miles on it, but only 3 of which are currently in TeslaMate.

Expected Behavior

Full data computed in each record.

Steps To Reproduce

  1. Complete a drive.
  2. Review the data in Grafana's dashboards.

Relevant log output

N/A

Screenshots

Screen Shot 2021-11-29 at 9 00 25 PM

Additional data

drives.csv

Type of installation

Docker

Version

1.25.0

cwanja commented 2 years ago

Looking at the Efficiency dashboard, there is "No data" in Consumption (net) and Consumption (gross) tiles. Just to add more details.

DrMichael commented 2 years ago

Could it be, that car efficiency is (still) zero? What gives select id, efficiency from cars;

cwanja commented 2 years ago

Could it be, that car efficiency is (still) zero? What gives select id, efficiency from cars;

teslamate=# select id, efficiency from cars;
 id | efficiency 
----+------------
  1 |           
(1 row)

teslamate=# 

I assumed efficiency had not been configured / calculated, but I wanted to validate. Is there a certain mileage TeslaMate needs to configure the efficiency?

DrMichael commented 2 years ago

I don't know...

manuelkamp commented 2 years ago

I think this is a normal behaviour - I have for the most short drives no values there (and never had since I started using teslamate).

Screenshot 2021-11-30 173915

cwanja commented 2 years ago

I think this is a normal behaviour - I have for the most short drives no values there (and never had since I started using teslamate).

Screenshot 2021-11-30 173915

So your 3 km drive that did get a consumption and efficiency is equal to roughly a mile and change here in the US. All of the drives in my original posted screenshot were over a mile - I would have expected a value similar to yours. Anything sub-one mile I would not expect it to compute.

I also just did a 17 mile drive and same results. I am still curious if there is something that TeslaMate has to compute, but cannot get a clear answer from the documentation.

cwanja commented 2 years ago

Current rated efficiency from the Efficiency dashboard says "No data". I thought that previously says 262 or 272 or something similar. Again, not sure if this is defined explicitly in the software based upon the car (Model S, Model 3, etc.) or it is derived from multiple drives (say after five or six).

Here is the code from the Current rated efficiency tile:

SELECT
    CASE WHEN '$length_unit' = 'km' THEN efficiency
         WHEN '$length_unit' = 'mi' THEN efficiency * 1.60934
    END * 1000 as "efficiency_$length_unit"
FROM
    cars
WHERE
    id = $car_id;
DrMichael commented 2 years ago

So your 3 km drive that did get a consumption and efficiency is equal to roughly a mile and change here in the US. All of the drives in that screenshot were over a mile - I would have expected a value.

Well there is a sanity check for consumption and efficiency:

duration_min > 1 AND
distance > 1 AND
( 
      start_position.usable_battery_level IS NULL OR end_position.usable_battery_level IS NULL  OR
      (end_position.battery_level - end_position.usable_battery_level) = 0 
 )

The first ones should be clear, the third, I cannot explain.

cwanja commented 2 years ago

Not sure I follow @DrMichael.

DrMichael commented 2 years ago

Well, the first two say, don't give consumption and efficiency, when the drive is less than one minute long or less than one km long.

cwanja commented 2 years ago

Well, the first two say, don't give consumption and efficiency, when the drive is less than one minute long or less than one km long.

Ah sorry, I see what you are saying. Let me post more data for the drives, obviously that will help. I would figure, like you, that sub-one minute or sub-one km or mile, it does not compute. But it is currently for every drive.

Screen Shot 2021-11-30 at 1 14 09 PM

I believe the reason it is missing is because the model in the car is not being populated. Anyone else with a refresh Model S or X seeing this?

teslamate=# select * from cars;
 id |       eid        |     vid      | model | efficiency |     inserted_at     |     updated_at      |        vin        |   name   | trim_badging | settings_id | exterior_color | spoiler_type | wheel_type | display_priority 
----+------------------+--------------+-------+------------+---------------------+---------------------+-------------------+----------+--------------+-------------+----------------+--------------+------------+------------------
  1 | 1493058266263777 | 265533451232 |       |            | 2021-11-22 17:33:31 | 2021-11-22 17:33:31 | 5YJSA1E5XMF454--- | Catalina | 100D         |           1 | SolidBlack     | None         | Cardenio19 |                1
(1 row)
cwanja commented 2 years ago

To add more data here, pulled the backup from my old (Sold) car and found this:

public.cars (id, eid, vid, model, efficiency, inserted_at, updated_at, vin, name, trim_badging, settings_id, exterior_color, spoiler_type, wheel_type) FROM stdin;
1   30288459899170027   761656843   S   0.162   2019-08-29 02:42:53 2021-01-01 20:02:06 5YJSA1E26KF330---   Catalina    \N  1   Black   None    Slipstream19Carbon
\.

So it seems the S and 0.162 is not being scraped and insert into the database refreshed Model S (at least in my car). I could insert this, but not sure what else it would mess up. I also do not want to drop and re-add the car or database.

@adriankumpf - thoughts?

cwanja commented 2 years ago

Updated the title with what I think the issue is. Confirmed with another user on TMC that has a Plaid, I have a LR, that they are not seeing the same issue. So it seems specific to my installation.

Has anyone dropped the car from the database and if so, what could that cause? If I re-sign in, will it just pickup the car again? Or will I now have "two cars" in the database? If I need to drop the database and restart from scratch, that is fine. Want to do it now, before I put a bunch of miles on the car.

cwanja commented 2 years ago

Brand new database, same exact issue:

docker-compose exec db psql teslamate teslamate -c \ "select * from cars;"
 id |       eid        |     vid      | model | efficiency |     inserted_at     |     updated_at     |        vin        |   name   | trim_badging | settings_id | exterior_color | spoiler_type | wheel_type | display_priority
----+------------------+--------------+-------+------------+---------------------+---------------------+-------------------+----------+--------------+-------------+----------------+--------------+------------+------------------
  1 | 1493058266263777 | 265533451232 |       |            | 2021-12-08 03:55:23 | 2021-12-08 03:56:34 | 5YJSA1E5XMF4548-- | Catalina | 100D         |           1 | SolidBlack     | None         | Cardenio19 |                1
(1 row)
cwanja commented 2 years ago

Full on removal of the docker images and re-initialization of the docker images - same exact issue. So it is either TeslaMate or my Tesla.

cwanja commented 2 years ago

Looking at the data returned against the https://owner-api.teslamotors.com/api/1/vehicles/?id=VID, no efficiency data point is there. Leading me to believe the Model and Efficiency data is inserted into the database based upon one of the codes returned compared to a configuration file in the application. And as such, there is no code for the refreshed Model S LR. But there is one for the Plaid (maybe a generic performance model?).

cwanja commented 2 years ago

Because I apparently do not give up, checked the api/1/vehicles/{ID}/vehicle_data end point this morning and reviewed the data. Not sure how it would map a Model S to the car, as there is no designation it seems in the response.

However, it does have a trim_badging response of 100d. So I am not sure if this maps to a configuration file in the database and because TeslaMate cannot identify the car as a the Model S, TeslaMate cannot then map to a trim_badging to log the efficiency. Obviously I have no clue and just pray Adrian responds :)

manuelkamp commented 2 years ago

well, you just have given the answer to yourself. With a little bit of searching (ok, i will do it for you: https://github.com/adriankumpf/teslamate/commit/6c0c0eeaa97b06bd1cdc4c6913d7d33fef93d5c0 ) - you are almost ready to go and make a pull request with your changes. This is the deal in community development. If you find something new, change it for future users. thanks for your contribution!

cwanja commented 2 years ago

well, you just have given the answer to yourself. With a little bit of searching (ok, i will do it for you: 6c0c0ee ) - you are almost ready to go and make a pull request with your changes. This is the deal in community development. If you find something new, change it for future users. thanks for your contribution!

While I appreciate most of the remark, less snarkiness, I am not about to go hack a working application where I do not have the knowledge and skillset to do so. I know where my technical ability ends.

manuelkamp commented 2 years ago

sorry to hear that. so let me ask you a simple question: you do not want to dive into and fix this by yourself, and you do not simply update the vehicle data in your db. please correct me, you wait until someone fixes it for you? otherwise you could have at least updated the efficiency column value (I'd suggest to also update the model value) for your car by yourself to have a working system until your model is included (if it is missing at all).

metaben commented 2 years ago

I think that cwanja has done good diagnosis.

If people more familiar with the codebase (Adrian or otherwise) clarifies that assumptions/proposals are correct, and further clarifies where to make the change in the code, I think there would be more PRs :)

cwanja commented 2 years ago

sorry to hear that. so let me ask you a simple question: you do not want to dive into and fix this by yourself, and you do not simply update the vehicle data in your db.

See a previous comment of mine:

Has anyone dropped the car from the database and if so, what could that cause? If I re-sign in, will it just pickup the car again? Or will I now have "two cars" in the database? If I need to drop the database and restart from scratch, that is fine. Want to do it now, before I put a bunch of miles on the car.

I am willing to to dive in (hopefully obvious from some of my other posts), but I am also wanting to validate any trickledown / downstream effects to just modifying and inserting data into the database.

please correct me, you wait until someone fixes it for you?

As mentioned above, yes I am willing to fix this in my installation due to not understanding / comfort hacking someone else's application through a pull request in a coding language I do not even know. My whole intent of bringing this up is if there is a bug, I would want it resolved for everyone.

otherwise you could have at least updated the efficiency column value for your car by yourself to have a working system until your model is included (if it is missing at all).

Again, not sure I want to just be hacking with the database without knowing the long term effects (if any). Nor can I find the efficiency value either in the file / commit / directory that you previously linked to.

However, if someone can help me identify the efficiency value I will certainly update the cars table and move along. But again, if there is clearly a bug I think others would appreciate it being fixed long term.

I think that cwanja has done good diagnosis.

If people more familiar with the codebase (Adrian or otherwise) clarifies that assumptions/proposals are correct, and further clarifies where to make the change in the code, I think there would be more PRs :)

That I definitely agree with and appreciate the comment. I know @adriankumpf is always encouraging more PRs. However, I think you might find users who are just not comfortable doing it nor have an understanding of the development language/s used - like myself.

Again, if there is a way to identify the efficiency number (say a website, tool or something similar), I am happy to go figure that out and update my database. However, I would probably keep this issue open for the underlying issue to be resolved.

cwanja commented 2 years ago

Not to keep adding to the fun, but I inserted Model S and Efficiency 0.162 into the cars table last night via a modified backup restore file. This morning, S was removed from the cars table.

adriankumpf commented 2 years ago

It is not necessary to insert the values manually. The efficiency values for your car will be calculated automatically after a few charging sessions: https://docs.teslamate.org/docs/faq#why-are-no-consumption-values-displayed-in-grafana

cwanja commented 2 years ago

It is not necessary to insert the values manually. The efficiency values for your car will be calculated automatically after a few charging sessions: https://docs.teslamate.org/docs/faq#why-are-no-consumption-values-displayed-in-grafana

Thanks @adriankumpf - should have dug more into the FAQs. My fault.

Any thoughts on why the Model keeps getting dropped from the cars record? Seems like the application is looking for a specific returned value in the API and if it does not find that, it forces a null value. Happy to provide you an output from my vehicle data if it helps improve.

adriankumpf commented 2 years ago

The model is read from the 'vehicle_config' -> 'car_type' field. Can you check what the API returns?

cwanja commented 2 years ago

The model is read from the 'vehicle_config' -> 'car_type' field. Can you check what the API returns?

Absolutely. “car_type":"lychee"

adriankumpf commented 2 years ago

Thanks. I've added it to the detection logic.

cwanja commented 2 years ago

Thanks. I've added it to the detection logic.

Perfect. Will close when the update is pushed and validated completion. Appreciate it!

tobiasehlert commented 2 years ago

@cwanja with v1.25.0 this should be resolved. Pull the latest image and see if it works :)

cwanja commented 2 years ago

@cwanja with v1.25.0 this should be resolved. Pull the latest image and see if it works :)

I was / am on 1.25. I was just impatient as the data value had not been inserted into the database. No issues now. And it is automatically updated to a new efficiency. Working as intended. Just some patience needed :)

adriankumpf commented 2 years ago

Closed in fc2b188