teslamate
teslamate copied to clipboard
Battery health KO
Is there an existing issue for this?
- [X] I have searched the existing issues
What happened?
Expected Behavior
in error I have this message : Status: 500. Message: db query error: pq: invalid input syntax for type json
SELECT
CASE WHEN $custom_kwh_new > 0 THEN $custom_kwh_new ELSE ('$aux'::json -> 'MaxCapacity')::text::float END as "Usable (new)",
('$aux'::json -> 'CurrentCapacity')::text::float as "Usable (now)",
('$aux'::json -> 'CurrentCapacity')::text::float - CASE WHEN $custom_kwh_new > 0 THEN $custom_kwh_new ELSE ('$aux'::json -> 'MaxCapacity')::text::float END as "Difference"
in query $aux is empty. Anyone have the solution ?
Steps To Reproduce
it's a fresh install, no data import. I want to try this project.
Relevant log output
2023-11-30 13:03:59.177 UTC [48] ERROR: invalid input syntax for type json at character 41
2023-11-30 13:03:59.177 UTC [48] DETAIL: The input string ended unexpectedly.
2023-11-30 13:03:59.177 UTC [48] CONTEXT: JSON data, line 1:
2023-11-30 13:03:59.177 UTC [48] STATEMENT: SELECT
CASE WHEN 0 > 0 THEN 0 ELSE (''::json -> 'MaxRange')::text::float END as "maxrange_km",
(''::json -> 'CurrentRange')::text::float as "currentrange_km",
CASE WHEN 0 > 0 THEN 0 ELSE (''::json -> 'MaxRange')::text::float END - (''::json -> 'CurrentRange')::text::float as "range_lost_km"
Screenshots
No response
Additional data
No response
Type of installation
Docker
Version
v1.28.2
This request have no result :
WITH aux AS ( SELECT cp.charge_energy_added, cp.car_id, (SELECT efficiency FROM cars WHERE id = $car_id) * 100.0 AS rated_efficiency, (cp.end_rated_range_km - cp.start_rated_range_km) AS added_range_km FROM charging_processes cp JOIN (SELECT charging_process_id, MAX(date) as date FROM charges GROUP BY charging_process_id) AS last_charges ON cp.id = last_charges.charging_process_id INNER JOIN charges c ON c.charging_process_id = cp.id AND c.date = last_charges.date WHERE cp.car_id = $car_id AND cp.end_date IS NOT NULL AND cp.end_rated_range_km > cp.start_rated_range_km ORDER BY cp.end_date DESC LIMIT 1 ), CurrentCapacity AS ( SELECT AVG(Capacity) AS CurrentCapacity FROM (SELECT (100.0 * cp.charge_energy_added) / (GREATEST(1,MAX(usable_battery_level) - MIN(usable_battery_level))) AS Capacity FROM charging_processes cp INNER JOIN charges c ON cp.id = c.charging_process_id INNER JOIN aux ON cp.car_id = aux.car_id WHERE cp.car_id = $car_id AND cp.charge_energy_added >= aux.rated_efficiency GROUP BY cp.charge_energy_added, cp.end_date ORDER BY cp.end_date DESC LIMIT 5 ) AS lastEstimatedCapacity ), MaxCapacity AS ( SELECT AVG(c.rated_battery_range_km * aux.rated_efficiency / c.usable_battery_level) AS MaxCapacity, cp.id FROM charging_processes cp JOIN (SELECT charging_process_id, MAX(date) as date FROM charges WHERE usable_battery_level > 0 GROUP BY charging_process_id) AS last_charges ON cp.id = last_charges.charging_process_id INNER JOIN charges c ON c.charging_process_id = cp.id AND c.date = last_charges.date INNER JOIN positions p ON p.id = cp.position_id INNER JOIN aux ON cp.car_id = aux.car_id WHERE cp.car_id = $car_id AND cp.end_date IS NOT NULL AND cp.charge_energy_added >= aux.rated_efficiency GROUP BY cp.id ORDER BY 1 DESC LIMIT 1 ), CurrentRange AS ( SELECT floor(extract(epoch from date)/86400)*86400 AS timecurrent, sum(rated_battery_range_km) / sum(usable_battery_level) * 100 AS rated_range_km FROM ( SELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c JOIN charging_processes p ON p.id = c.charging_process_id WHERE p.car_id = $car_id AND usable_battery_level IS NOT NULL) AS data GROUP BY 1 ORDER BY 1 DESC LIMIT 1 ), MaxRange AS ( SELECT floor(extract(epoch from date)/86400)*86400 AS time, sum(rated_battery_range_km) / sum(usable_battery_level) * 100 AS max_rated_range_km FROM ( SELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c JOIN charging_processes p ON p.id = c.charging_process_id WHERE p.car_id = $car_id AND usable_battery_level IS NOT NULL) AS data GROUP BY 1 ORDER BY 2 DESC LIMIT 1 ) SELECT CONCAT('{"LastChargekWhAdded": ', aux.charge_energy_added, ', "LastMileageAdded" : ', convert_km(aux.added_range_km,'$length_unit'), ', "MaxRange": ', convert_km(MaxRange.max_rated_range_km,'$length_unit'), ', "CurrentRange": ',convert_km(CurrentRange.rated_range_km,'$length_unit'), ', "MaxCapacity": ', MaxCapacity.MaxCapacity, ', "CurrentCapacity": ', CASE WHEN CurrentCapacity.CurrentCapacity IS NULL THEN 1 ELSE CurrentCapacity.CurrentCapacity END, ', "RatedEfficiency": ',aux.rated_efficiency, '}') FROM MaxRange, CurrentRange, Aux, MaxCapacity, CurrentCapacity;
I have the same problem, but not nearly enough technical chops to diagnose.
After a long charge, 33% to 80%. Dashboard is ok.
Thanks for reporting. Battery Health do need data logged before it can calculate the battery health.
You can see hints about it while hovering, for example:
But anyway, the behavior when no data is available can be improved. Perhaps @swiffer or @oivindoh can look into it.
Also comment that this might use the consumption value and it is documented that you need a certain amount of charge cycles to derive that value.
https://docs.teslamate.org/docs/faq#why-are-no-consumption-values-displayed-in-grafana
@jheredianet can confirm further, I believe this is merged from your dashboards.
@jheredianet can confirm further, I believe this is merged from your dashboards. Yes, I've made a fix included in this PR https://github.com/teslamate-org/teslamate/pull/3531 waiting to be approved.
Thanks for reporting. Battery Health do need data logged before it can calculate the battery health. You can see hints about it while hovering, for example:
But anyway, the behavior when no data is available can be improved. Perhaps @swiffer or @oivindoh can look into it.
I have the same problem, but in my case I have 5 charging sessions already logged with Teslamate:
The Battery health (both the standard and the LFP) shows "No Data". Other dashboards works fine
LFP variants of dashboards have been added. However for battery health efficieny is only calculated if charged for min 10 minutes and below 95% currently. this needs to be changed in teslamate (elixir) codebase
https://github.com/teslamate-org/teslamate/blob/83a0b38854572ba8fc816cd6df5bac9b71c00a01/lib/teslamate/log.ex#L603
i question if we can simply raise the upper bound or if we need to do that dynamically based on the yet to be introduced vehicle type battery config setting proposed by @NirKli here
https://github.com/teslamate-org/teslamate/issues/3438#issuecomment-1835618834
@NirKli - it shouldn't be a overall setting but configured per vehicle, right? we might need to implement a flow similar to how charge costs are set to be able to set car specific settings? (add a battery type single stat chart to battery health that when clicking on it opens a settings page for the currently selected car in teslamate that then updates a value in the cars table - changing it should trigger recalculate_efficiency afterwards).
@JakobLichterfeld - what do you think?
i question if we can simply raise the upper bound or if we need to do that dynamically based on the yet to be introduced vehicle type battery config setting proposed by @NirKli here
From my point of view we need to do that dynamically, as battery health calculation for non LFP variants will break otherwise, as there values reported for 100% charging are not accurate for those battery types.
I checked the data in the same situation,
PostgreSQL did not have the efficiency information for the cars table.
I looked at the source code of teslamate and the problem was that it was updating the efficiency information based on the information up to 95% charge. I also have a ModelY RWD, so I charge it to 100% every charging session, so the data was not updated, and the battery information in Grafana was always 'No Data'.
I checked the source code and charged the car from 70% charge to about 10% and got the results.
It would be nice to allow vehicles with LFP batteries to reach 100% to calculate results.
Fix here: https://github.com/jheredianet/Teslamate-CustomGrafanaDashboards/pull/63
PR created. If approved, will be fixed for next release.
With the 1.28.2 release, I have new LFP dashboards but the issue is still existing.
In which release this patch should be included ?
This patch was integrated into dashboard author repository and lately created a new PR for Teslamate. But not yet approved. Anyway, we fixed Battery Dashboard but not LFP dashboard. But the problem is probably the same.
You can open source file and just copy & paste code into Grafana dashboard and will be available immediately or wait until it's included in Teslamate master and a new release is launched.
I have updated Teslamate-CustomGrafanaDashboards from repository. Now BatteryHealth.json release is the last one. But I still have the same issue
POST http://192.168.1.2:3000/api/ds/query?ds_type=postgres&requestId=Q100 400 (Bad Request)
From the error you show, it looks like it's Grafana that isn't being able to access the database (400 Bad Request). Are you sure you have imported the dashboard with its corresponding datasource? Yesterday was approved this PR https://github.com/teslamate-org/teslamate/pull/3593 Maybe you should wait to the release that it would be integrated as all the common dashboards.
Yes I'm sure. That's weird, I have this error message from Chrome console for each grafana dashboard even if there is no visual error.
Did you have any data captured with TeslaMate yet? The Dashboard does have an issue with no data yet available for calculation, which will be fixed with the next release of Teslamate.
Yes
@Viald may I kindly ask you to import this release in order make some tests? https://github.com/jheredianet/Teslamate-CustomGrafanaDashboards/blob/develop/dashboards/BatteryHealth.json
I've made some adjustments to control none o null values (just on the "develop" branch for now). Once you import this Dashboard, you need to go to "Dashboard settings" | Variables, then click on "aux" variable and let me know the values you get in the Preview section, as the screenshot below:
I did it, and found None in the Preview section.
Ok, it's because there is some query that it is not working based on the data you have. May you run these queries individually? Let me know all the results (a screenshot would be ok) in order to see exactly which one is not getting the expected data. I'm assuming that your car id is 1, if not, change it accordantly in each query.
To get DerivatedEfficiency:
SELECT (charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric * 100.0 as "efficiency", count(*) as count FROM charging_processes WHERE car_id = 1 AND duration_min > 10 AND end_battery_level <= 95 AND start_rated_range_km IS NOT NULL AND end_rated_range_km IS NOT NULL AND charge_energy_added > 0 GROUP BY 1 ORDER BY 2 DESC LIMIT 1
Last info on charges:
SELECT cp.charge_energy_added, cp.car_id, (cp.end_rated_range_km - cp.start_rated_range_km) AS added_range_km FROM charging_processes cp JOIN (SELECT charging_process_id, MAX(date) as date FROM charges GROUP BY charging_process_id) AS last_charges ON cp.id = last_charges.charging_process_id INNER JOIN charges c ON c.charging_process_id = cp.id AND c.date = last_charges.date WHERE cp.car_id = 1 AND cp.end_date IS NOT NULL AND cp.end_rated_range_km > cp.start_rated_range_km ORDER BY cp.end_date DESC LIMIT 1
Current Capacity:
SELECT AVG(Capacity) AS CurrentCapacity FROM (SELECT (100.0 * cp.charge_energy_added) / (GREATEST(1,MAX(usable_battery_level) - MIN(usable_battery_level))) AS Capacity FROM charging_processes cp INNER JOIN charges c ON cp.id = c.charging_process_id WHERE cp.car_id = 1 AND cp.charge_energy_added >= 10 GROUP BY cp.charge_energy_added, cp.end_date ORDER BY cp.end_date DESC LIMIT 5 ) AS lastEstimatedCapacity
Max Capacity:
SELECT AVG(c.rated_battery_range_km * 14 / c.usable_battery_level) AS MaxCapacity, cp.id FROM charging_processes cp JOIN (SELECT charging_process_id, MAX(date) as date FROM charges WHERE usable_battery_level > 0 GROUP BY charging_process_id) AS last_charges ON cp.id = last_charges.charging_process_id INNER JOIN charges c ON c.charging_process_id = cp.id AND c.date = last_charges.date INNER JOIN positions p ON p.id = cp.position_id WHERE cp.car_id = 1 AND cp.end_date IS NOT NULL AND cp.charge_energy_added >= 14 GROUP BY cp.id ORDER BY 1 DESC LIMIT 1
Current Range:
SELECT floor(extract(epoch from date)/86400)*86400 AS timecurrent, CASE WHEN sum(usable_battery_level) = 0 THEN sum(rated_battery_range_km) * 100 ELSE sum(rated_battery_range_km) / sum(usable_battery_level) * 100 END AS rated_range_km FROM ( SELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c JOIN charging_processes p ON p.id = c.charging_process_id WHERE p.car_id = 1 AND usable_battery_level IS NOT NULL) AS data GROUP BY 1 ORDER BY 1 DESC LIMIT 1
Max Range:
SELECT floor(extract(epoch from date)/86400)*86400 AS time, CASE WHEN sum(usable_battery_level) = 0 THEN sum(rated_battery_range_km) * 100 ELSE sum(rated_battery_range_km) / sum(usable_battery_level) * 100 END AS max_rated_range_km FROM ( SELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c JOIN charging_processes p ON p.id = c.charging_process_id WHERE p.car_id = 1 AND usable_battery_level IS NOT NULL) AS data GROUP BY 1 ORDER BY 2 DESC LIMIT 1
Sorry, I'm not a grafana expert, I did my best. Is this result below is readable ?
I saw 2 errors as well:
{ "request": { "url": "api/ds/query?ds_type=postgres&requestId=Q117", "method": "POST", "data": { "queries": [ { "refId": "DerivatedEfficiency", "datasource": { "type": "postgres", "uid": "PC98BA2F4D77E1A42" }, "rawSql": "SELECT (charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric * 100.0 as "efficiency", count(*) as count FROM charging_processes WHERE car_id = 1 AND duration_min > 10 AND end_battery_level <= 95 AND start_rated_range_km IS NOT NULL AND end_rated_range_km IS NOT NULL AND charge_energy_added > 0 GROUP BY 1 ORDER BY 2 DESC LIMIT 1", "format": "table", "datasourceId": 1, "intervalMs": 60000, "maxDataPoints": 1180 }, { "refId": "Last info on charges", "datasource": { "type": "postgres", "uid": "PC98BA2F4D77E1A42" }, "rawSql": "SELECT cp.charge_energy_added, cp.car_id, (cp.end_rated_range_km - cp.start_rated_range_km) AS added_range_km FROM charging_processes cp JOIN (SELECT charging_process_id, MAX(date) as date FROM charges GROUP BY charging_process_id) AS last_charges ON cp.id = last_charges.charging_process_id INNER JOIN charges c ON c.charging_process_id = cp.id AND c.date = last_charges.date WHERE cp.car_id = 1 AND cp.end_date IS NOT NULL AND cp.end_rated_range_km > cp.start_rated_range_km ORDER BY cp.end_date DESC LIMIT 1", "format": "table", "datasourceId": 1, "intervalMs": 60000, "maxDataPoints": 1180 }, { "refId": "Current Capacity", "datasource": { "type": "postgres", "uid": "PC98BA2F4D77E1A42" }, "rawSql": "SELECT AVG(Capacity) AS CurrentCapacity FROM (SELECT (100.0 * cp.charge_energy_added) / (GREATEST(1,MAX(usable_battery_level) - MIN(usable_battery_level))) AS Capacity\t FROM charging_processes cp INNER JOIN charges c ON cp.id = c.charging_process_id INNER JOIN aux ON cp.car_id = 1 WHERE cp.car_id = 1 AND cp.charge_energy_added >= 10 GROUP BY cp.charge_energy_added, cp.end_date ORDER BY cp.end_date DESC LIMIT 5 ) AS lastEstimatedCapacity", "format": "table", "datasourceId": 1, "intervalMs": 60000, "maxDataPoints": 1180 }, { "refId": "Max Capacity", "datasource": { "type": "postgres", "uid": "PC98BA2F4D77E1A42" }, "rawSql": "SELECT AVG(c.rated_battery_range_km * 14 / c.usable_battery_level) AS MaxCapacity, cp.id FROM charging_processes cp JOIN (SELECT charging_process_id, MAX(date) as date FROM charges WHERE usable_battery_level > 0 GROUP BY charging_process_id) AS last_charges\t ON cp.id = last_charges.charging_process_id INNER JOIN charges c ON c.charging_process_id = cp.id AND c.date = last_charges.date INNER JOIN positions p ON p.id = cp.position_id INNER JOIN aux ON cp.car_id = 1 WHERE cp.car_id = 1 AND cp.end_date IS NOT NULL AND cp.charge_energy_added >= 14 GROUP BY cp.id ORDER BY 1 DESC LIMIT 1", "format": "table", "datasourceId": 1, "intervalMs": 60000, "maxDataPoints": 1180 }, { "refId": "Current Range", "datasource": { "type": "postgres", "uid": "PC98BA2F4D77E1A42" }, "rawSql": "SELECT floor(extract(epoch from date)/86400)*86400 AS timecurrent, CASE WHEN sum(usable_battery_level) = 0 THEN sum(rated_battery_range_km) * 100 ELSE sum(rated_battery_range_km) / sum(usable_battery_level) * 100 END AS rated_range_km FROM ( SELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c JOIN charging_processes p ON p.id = c.charging_process_id WHERE p.car_id = 1 AND usable_battery_level IS NOT NULL) AS data GROUP BY 1 ORDER BY 1 DESC LIMIT 1", "format": "table", "datasourceId": 1, "intervalMs": 60000, "maxDataPoints": 1180 }, { "refId": "Max Range", "datasource": { "type": "postgres", "uid": "PC98BA2F4D77E1A42" }, "rawSql": "SELECT floor(extract(epoch from date)/86400)*86400 AS time, CASE WHEN sum(usable_battery_level) = 0 THEN sum(rated_battery_range_km) * 100 ELSE sum(rated_battery_range_km) / sum(usable_battery_level) * 100 END AS max_rated_range_km FROM ( SELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c JOIN charging_processes p ON p.id = c.charging_process_id WHERE p.car_id = 1 AND usable_battery_level IS NOT NULL) AS data GROUP BY 1 ORDER BY 2 DESC LIMIT 1", "format": "table", "datasourceId": 1, "intervalMs": 60000, "maxDataPoints": 1180 } ], "from": "1705818740662", "to": "1705840340662" }, "hideFromInspector": false }, "response": { "results": { "Current Capacity": { "error": "db query error: pq: relation "aux" does not exist", "status": 500, "frames": [ { "schema": { "refId": "Current Capacity", "meta": { "typeVersion": [ 0, 0 ], "executedQueryString": "SELECT AVG(Capacity) AS CurrentCapacity FROM (SELECT (100.0 * cp.charge_energy_added) / (GREATEST(1,MAX(usable_battery_level) - MIN(usable_battery_level))) AS Capacity\t FROM charging_processes cp INNER JOIN charges c ON cp.id = c.charging_process_id INNER JOIN aux ON cp.car_id = 1 WHERE cp.car_id = 1 AND cp.charge_energy_added >= 10 GROUP BY cp.charge_energy_added, cp.end_date ORDER BY cp.end_date DESC LIMIT 5 ) AS lastEstimatedCapacity" }, "fields": [] }, "data": { "values": [] } } ], "refId": "Current Capacity" }, "Current Range": { "status": 200, "frames": [ { "schema": { "refId": "Current Range", "meta": { "typeVersion": [ 0, 0 ], "executedQueryString": "SELECT floor(extract(epoch from date)/86400)86400 AS timecurrent, CASE WHEN sum(usable_battery_level) = 0 THEN sum(rated_battery_range_km) * 100 ELSE sum(rated_battery_range_km) / sum(usable_battery_level) * 100 END AS rated_range_km FROM ( SELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c JOIN charging_processes p ON p.id = c.charging_process_id WHERE p.car_id = 1 AND usable_battery_level IS NOT NULL) AS data GROUP BY 1 ORDER BY 1 DESC LIMIT 1" }, "fields": [ { "name": "timecurrent", "type": "number", "typeInfo": { "frame": "float64", "nullable": true } }, { "name": "rated_range_km", "type": "number", "typeInfo": { "frame": "float64", "nullable": true } } ] }, "data": { "values": [ [ 1705449600 ], [ 400.43157134098277 ] ] } } ], "refId": "Current Range" }, "DerivatedEfficiency": { "status": 200, "frames": [ { "schema": { "refId": "DerivatedEfficiency", "meta": { "typeVersion": [ 0, 0 ], "executedQueryString": "SELECT (charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric * 100.0 as "efficiency", count() as count FROM charging_processes WHERE car_id = 1 AND duration_min > 10 AND end_battery_level <= 95 AND start_rated_range_km IS NOT NULL AND end_rated_range_km IS NOT NULL AND charge_energy_added > 0 GROUP BY 1 ORDER BY 2 DESC LIMIT 1" }, "fields": [] }, "data": { "values": [] } } ], "refId": "DerivatedEfficiency" }, "Last info on charges": { "status": 200, "frames": [ { "schema": { "refId": "Last info on charges", "meta": { "typeVersion": [ 0, 0 ], "executedQueryString": "SELECT cp.charge_energy_added, cp.car_id, (cp.end_rated_range_km - cp.start_rated_range_km) AS added_range_km FROM charging_processes cp JOIN (SELECT charging_process_id, MAX(date) as date FROM charges GROUP BY charging_process_id) AS last_charges ON cp.id = last_charges.charging_process_id INNER JOIN charges c ON c.charging_process_id = cp.id AND c.date = last_charges.date WHERE cp.car_id = 1 AND cp.end_date IS NOT NULL AND cp.end_rated_range_km > cp.start_rated_range_km ORDER BY cp.end_date DESC LIMIT 1" }, "fields": [ { "name": "charge_energy_added", "type": "number", "typeInfo": { "frame": "float64", "nullable": true } }, { "name": "car_id", "type": "number", "typeInfo": { "frame": "int16", "nullable": true } }, { "name": "added_range_km", "type": "number", "typeInfo": { "frame": "float64", "nullable": true } } ] }, "data": { "values": [ [ 47.64 ], [ 1 ], [ 373.99 ] ] } } ], "refId": "Last info on charges" }, "Max Capacity": { "error": "db query error: pq: relation "aux" does not exist", "status": 500, "frames": [ { "schema": { "refId": "Max Capacity", "meta": { "typeVersion": [ 0, 0 ], "executedQueryString": "SELECT AVG(c.rated_battery_range_km * 14 / c.usable_battery_level) AS MaxCapacity, cp.id FROM charging_processes cp JOIN (SELECT charging_process_id, MAX(date) as date FROM charges WHERE usable_battery_level > 0 GROUP BY charging_process_id) AS last_charges\t ON cp.id = last_charges.charging_process_id INNER JOIN charges c ON c.charging_process_id = cp.id AND c.date = last_charges.date INNER JOIN positions p ON p.id = cp.position_id INNER JOIN aux ON cp.car_id = 1 WHERE cp.car_id = 1 AND cp.end_date IS NOT NULL AND cp.charge_energy_added >= 14 GROUP BY cp.id ORDER BY 1 DESC LIMIT 1" }, "fields": [] }, "data": { "values": [] } } ], "refId": "Max Capacity" }, "Max Range": { "status": 200, "frames": [ { "schema": { "refId": "Max Range", "meta": { "typeVersion": [ 0, 0 ], "executedQueryString": "SELECT floor(extract(epoch from date)/86400)*86400 AS time, CASE WHEN sum(usable_battery_level) = 0 THEN sum(rated_battery_range_km) * 100 ELSE sum(rated_battery_range_km) / sum(usable_battery_level) * 100 END AS max_rated_range_km FROM ( SELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c JOIN charging_processes p ON p.id = c.charging_process_id WHERE p.car_id = 1 AND usable_battery_level IS NOT NULL) AS data GROUP BY 1 ORDER BY 2 DESC LIMIT 1" }, "fields": [ { "name": "time", "type": "time", "typeInfo": { "frame": "time.Time", "nullable": true } }, { "name": "max_rated_range_km", "type": "number", "typeInfo": { "frame": "float64", "nullable": true } } ] }, "data": { "values": [ [ 1702944000000 ], [ 401.64309704790526 ] ] } } ], "refId": "Max Range" } } } }
Hi @Viald It's hard to read those long lines in JSON. In the other hand, I've edited the queries in the previous post (the ones that failed).
If you are using Grafana, you may go to main menu "Explore", then choose your data source, then click on "code", paste and run the query as the image below (the results will be showed at the button):
Could you run them again? and show a screenshot for each one?
Sure, here it is.
Ok @Viald, so the issue is something with your data. We cannot get the current efficiency with this query:
SELECT (charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric * 100.0 as "efficiency", count(*) as count FROM charging_processes WHERE car_id = 1 AND duration_min > 10 AND end_battery_level <= 95 AND start_rated_range_km IS NOT NULL AND end_rated_range_km IS NOT NULL AND charge_energy_added > 0 GROUP BY 1 ORDER BY 2 DESC LIMIT 1`
This is strange, it looks like you don't have any charge that lasts longer than 10 minutes and is less than 95%. As the graph you shared before, it says that you have logged 2.181 Kms in Teslamate and you have added 745kWh and only with AC, not DC o SuperCharger, is that true? Which model is your car? Have you imported data from other sources?
Maybe you should check your charging_processes table and check if you have unclosed sessions (here you can see how to manually fix if it is your case https://docs.teslamate.org/docs/maintenance/manually_fixing_data).
Anyway, could you share what you get on the "Efficiency Dashboard" as the image below?
If you want, you may share a screenshot of the "Charges Dashboard" as well to clarify what is happening.
This is strange, it looks like you don't have any charge that lasts longer than 10 minutes.
All charges take few hours (see below)
and is less than 95%.
True, as recommanded by Tesla for FLP battery, I always charge at 100%
As the graph you shared before, it says that you have logged 2.181 Kms in Teslamate and you have added 745kWh and only with AC, not DC o SuperCharger, is that true?
Since I have been using Teslamate, I have not charged the car with supercharger, only AC.
Which model is your car?
Model 3 2021 (LFP battery)
Have you imported data from other sources?
No
Anyway, could you share what you get on the "Efficiency Dashboard" as the image below?
If you want, you may share a screenshot of the "Charges Dashboard" as well to clarify what is happening.
Model 3 2021 (LFP battery)
So why are you not using the LFP dashboard (battery-health-lfp)?
But it will fails as well, see as it currently only calculate when below 95%, see https://github.com/teslamate-org/teslamate/issues/3524#issuecomment-1850452981
As you specify, I have the same issue with the LFP dashboard.
As I've told you before, we cannot get the efficiency, as you can see in the screen shot. Any efficiency at all
I recommend you to charge your car at different percent, once to 50% other to 60% .. 80%.. 90%, etc. Not always at 100% except you strictly needed. I don't think changing always to 100% is a good way to keep the battery health even for a LFP one. As you show in your graph your charges are always to 100%. Experts says is better to charge many times a week than to charge once.