Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battery Health dashboard: new stats panel for efficiency and improve query performance #3806

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 190 additions & 63 deletions grafana/dashboards/battery-health.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"type": "grafana",
"uid": "-- Grafana --"
},
"definition": "TeslaMate|U2FsdGVkX1/cEWK+8cz7pjEKXtzJnDN7b21ZDXt1MGneFGPWTLqOPtxKmu02mJPLzi/f29I+NBHd3vi0FB8R4Xn0+GtobWDgk6VAVSBTdSNniOKO8i2WPlhRaOsl2+hG7gnZ7wrf1Th2nxR7f1uYCrbwOek0IzkfLzrkjh7gkr6inT6bbDuJqrmogZajLxmAMrQ6V+/vHxBRGiwjJhgiEeq3hM1q2h04JKkNiZ8RHbsF5Cd/xd8Q9u0JVrZzIrtnhM/SFlaApU7RtRMu8CSj1llTX7WEOj6VDZAMSf+XUAanWdk725kEPN9MNu89o2zEq5P3E3cju8IbbBdPzXLV3oVuzD6/tMnxFToIIV1E/BrpF7s2RtNa8+KJJ1PF8xgs6m+/KTD2hy+WsP0636AgObRAmYg7+qotGrgNvpNPdE0EgrB7WHYlV7R/1q66bcq6tCe51X1Un70k+zo+K6AK0o4B1H6IyMlEVuRH/Fz8QVl9aYu2ztd08RbuKJlYVKpkH+pxVETAO9MclYQ90tzE6TfwDZrQZzsAlMenr4s1ZB1OlFXjLjVjnddnUilzO76cqv4yI2THQEuyQ47nuVQ4gUbx02K59vMQhns3C01JOAYokOaSXe66Y7QYdMlk09Lf|aes-256-cbc",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
Expand Down Expand Up @@ -363,7 +364,7 @@
"x": 12,
"y": 0
},
"id": 32,
"id": 37,
"options": {
"colorMode": "value",
"graphMode": "none",
Expand Down Expand Up @@ -422,7 +423,7 @@
"hide": false,
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT ROUND(convert_km((max(odometer) - min(odometer))::numeric, '$length_unit'),0)|| ' $length_unit' as \"Mileage\"\nfrom positions where car_id = $car_id;",
"rawSql": "SELECT ROUND(convert_km((max(end_km) - min(start_km))::numeric, '$length_unit'),0)|| ' $length_unit' as \"Mileage\"\nFROM drives WHERE car_id = $car_id;",
"refId": "Mileage",
"select": [
[
Expand Down Expand Up @@ -467,12 +468,13 @@
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"editorMode": "code",
"format": "table",
"group": [],
"hide": false,
"metricColumn": "none",
"rawQuery": true,
"rawSql": "select ROUND(convert_km(ROUND(odometer::numeric,0), '$length_unit'),0) || ' $length_unit' as \"Odometer\"\nfrom positions \nwhere car_id = $car_id\norder by date desc \nlimit 1;",
"rawSql": "SELECT ROUND(convert_km(max(end_km)::numeric, '$length_unit'),0) || ' $length_unit' as \"Odometer\"\nFROM drives WHERE car_id = $car_id;",
"refId": "Odometer",
"select": [
[
Expand All @@ -484,6 +486,23 @@
}
]
],
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "cars",
"timeColumn": "inserted_at",
"timeColumnType": "timestamp",
Expand Down Expand Up @@ -937,21 +956,10 @@
},
"editorMode": "code",
"format": "table",
"group": [],
"metricColumn": "none",
"hide": false,
"rawQuery": true,
"rawSql": "SELECT\n\tsum(charge_energy_added) as \"Total energy added\"\nFROM\n\tcharging_processes\nWHERE\n\tcar_id = $car_id AND charge_energy_added > 0.01",
"refId": "Total energy added",
"select": [
[
{
"params": [
"efficiency"
],
"type": "column"
}
]
],
"rawSql": "SELECT\r\n\tCOUNT(*) AS \"Total charges\"\r\nFROM\r\n\tcharging_processes\r\nWHERE\r\n\tcar_id = $car_id AND charge_energy_added > 0.01\r\n\t",
"refId": "Total charges",
"sql": {
"columns": [
{
Expand All @@ -968,17 +976,7 @@
}
],
"limit": 50
},
"table": "cars",
"timeColumn": "inserted_at",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
},
{
"datasource": {
Expand All @@ -987,10 +985,22 @@
},
"editorMode": "code",
"format": "table",
"group": [],
"hide": false,
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\r\n\tSUM(charge_energy_used) AS \"Total energy used\"\r\nFROM\r\n\tcharging_processes\r\nWHERE\r\n\tcar_id = $car_id AND charge_energy_added > 0.01\r\n",
"refId": "Total energy used",
"rawSql": "SELECT\n\tfloor(sum(charge_energy_added) / CASE WHEN $custom_kwh_new > 0 THEN $custom_kwh_new ELSE ('$aux'::json -> 'MaxCapacity')::text::float END) AS \"Charging cycles\"\nFROM charging_processes WHERE car_id = $car_id AND charge_energy_added > 0.01",
"refId": "Charging cycles",
"select": [
[
{
"params": [
"start_km"
],
"type": "column"
}
]
],
"sql": {
"columns": [
{
Expand All @@ -1007,7 +1017,17 @@
}
],
"limit": 50
}
},
"table": "drives",
"timeColumn": "start_date",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
},
{
"datasource": {
Expand All @@ -1016,10 +1036,21 @@
},
"editorMode": "code",
"format": "table",
"hide": false,
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\r\n\tCOUNT(*) AS \"Total charges\"\r\nFROM\r\n\tcharging_processes\r\nWHERE\r\n\tcar_id = $car_id AND charge_energy_added > 0.01\r\n\t",
"refId": "Total charges",
"rawSql": "SELECT\n\tsum(charge_energy_added) as \"Total energy added\"\nFROM\n\tcharging_processes\nWHERE\n\tcar_id = $car_id AND charge_energy_added > 0.01",
"refId": "Total energy added",
"select": [
[
{
"params": [
"efficiency"
],
"type": "column"
}
]
],
"sql": {
"columns": [
{
Expand All @@ -1036,7 +1067,17 @@
}
],
"limit": 50
}
},
"table": "cars",
"timeColumn": "inserted_at",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
},
{
"datasource": {
Expand All @@ -1045,22 +1086,10 @@
},
"editorMode": "code",
"format": "table",
"group": [],
"hide": false,
"metricColumn": "none",
"rawQuery": true,
"rawSql": "SELECT\n\tfloor(sum(charge_energy_added) / CASE WHEN $custom_kwh_new > 0 THEN $custom_kwh_new ELSE ('$aux'::json -> 'MaxCapacity')::text::float END) AS \"Charging cycles\"\nFROM charging_processes WHERE car_id = $car_id AND charge_energy_added > 0.01",
"refId": "Charging cycles",
"select": [
[
{
"params": [
"start_km"
],
"type": "column"
}
]
],
"rawSql": "SELECT\r\n\tSUM(charge_energy_used) AS \"Total energy used\"\r\nFROM\r\n\tcharging_processes\r\nWHERE\r\n\tcar_id = $car_id AND charge_energy_added > 0.01\r\n",
"refId": "Total energy used",
"sql": {
"columns": [
{
Expand All @@ -1077,17 +1106,7 @@
}
],
"limit": 50
},
"table": "drives",
"timeColumn": "start_date",
"timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
},
{
"datasource": {
Expand Down Expand Up @@ -1163,7 +1182,7 @@
},
"gridPos": {
"h": 2,
"w": 6,
"w": 4,
"x": 6,
"y": 9
},
Expand Down Expand Up @@ -1243,6 +1262,114 @@
"title": "Current SOC",
"type": "bargauge"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"description": "This is the Derived Rated Efficiency that TeslaMate calculates based on battery charges. \nThis information can be seen in more detail on the \"Efficiency\" dashboard.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"decimals": 0,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "super-light-blue",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byRegexp",
"options": "/.*_km/"
},
"properties": [
{
"id": "unit",
"value": "Wh/km"
}
]
},
{
"matcher": {
"id": "byRegexp",
"options": "/.*_mi/"
},
"properties": [
{
"id": "unit",
"value": "Wh/mi"
}
]
}
]
},
"gridPos": {
"h": 4,
"w": 2,
"x": 10,
"y": 9
},
"id": 32,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "/.*/",
"values": false
},
"showPercentChange": false,
"textMode": "value",
"wideLayout": true
},
"pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"editorMode": "code",
"format": "table",
"hide": false,
"rawQuery": true,
"rawSql": "SELECT ('$aux'::json -> 'RatedEfficiency')::text::float * \r\n CASE \r\n WHEN '$length_unit' = 'km' THEN 10\r\n WHEN '$length_unit' = 'mi' THEN 16.0934 \r\n END AS efficiency_$length_unit",
"refId": "Looged",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "Efficiency",
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
Expand Down Expand Up @@ -1284,7 +1411,7 @@
},
"gridPos": {
"h": 2,
"w": 6,
"w": 4,
"x": 6,
"y": 11
},
Expand Down Expand Up @@ -1761,6 +1888,6 @@
"timezone": "browser",
"title": "Battery Health",
"uid": "jchmRiqUfXgTM",
"version": 16,
"version": 18,
"weekStart": ""
}
Binary file modified website/static/screenshots/battery-health.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading