diff --git a/dashboards/ChargingCostsStats.json b/dashboards/ChargingCostsStats.json
index aad214b..e0e7267 100644
--- a/dashboards/ChargingCostsStats.json
+++ b/dashboards/ChargingCostsStats.json
@@ -44,9 +44,9 @@
"$$hashKey": "object:75",
"builtIn": 1,
"datasource": "-- 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,
- "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",
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
@@ -3435,13 +3435,14 @@
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "definition": "SELECT convert_km((max(odometer) - min(odometer))::numeric, '$length_unit')\nfrom positions where car_id = $car_id AND $__timeFilter(date)",
+ "definition": "SELECT ROUND(convert_km((max(end_km) - min(start_km))::numeric, '$length_unit'),0) as \"Mileage\"\nFROM drives WHERE car_id = $car_id AND $__timeFilter(end_date)",
+ "error": {},
"hide": 2,
"includeAll": false,
"multi": false,
"name": "distance_driven",
"options": [],
- "query": "SELECT convert_km((max(odometer) - min(odometer))::numeric, '$length_unit')\nfrom positions where car_id = $car_id AND $__timeFilter(date)",
+ "query": "SELECT ROUND(convert_km((max(end_km) - min(start_km))::numeric, '$length_unit'),0) as \"Mileage\"\nFROM drives WHERE car_id = $car_id AND $__timeFilter(end_date)",
"refresh": 2,
"regex": "",
"skipUrlSync": false,
@@ -3531,6 +3532,6 @@
"timezone": "",
"title": "Charging Costs Stats",
"uid": "jchmDdLe5uFVk",
- "version": 16,
+ "version": 17,
"weekStart": ""
}
\ No newline at end of file
diff --git a/dashboards/ContinuousTrips.json b/dashboards/ContinuousTrips.json
index 5b1b0d3..17359c5 100644
--- a/dashboards/ContinuousTrips.json
+++ b/dashboards/ContinuousTrips.json
@@ -5,11 +5,11 @@
"type": "grafana",
"id": "grafana",
"name": "Grafana",
- "version": "10.1.2"
+ "version": "10.4.0"
},
{
"type": "datasource",
- "id": "postgres",
+ "id": "grafana-postgresql-datasource",
"name": "PostgreSQL",
"version": "1.0.0"
},
@@ -29,9 +29,9 @@
"type": "datasource",
"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,
- "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",
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
@@ -85,7 +85,7 @@
"panels": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"description": "This dashboard has a table with all the trips you've made between charges sessions, so you can browse the longest or shortest mileage you travel.\n\nYou may also take a look to a specific trip from the initial charge session (before the trip) to the end of the of the charge session (after the trip), through the link in the first column that will take you to the Trips dashboard.",
@@ -420,7 +420,7 @@
{
"matcher": {
"id": "byName",
- "options": "outside_temp_f"
+ "options": "avg_temp_f"
},
"properties": [
{
@@ -560,7 +560,6 @@
"y": 0
},
"id": 2,
- "links": [],
"options": {
"cellHeight": "sm",
"footer": {
@@ -574,12 +573,12 @@
"showHeader": true,
"sortBy": []
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"alias": "",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"editorMode": "code",
@@ -628,13 +627,11 @@
}
],
"title": "Long Trips",
- "transformations": [],
"type": "table"
}
],
"refresh": "",
- "schemaVersion": 38,
- "style": "dark",
+ "schemaVersion": 39,
"tags": [
"TeslamateCustomDashboards"
],
@@ -643,7 +640,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC",
@@ -663,7 +660,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT unit_of_length FROM settings limit 1",
@@ -686,7 +683,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT base_url FROM settings LIMIT 1",
@@ -708,6 +705,10 @@
},
{
"current": {},
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
+ },
"definition": "SELECT preferred_range FROM settings LIMIT 1",
"hide": 2,
"includeAll": false,
@@ -724,7 +725,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT unit_of_temperature FROM settings LIMIT 1",
@@ -815,6 +816,6 @@
"timezone": "",
"title": "Continuous Trips",
"uid": "jchmY8upc6ZRk",
- "version": 5,
+ "version": 6,
"weekStart": ""
}
\ No newline at end of file
diff --git a/dashboards/CurrentChargeView.json b/dashboards/CurrentChargeView.json
index 9b23ca5..ccd559d 100644
--- a/dashboards/CurrentChargeView.json
+++ b/dashboards/CurrentChargeView.json
@@ -23,11 +23,11 @@
"type": "grafana",
"id": "grafana",
"name": "Grafana",
- "version": "10.1.2"
+ "version": "10.4.0"
},
{
"type": "datasource",
- "id": "postgres",
+ "id": "grafana-postgresql-datasource",
"name": "PostgreSQL",
"version": "1.0.0"
},
@@ -58,9 +58,9 @@
"type": "datasource",
"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,
- "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",
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
@@ -76,7 +76,6 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
- "id": null,
"links": [
{
"asDropdown": true,
@@ -116,14 +115,14 @@
"title": "Current Charge",
"tooltip": "Show Current Charge Data",
"type": "link",
- "url": "d/jchm9RxutVS7a/current-charge-view?kiosk&var-car_id=${car_id}&from=${current_charge_time}&to=${current_end_time}&var-BatteryCapacity=${BatteryCapacity}&var-charging_processes=${charging_processes}"
+ "url": "d/jchm9RxutVS7a/current-charge-view?kiosk&var-car_id=${car_id}&from=${current_charge_time}&to=${current_end_time}&var-BatteryCapacity=${BatteryCapacity}&var-charging_processes=${charging_processes}&var-temp_unit=${temp_unit}&var-length_unit=${length_unit}&var-preferred_range=${preferred_range}"
}
],
"liveNow": false,
"panels": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -139,8 +138,7 @@
"mode": "absolute",
"steps": [
{
- "color": "dark-red",
- "value": null
+ "color": "dark-red"
},
{
"color": "semi-dark-green",
@@ -161,16 +159,18 @@
"overrides": []
},
"gridPos": {
- "h": 2,
- "w": 6,
+ "h": 3,
+ "w": 5,
"x": 0,
"y": 0
},
"id": 8,
"options": {
"displayMode": "lcd",
+ "maxVizHeight": 300,
"minVizHeight": 10,
"minVizWidth": 0,
+ "namePlacement": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
@@ -180,16 +180,17 @@
"values": false
},
"showUnfilled": true,
+ "sizing": "auto",
"text": {
"valueSize": 40
},
"valueMode": "color"
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -242,7 +243,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"description": "",
@@ -258,8 +259,7 @@
"mode": "absolute",
"steps": [
{
- "color": "dark-red",
- "value": null
+ "color": "dark-red"
},
{
"color": "dark-green",
@@ -280,16 +280,18 @@
"overrides": []
},
"gridPos": {
- "h": 2,
- "w": 6,
- "x": 6,
+ "h": 3,
+ "w": 5,
+ "x": 5,
"y": 0
},
"id": 33,
"options": {
"displayMode": "gradient",
+ "maxVizHeight": 300,
"minVizHeight": 10,
"minVizWidth": 0,
+ "namePlacement": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
@@ -299,16 +301,17 @@
"values": false
},
"showUnfilled": true,
+ "sizing": "auto",
"text": {
"valueSize": 40
},
"valueMode": "color"
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -361,7 +364,115 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
+ },
+ "description": "",
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "palette-classic"
+ },
+ "decimals": 0,
+ "mappings": [],
+ "max": 49,
+ "min": 0,
+ "noValue": "0",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "light-orange"
+ }
+ ]
+ },
+ "unit": "kwatth"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 3,
+ "w": 2,
+ "x": 10,
+ "y": 0
+ },
+ "id": 53,
+ "options": {
+ "colorMode": "value",
+ "graphMode": "area",
+ "justifyMode": "center",
+ "orientation": "auto",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "value_and_name",
+ "wideLayout": true
+ },
+ "pluginVersion": "10.4.0",
+ "targets": [
+ {
+ "alias": "kWh Added",
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
+ },
+ "editorMode": "code",
+ "format": "table",
+ "group": [],
+ "hide": false,
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT $BatteryCapacity AS \"Battery Capacity\"",
+ "refId": "B",
+ "select": [
+ [
+ {
+ "params": [
+ "start_km"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "table": "drives",
+ "timeColumn": "start_date",
+ "timeColumnType": "timestamp",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ ],
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"description": "Load this dashboard to while you are in a charging session. When you open this dashboard it will show the last 15 minutes, but you should click the \"Current Charge\" button at the top right corner, to enter in Kiosk mode:\n\n- If you are charging, you will see the information from the start time of the current charge session until now and it will refesh automatically every 30 seconds.\n\n- If you are just browsing (not charging) you will see the information of the last charge session.",
@@ -381,11 +492,11 @@
"content": "
\n\n",
"mode": "html"
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "time_series",
@@ -420,7 +531,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"description": "",
@@ -438,8 +549,7 @@
"mode": "absolute",
"steps": [
{
- "color": "light-orange",
- "value": null
+ "color": "light-orange"
}
]
},
@@ -455,6 +565,8 @@
},
"id": 36,
"options": {
+ "minVizHeight": 75,
+ "minVizWidth": 75,
"orientation": "auto",
"reduceOptions": {
"calcs": [
@@ -464,14 +576,15 @@
"values": false
},
"showThresholdLabels": false,
- "showThresholdMarkers": true
+ "showThresholdMarkers": true,
+ "sizing": "auto"
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"alias": "kWh Added",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "time_series",
@@ -508,7 +621,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -522,8 +635,7 @@
"mode": "absolute",
"steps": [
{
- "color": "super-light-blue",
- "value": null
+ "color": "super-light-blue"
}
]
}
@@ -549,14 +661,16 @@
"fields": "/^coalesce$/",
"values": false
},
+ "showPercentChange": false,
"text": {},
- "textMode": "value"
+ "textMode": "value",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -589,7 +703,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -598,6 +712,7 @@
"mode": "palette-classic"
},
"custom": {
+ "axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
@@ -633,8 +748,7 @@
"mode": "absolute",
"steps": [
{
- "color": "green",
- "value": null
+ "color": "green"
}
]
}
@@ -696,10 +810,10 @@
]
},
"gridPos": {
- "h": 20,
+ "h": 19,
"w": 12,
"x": 0,
- "y": 2
+ "y": 3
},
"id": 28,
"options": {
@@ -724,7 +838,7 @@
{
"alias": "Power [kW]",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "time_series",
@@ -777,7 +891,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -792,8 +906,7 @@
"mode": "absolute",
"steps": [
{
- "color": "green",
- "value": null
+ "color": "green"
}
]
},
@@ -820,15 +933,17 @@
"fields": "",
"values": true
},
+ "showPercentChange": false,
"text": {},
- "textMode": "auto"
+ "textMode": "auto",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"alias": "Real",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -866,7 +981,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -902,7 +1017,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -913,8 +1028,7 @@
"mode": "absolute",
"steps": [
{
- "color": "super-light-blue",
- "value": null
+ "color": "super-light-blue"
}
]
},
@@ -941,17 +1055,20 @@
"fields": "",
"values": false
},
+ "showPercentChange": false,
"text": {},
- "textMode": "auto"
+ "textMode": "auto",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"alias": "Elapsed Time",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "editorMode": "code",
"format": "table",
"group": [],
"groupBy": [
@@ -972,7 +1089,7 @@
"orderByTime": "ASC",
"policy": "default",
"rawQuery": true,
- "rawSql": "WITH start_process AS ( SELECT date FROM charges \twhere charging_process_id=$charging_processes \tORDER BY DATE ASC \tLIMIT 1 ) SELECT EXTRACT(EPOCH FROM (charges.date - start_process.date)) AS \"Elapsed\" FROM charges, start_process WHERE charging_process_id = $charging_processes AND $__timeFilter(charges.date) order by charges.date desc LIMIT 1",
+ "rawSql": "SELECT EXTRACT(EPOCH FROM (end_date - start_date)) AS \"Elapsed\" FROM \r\n (SELECT min(date) as start_date FROM charges where charging_process_id=$charging_processes) s\r\n CROSS JOIN \r\n (SELECT max(date) as end_date FROM charges where charging_process_id=$charging_processes) e",
"refId": "A",
"resultFormat": "time_series",
"select": [
@@ -989,6 +1106,23 @@
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"tags": [],
"timeColumn": "time",
"where": [
@@ -1004,7 +1138,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -1025,8 +1159,7 @@
"mode": "absolute",
"steps": [
{
- "color": "green",
- "value": null
+ "color": "green"
}
]
}
@@ -1040,7 +1173,6 @@
"y": 4
},
"id": 50,
- "links": [],
"maxDataPoints": 50000,
"options": {
"basemap": {
@@ -1115,12 +1247,12 @@
"zoom": 15
}
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"alias": "",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"editorMode": "code",
@@ -1213,7 +1345,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -1222,14 +1354,12 @@
"fixedColor": "super-light-yellow",
"mode": "fixed"
},
- "decimals": 0,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
- "color": "green",
- "value": null
+ "color": "green"
}
]
},
@@ -1253,21 +1383,24 @@
"calcs": [
"first"
],
- "fields": "",
+ "fields": "/^odometer$/",
"values": true
},
+ "showPercentChange": false,
"text": {},
- "textMode": "auto"
+ "textMode": "value",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"alias": "Real",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "format": "time_series",
+ "editorMode": "code",
+ "format": "table",
"group": [],
"groupBy": [],
"hide": false,
@@ -1276,7 +1409,7 @@
"orderByTime": "ASC",
"policy": "default",
"rawQuery": true,
- "rawSql": "select $__time(date), convert_km(odometer::numeric, '$length_unit') as \"Odometer\" from positions where car_id = $car_id order by date desc limit 1;",
+ "rawSql": "SELECT ROUND(convert_km(max(end_km)::numeric, '$length_unit'),0) || ' $length_unit' as odometer\r\nFROM drives WHERE car_id = $car_id;",
"refId": "odometer",
"resultFormat": "time_series",
"select": [
@@ -1289,6 +1422,23 @@
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"table": "drives",
"timeColumn": "start_date",
"timeColumnType": "timestamp",
@@ -1301,87 +1451,90 @@
]
}
],
+ "title": "Odometer",
"type": "stat"
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "description": "",
"fieldConfig": {
"defaults": {
"color": {
- "fixedColor": "blue",
- "mode": "palette-classic"
+ "fixedColor": "light-blue",
+ "mode": "fixed"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
- "color": "orange",
- "value": null
+ "color": "green"
}
]
- },
- "unit": "lengthkm"
+ }
},
- "overrides": []
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "Current"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "amp"
+ }
+ ]
+ }
+ ]
},
"gridPos": {
"h": 4,
- "w": 6,
+ "w": 3,
"x": 12,
"y": 10
},
- "id": 5,
+ "id": 49,
"options": {
"colorMode": "value",
- "graphMode": "none",
+ "graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
- "lastNotNull"
+ "mean"
],
"fields": "",
"values": false
},
+ "showPercentChange": false,
"text": {},
- "textMode": "auto"
+ "textMode": "auto",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
- "alias": "Real",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "time_series",
"group": [],
- "groupBy": [],
"hide": false,
- "measurement": "km",
"metricColumn": "none",
- "orderByTime": "ASC",
- "policy": "default",
"rawQuery": true,
- "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_km(rated_battery_range_km, '$length_unit')) as \"Initial Range\" FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 asc limit 1",
- "refId": "Initial Range",
- "resultFormat": "time_series",
+ "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(case when charger_voltage > 2 then charger_actual_current else ((2.85 + (usable_battery_level * 0.013)) * 96) * charger_power / 100 end) as \"Current\" FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
+ "refId": "Current",
"select": [
[
{
"params": [
"value"
],
- "type": "field"
- },
- {
- "params": [],
- "type": "last"
+ "type": "column"
}
]
],
@@ -1393,77 +1546,77 @@
"type": "macro"
}
]
+ }
+ ],
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "continuous-GrYlRd"
+ },
+ "mappings": [],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "green"
+ }
+ ]
+ },
+ "unit": "volt"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 4,
+ "w": 3,
+ "x": 15,
+ "y": 10
+ },
+ "id": 47,
+ "options": {
+ "colorMode": "value",
+ "graphMode": "area",
+ "justifyMode": "auto",
+ "orientation": "auto",
+ "reduceOptions": {
+ "calcs": [
+ "mean"
+ ],
+ "fields": "/^Volt$/",
+ "values": false
},
+ "showPercentChange": false,
+ "text": {},
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "pluginVersion": "10.4.0",
+ "targets": [
{
- "alias": "Real",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "time_series",
"group": [],
- "groupBy": [],
- "hide": false,
- "measurement": "km",
"metricColumn": "none",
- "orderByTime": "ASC",
- "policy": "default",
"rawQuery": true,
- "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_km(rated_battery_range_km, '$length_unit')) as \"Rated Range\" FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 desc limit 1",
- "refId": "Rated",
- "resultFormat": "time_series",
+ "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(case when charger_voltage > 2 then charger_voltage else charger_power / GREATEST(0.1, (((2.85 + (usable_battery_level * 0.013)) * 96.0) * charger_power / 100.0)) * 1000.0 end) as \"Volt\" FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
+ "refId": "Voltage",
"select": [
[
{
"params": [
"value"
],
- "type": "field"
- },
- {
- "params": [],
- "type": "last"
- }
- ]
- ],
- "timeColumn": "time",
- "where": [
- {
- "name": "$__timeFilter",
- "params": [],
- "type": "macro"
- }
- ]
- },
- {
- "alias": "Estimated",
- "datasource": {
- "type": "postgres",
- "uid": "TeslaMate"
- },
- "format": "time_series",
- "group": [],
- "groupBy": [],
- "hide": false,
- "measurement": "km",
- "metricColumn": "none",
- "orderByTime": "ASC",
- "policy": "default",
- "rawQuery": true,
- "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_km(est_battery_range_km, '$length_unit')) as \"Estimated Range\" FROM positions WHERE $__timeFilter(date) GROUP BY 1 ORDER BY 1 desc limit 1",
- "refId": "Estimated",
- "resultFormat": "time_series",
- "select": [
- [
- {
- "params": [
- "value"
- ],
- "type": "field"
- },
- {
- "params": [],
- "type": "last"
+ "type": "column"
}
]
],
@@ -1481,13 +1634,13 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
"color": {
- "fixedColor": "light-blue",
+ "fixedColor": "orange",
"mode": "fixed"
},
"mappings": [],
@@ -1495,34 +1648,21 @@
"mode": "absolute",
"steps": [
{
- "color": "green",
- "value": null
+ "color": "green"
}
]
- }
+ },
+ "unit": "kwatt"
},
- "overrides": [
- {
- "matcher": {
- "id": "byName",
- "options": "Current"
- },
- "properties": [
- {
- "id": "unit",
- "value": "amp"
- }
- ]
- }
- ]
+ "overrides": []
},
"gridPos": {
"h": 4,
- "w": 3,
+ "w": 6,
"x": 12,
"y": 14
},
- "id": 49,
+ "id": 34,
"options": {
"colorMode": "value",
"graphMode": "area",
@@ -1535,14 +1675,16 @@
"fields": "",
"values": false
},
+ "showPercentChange": false,
"text": {},
- "textMode": "auto"
+ "textMode": "auto",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "time_series",
@@ -1550,7 +1692,7 @@
"hide": false,
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(case when charger_voltage > 2 then charger_actual_current else ((2.85 + (usable_battery_level * 0.013)) * 96) * charger_power / 100 end) as \"Current\" FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
+ "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(case when charger_phases >= 1 then (case when charger_phases = 2 then 3 when charger_phases = 1 then 1 else 0 end) * charger_actual_current * charger_voltage / 1000.0 else charger_power end) as \"Power\" FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
"refId": "Current",
"select": [
[
@@ -1576,73 +1718,165 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "description": "",
"fieldConfig": {
"defaults": {
"color": {
- "mode": "continuous-GrYlRd"
+ "fixedColor": "blue",
+ "mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
- "color": "green",
- "value": null
+ "color": "orange"
}
]
- },
- "unit": "volt"
+ }
},
- "overrides": []
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/.*_km/"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "lengthkm"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/.*_mi/"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "lengthmi"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/start*/"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Start"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/added*/"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Added"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/current*/"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Current"
+ }
+ ]
+ }
+ ]
},
"gridPos": {
"h": 4,
- "w": 3,
- "x": 15,
- "y": 14
+ "w": 6,
+ "x": 12,
+ "y": 18
},
- "id": 47,
+ "id": 52,
"options": {
"colorMode": "value",
"graphMode": "area",
- "justifyMode": "auto",
- "orientation": "auto",
+ "justifyMode": "center",
+ "orientation": "vertical",
"reduceOptions": {
"calcs": [
- "mean"
+ "lastNotNull"
],
- "fields": "/^Volt$/",
+ "fields": "",
"values": false
},
+ "showPercentChange": false,
"text": {},
- "textMode": "auto"
+ "textMode": "value_and_name",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
+ "alias": "Real",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "format": "time_series",
+ "editorMode": "code",
+ "format": "table",
"group": [],
+ "groupBy": [],
+ "hide": false,
+ "measurement": "km",
"metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
"rawQuery": true,
- "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(case when charger_voltage > 2 then charger_voltage else charger_power / GREATEST(0.1, (((2.85 + (usable_battery_level * 0.013)) * 96.0) * charger_power / 100.0)) * 1000.0 end) as \"Volt\" FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
- "refId": "Voltage",
+ "rawSql": "SELECT MIN(convert_km([[preferred_range]]_battery_range_km, '$length_unit')) as start_$length_unit\r\nFROM charges WHERE charging_process_id = $charging_processes",
+ "refId": "Initial Range",
+ "resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
- "type": "column"
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "last"
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"timeColumn": "time",
"where": [
{
@@ -1651,81 +1885,116 @@
"type": "macro"
}
]
- }
- ],
- "type": "stat"
- },
- {
- "datasource": {
- "type": "postgres",
- "uid": "TeslaMate"
- },
- "fieldConfig": {
- "defaults": {
- "color": {
- "fixedColor": "orange",
- "mode": "fixed"
+ },
+ {
+ "alias": "Real",
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
},
- "mappings": [],
- "thresholds": {
- "mode": "absolute",
- "steps": [
+ "editorMode": "code",
+ "format": "table",
+ "group": [],
+ "groupBy": [],
+ "hide": false,
+ "measurement": "km",
+ "metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "rawQuery": true,
+ "rawSql": "SELECT ROUND(convert_km(end_range - start_range, '$length_unit'),0) as added_$length_unit \r\nFROM\r\n(SELECT MIN([[preferred_range]]_battery_range_km) as start_range\r\nFROM charges WHERE charging_process_id = $charging_processes) s\r\nCROSS JOIN (\r\nSELECT MAX([[preferred_range]]_battery_range_km) as end_range \r\nFROM charges WHERE charging_process_id = $charging_processes) e",
+ "refId": "Range Added",
+ "resultFormat": "time_series",
+ "select": [
+ [
{
- "color": "green",
- "value": null
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "last"
}
]
- },
- "unit": "kwatt"
- },
- "overrides": []
- },
- "gridPos": {
- "h": 4,
- "w": 6,
- "x": 12,
- "y": 18
- },
- "id": 34,
- "options": {
- "colorMode": "value",
- "graphMode": "area",
- "justifyMode": "auto",
- "orientation": "auto",
- "reduceOptions": {
- "calcs": [
- "mean"
],
- "fields": "",
- "values": false
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
},
- "text": {},
- "textMode": "auto"
- },
- "pluginVersion": "10.1.2",
- "targets": [
{
+ "alias": "Estimated",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "format": "time_series",
+ "editorMode": "code",
+ "format": "table",
"group": [],
+ "groupBy": [],
"hide": false,
+ "measurement": "km",
"metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
"rawQuery": true,
- "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(case when charger_phases >= 1 then (case when charger_phases = 2 then 3 when charger_phases = 1 then 1 else 0 end) * charger_actual_current * charger_voltage / 1000.0 else charger_power end) as \"Power\" FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
- "refId": "Current",
+ "rawSql": "SELECT MAX(convert_km([[preferred_range]]_battery_range_km, '$length_unit')) as current_$length_unit \r\nFROM charges WHERE charging_process_id = $charging_processes",
+ "refId": "Current Range",
+ "resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
- "type": "column"
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "last"
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"timeColumn": "time",
"where": [
{
@@ -1736,11 +2005,12 @@
]
}
],
+ "title": "Ranges ($preferred_range)",
"type": "stat"
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -1761,10 +2031,70 @@
"value": 80
}
]
- },
- "unit": "celsius"
+ }
},
- "overrides": []
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/.*_f/"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "fahrenheit"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/.*_c/"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "celsius"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/outdoor*/"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Outdoor"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/inside*/"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Inside"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/driver*/"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Driver"
+ }
+ ]
+ }
+ ]
},
"gridPos": {
"h": 4,
@@ -1785,21 +2115,24 @@
"fields": "",
"values": false
},
+ "showPercentChange": false,
"text": {},
- "textMode": "auto"
+ "textMode": "auto",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "editorMode": "code",
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(outside_temp, '$temp_unit')) as \"Outdoor\" FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
+ "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(outside_temp, '$temp_unit')) as outdoor_$temp_unit FROM charges WHERE charging_process_id = $charging_processes AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
"refId": "Outdoor",
"select": [
[
@@ -1811,6 +2144,23 @@
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"timeColumn": "time",
"where": [
{
@@ -1822,15 +2172,16 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "editorMode": "code",
"format": "time_series",
"group": [],
"hide": false,
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(inside_temp, '$temp_unit')) AS \"Inside\" FROM positions WHERE car_id = $car_id and inside_temp is not null AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
+ "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(inside_temp, '$temp_unit')) AS inside_$temp_unit FROM positions WHERE car_id = $car_id and inside_temp is not null AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
"refId": "Inside",
"select": [
[
@@ -1842,6 +2193,23 @@
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"timeColumn": "time",
"where": [
{
@@ -1853,15 +2221,16 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "editorMode": "code",
"format": "time_series",
"group": [],
"hide": false,
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "SELECT \t$__timeGroupAlias(date,$__interval), \tavg(convert_celsius(driver_temp_setting, '$temp_unit')) as \"Driver\" FROM positions WHERE driver_temp_setting IS NOT NULL AND car_id = $car_id AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
+ "rawSql": "SELECT \t$__timeGroupAlias(date,$__interval), \tavg(convert_celsius(driver_temp_setting, '$temp_unit')) as driver_$temp_unit FROM positions WHERE driver_temp_setting IS NOT NULL AND car_id = $car_id AND $__timeFilter(date) GROUP BY 1 ORDER BY 1 ",
"refId": "Driver",
"select": [
[
@@ -1873,6 +2242,23 @@
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"table": "drives",
"timeColumn": "start_date",
"timeColumnType": "timestamp",
@@ -1888,9 +2274,7 @@
"type": "stat"
}
],
- "refresh": false,
- "schemaVersion": 38,
- "style": "dark",
+ "schemaVersion": 39,
"tags": [
"TeslamateCustomDashboards"
],
@@ -1899,7 +2283,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
@@ -1910,7 +2294,7 @@
"name": "car_id",
"options": [],
"query": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
- "refresh": 1,
+ "refresh": 2,
"regex": "",
"skipUrlSync": false,
"sort": 0,
@@ -1919,7 +2303,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select unit_of_length from settings limit 1;",
@@ -1938,7 +2322,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select unit_of_temperature from settings limit 1;",
@@ -1957,7 +2341,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "--- Extracted from Battery Health Dashboard",
@@ -1966,8 +2350,8 @@
"multi": false,
"name": "BatteryCapacity",
"options": [],
- "query": "SELECT AVG(Capacity) AS CurrentCapacity FROM\n (SELECT (100.0 * cp.charge_energy_added) / (GREATEST(1,MAX(usable_battery_level) - MIN(usable_battery_level))) AS Capacity\t\n FROM charging_processes cp\n\t INNER JOIN charges c ON cp.id = c.charging_process_id\n\t WHERE cp.car_id = $car_id AND \n cp.charge_energy_added >= (SELECT efficiency FROM cars WHERE id = 1) * 100.0\n GROUP BY cp.charge_energy_added, cp.end_date\n ORDER BY cp.end_date DESC \n LIMIT 5) AS lastEstimatedCapacity;",
- "refresh": 1,
+ "query": "WITH Aux AS\n(SELECT car_id,\n\t\tCOALESCE(efficiency, \n\t\t(SELECT efficiency\n\t\t\tFROM cars WHERE id = $car_id) * 100) AS efficiency\n\tFROM (\n\t\tSELECT ROUND((charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric, 3) * 100 as efficiency,\n\t\t\tCOUNT(*) as count, $car_id AS car_id \n\t\tFROM charging_processes\n\t\tWHERE car_id = $car_id\n\t\t\tAND duration_min > 10\n\t\t\tAND end_battery_level <= 95\n\t\t\tAND start_rated_range_km IS NOT NULL\n\t\t\tAND end_rated_range_km IS NOT NULL\n\t\t\tAND charge_energy_added > 0\n\t\tGROUP BY 1\n\t\tORDER BY 2 DESC\n\t\tLIMIT 1\n\t) AS DerivatedEfficiency\n),\nCurrentCapacity\t AS\n(SELECT AVG(Capacity) AS CurrentCapacity \nFROM (\nSELECT \n\tc.[[preferred_range]]_battery_range_km * aux.efficiency / c.usable_battery_level AS Capacity \n\tFROM charging_processes cp\n\t\tINNER JOIN charges c\n\t\tON c.charging_process_id = cp.id \n INNER JOIN aux ON cp.car_id = aux.car_id\n\tWHERE cp.car_id = $car_id\n\t\tAND cp.end_date IS NOT NULL\n\t\tAND cp.charge_energy_added >= aux.efficiency\n\t\tAND c.usable_battery_level > 0\n\t ORDER BY cp.end_date DESC LIMIT 10) AS lastCharges\n)\nSELECT CurrentCapacity FROM CurrentCapacity",
+ "refresh": 2,
"regex": "",
"skipUrlSync": false,
"sort": 0,
@@ -1976,7 +2360,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT (round(extract(epoch FROM start_date) - 10) * 1000) AS start_date_ts FROM charging_processes WHERE id = $charging_processes",
@@ -1986,7 +2370,7 @@
"name": "current_charge_time",
"options": [],
"query": "SELECT (round(extract(epoch FROM start_date) - 10) * 1000) AS start_date_ts FROM charging_processes WHERE id = $charging_processes",
- "refresh": 1,
+ "refresh": 2,
"regex": "",
"skipUrlSync": false,
"sort": 0,
@@ -1995,7 +2379,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT id FROM charging_processes WHERE car_id = $car_id ORDER BY start_date DESC LIMIT 1",
@@ -2005,7 +2389,7 @@
"name": "charging_processes",
"options": [],
"query": "SELECT id FROM charging_processes WHERE car_id = $car_id ORDER BY start_date DESC LIMIT 1",
- "refresh": 1,
+ "refresh": 2,
"regex": "",
"skipUrlSync": false,
"sort": 0,
@@ -2014,7 +2398,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT CASE WHEN end_date IS NULL THEN 'now&refresh=10s' ELSE CAST(round(extract(epoch FROM end_date) - 10) * 1000 AS VARCHAR(100)) END FROM charging_processes WHERE id = $charging_processes",
@@ -2024,6 +2408,26 @@
"name": "current_end_time",
"options": [],
"query": "SELECT CASE WHEN end_date IS NULL THEN 'now&refresh=10s' ELSE CAST(round(extract(epoch FROM end_date) - 10) * 1000 AS VARCHAR(100)) END FROM charging_processes WHERE id = $charging_processes",
+ "refresh": 2,
+ "regex": "",
+ "skipUrlSync": false,
+ "sort": 0,
+ "type": "query"
+ },
+ {
+ "current": {},
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
+ },
+ "definition": "select preferred_range from settings limit 1;",
+ "description": "preferred_range",
+ "hide": 2,
+ "includeAll": false,
+ "multi": false,
+ "name": "preferred_range",
+ "options": [],
+ "query": "select preferred_range from settings limit 1;",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
@@ -2052,6 +2456,6 @@
"timezone": "",
"title": "Current Charge View",
"uid": "jchm9RxutVS7a",
- "version": 7,
+ "version": 10,
"weekStart": ""
}
\ No newline at end of file
diff --git a/dashboards/CurrentDriveView.json b/dashboards/CurrentDriveView.json
index 462d218..fa9b559 100644
--- a/dashboards/CurrentDriveView.json
+++ b/dashboards/CurrentDriveView.json
@@ -7,12 +7,6 @@
"name": "Bar gauge",
"version": ""
},
- {
- "type": "panel",
- "id": "gauge",
- "name": "Gauge",
- "version": ""
- },
{
"type": "panel",
"id": "geomap",
@@ -23,11 +17,11 @@
"type": "grafana",
"id": "grafana",
"name": "Grafana",
- "version": "10.1.2"
+ "version": "10.4.0"
},
{
"type": "datasource",
- "id": "postgres",
+ "id": "grafana-postgresql-datasource",
"name": "PostgreSQL",
"version": "1.0.0"
},
@@ -50,9 +44,9 @@
"$$hashKey": "object:286",
"builtIn": 1,
"datasource": "-- 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,
- "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",
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
@@ -69,16 +63,7 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
- "id": null,
"links": [
- {
- "icon": "dashboard",
- "tags": [],
- "title": "TeslaMate",
- "tooltip": "",
- "type": "link",
- "url": "[[base_url:raw]]"
- },
{
"asDropdown": true,
"icon": "external link",
@@ -112,14 +97,14 @@
"title": "Current Drive",
"tooltip": "Adjust to current drive",
"type": "link",
- "url": "d/jchmkOuP_Fggz/current-drive-view?kiosk&var-car_id=${car_id}&from=${current_drive_start_time}&to=${current_drive_end_time}&var-current_drive=${current_drive}&var-BatteryCapacity=${BatteryCapacity}&var-efficiency=${efficiency}&var-preferred_range=${preferred_range}"
+ "url": "d/jchmkOuP_Fggz/current-drive-view?kiosk&var-car_id=${car_id}&from=${current_drive_start_time}&to=${current_drive_end_time}&var-current_drive=${current_drive}&var-BatteryCapacity=${BatteryCapacity}&var-efficiency=${efficiency}&var-preferred_range=${preferred_range}&var-length_unit=${length_unit}&var-temp_unit=${temp_unit}&var-alternative_length_unit=${alternative_length_unit}"
}
],
"liveNow": false,
"panels": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"description": "This is a special dashboard to load while driving. When you open this dashboard it will show the last 15 minutes, but you should click the \"Current Drive\" button at the top right corner, to enter in Kiosk mode:\n\n - If you are driving, you will see the information from the start time of the current drive until now and it will refesh automatically every 30 seconds.\n\n - If you are just browsing (not driving) you will see the information of the last drive.",
@@ -129,6 +114,7 @@
"mode": "fixed"
},
"custom": {
+ "axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
@@ -307,17 +293,32 @@
"value": "hidden"
}
]
+ },
+ {
+ "matcher": {
+ "id": "byName",
+ "options": "elevation_ft"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "lengthft"
+ },
+ {
+ "id": "displayName",
+ "value": "Elevation"
+ }
+ ]
}
]
},
"gridPos": {
- "h": 12,
- "w": 20,
+ "h": 11,
+ "w": 16,
"x": 0,
"y": 0
},
"id": 26,
- "links": [],
"options": {
"legend": {
"calcs": [],
@@ -335,9 +336,10 @@
{
"alias": "",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "editorMode": "code",
"format": "time_series",
"group": [],
"hide": false,
@@ -355,6 +357,23 @@
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"table": "charging",
"timeColumn": "Datum",
"timeColumnType": "timestamp",
@@ -368,7 +387,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "time_series",
@@ -405,11 +424,22 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
+ "color": {
+ "fixedColor": "red",
+ "mode": "thresholds"
+ },
+ "custom": {
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ }
+ },
"mappings": [],
"thresholds": {
"mode": "absolute",
@@ -421,80 +451,174 @@
]
}
},
- "overrides": [
- {
- "matcher": {
- "id": "byRegexp",
- "options": ".*_km"
- },
- "properties": [
- {
- "id": "unit",
- "value": "Wh/km"
- }
- ]
- },
- {
- "matcher": {
- "id": "byRegexp",
- "options": ".*_mi"
- },
- "properties": [
- {
- "id": "unit",
- "value": "Wh/mi"
- }
- ]
- }
- ]
+ "overrides": []
},
"gridPos": {
- "h": 3,
- "w": 4,
- "x": 20,
+ "h": 21,
+ "w": 8,
+ "x": 16,
"y": 0
},
- "id": 24,
+ "id": 33,
+ "maxDataPoints": 50000,
"options": {
- "colorMode": "value",
- "graphMode": "none",
- "justifyMode": "auto",
- "orientation": "auto",
- "reduceOptions": {
- "calcs": [
- "mean"
- ],
- "fields": "",
- "values": false
+ "basemap": {
+ "config": {},
+ "name": "Layer 0",
+ "type": "osm-standard"
+ },
+ "controls": {
+ "mouseWheelZoom": true,
+ "showAttribution": true,
+ "showDebug": false,
+ "showMeasure": false,
+ "showScale": false,
+ "showZoom": true
+ },
+ "layers": [
+ {
+ "config": {
+ "arrow": 0,
+ "style": {
+ "color": {
+ "fixed": "dark-blue"
+ },
+ "lineWidth": 2,
+ "opacity": 1,
+ "rotation": {
+ "fixed": 0,
+ "max": 360,
+ "min": -360,
+ "mode": "mod"
+ },
+ "size": {
+ "fixed": 3,
+ "max": 15,
+ "min": 2
+ },
+ "symbol": {
+ "field": "",
+ "fixed": "",
+ "mode": "fixed"
+ },
+ "symbolAlign": {
+ "horizontal": "center",
+ "vertical": "center"
+ },
+ "textConfig": {
+ "fontSize": 12,
+ "offsetX": 0,
+ "offsetY": 0,
+ "textAlign": "center",
+ "textBaseline": "middle"
+ }
+ }
+ },
+ "location": {
+ "mode": "auto"
+ },
+ "name": "route",
+ "opacity": 1,
+ "tooltip": true,
+ "type": "route"
+ }
+ ],
+ "tooltip": {
+ "mode": "details"
},
- "textMode": "auto"
+ "view": {
+ "allLayers": true,
+ "id": "fit",
+ "lat": 0,
+ "lon": 0,
+ "zoom": 15
+ }
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
+ "alias": "",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "format": "table",
- "group": [],
+ "editorMode": "code",
+ "format": "time_series",
+ "group": [
+ {
+ "params": [
+ "$__interval",
+ "none"
+ ],
+ "type": "time"
+ }
+ ],
+ "hide": false,
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "WITH d AS (\n\tSELECT\n\t\tc.car_id,\n\t\tlag(end_[[preferred_range]]_range_km) OVER (ORDER BY start_date) - start_[[preferred_range]]_range_km AS range_loss,\n\t\tp.odometer - lag(p.odometer) OVER (ORDER BY start_date) AS distance\n\tFROM charging_processes c\n\tLEFT JOIN positions p ON p.id = c.position_id \n\tWHERE\n\t end_date IS NOT NULL AND\n\t c.car_id = $car_id AND\n\t $__timeFilter(start_date)\n\tORDER BY start_date\n),\n\nrange_loss_between_charges AS (\n SELECT sum(range_loss) AS range_loss\n FROM d\n WHERE distance >= 0 AND range_loss >= 0\n GROUP BY car_id\n),\n\ncharge_dates AS (\n\tSELECT\n\t\tmin(start_date) as first_charge,\n\t\tmax(end_date) as last_charge\n\tFROM\n\t\tcharging_processes\n\tWHERE\n\t\tend_date IS NOT NULL\n\t\tAND car_id = $car_id\n\t\tAND $__timeFilter(start_date)\n),\n\nrange_loss_before_first_charge AS (\n\tSELECT\n\t\tmax([[preferred_range]]_battery_range_km) - min([[preferred_range]]_battery_range_km) AS range_loss\n\tFROM positions, charge_dates\n\tWHERE\n\t\tcar_id = $car_id\n\t\tAND $__timeFilter(date)\n\t\tAND ((select first_charge from charge_dates) is null OR date < (select first_charge from charge_dates))\n),\n\nrange_loss_after_last_charge AS (\n\tSELECT\n\t\tmax([[preferred_range]]_battery_range_km) - min([[preferred_range]]_battery_range_km) AS range_loss\n\tFROM positions, charge_dates\n\tWHERE\n\t\tcar_id = $car_id\n\t\tAND $__timeFilter(date)\n\t\tAND date > (select last_charge from charge_dates)\t\n),\n\ntotal_range_loss AS (\n SELECT sum(range_loss) as range_loss\n FROM (\n SELECT range_loss FROM range_loss_between_charges\n UNION ALL\n SELECT range_loss FROM range_loss_before_first_charge\n UNION ALL\n SELECT range_loss FROM range_loss_after_last_charge\n ) r\n),\n\ndistance AS (\n SELECT max(odometer) - min(odometer) as distance\n FROM positions\n WHERE car_id = $car_id AND $__timeFilter(date)\n)\n\nSELECT \n NULLIF(range_loss, 0) * (c.efficiency * 1000) / convert_km(NULLIF(distance::numeric, 0), '$length_unit') as \"consumption_$length_unit\"\nFROM total_range_loss, distance\nLEFT JOIN cars c ON c.id = $car_id",
+ "rawSql": "SELECT\n $__time(date),\n latitude,\n longitude\nFROM positions\nWHERE \n car_id = $car_id AND \n $__timeFilter(date)\nORDER BY \n date ASC",
"refId": "A",
"select": [
[
{
"params": [
- "start_km"
+ "lat"
+ ],
+ "type": "column"
+ },
+ {
+ "params": [
+ "avg"
+ ],
+ "type": "aggregate"
+ },
+ {
+ "params": [
+ "lat"
+ ],
+ "type": "alias"
+ }
+ ],
+ [
+ {
+ "params": [
+ "lng"
],
"type": "column"
+ },
+ {
+ "params": [
+ "avg"
+ ],
+ "type": "aggregate"
+ },
+ {
+ "params": [
+ "lat"
+ ],
+ "type": "alias"
}
]
],
- "table": "drives",
- "timeColumn": "start_date",
- "timeColumnType": "timestamp",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ]
+ },
+ "table": "pos",
+ "timeColumn": "Datum",
+ "timeColumnType": "datetime",
"where": [
{
"name": "$__timeFilter",
@@ -504,12 +628,11 @@
]
}
],
- "title": "Current Consumption",
- "type": "stat"
+ "type": "geomap"
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -553,10 +676,10 @@
]
},
"gridPos": {
- "h": 3,
+ "h": 4,
"w": 4,
- "x": 20,
- "y": 3
+ "x": 0,
+ "y": 11
},
"id": 32,
"options": {
@@ -571,21 +694,24 @@
"fields": "",
"values": false
},
- "textMode": "auto"
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "editorMode": "code",
"format": "table",
"group": [],
"hide": false,
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "SELECT\n\tCASE WHEN '$length_unit' = 'km' THEN $efficiency\n\t WHEN '$length_unit' = 'mi' THEN $efficiency * 1.60934\n\tEND as \"efficiency_$length_unit\"\nFROM settings\nWHERE\tid = $car_id;\n",
+ "rawSql": "SELECT\n\t(CASE WHEN '$length_unit' = 'km' THEN $efficiency\n\t WHEN '$length_unit' = 'mi' THEN $efficiency * 1.60934\n\tEND) * 10 as \"efficiency_$length_unit\"",
"refId": "A",
"select": [
[
@@ -597,114 +723,119 @@
}
]
],
- "table": "drives",
- "timeColumn": "start_date",
- "timeColumnType": "timestamp",
- "where": [
- {
- "name": "$__timeFilter",
- "params": [],
- "type": "macro"
- }
- ]
- }
- ],
- "title": "Current $preferred_range efficiency",
- "type": "stat"
- },
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "table": "drives",
+ "timeColumn": "start_date",
+ "timeColumnType": "timestamp",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ ],
+ "title": "Derivated Efficiency",
+ "type": "stat"
+ },
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
- "color": {
- "mode": "thresholds"
- },
- "decimals": 1,
"mappings": [],
- "max": 100,
- "min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
- "color": "dark-red",
+ "color": "yellow",
"value": null
- },
- {
- "color": "semi-dark-green",
- "value": 20
- },
- {
- "color": "semi-dark-orange",
- "value": 80
- },
+ }
+ ]
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": ".*_km"
+ },
+ "properties": [
{
- "color": "light-blue",
- "value": 100
+ "id": "unit",
+ "value": "Wh/km"
}
]
},
- "unit": "%"
- },
- "overrides": []
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": ".*_mi"
+ },
+ "properties": [
+ {
+ "id": "unit",
+ "value": "Wh/mi"
+ }
+ ]
+ }
+ ]
},
"gridPos": {
- "h": 9,
- "w": 2,
- "x": 20,
- "y": 6
+ "h": 4,
+ "w": 4,
+ "x": 4,
+ "y": 11
},
- "id": 29,
+ "id": 24,
"options": {
- "displayMode": "lcd",
- "minVizHeight": 10,
- "minVizWidth": 0,
- "orientation": "vertical",
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "auto",
"reduceOptions": {
"calcs": [
- "lastNotNull"
+ "mean"
],
"fields": "",
"values": false
},
- "showUnfilled": true,
- "text": {},
- "valueMode": "color"
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
"group": [],
- "groupBy": [
- {
- "params": [
- "$__interval"
- ],
- "type": "time"
- },
- {
- "params": [
- "null"
- ],
- "type": "fill"
- }
- ],
- "measurement": "%",
"metricColumn": "none",
- "orderByTime": "ASC",
- "policy": "default",
"rawQuery": true,
- "rawSql": "(SELECT battery_level, date\nFROM positions\nWHERE car_id = $car_id\nORDER BY date DESC\nLIMIT 1)\nUNION\nSELECT battery_level, date\nFROM charges c\nJOIN charging_processes p ON p.id = c.charging_process_id\nWHERE $__timeFilter(date) AND p.car_id = $car_id\nORDER BY date DESC\nLIMIT 1",
- "refId": "SOC",
- "resultFormat": "time_series",
+ "rawSql": "WITH d AS (\n\tSELECT\n\t\tc.car_id,\n\t\tlag(end_[[preferred_range]]_range_km) OVER (ORDER BY start_date) - start_[[preferred_range]]_range_km AS range_loss,\n\t\tp.odometer - lag(p.odometer) OVER (ORDER BY start_date) AS distance\n\tFROM charging_processes c\n\tLEFT JOIN positions p ON p.id = c.position_id \n\tWHERE\n\t end_date IS NOT NULL AND\n\t c.car_id = $car_id AND\n\t $__timeFilter(start_date)\n\tORDER BY start_date\n),\n\nrange_loss_between_charges AS (\n SELECT sum(range_loss) AS range_loss\n FROM d\n WHERE distance >= 0 AND range_loss >= 0\n GROUP BY car_id\n),\n\ncharge_dates AS (\n\tSELECT\n\t\tmin(start_date) as first_charge,\n\t\tmax(end_date) as last_charge\n\tFROM\n\t\tcharging_processes\n\tWHERE\n\t\tend_date IS NOT NULL\n\t\tAND car_id = $car_id\n\t\tAND $__timeFilter(start_date)\n),\n\nrange_loss_before_first_charge AS (\n\tSELECT\n\t\tmax([[preferred_range]]_battery_range_km) - min([[preferred_range]]_battery_range_km) AS range_loss\n\tFROM positions, charge_dates\n\tWHERE\n\t\tcar_id = $car_id\n\t\tAND $__timeFilter(date)\n\t\tAND ((select first_charge from charge_dates) is null OR date < (select first_charge from charge_dates))\n),\n\nrange_loss_after_last_charge AS (\n\tSELECT\n\t\tmax([[preferred_range]]_battery_range_km) - min([[preferred_range]]_battery_range_km) AS range_loss\n\tFROM positions, charge_dates\n\tWHERE\n\t\tcar_id = $car_id\n\t\tAND $__timeFilter(date)\n\t\tAND date > (select last_charge from charge_dates)\t\n),\n\ntotal_range_loss AS (\n SELECT sum(range_loss) as range_loss\n FROM (\n SELECT range_loss FROM range_loss_between_charges\n UNION ALL\n SELECT range_loss FROM range_loss_before_first_charge\n UNION ALL\n SELECT range_loss FROM range_loss_after_last_charge\n ) r\n),\n\ndistance AS (\n SELECT max(odometer) - min(odometer) as distance\n FROM positions\n WHERE car_id = $car_id AND $__timeFilter(date)\n)\n\nSELECT \n NULLIF(range_loss, 0) * (c.efficiency * 1000) / convert_km(NULLIF(distance::numeric, 0), '$length_unit') as \"consumption_$length_unit\"\nFROM total_range_loss, distance\nLEFT JOIN cars c ON c.id = $car_id",
+ "refId": "A",
"select": [
[
{
@@ -727,113 +858,163 @@
]
}
],
- "type": "bargauge"
+ "title": "Current Consumption",
+ "type": "stat"
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "description": "",
"fieldConfig": {
"defaults": {
"color": {
- "mode": "thresholds"
+ "mode": "continuous-GrYlRd"
},
- "decimals": 1,
"mappings": [],
- "min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
- "color": "dark-red",
+ "color": "green",
"value": null
},
{
- "color": "dark-green",
- "value": 7.84
- },
+ "color": "red",
+ "value": 80
+ }
+ ]
+ }
+ },
+ "overrides": [
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/.*_f/"
+ },
+ "properties": [
{
- "color": "semi-dark-orange",
- "value": 31.36
- },
+ "id": "unit",
+ "value": "fahrenheit"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/.*_c/"
+ },
+ "properties": [
{
- "color": "light-blue",
- "value": 35.28
+ "id": "unit",
+ "value": "celsius"
}
]
},
- "unit": "kwatth"
- },
- "overrides": []
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/outdoor*/"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Outdoor"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/inside*/"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Inside"
+ }
+ ]
+ },
+ {
+ "matcher": {
+ "id": "byRegexp",
+ "options": "/driver*/"
+ },
+ "properties": [
+ {
+ "id": "displayName",
+ "value": "Driver"
+ }
+ ]
+ }
+ ]
},
"gridPos": {
- "h": 9,
- "w": 2,
- "x": 22,
- "y": 6
+ "h": 4,
+ "w": 4,
+ "x": 8,
+ "y": 11
},
- "id": 31,
+ "id": 34,
"options": {
- "displayMode": "gradient",
- "minVizHeight": 10,
- "minVizWidth": 0,
- "orientation": "vertical",
+ "colorMode": "value",
+ "graphMode": "area",
+ "justifyMode": "center",
+ "orientation": "auto",
"reduceOptions": {
"calcs": [
- "lastNotNull"
+ "mean"
],
- "fields": "/^kwh$/",
+ "fields": "",
"values": false
},
- "showUnfilled": true,
+ "showPercentChange": false,
"text": {},
- "valueMode": "color"
+ "textMode": "auto",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "format": "table",
+ "editorMode": "code",
+ "format": "time_series",
"group": [],
- "groupBy": [
- {
- "params": [
- "$__interval"
- ],
- "type": "time"
- },
- {
- "params": [
- "null"
- ],
- "type": "fill"
- }
- ],
- "measurement": "%",
"metricColumn": "none",
- "policy": "default",
"rawQuery": true,
- "rawSql": "(SELECT battery_level * $BatteryCapacity / 100 as kWh, date, $BatteryCapacity as Total\nFROM positions\nWHERE car_id = $car_id\nORDER BY date DESC\nLIMIT 1)\nUNION\nSELECT battery_level * $BatteryCapacity / 100 as kWh, date, $BatteryCapacity as Total\nFROM charges c\nJOIN charging_processes p ON p.id = c.charging_process_id\nWHERE $__timeFilter(date) AND p.car_id = $car_id\nORDER BY date DESC\nLIMIT 1",
- "refId": "A",
- "resultFormat": "time_series",
+ "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(outside_temp, '$temp_unit')) as outdoor_$temp_unit \r\nFROM positions \r\nWHERE car_id = $car_id AND outside_temp IS NOT NULL AND $__timeFilter(date)\r\nGROUP BY date\r\nORDER BY date",
+ "refId": "Outdoor",
"select": [
[
{
"params": [
- "start_km"
+ "value"
],
"type": "column"
}
]
],
- "table": "drives",
- "timeColumn": "start_date",
- "timeColumnType": "timestamp",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
"where": [
{
"name": "$__timeFilter",
@@ -841,82 +1022,48 @@
"type": "macro"
}
]
- }
- ],
- "type": "bargauge"
- },
- {
- "datasource": {
- "type": "postgres",
- "uid": "TeslaMate"
- },
- "fieldConfig": {
- "defaults": {
- "color": {
- "mode": "thresholds"
- },
- "decimals": 0,
- "mappings": [],
- "max": 100,
- "min": 0,
- "thresholds": {
- "mode": "absolute",
- "steps": [
- {
- "color": "semi-dark-green",
- "value": null
- }
- ]
- },
- "unit": "degree"
},
- "overrides": []
- },
- "gridPos": {
- "h": 3,
- "w": 3,
- "x": 0,
- "y": 12
- },
- "id": 8,
- "options": {
- "orientation": "auto",
- "reduceOptions": {
- "calcs": [
- "firstNotNull"
- ],
- "fields": "",
- "values": false
- },
- "showThresholdLabels": false,
- "showThresholdMarkers": true
- },
- "pluginVersion": "10.1.2",
- "targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "format": "table",
+ "editorMode": "code",
+ "format": "time_series",
"group": [],
+ "hide": false,
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "WITH last_position AS (\n\tSELECT date, convert_celsius(outside_temp, '$temp_unit') AS \"Outside Temperature [°$temp_unit]\"\n\tFROM positions\n\tWHERE car_id = $car_id AND outside_temp IS NOT NULL AND $__timeFilter(date)\n\tORDER BY date DESC\n\tLIMIT 1\n),\nlast_charge AS (\n\tSELECT date, convert_celsius(outside_temp, '$temp_unit') AS \"Outside Temperature [°$temp_unit]\"\n\tFROM charges\n\tJOIN charging_processes ON charges.charging_process_id = charging_processes.id\n\tWHERE car_id = $car_id AND outside_temp IS NOT NULL AND $__timeFilter(date)\n\tORDER BY date DESC\n\tLIMIT 1\n)\nSELECT * FROM last_position\nUNION ALL\nSELECT * FROM last_charge\nORDER BY date DESC\nLIMIT 1;",
- "refId": "A",
+ "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(inside_temp, '$temp_unit')) as inside_$temp_unit \r\nFROM positions \r\nWHERE car_id = $car_id AND outside_temp IS NOT NULL AND $__timeFilter(date)\r\nGROUP BY date\r\nORDER BY date",
+ "refId": "Inside",
"select": [
[
{
"params": [
- "outside_temp"
+ "value"
],
"type": "column"
}
]
],
- "table": "positions",
- "timeColumn": "date",
- "timeColumnType": "timestamp",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
"where": [
{
"name": "$__timeFilter",
@@ -924,82 +1071,49 @@
"type": "macro"
}
]
- }
- ],
- "title": "Outside Temp",
- "type": "gauge"
- },
- {
- "datasource": {
- "type": "postgres",
- "uid": "TeslaMate"
- },
- "fieldConfig": {
- "defaults": {
- "color": {
- "mode": "thresholds"
- },
- "decimals": 0,
- "mappings": [],
- "max": 100,
- "min": 0,
- "thresholds": {
- "mode": "absolute",
- "steps": [
- {
- "color": "semi-dark-green",
- "value": null
- }
- ]
- },
- "unit": "degree"
},
- "overrides": []
- },
- "gridPos": {
- "h": 3,
- "w": 3,
- "x": 3,
- "y": 12
- },
- "id": 9,
- "options": {
- "orientation": "auto",
- "reduceOptions": {
- "calcs": [
- "firstNotNull"
- ],
- "fields": "",
- "values": false
- },
- "showThresholdLabels": false,
- "showThresholdMarkers": true
- },
- "pluginVersion": "10.1.2",
- "targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "format": "table",
+ "editorMode": "code",
+ "format": "time_series",
"group": [],
+ "hide": false,
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "SELECT\n date,\n convert_celsius(inside_temp, '$temp_unit') AS \"Inside Temperature [°$temp_unit]\"\nFROM positions\nWHERE\n car_id = $car_id\n and inside_temp is not null AND $__timeFilter(date)\norder by date desc\nlimit 1 ",
- "refId": "A",
+ "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(driver_temp_setting, '$temp_unit')) as driver_$temp_unit \r\nFROM positions \r\nWHERE car_id = $car_id AND outside_temp IS NOT NULL AND $__timeFilter(date)\r\nGROUP BY date\r\nORDER BY date",
+ "refId": "Driver",
"select": [
[
{
"params": [
- "outside_temp"
+ "start_km"
],
"type": "column"
}
]
],
- "table": "positions",
- "timeColumn": "date",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "table": "drives",
+ "timeColumn": "start_date",
"timeColumnType": "timestamp",
"where": [
{
@@ -1010,81 +1124,119 @@
]
}
],
- "title": "Inside Temp",
- "type": "gauge"
+ "type": "stat"
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
- "color": {
- "mode": "thresholds"
- },
- "decimals": 0,
+ "decimals": 1,
"mappings": [],
- "max": 100,
- "min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
- "color": "semi-dark-green",
+ "color": "super-light-blue",
"value": null
}
]
},
- "unit": "degree"
+ "unit": "clocks"
},
"overrides": []
},
"gridPos": {
- "h": 3,
- "w": 3,
- "x": 6,
- "y": 12
+ "h": 4,
+ "w": 4,
+ "x": 12,
+ "y": 11
},
- "id": 16,
+ "id": 36,
"options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
- "firstNotNull"
+ "sum"
],
"fields": "",
"values": false
},
- "showThresholdLabels": false,
- "showThresholdMarkers": true
+ "showPercentChange": false,
+ "text": {},
+ "textMode": "value",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
+ "alias": "Elapsed Time",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "editorMode": "code",
"format": "table",
"group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
"metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
"rawQuery": true,
- "rawSql": "SELECT\n\t$__time(date),\n\tconvert_celsius(driver_temp_setting, '$temp_unit') as \"Driver Temperature [°$temp_unit]\"\nFROM positions\nWHERE driver_temp_setting IS NOT NULL AND car_id = $car_id AND $__timeFilter(date)\nORDER BY date DESC\nLIMIT 1;",
+ "rawSql": "SELECT ${__to:date:seconds} - ${__from:date:seconds}",
"refId": "A",
+ "resultFormat": "time_series",
"select": [
[
{
"params": [
- "outside_temp"
+ "utc"
],
- "type": "column"
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "mean"
}
]
],
- "table": "positions",
- "timeColumn": "date",
- "timeColumnType": "timestamp",
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "tags": [],
+ "timeColumn": "time",
"where": [
{
"name": "$__timeFilter",
@@ -1094,12 +1246,12 @@
]
}
],
- "title": "Driver Temp",
- "type": "gauge"
+ "title": "Elapsed",
+ "type": "stat"
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -1145,10 +1297,10 @@
]
},
"gridPos": {
- "h": 3,
- "w": 3,
- "x": 9,
- "y": 12
+ "h": 4,
+ "w": 4,
+ "x": 0,
+ "y": 15
},
"id": 27,
"links": [
@@ -1176,20 +1328,23 @@
"fields": "",
"values": false
},
- "textMode": "value"
+ "showPercentChange": false,
+ "textMode": "value",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "editorMode": "code",
"format": "table",
"group": [],
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "SELECT convert_km((max(odometer) - min(odometer))::numeric, '$length_unit') as \"distance_$length_unit\"\n FROM positions\n WHERE car_id = $car_id AND $__timeFilter(date)",
+ "rawSql": "SELECT convert_km((max(odometer) - min(odometer))::numeric, '$length_unit') as \"distance_$length_unit\"\n FROM positions\n WHERE $__timeFilter(date) AND drive_id=$current_drive ",
"refId": "A",
"select": [
[
@@ -1201,6 +1356,23 @@
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"timeColumn": "time",
"where": [
{
@@ -1216,7 +1388,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -1272,13 +1444,12 @@
]
},
"gridPos": {
- "h": 3,
- "w": 3,
- "x": 12,
- "y": 12
+ "h": 4,
+ "w": 4,
+ "x": 4,
+ "y": 15
},
"id": 14,
- "links": [],
"maxDataPoints": 100,
"options": {
"colorMode": "value",
@@ -1297,20 +1468,23 @@
"fields": "",
"values": false
},
- "textMode": "value"
+ "showPercentChange": false,
+ "textMode": "value",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "editorMode": "code",
"format": "time_series",
"group": [],
"metricColumn": "none",
"rawQuery": true,
- "rawSql": "SELECT $__time(date), range as \"range_$length_unit\"\nFROM (\n\t(SELECT date, convert_km([[preferred_range]]_battery_range_km, '$length_unit') AS range\n\tFROM positions\n\tWHERE car_id = $car_id AND [[preferred_range]]_battery_range_km IS NOT NULL\n ORDER BY date DESC\n\tLIMIT 1)\n\tUNION ALL\n\t(SELECT date, convert_km([[preferred_range]]_battery_range_km, '$length_unit') AS range\n\tFROM charges c\n\tJOIN charging_processes p ON p.id = c.charging_process_id\n\tWHERE p.car_id = $car_id\n\tORDER BY date DESC\n\tLIMIT 1)\n) AS data\nORDER BY date DESC\nLIMIT 1;",
+ "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_km([[preferred_range]]_battery_range_km, '$length_unit')) as range_$length_unit \nFROM positions WHERE $__timeFilter(date) AND drive_id=$current_drive GROUP BY 1 ORDER BY 1 desc limit 1",
"refId": "A",
"select": [
[
@@ -1322,6 +1496,23 @@
}
]
],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
"timeColumn": "time",
"where": [
{
@@ -1332,12 +1523,12 @@
]
}
],
- "title": "Range",
+ "title": "Current Range ($preferred_range)",
"type": "stat"
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -1383,10 +1574,10 @@
]
},
"gridPos": {
- "h": 3,
- "w": 5,
- "x": 15,
- "y": 12
+ "h": 4,
+ "w": 4,
+ "x": 8,
+ "y": 15
},
"id": 6,
"links": [
@@ -1409,37 +1600,288 @@
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
- "mean"
+ "mean"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "value",
+ "wideLayout": true
+ },
+ "pluginVersion": "10.4.0",
+ "targets": [
+ {
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
+ },
+ "editorMode": "code",
+ "format": "time_series",
+ "group": [],
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "select $__time(date), convert_km(odometer::numeric, '$length_unit') as \"odometer_$length_unit\"\nfrom positions \nwhere drive_id = $current_drive \norder by date desc \nlimit 1;",
+ "refId": "A",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "timeColumn": "time",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ ],
+ "title": "Odometer",
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
+ },
+ "description": "",
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "palette-classic"
+ },
+ "decimals": 0,
+ "mappings": [],
+ "max": 49,
+ "min": 0,
+ "noValue": "0",
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "light-orange",
+ "value": null
+ }
+ ]
+ },
+ "unit": "kwatth"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 4,
+ "w": 4,
+ "x": 12,
+ "y": 15
+ },
+ "id": 35,
+ "options": {
+ "colorMode": "value",
+ "graphMode": "area",
+ "justifyMode": "center",
+ "orientation": "vertical",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "value",
+ "wideLayout": true
+ },
+ "pluginVersion": "10.4.0",
+ "targets": [
+ {
+ "alias": "kWh Added",
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
+ },
+ "editorMode": "code",
+ "format": "table",
+ "group": [],
+ "hide": false,
+ "metricColumn": "none",
+ "rawQuery": true,
+ "rawSql": "SELECT $BatteryCapacity AS \"Battery Capacity\"",
+ "refId": "B",
+ "select": [
+ [
+ {
+ "params": [
+ "start_km"
+ ],
+ "type": "column"
+ }
+ ]
+ ],
+ "sql": {
+ "columns": [
+ {
+ "parameters": [],
+ "type": "function"
+ }
+ ],
+ "groupBy": [
+ {
+ "property": {
+ "type": "string"
+ },
+ "type": "groupBy"
+ }
+ ],
+ "limit": 50
+ },
+ "table": "drives",
+ "timeColumn": "start_date",
+ "timeColumnType": "timestamp",
+ "where": [
+ {
+ "name": "$__timeFilter",
+ "params": [],
+ "type": "macro"
+ }
+ ]
+ }
+ ],
+ "title": "Battery Capacity",
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "grafana-postgresql-datasource",
+ "uid": "TeslaMate"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "decimals": 1,
+ "mappings": [],
+ "max": 100,
+ "min": 0,
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "dark-red",
+ "value": null
+ },
+ {
+ "color": "semi-dark-green",
+ "value": 20
+ },
+ {
+ "color": "semi-dark-orange",
+ "value": 80
+ },
+ {
+ "color": "light-blue",
+ "value": 100
+ }
+ ]
+ },
+ "unit": "%"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 2,
+ "w": 8,
+ "x": 0,
+ "y": 19
+ },
+ "id": 29,
+ "options": {
+ "displayMode": "lcd",
+ "maxVizHeight": 300,
+ "minVizHeight": 10,
+ "minVizWidth": 0,
+ "namePlacement": "auto",
+ "orientation": "horizontal",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
],
"fields": "",
"values": false
},
- "textMode": "value"
+ "showUnfilled": true,
+ "sizing": "auto",
+ "text": {},
+ "valueMode": "color"
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "format": "time_series",
+ "format": "table",
"group": [],
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "%",
"metricColumn": "none",
+ "orderByTime": "ASC",
+ "policy": "default",
"rawQuery": true,
- "rawSql": "select $__time(date), convert_km(odometer::numeric, '$length_unit') as \"odometer_$length_unit\"\nfrom positions \nwhere car_id = $car_id \norder by date desc \nlimit 1;",
- "refId": "A",
+ "rawSql": "(SELECT battery_level, date\nFROM positions\nWHERE car_id = $car_id\nORDER BY date DESC\nLIMIT 1)\nUNION\nSELECT battery_level, date\nFROM charges c\nJOIN charging_processes p ON p.id = c.charging_process_id\nWHERE $__timeFilter(date) AND p.car_id = $car_id\nORDER BY date DESC\nLIMIT 1",
+ "refId": "SOC",
+ "resultFormat": "time_series",
"select": [
[
{
"params": [
- "value"
+ "start_km"
],
"type": "column"
}
]
],
- "timeColumn": "time",
+ "table": "drives",
+ "timeColumn": "start_date",
+ "timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
@@ -1449,207 +1891,116 @@
]
}
],
- "title": "Odometer",
- "type": "stat"
+ "type": "bargauge"
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
+ "description": "",
"fieldConfig": {
"defaults": {
"color": {
- "fixedColor": "red",
"mode": "thresholds"
},
- "custom": {
- "hideFrom": {
- "legend": false,
- "tooltip": false,
- "viz": false
- }
- },
+ "decimals": 1,
"mappings": [],
+ "min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
- "color": "green",
+ "color": "dark-red",
"value": null
+ },
+ {
+ "color": "dark-green",
+ "value": 7.84
+ },
+ {
+ "color": "semi-dark-orange",
+ "value": 31.36
+ },
+ {
+ "color": "light-blue",
+ "value": 35.28
}
]
- }
+ },
+ "unit": "kwatth"
},
"overrides": []
},
"gridPos": {
- "h": 10,
- "w": 24,
- "x": 0,
- "y": 15
+ "h": 2,
+ "w": 8,
+ "x": 8,
+ "y": 19
},
- "id": 33,
- "links": [],
- "maxDataPoints": 50000,
+ "id": 31,
"options": {
- "basemap": {
- "config": {},
- "name": "Layer 0",
- "type": "osm-standard"
- },
- "controls": {
- "mouseWheelZoom": true,
- "showAttribution": true,
- "showDebug": false,
- "showMeasure": false,
- "showScale": false,
- "showZoom": true
- },
- "layers": [
- {
- "config": {
- "arrow": 0,
- "style": {
- "color": {
- "fixed": "dark-blue"
- },
- "lineWidth": 2,
- "opacity": 1,
- "rotation": {
- "fixed": 0,
- "max": 360,
- "min": -360,
- "mode": "mod"
- },
- "size": {
- "fixed": 3,
- "max": 15,
- "min": 2
- },
- "symbol": {
- "field": "",
- "fixed": "",
- "mode": "fixed"
- },
- "symbolAlign": {
- "horizontal": "center",
- "vertical": "center"
- },
- "textConfig": {
- "fontSize": 12,
- "offsetX": 0,
- "offsetY": 0,
- "textAlign": "center",
- "textBaseline": "middle"
- }
- }
- },
- "location": {
- "mode": "auto"
- },
- "name": "route",
- "opacity": 1,
- "tooltip": true,
- "type": "route"
- }
- ],
- "tooltip": {
- "mode": "details"
+ "displayMode": "gradient",
+ "maxVizHeight": 300,
+ "minVizHeight": 10,
+ "minVizWidth": 0,
+ "namePlacement": "auto",
+ "orientation": "horizontal",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "/^kwh$/",
+ "values": false
},
- "view": {
- "allLayers": true,
- "id": "fit",
- "lat": 0,
- "lon": 0,
- "zoom": 15
- }
+ "showUnfilled": true,
+ "sizing": "auto",
+ "text": {},
+ "valueMode": "color"
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
- "alias": "",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "editorMode": "code",
- "format": "time_series",
- "group": [
+ "format": "table",
+ "group": [],
+ "groupBy": [
{
"params": [
- "$__interval",
- "none"
+ "$__interval"
],
"type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
}
],
- "hide": false,
+ "measurement": "%",
"metricColumn": "none",
+ "policy": "default",
"rawQuery": true,
- "rawSql": "SELECT\n $__time(date),\n latitude,\n longitude\nFROM positions\nWHERE \n car_id = $car_id AND \n $__timeFilter(date)\nORDER BY \n date ASC",
+ "rawSql": "(SELECT battery_level * $BatteryCapacity / 100 as kWh, date, $BatteryCapacity as Total\nFROM positions\nWHERE car_id = $car_id\nORDER BY date DESC\nLIMIT 1)\nUNION\nSELECT battery_level * $BatteryCapacity / 100 as kWh, date, $BatteryCapacity as Total\nFROM charges c\nJOIN charging_processes p ON p.id = c.charging_process_id\nWHERE $__timeFilter(date) AND p.car_id = $car_id\nORDER BY date DESC\nLIMIT 1",
"refId": "A",
+ "resultFormat": "time_series",
"select": [
[
{
"params": [
- "lat"
- ],
- "type": "column"
- },
- {
- "params": [
- "avg"
- ],
- "type": "aggregate"
- },
- {
- "params": [
- "lat"
- ],
- "type": "alias"
- }
- ],
- [
- {
- "params": [
- "lng"
+ "start_km"
],
"type": "column"
- },
- {
- "params": [
- "avg"
- ],
- "type": "aggregate"
- },
- {
- "params": [
- "lat"
- ],
- "type": "alias"
}
]
],
- "sql": {
- "columns": [
- {
- "parameters": [],
- "type": "function"
- }
- ],
- "groupBy": [
- {
- "property": {
- "type": "string"
- },
- "type": "groupBy"
- }
- ]
- },
- "table": "pos",
- "timeColumn": "Datum",
- "timeColumnType": "datetime",
+ "table": "drives",
+ "timeColumn": "start_date",
+ "timeColumnType": "timestamp",
"where": [
{
"name": "$__timeFilter",
@@ -1659,12 +2010,11 @@
]
}
],
- "type": "geomap"
+ "type": "bargauge"
}
],
- "refresh": "10s",
- "schemaVersion": 38,
- "style": "dark",
+ "refresh": "",
+ "schemaVersion": 39,
"tags": [
"TeslamateCustomDashboards"
],
@@ -1673,7 +2023,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
@@ -1696,7 +2046,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select unit_of_length from settings limit 1;",
@@ -1718,7 +2068,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select unit_of_temperature from settings limit 1;",
@@ -1740,7 +2090,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select preferred_range from settings limit 1;",
@@ -1763,30 +2113,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
- "uid": "TeslaMate"
- },
- "definition": "select base_url from settings limit 1;",
- "hide": 2,
- "includeAll": false,
- "label": "",
- "multi": false,
- "name": "base_url",
- "options": [],
- "query": "select base_url from settings limit 1;",
- "refresh": 1,
- "regex": "",
- "skipUrlSync": false,
- "sort": 0,
- "tagValuesQuery": "",
- "tagsQuery": "",
- "type": "query",
- "useTags": false
- },
- {
- "current": {},
- "datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select case when unit_of_length = 'km' then 'm' when unit_of_length = 'mi' then 'ft' end from settings limit 1;",
@@ -1805,7 +2132,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT drive_id FROM positions WHERE car_id = $car_id AND drive_id IS NOT NULL ORDER BY date DESC LIMIT 1;",
@@ -1824,7 +2151,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT \n (round(extract(epoch FROM start_date) - 10) * 1000) AS start_date_ts\n FROM drives \n WHERE id = $current_drive",
@@ -1843,7 +2170,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT \n CASE WHEN end_date IS NULL THEN 'now&refresh=10s' \n ELSE CAST(round(extract(epoch FROM end_date) - 10) * 1000 AS VARCHAR(100)) END\n FROM drives\n WHERE id = $current_drive",
@@ -1862,7 +2189,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "--- Extracted from Battery Health Dashboard",
@@ -1871,7 +2198,7 @@
"multi": false,
"name": "BatteryCapacity",
"options": [],
- "query": "SELECT AVG(Capacity) AS CurrentCapacity FROM\n (SELECT (100.0 * cp.charge_energy_added) / (GREATEST(1,MAX(usable_battery_level) - MIN(usable_battery_level))) AS Capacity\t\n FROM charging_processes cp\n\t INNER JOIN charges c ON cp.id = c.charging_process_id\n\t WHERE cp.car_id = $car_id AND \n cp.charge_energy_added >= (SELECT efficiency FROM cars WHERE id = 1) * 100.0\n GROUP BY cp.charge_energy_added, cp.end_date\n ORDER BY cp.end_date DESC \n LIMIT 5) AS lastEstimatedCapacity;",
+ "query": "WITH Aux AS\n(SELECT car_id,\n\t\tCOALESCE(efficiency, \n\t\t(SELECT efficiency\n\t\t\tFROM cars WHERE id = $car_id) * 100) AS efficiency\n\tFROM (\n\t\tSELECT ROUND((charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric, 3) * 100 as efficiency,\n\t\t\tCOUNT(*) as count, $car_id AS car_id \n\t\tFROM charging_processes\n\t\tWHERE car_id = $car_id\n\t\t\tAND duration_min > 10\n\t\t\tAND end_battery_level <= 95\n\t\t\tAND start_rated_range_km IS NOT NULL\n\t\t\tAND end_rated_range_km IS NOT NULL\n\t\t\tAND charge_energy_added > 0\n\t\tGROUP BY 1\n\t\tORDER BY 2 DESC\n\t\tLIMIT 1\n\t) AS DerivatedEfficiency\n),\nCurrentCapacity\t AS\n(SELECT AVG(Capacity) AS CurrentCapacity \nFROM (\nSELECT \n\tc.[[preferred_range]]_battery_range_km * aux.efficiency / c.usable_battery_level AS Capacity \n\tFROM charging_processes cp\n\t\tINNER JOIN charges c\n\t\tON c.charging_process_id = cp.id \n INNER JOIN aux ON cp.car_id = aux.car_id\n\tWHERE cp.car_id = $car_id\n\t\tAND cp.end_date IS NOT NULL\n\t\tAND cp.charge_energy_added >= aux.efficiency\n\t\tAND c.usable_battery_level > 0\n\t ORDER BY cp.end_date DESC LIMIT 10) AS lastCharges\n)\nSELECT CurrentCapacity FROM CurrentCapacity",
"refresh": 2,
"regex": "",
"skipUrlSync": false,
@@ -1881,16 +2208,16 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
- "definition": "SELECT\n\tCASE WHEN '$length_unit' = 'km' THEN efficiency\n\t WHEN '$length_unit' = 'mi' THEN efficiency * 1.60934\n\tEND * 1000 as \"efficiency_$length_unit\"\nFROM\n\tcars\nWHERE\n\tid = $car_id;",
+ "definition": "--- Extracted from Battery Health Dashboard",
"hide": 2,
"includeAll": false,
"multi": false,
"name": "efficiency",
"options": [],
- "query": "SELECT\n\tCASE WHEN '$length_unit' = 'km' THEN efficiency\n\t WHEN '$length_unit' = 'mi' THEN efficiency * 1.60934\n\tEND * 1000 as \"efficiency_$length_unit\"\nFROM\n\tcars\nWHERE\n\tid = $car_id;",
+ "query": "\t\tSELECT \n\t\tCOALESCE(efficiency, \n\t\t(SELECT efficiency\n\t\t\tFROM cars WHERE id = $car_id) * 100) AS efficiency\n\tFROM (\n\t\tSELECT ROUND((charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric, 3) * 100 as efficiency,\n\t\t\tCOUNT(*) as count, $car_id AS car_id \n\t\tFROM charging_processes\n\t\tWHERE car_id = $car_id\n\t\t\tAND duration_min > 10\n\t\t\tAND end_battery_level <= 95\n\t\t\tAND start_rated_range_km IS NOT NULL\n\t\t\tAND end_rated_range_km IS NOT NULL\n\t\t\tAND charge_energy_added > 0\n\t\tGROUP BY 1\n\t\tORDER BY 2 DESC\n\t\tLIMIT 1\n\t) AS DerivatedEfficiency",
"refresh": 2,
"regex": "",
"skipUrlSync": false,
@@ -1932,6 +2259,6 @@
"timezone": "",
"title": "Current Drive View",
"uid": "jchmkOuP_Fggz",
- "version": 8,
+ "version": 10,
"weekStart": ""
}
\ No newline at end of file
diff --git a/dashboards/DatabaseDashboadInfo.json b/dashboards/DatabaseDashboadInfo.json
index cc036d6..18e7642 100644
--- a/dashboards/DatabaseDashboadInfo.json
+++ b/dashboards/DatabaseDashboadInfo.json
@@ -1180,7 +1180,7 @@
"format": "table",
"hide": false,
"rawQuery": true,
- "rawSql": "SELECT '2024.04.05' AS \"Current Version\"",
+ "rawSql": "SELECT '2024.04.10' AS \"Current Version\"",
"refId": "DashboardVersion",
"sql": {
"columns": [
diff --git a/dashboards/TrackingDrives.json b/dashboards/TrackingDrives.json
index 05e0f36..2fe333d 100644
--- a/dashboards/TrackingDrives.json
+++ b/dashboards/TrackingDrives.json
@@ -11,11 +11,11 @@
"type": "grafana",
"id": "grafana",
"name": "Grafana",
- "version": "10.1.2"
+ "version": "10.4.0"
},
{
"type": "datasource",
- "id": "postgres",
+ "id": "grafana-postgresql-datasource",
"name": "PostgreSQL",
"version": "1.0.0"
},
@@ -41,9 +41,9 @@
"type": "datasource",
"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,
- "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",
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
@@ -97,7 +97,7 @@
"panels": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"description": "This dashboard is meant to analize a drive based on a date you select, then you can pass the pointer over the lines in graph to see data details and a blue point in the map tranking the route. With this option you can analized a specific point location in the map, to see the speed, power, SOC, elevation and if battery heater was on.\n\nBe aware that the drive you select in the dropdown list from the top could be outside the time range of the Timeline graph, if its the case you have to click on the \"Zoom to data\" button on the graph in order to update it.\n\nTip: On Grafana you can press \"h\" to get a keyboard shortcuts if you want to change the current Zoom out time range or use the mouse to select/change the time range.",
@@ -107,6 +107,7 @@
"mode": "palette-classic"
},
"custom": {
+ "axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
@@ -389,7 +390,6 @@
},
"hideTimeOverride": false,
"id": 8,
- "links": [],
"options": {
"legend": {
"calcs": [],
@@ -407,7 +407,7 @@
{
"alias": "",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "time_series",
@@ -444,14 +444,14 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "red",
- "mode": "thresholds"
+ "mode": "fixed"
},
"custom": {
"hideFrom": {
@@ -480,13 +480,14 @@
"y": 0
},
"id": 18,
- "links": [],
"maxDataPoints": 50000,
"options": {
"basemap": {
- "config": {},
+ "config": {
+ "server": "streets"
+ },
"name": "Layer 0",
- "type": "osm-standard"
+ "type": "esri-xyz"
},
"controls": {
"mouseWheelZoom": true,
@@ -519,7 +520,7 @@
},
"symbol": {
"field": "",
- "fixed": "",
+ "fixed": "img/icons/marker/triangle.svg",
"mode": "fixed"
},
"symbolAlign": {
@@ -545,7 +546,7 @@
}
],
"tooltip": {
- "mode": "details"
+ "mode": "none"
},
"view": {
"allLayers": true,
@@ -555,12 +556,12 @@
"zoom": 15
}
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"alias": "",
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"editorMode": "code",
@@ -653,7 +654,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"description": "",
@@ -726,7 +727,6 @@
"y": 17
},
"id": 14,
- "links": [],
"maxDataPoints": 100,
"options": {
"colorMode": "value",
@@ -740,16 +740,18 @@
"fields": "",
"values": false
},
+ "showPercentChange": false,
"text": {
"titleSize": 16
},
- "textMode": "value_and_name"
+ "textMode": "value_and_name",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -781,7 +783,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -817,7 +819,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"description": "",
@@ -920,7 +922,6 @@
"y": 17
},
"id": 12,
- "links": [],
"maxDataPoints": 100,
"options": {
"colorMode": "value",
@@ -932,16 +933,18 @@
"fields": "",
"values": false
},
+ "showPercentChange": false,
"text": {
"titleSize": 16
},
- "textMode": "auto"
+ "textMode": "auto",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -973,7 +976,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -1009,7 +1012,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -1047,7 +1050,6 @@
"y": 17
},
"id": 16,
- "links": [],
"maxDataPoints": 100,
"options": {
"colorMode": "value",
@@ -1061,16 +1063,18 @@
"fields": "",
"values": false
},
+ "showPercentChange": false,
"text": {
"titleSize": 16
},
- "textMode": "value"
+ "textMode": "value",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -1106,7 +1110,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
@@ -1146,16 +1150,18 @@
"fields": "/.*/",
"values": false
},
+ "showPercentChange": false,
"text": {
"titleSize": 16
},
- "textMode": "value_and_name"
+ "textMode": "value_and_name",
+ "wideLayout": true
},
- "pluginVersion": "10.1.2",
+ "pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -1187,7 +1193,7 @@
},
{
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"format": "table",
@@ -1224,8 +1230,7 @@
}
],
"refresh": "",
- "schemaVersion": 38,
- "style": "dark",
+ "schemaVersion": 39,
"tags": [
"TeslamateCustomDashboards"
],
@@ -1234,7 +1239,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select unit_of_length from settings limit 1;",
@@ -1253,7 +1258,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select case when unit_of_length = 'km' then 'm' when unit_of_length = 'mi' then 'ft' end from settings limit 1;",
@@ -1272,7 +1277,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
@@ -1295,7 +1300,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT TO_CHAR(start_date, 'YYYY') as year FROM drives\nWHERE car_id = $car_id\nGROUP BY 1\nORDER BY 1 DESC;",
@@ -1314,7 +1319,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "(SELECT TO_CHAR(start_date, 'MM') as month FROM drives WHERE car_id = $car_id ORDER BY start_date DESC LIMIT 1)\nUNION ALL\n(SELECT TO_CHAR(start_date, 'MM') as month FROM drives WHERE car_id = $car_id AND TO_CHAR(start_date, 'YYYY') = '$Year'\nGROUP BY 1\nORDER BY 1);",
@@ -1333,7 +1338,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "(SELECT TO_CHAR(start_date, 'DD') as day FROM drives WHERE car_id = $car_id ORDER BY start_date DESC LIMIT 1)\nUNION ALL\n(SELECT TO_CHAR(start_date, 'DD') as day FROM drives \nWHERE car_id = $car_id AND TO_CHAR(start_date, 'YYYY') = '$Year' AND TO_CHAR(start_date, 'MM') = '$Month'\nGROUP BY 1 ORDER BY 1);",
@@ -1352,7 +1357,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "WITH data AS (\n SELECT\n drives.id as drive_id,\n start_date,\n COALESCE(start_geofence.name, CONCAT_WS(', ', COALESCE(start_address.name, nullif(CONCAT_WS(' ', start_address.road, start_address.house_number), '')), start_address.city)) AS start_address,\n COALESCE(end_geofence.name, CONCAT_WS(', ', COALESCE(end_address.name, nullif(CONCAT_WS(' ', end_address.road, end_address.house_number), '')), end_address.city)) AS end_address\n FROM drives\n LEFT JOIN addresses start_address ON start_address_id = start_address.id\n LEFT JOIN addresses end_address ON end_address_id = end_address.id\n LEFT JOIN positions start_position ON start_position_id = start_position.id\n LEFT JOIN positions end_position ON end_position_id = end_position.id\n LEFT JOIN geofences start_geofence ON start_geofence_id = start_geofence.id\n LEFT JOIN geofences end_geofence ON end_geofence_id = end_geofence.id\n LEFT JOIN cars car ON car.id = drives.car_id\n WHERE drives.car_id = $car_id AND start_date::date = '$Year-$Month-$Day' AND distance > 0 \n ORDER BY start_date DESC\n)\nSELECT\n 'route=\"' || to_char(start_date:: timestamp, 'YYYY-MM-DD') || ' ' || start_address || ' ---> ' || end_address || '\" id=\"' || drive_id || '\"'AS journey\nFROM data;",
@@ -1372,7 +1377,7 @@
{
"current": {},
"datasource": {
- "type": "postgres",
+ "type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select preferred_range from settings limit 1;",
@@ -1390,9 +1395,9 @@
}
]
},
- "time": {
- "from": "2023-11-28T12:32:29.961Z",
- "to": "2023-11-28T12:40:33.863Z"
+ "time": {
+ "from": "now-15m",
+ "to": "now"
},
"timepicker": {
"hidden": true,
@@ -1401,6 +1406,6 @@
"timezone": "",
"title": "Tracking Drives",
"uid": "jchmX8upc6ZRk",
- "version": 3,
+ "version": 4,
"weekStart": ""
}
\ No newline at end of file
diff --git a/screenshots/CurrentChargeView.png b/screenshots/CurrentChargeView.png
index 6344d86..17e57ac 100644
Binary files a/screenshots/CurrentChargeView.png and b/screenshots/CurrentChargeView.png differ
diff --git a/screenshots/CurrentDriveView.png b/screenshots/CurrentDriveView.png
index dada153..1cb741b 100644
Binary files a/screenshots/CurrentDriveView.png and b/screenshots/CurrentDriveView.png differ
diff --git a/screenshots/CurrentState.png b/screenshots/CurrentState.png
index a41cde1..6cb0926 100644
Binary files a/screenshots/CurrentState.png and b/screenshots/CurrentState.png differ
diff --git a/screenshots/IncompleteData.png b/screenshots/IncompleteData.png
index 32461e9..13f262d 100644
Binary files a/screenshots/IncompleteData.png and b/screenshots/IncompleteData.png differ
diff --git a/screenshots/MileageStats.png b/screenshots/MileageStats.png
index aff34bd..5362e04 100644
Binary files a/screenshots/MileageStats.png and b/screenshots/MileageStats.png differ
diff --git a/screenshots/SpeedRates.png b/screenshots/SpeedRates.png
index 464d532..aa08b39 100644
Binary files a/screenshots/SpeedRates.png and b/screenshots/SpeedRates.png differ