diff --git a/CHANGELOG.md b/CHANGELOG.md index 5984b19f80..8ddac4acbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,10 @@ - Battery Health: Fix a bug on efficiency estimations (#3795 - @jheredianet) - Add more info on charge details dashboard (#3821, #3827 -@jheredianet) - Battery Health dashboard: new stats panel for efficiency and improve query performance (#3806 -@jheredianet) +- Add stats to Visited dashboard (#3824 - @jheredianet) +- Update Thresholds colors for ºF temperature in Charges dashboard (#3834 - @jheredianet) +- Velocity/Speed histogram in drive details dashboard (#3836 - @jheredianet) +- Change car id selector by row on Charge Details dashboard (#3844- @jheredianet) #### Translations @@ -31,6 +35,7 @@ - doc: remove update steps in installation instructions and link to maintenance section ([dbf23fa](https://github.com/teslamate-org/teslamate/commit/dbf23faa31d84f222c99dba9f5de52c69dd43afb) and #3794 - @JakobLichterfeld and @brianmay) - doc: add instructions how to update pot files to development guide ([3ab8ee8](https://github.com/teslamate-org/teslamate/commit/3ab8ee8535da32ba0c11307aaacc65379ddcc0b2) - @JakobLichterfeld) +- doc: update links to token apps in FAQ (#3833 - @JakobLichterfeld) ## [1.28.5] - 2024-03-25 diff --git a/grafana/dashboards/charges.json b/grafana/dashboards/charges.json index d78c87ae05..e85b8fd289 100644 --- a/grafana/dashboards/charges.json +++ b/grafana/dashboards/charges.json @@ -1,9 +1,37 @@ { + "__elements": {}, + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "10.4.0" + }, + { + "type": "datasource", + "id": "grafana-postgresql-datasource", + "name": "PostgreSQL", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "" + } + ], "annotations": { "list": [ { "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, "iconColor": "rgba(0, 211, 255, 1)", @@ -21,7 +49,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "iteration": 1642763869363, + "id": null, "links": [ { "icon": "dashboard", @@ -58,6 +86,10 @@ "type": "row" }, { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -65,7 +97,10 @@ }, "custom": { "align": "auto", - "displayMode": "auto" + "cellOptions": { + "type": "auto" + }, + "inspect": false }, "decimals": 2, "displayName": "", @@ -246,8 +281,10 @@ "value": 1 }, { - "id": "custom.displayMode", - "value": "color-text" + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } }, { "id": "custom.align" @@ -448,8 +485,10 @@ "value": 1 }, { - "id": "custom.displayMode", - "value": "color-text" + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } }, { "id": "custom.align" @@ -531,6 +570,32 @@ { "id": "custom.width", "value": 80 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-blue", + "value": null + }, + { + "color": "super-light-green", + "value": 50 + }, + { + "color": "super-light-red", + "value": 68 + } + ] + } } ] }, @@ -786,9 +851,10 @@ "y": 1 }, "id": 6, - "links": [], "options": { + "cellHeight": "sm", "footer": { + "countRows": false, "fields": "", "reducer": [ "sum" @@ -803,10 +869,14 @@ } ] }, - "pluginVersion": "8.3.4", + "pluginVersion": "10.4.0", "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", @@ -823,6 +893,23 @@ } ] ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, "timeColumn": "time", "where": [ { @@ -833,7 +920,6 @@ ] } ], - "datasource": "TeslaMate", "title": "Charges", "transformations": [ { @@ -846,7 +932,10 @@ "type": "table" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -881,13 +970,12 @@ "overrides": [] }, "gridPos": { - "h": 2, - "w": 8, + "h": 4, + "w": 6, "x": 0, "y": 20 }, "id": 10, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "none", @@ -901,9 +989,11 @@ "fields": "", "values": false }, - "textMode": "auto" + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "8.3.4", + "pluginVersion": "10.4.0", "targets": [ { "format": "time_series", @@ -931,7 +1021,11 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Energy added", @@ -939,7 +1033,10 @@ "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -974,13 +1071,12 @@ "overrides": [] }, "gridPos": { - "h": 2, - "w": 8, - "x": 8, + "h": 4, + "w": 6, + "x": 6, "y": 20 }, "id": 12, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "none", @@ -994,9 +1090,11 @@ "fields": "", "values": false }, - "textMode": "auto" + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "8.3.4", + "pluginVersion": "10.4.0", "targets": [ { "format": "time_series", @@ -1024,7 +1122,11 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Energy used", @@ -1032,7 +1134,10 @@ "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -1068,13 +1173,12 @@ "overrides": [] }, "gridPos": { - "h": 2, - "w": 8, - "x": 16, + "h": 4, + "w": 5, + "x": 12, "y": 20 }, "id": 13, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "none", @@ -1088,9 +1192,11 @@ "fields": "", "values": false }, - "textMode": "auto" + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "8.3.4", + "pluginVersion": "10.4.0", "targets": [ { "format": "time_series", @@ -1118,7 +1224,11 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Cost", @@ -1126,20 +1236,18 @@ "type": "stat" } ], - "schemaVersion": 36, - "style": "dark", + "schemaVersion": 39, "tags": [ "tesla" ], "templating": { "list": [ { - "current": { - "selected": false, - "text": "All", - "value": "$__all" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", "hide": 2, "includeAll": true, @@ -1158,12 +1266,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "km", - "value": "km" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select unit_of_length from settings limit 1;", "hide": 2, "includeAll": false, @@ -1182,12 +1289,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "C", - "value": "C" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select unit_of_temperature from settings limit 1;", "hide": 2, "includeAll": false, @@ -1206,12 +1312,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "ideal", - "value": "ideal" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select preferred_range from settings limit 1;", "hide": 2, "includeAll": false, @@ -1229,12 +1334,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "http://localhost:4000", - "value": "http://localhost:4000" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select base_url from settings limit 1;", "hide": 2, "includeAll": false, @@ -1253,16 +1357,11 @@ }, { "allValue": "-1", - "current": { - "selected": false, - "text": [ - "All" - ], - "value": [ - "$__all" - ] + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "SELECT name AS __text, id AS __value FROM geofences ORDER BY name COLLATE \"C\" ASC;", "hide": 0, "includeAll": true, @@ -1354,6 +1453,6 @@ "timezone": "", "title": "Charges", "uid": "TSmNYvRRk", - "version": 4, + "version": 5, "weekStart": "" -} +} \ No newline at end of file diff --git a/grafana/dashboards/internal/drive-details.json b/grafana/dashboards/internal/drive-details.json index 7828d79e6c..37705737d2 100644 --- a/grafana/dashboards/internal/drive-details.json +++ b/grafana/dashboards/internal/drive-details.json @@ -1,10 +1,50 @@ { + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "barchart", + "name": "Bar chart", + "version": "" + }, + { + "type": "panel", + "id": "geomap", + "name": "Geomap", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "10.4.0" + }, + { + "type": "datasource", + "id": "grafana-postgresql-datasource", + "name": "PostgreSQL", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + } + ], "annotations": { "list": [ { "$$hashKey": "object:31", "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, "iconColor": "rgba(0, 211, 255, 1)", @@ -22,7 +62,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, - "iteration": 1658136653681, + "id": null, "links": [ { "icon": "dashboard", @@ -53,14 +93,31 @@ "liveNow": false, "panels": [ { - "datasource": "TeslaMate", + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 40, + "panels": [], + "title": "Car: $car_id", + "type": "row" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { - "axisCenteredZero": false, + "axisBorderShow": false, + "axisCenteredZero": true, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", @@ -196,7 +253,7 @@ }, { "id": "custom.axisPlacement", - "value": "left" + "value": "right" }, { "id": "displayName", @@ -212,7 +269,7 @@ "properties": [ { "id": "displayName", - "value": "Battery heater" + "value": "Battery Heater" }, { "id": "unit", @@ -284,7 +341,7 @@ "properties": [ { "id": "displayName", - "value": "usable SOC" + "value": "Usable SOC" }, { "id": "unit", @@ -311,169 +368,196 @@ "value": "hidden" } ] - } - ] - }, - "gridPos": { - "h": 17, - "w": 12, - "x": 0, - "y": 0 - }, - "id": 2, - "links": [], - "options": { - "legend": { - "calcs": [ - "mean", - "max", - "min" - ], - "displayMode": "list", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ - { - "alias": "", - "datasource": "TeslaMate", - "format": "time_series", - "group": [], - "hide": false, - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\t$__time(date),\n\tconvert_km(speed::numeric, '$length_unit') AS speed_[[length_unit]]h,\n\tpower,\n\tbattery_heater::integer,\n\tconvert_km([[preferred_range]]_battery_range_km, '$length_unit') AS range_[[preferred_range]]_[[length_unit]],\n\tconvert_km(est_battery_range_km, '$length_unit') AS range_estimated_[[length_unit]],\n\tbattery_level,\n\tusable_battery_level\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC", - "refId": "A", - "select": [ - [ + }, + { + "matcher": { + "id": "byName", + "options": "Power" + }, + "properties": [ { - "params": [ - "id" - ], - "type": "column" + "id": "color", + "value": { + "fixedColor": "semi-dark-orange", + "mode": "fixed" + } } ] - ], - "table": "charging", - "timeColumn": "Datum", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Drive", - "type": "timeseries" - }, - { - "datasource": "TeslaMate", - "description": "", - "fieldConfig": { - "defaults": { - "decimals": 2, - "displayName": "Distance", - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" + }, + { + "matcher": { + "id": "byName", + "options": "Usable SOC" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "semi-dark-green", + "mode": "fixed" } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "SOC" + }, + "properties": [ { - "color": "semi-dark-green", - "value": null + "id": "color", + "value": { + "fixedColor": "light-green", + "mode": "fixed" + } } ] }, - "unit": "none" - }, - "overrides": [ { "matcher": { "id": "byName", - "options": "km" + "options": "Range (est.)" }, "properties": [ { - "id": "unit", - "value": "lengthkm" + "id": "color", + "value": { + "fixedColor": "light-purple", + "mode": "fixed" + } } ] }, { "matcher": { "id": "byName", - "options": "mi" + "options": "Range (ideal)" }, "properties": [ { - "id": "unit", - "value": "lengthmi" + "id": "color", + "value": { + "fixedColor": "semi-dark-purple", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Battery Heater" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "dark-red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Speed" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "light-blue", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Range (rated)" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "semi-dark-purple", + "mode": "fixed" + } } ] } ] }, "gridPos": { - "h": 2, - "w": 6, - "x": 12, - "y": 0 + "h": 12, + "w": 12, + "x": 0, + "y": 1 }, - "id": 10, - "links": [], - "maxDataPoints": 100, + "id": 39, "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { + "legend": { "calcs": [ - "lastNotNull" + "mean", + "max", + "min" ], - "fields": "", - "values": false + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, - "textMode": "auto" + "tooltip": { + "mode": "multi", + "sort": "none" + } }, - "pluginVersion": "10.1.2", "targets": [ { - "format": "table", + "alias": "", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "time_series", "group": [], + "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "select convert_km(distance::numeric, '$length_unit') as \"$length_unit\" from drives where id = $drive_id;", + "rawSql": "SELECT\n\t$__time(date),\n\tconvert_km(speed::numeric, '$length_unit') AS speed_[[length_unit]]h,\n\tpower,\n\tconvert_km([[preferred_range]]_battery_range_km, '$length_unit') AS range_[[preferred_range]]_[[length_unit]],\n\tconvert_km(est_battery_range_km, '$length_unit') AS range_estimated_[[length_unit]],\n\tbattery_level,\n\tusable_battery_level,\n\tbattery_heater::integer\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC", "refId": "A", "select": [ [ { "params": [ - "latitude" + "id" ], "type": "column" } ] ], - "table": "addresses", - "timeColumn": "inserted_at", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "table": "charging", + "timeColumn": "Datum", "timeColumnType": "timestamp", "where": [ { @@ -484,158 +568,636 @@ ] } ], - "type": "stat" + "title": "Drive", + "type": "timeseries" }, { - "datasource": "TeslaMate", - "description": "", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { + "fixedColor": "red", "mode": "thresholds" }, - "decimals": 1, + "custom": { + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + } + }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "semi-dark-blue", + "color": "green", "value": null } ] - }, - "unit": "dtdurations" + } }, "overrides": [] }, "gridPos": { - "h": 2, - "w": 3, - "x": 18, - "y": 0 + "h": 12, + "w": 12, + "x": 12, + "y": 1 }, - "id": 34, + "id": 4, + "maxDataPoints": 50000, "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false + "basemap": { + "config": {}, + "name": "Layer 0", + "type": "osm-standard" }, - "textMode": "auto", - "wideLayout": true + "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" + }, + "view": { + "allLayers": true, + "id": "fit", + "lat": 0, + "lon": 0, + "zoom": 15 + } }, + "pluginVersion": "10.4.0", "targets": [ { - "datasource": "TeslaMate", + "alias": "", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "editorMode": "code", - "format": "table", + "format": "time_series", + "group": [ + { + "params": [ + "$__interval", + "none" + ], + "type": "time" + } + ], + "hide": false, + "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT ${__to:date:seconds} - ${__from:date:seconds}", + "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": [ + "lat" + ], + "type": "column" + }, + { + "params": [ + "avg" + ], + "type": "aggregate" + }, + { + "params": [ + "lat" + ], + "type": "alias" + } + ], + [ + { + "params": [ + "lng" + ], + "type": "column" + }, + { + "params": [ + "avg" + ], + "type": "aggregate" + }, + { + "params": [ + "lat" + ], + "type": "alias" + } + ] + ], "sql": { "columns": [ { - "parameters": [], - "type": "function" + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ] + }, + "table": "pos", + "timeColumn": "Datum", + "timeColumnType": "datetime", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "type": "geomap" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 5, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 0, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": ".*_m$" + }, + "properties": [ + { + "id": "unit", + "value": "lengthm" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*_ft$" + }, + "properties": [ + { + "id": "unit", + "value": "feet" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "elevation_.*" + }, + "properties": [ + { + "id": "displayName", + "value": "Elevation" + }, + { + "id": "color", + "value": { + "fixedColor": "super-light-blue", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 12, + "w": 12, + "x": 0, + "y": 13 + }, + "id": 8, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": false + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n\t$__time(date),\n\tROUND(convert_m(elevation, '$alternative_length_unit')) AS elevation_[[alternative_length_unit]]\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC", + "refId": "A", + "select": [ + [ + { + "params": [ + "charge_energy_added" + ], + "type": "column" + } + ] + ], + "table": "charges", + "timeColumn": "date", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Elevation", + "type": "timeseries" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 5, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "smooth", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "is_climate_on" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "rgb(210, 203, 203)", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "fan_status" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#96D98D", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*_c$" + }, + "properties": [ + { + "id": "unit", + "value": "celsius" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*_f$" + }, + "properties": [ + { + "id": "unit", + "value": "fahrenheit" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "outside_temp_.*" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#8AB8FF", + "mode": "fixed" + } + }, + { + "id": "displayName", + "value": "Outside Temperature" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "inside_temp_.*" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "#F2CC0C", + "mode": "fixed" + } + }, + { + "id": "displayName", + "value": "Inside Temperature" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "driver_temp_.*" + }, + "properties": [ + { + "id": "displayName", + "value": "Driver Temperature" } - ], - "groupBy": [ + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "passenger_temp_.*" + }, + "properties": [ { - "property": { - "type": "string" - }, - "type": "groupBy" + "id": "displayName", + "value": "Passenger Temperature" } - ], - "limit": 50 - } - } - ], - "title": "Selected duration", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "description": "", - "fieldConfig": { - "defaults": { - "decimals": 1, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_climate_on" + }, + "properties": [ + { + "id": "unit", + "value": "bool_on_off" }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ { - "color": "semi-dark-blue", - "value": null + "id": "custom.axisPlacement", + "value": "hidden" + }, + { + "id": "displayName", + "value": "Climate" } ] }, - "unit": "dtdurations" - }, - "overrides": [] + { + "matcher": { + "id": "byName", + "options": "fan_status" + }, + "properties": [ + { + "id": "displayName", + "value": "Fan status" + }, + { + "id": "custom.axisPlacement", + "value": "hidden" + } + ] + } + ] }, "gridPos": { - "h": 2, - "w": 3, - "x": 21, - "y": 0 + "h": 6, + "w": 12, + "x": 12, + "y": 13 }, - "id": 14, - "links": [], - "maxDataPoints": 100, + "id": 6, "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, - "textMode": "auto", - "wideLayout": true + "tooltip": { + "mode": "multi", + "sort": "none" + } }, - "pluginVersion": "10.1.2", "targets": [ { - "format": "table", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "format": "time_series", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT ((DATE_PART('day', end_date - start_date) * 24 + \n DATE_PART('hour', end_date - start_date)) * 60 +\n DATE_PART('minute', end_date - start_date)) * 60 +\n DATE_PART('second', end_date - start_date) as sec_diff\nFROM drives\nWHERE drives.id = $drive_id;", + "rawSql": "SELECT\n\t$__time(date),\n\tconvert_celsius(outside_temp, '$temp_unit') AS outside_temp_$temp_unit,\n\tconvert_celsius(inside_temp, '$temp_unit') AS inside_temp_$temp_unit,\n\tconvert_celsius(driver_temp_setting, '$temp_unit') as driver_temp_$temp_unit,\n\tconvert_celsius(passenger_temp_setting, '$temp_unit') as passenger_temp_$temp_unit,\n is_climate_on::integer,\n\tfan_status\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC", "refId": "A", "select": [ [ { "params": [ - "latitude" + "charge_energy_added" ], "type": "column" } ] ], - "table": "addresses", - "timeColumn": "inserted_at", + "table": "charges", + "timeColumn": "date", "timeColumnType": "timestamp", "where": [ { @@ -646,189 +1208,250 @@ ] } ], - "title": "Drive duration", - "type": "stat" + "title": "Temperatures", + "type": "timeseries" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { - "decimals": 2, - "displayName": "Energy used", - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 5, + "gradientMode": "opacity", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" } - ], + }, + "links": [], + "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "light-yellow", + "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] }, - "unit": "kwatth" - }, - "overrides": [] - }, - "gridPos": { - "h": 2, - "w": 6, - "x": 12, - "y": 2 - }, - "id": 12, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false + "unit": "short" }, - "textMode": "auto" - }, - "pluginVersion": "10.1.2", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\t(NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) * car.efficiency)\nFROM\n\tdrives d\nJOIN cars car ON car.id = car_id\nWHERE\n\td.id = $drive_id;", - "refId": "A", - "select": [ - [ + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "tpms_pressure_front_left_bar" + }, + "properties": [ + { + "id": "unit", + "value": "pressurebar" + }, + { + "id": "displayName", + "value": "Front Left" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tpms_pressure_front_right_bar" + }, + "properties": [ + { + "id": "unit", + "value": "pressurebar" + }, + { + "id": "displayName", + "value": "Front Right" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tpms_pressure_rear_left_bar" + }, + "properties": [ + { + "id": "unit", + "value": "pressurebar" + }, { - "params": [ - "latitude" - ], - "type": "column" + "id": "displayName", + "value": "Rear Left" } ] - ], - "table": "addresses", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "displayName": "Consumption", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ + }, + { + "matcher": { + "id": "byName", + "options": "tpms_pressure_rear_right_bar" + }, + "properties": [ { - "color": "green", - "value": null + "id": "unit", + "value": "pressurebar" }, { - "color": "yellow", - "value": 200 + "id": "displayName", + "value": "Rear Right" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tpms_pressure_front_left_psi" + }, + "properties": [ + { + "id": "unit", + "value": "pressurepsi" }, { - "color": "red", - "value": 250 + "id": "displayName", + "value": "Front Left" } ] }, - "unit": "none" - }, - "overrides": [ { "matcher": { - "id": "byRegexp", - "options": "km" + "id": "byName", + "options": "tpms_pressure_front_right_psi" }, "properties": [ { "id": "unit", - "value": "Wh/km" + "value": "pressurepsi" + }, + { + "id": "displayName", + "value": "Front Right" } ] }, { "matcher": { - "id": "byRegexp", - "options": "mi" + "id": "byName", + "options": "tpms_pressure_rear_left_psi" }, "properties": [ { "id": "unit", - "value": "Wh/mi" + "value": "pressurepsi" + }, + { + "id": "displayName", + "value": "Rear Left" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tpms_pressure_rear_right_psi" + }, + "properties": [ + { + "id": "unit", + "value": "pressurepsi" + }, + { + "id": "displayName", + "value": "Rear Right" } ] } ] }, "gridPos": { - "h": 2, - "w": 6, - "x": 18, - "y": 2 + "h": 6, + "w": 12, + "x": 12, + "y": 19 }, - "id": 18, + "id": 32, "options": { - "colorMode": "value", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { + "legend": { "calcs": [ - "mean" + "logmin", + "max" ], - "fields": "", - "values": false + "displayMode": "list", + "placement": "bottom", + "showLegend": true }, - "textMode": "auto" + "tooltip": { + "mode": "multi", + "sort": "none" + } }, - "pluginVersion": "10.1.2", "targets": [ { - "format": "table", + "alias": "", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "format": "time_series", "group": [], + "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "select\n\t(NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) * car.efficiency) *1000 /\n\t convert_km(distance::numeric, '$length_unit') as \"$length_unit\"\nfrom drives d\nJOIN cars car ON car.id = car_id\nwhere d.id = $drive_id;", + "rawSql": "SELECT\r\n $__time(date),\r\n convert_tire_pressure(tpms_pressure_fl,'$pressure_unit') AS tpms_pressure_front_left_$pressure_unit,\r\n convert_tire_pressure(tpms_pressure_fr,'$pressure_unit') AS tpms_pressure_front_right_$pressure_unit,\r\n convert_tire_pressure(tpms_pressure_rl,'$pressure_unit') AS tpms_pressure_rear_left_$pressure_unit,\r\n convert_tire_pressure(tpms_pressure_rr,'$pressure_unit') AS tpms_pressure_rear_right_$pressure_unit\r\nFROM\r\n positions\r\nWHERE\r\n car_id = $car_id AND\r\n $__timeFilter(date) AND\r\n tpms_pressure_fl is not null\r\nORDER BY\r\n date ASC", "refId": "A", "select": [ [ { "params": [ - "start_km" + "id" ], "type": "column" } ] ], - "table": "drives", - "timeColumn": "start_date", + "table": "pos", + "timeColumn": "date", "timeColumnType": "timestamp", "where": [ { @@ -839,178 +1462,99 @@ ] } ], - "type": "stat" + "title": "Tire Pressure", + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 36, + "panels": [], + "title": "More Details", + "type": "row" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "description": "", "fieldConfig": { "defaults": { - "color": { - "fixedColor": "red", - "mode": "thresholds" - }, - "custom": { - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false + "decimals": 2, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" } - }, - "mappings": [], + ], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "super-light-blue" } ] - } + }, + "unit": "none" }, "overrides": [] }, "gridPos": { - "h": 27, - "w": 12, - "x": 12, - "y": 4 + "h": 3, + "w": 6, + "x": 0, + "y": 26 }, - "id": 4, - "links": [], - "maxDataPoints": 50000, + "id": 38, + "maxDataPoints": 100, "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" - }, - "view": { - "allLayers": true, - "id": "fit", - "lat": 0, - "lon": 0, - "zoom": 15 - } + "colorMode": "value", + "graphMode": "area", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/.*/", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "10.1.2", + "pluginVersion": "10.4.0", "targets": [ { - "alias": "", - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "editorMode": "code", - "format": "time_series", - "group": [ - { - "params": [ - "$__interval", - "none" - ], - "type": "time" - } - ], - "hide": false, + "format": "table", + "group": [], "metricColumn": "none", "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 CONCAT_WS(' - ', round(convert_km(start_km::numeric, '$length_unit')), round(convert_km(end_km::numeric, '$length_unit'))) ||' $length_unit' as \"Odometer\"\r\nFROM drives d\r\nWHERE d.id = $drive_id", "refId": "A", "select": [ [ { "params": [ - "lat" - ], - "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "lat" - ], - "type": "alias" - } - ], - [ - { - "params": [ - "lng" + "latitude" ], "type": "column" - }, - { - "params": [ - "avg" - ], - "type": "aggregate" - }, - { - "params": [ - "lat" - ], - "type": "alias" } ] ], @@ -1028,11 +1572,12 @@ }, "type": "groupBy" } - ] + ], + "limit": 50 }, - "table": "pos", - "timeColumn": "Datum", - "timeColumnType": "datetime", + "table": "addresses", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", @@ -1042,245 +1587,323 @@ ] } ], - "title": "Map", - "type": "geomap" + "title": "Odometer (From - To)", + "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "description": "", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 5, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" + "decimals": 1, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" } - }, - "links": [], - "mappings": [], + ], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 + "color": "text" } ] }, - "unit": "short" + "unit": "dtdurations" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "tpms_pressure_front_left_bar" - }, - "properties": [ - { - "id": "unit", - "value": "pressurebar" - }, - { - "id": "displayName", - "value": "front left" - } - ] + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 6, + "y": 26 + }, + "id": 14, + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - { - "matcher": { - "id": "byName", - "options": "tpms_pressure_front_right_bar" - }, - "properties": [ - { - "id": "unit", - "value": "pressurebar" - }, + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT ((DATE_PART('day', end_date - start_date) * 24 + \n DATE_PART('hour', end_date - start_date)) * 60 +\n DATE_PART('minute', end_date - start_date)) * 60 +\n DATE_PART('second', end_date - start_date) as sec_diff\nFROM drives\nWHERE drives.id = $drive_id;", + "refId": "A", + "select": [ + [ { - "id": "displayName", - "value": "front right" + "params": [ + "latitude" + ], + "type": "column" } ] + ], + "table": "addresses", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Drive Duration", + "type": "stat" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" }, - { - "matcher": { - "id": "byName", - "options": "tpms_pressure_rear_left_bar" - }, - "properties": [ - { - "id": "unit", - "value": "pressurebar" - }, + "decimals": 1, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ { - "id": "displayName", - "value": "rear left" + "color": "text" } ] }, - { - "matcher": { - "id": "byName", - "options": "tpms_pressure_rear_right_bar" - }, - "properties": [ - { - "id": "unit", - "value": "pressurebar" - }, - { - "id": "displayName", - "value": "rear right" - } - ] + "unit": "dtdurations" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 9, + "y": 26 + }, + "id": 34, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - { - "matcher": { - "id": "byName", - "options": "tpms_pressure_front_left_psi" - }, - "properties": [ - { - "id": "unit", - "value": "pressurepsi" - }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "SELECT ${__to:date:seconds} - ${__from:date:seconds}", + "refId": "A", + "sql": { + "columns": [ { - "id": "displayName", - "value": "front left" + "parameters": [], + "type": "function" } - ] - }, - { - "matcher": { - "id": "byName", - "options": "tpms_pressure_front_right_psi" - }, - "properties": [ - { - "id": "unit", - "value": "pressurepsi" - }, + ], + "groupBy": [ { - "id": "displayName", - "value": "front right" + "property": { + "type": "string" + }, + "type": "groupBy" } - ] + ], + "limit": 50 + } + } + ], + "title": "Selected Duration", + "type": "stat" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" }, - { - "matcher": { - "id": "byName", - "options": "tpms_pressure_rear_left_psi" + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": false, + "axisLabel": "", + "axisPlacement": "auto", + "axisWidth": -10, + "fillOpacity": 90, + "gradientMode": "hue", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "properties": [ - { - "id": "unit", - "value": "pressurepsi" - }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "fieldMinMax": true, + "mappings": [], + "noValue": "0", + "thresholds": { + "mode": "absolute", + "steps": [ { - "id": "displayName", - "value": "rear left" + "color": "super-light-green" } ] - }, + } + }, + "overrides": [ { "matcher": { "id": "byName", - "options": "tpms_pressure_rear_right_psi" + "options": "Elapsed" }, "properties": [ { "id": "unit", - "value": "pressurepsi" + "value": "percent" }, { - "id": "displayName", - "value": "rear right" + "id": "decimals", + "value": 0 } ] } ] }, "gridPos": { - "h": 8, + "h": 9, "w": 12, - "x": 0, - "y": 17 + "x": 12, + "y": 26 }, - "id": 32, - "links": [], + "id": 35, "options": { + "barRadius": 0.05, + "barWidth": 0.97, + "colorByField": "Elapsed", + "fullHighlight": false, + "groupWidth": 0.7, "legend": { - "calcs": [ - "logmin", - "max" - ], + "calcs": [], "displayMode": "list", "placement": "bottom", - "showLegend": true + "showLegend": false }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "text": {}, "tooltip": { "mode": "multi", "sort": "none" - } + }, + "xField": "Speed", + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 }, + "pluginVersion": "10.4.0", "targets": [ { - "alias": "", - "datasource": "TeslaMate", - "format": "time_series", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", "group": [], - "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\r\n $__time(date),\r\n convert_tire_pressure(tpms_pressure_fl,'$pressure_unit') AS tpms_pressure_front_left_$pressure_unit,\r\n convert_tire_pressure(tpms_pressure_fr,'$pressure_unit') AS tpms_pressure_front_right_$pressure_unit,\r\n convert_tire_pressure(tpms_pressure_rl,'$pressure_unit') AS tpms_pressure_rear_left_$pressure_unit,\r\n convert_tire_pressure(tpms_pressure_rr,'$pressure_unit') AS tpms_pressure_rear_right_$pressure_unit\r\nFROM\r\n positions\r\nWHERE\r\n car_id = $car_id AND\r\n $__timeFilter(date) AND\r\n tpms_pressure_fl is not null\r\nORDER BY\r\n date ASC", + "rawSql": "SELECT \r\n speed_section_$length_unit AS \"Speed\",\r\n SUM(seconds_elapsed) * 100 / MAX(duration) as \"Elapsed\",\r\n TO_CHAR((SUM(seconds_elapsed) || ' second')::interval, 'HH24:MI:SS') AS \"Time\"\r\nFROM (\r\n SELECT\r\n ROUND(convert_km(p.speed::numeric, '$length_unit') / 10,0) * 10 AS speed_section_$length_unit,\r\n EXTRACT(EPOCH FROM (LEAD(p.\"date\") OVER (ORDER BY p.\"date\") - p.\"date\")) AS seconds_elapsed,\r\n EXTRACT(EPOCH FROM (end_date - start_date)) AS duration\r\n FROM drives d\r\n INNER JOIN positions p ON p.drive_id = d.id\r\n WHERE d.id = $drive_id\r\n) AS drivedata\r\nGROUP BY 1\r\nORDER BY 1", "refId": "A", "select": [ [ { "params": [ - "id" + "value" ], "type": "column" } ] ], - "table": "pos", - "timeColumn": "date", - "timeColumnType": "timestamp", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "timeColumn": "time", "where": [ { "name": "$__timeFilter", @@ -1290,56 +1913,50 @@ ] } ], - "title": "Tire Pressure", - "type": "timeseries" + "title": "Speed Histogram ($speed_unit)", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "Elapsed", + "Time", + "Speed", + "SpeedUnit" + ] + } + } + } + ], + "type": "barchart" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "description": "", "fieldConfig": { "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 5, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" + "decimals": 2, + "displayName": "Distance", + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" } - }, - "decimals": 0, - "links": [], - "mappings": [], + ], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green" - }, - { - "color": "red", - "value": 80 + "color": "semi-dark-green" } ] }, @@ -1348,89 +1965,79 @@ "overrides": [ { "matcher": { - "id": "byRegexp", - "options": ".*_m$" + "id": "byName", + "options": "km" }, "properties": [ { "id": "unit", - "value": "lengthm" + "value": "lengthkm" } ] }, { "matcher": { - "id": "byRegexp", - "options": ".*_ft$" + "id": "byName", + "options": "mi" }, "properties": [ { "id": "unit", - "value": "feet" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "elevation_.*" - }, - "properties": [ - { - "id": "displayName", - "value": "Elevation" - }, - { - "id": "color", - "value": { - "fixedColor": "semi-dark-blue", - "mode": "fixed" - } + "value": "lengthmi" } ] } ] }, "gridPos": { - "h": 6, - "w": 12, + "h": 3, + "w": 6, "x": 0, - "y": 25 + "y": 29 }, - "id": 8, + "id": 10, + "maxDataPoints": 100, "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value", + "wideLayout": true }, + "pluginVersion": "10.4.0", "targets": [ { - "datasource": "TeslaMate", - "format": "time_series", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\t$__time(date),\n\tROUND(convert_m(elevation, '$alternative_length_unit')) AS elevation_[[alternative_length_unit]]\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC", + "rawSql": "select convert_km(distance::numeric, '$length_unit') as \"$length_unit\" from drives where id = $drive_id;", "refId": "A", "select": [ [ { "params": [ - "charge_energy_added" + "latitude" ], "type": "column" } ] ], - "table": "charges", - "timeColumn": "date", + "table": "addresses", + "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { @@ -1441,255 +2048,149 @@ ] } ], - "title": "Elevation", - "type": "timeseries" + "title": "Distance", + "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 5, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } + "mode": "thresholds" }, - "links": [], "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green" - }, - { - "color": "red", - "value": 80 } ] - }, - "unit": "short" + } }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "is_climate_on" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "rgb(210, 203, 203)", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "fan_status" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": ".*_c$" - }, - "properties": [ - { - "id": "unit", - "value": "celsius" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": ".*_f$" - }, - "properties": [ - { - "id": "unit", - "value": "fahrenheit" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "outside_temp_.*" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - }, - { - "id": "displayName", - "value": "Outside Temperature" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "inside_temp_.*" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - }, - { - "id": "displayName", - "value": "Inside Temperature" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "driver_temp_.*" - }, - "properties": [ - { - "id": "displayName", - "value": "Driver Temperature" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "passenger_temp_.*" - }, - "properties": [ - { - "id": "displayName", - "value": "Passenger Temperature" - } - ] + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 6, + "x": 6, + "y": 29 + }, + "id": 20, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "vertical", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/.*/", + "values": false + }, + "showPercentChange": false, + "text": {}, + "textMode": "value_and_name", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - { - "matcher": { - "id": "byName", - "options": "is_climate_on" - }, - "properties": [ - { - "id": "unit", - "value": "bool_on_off" - }, - { - "id": "custom.axisPlacement", - "value": "hidden" - }, + "editorMode": "code", + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "WITH height as (SELECT\n\televation-LAG(elevation,1) over ( order BY\n\tdate ASC ) as diff\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC\n\t)\nSELECT ROUND(convert_m(sum(diff), '$alternative_length_unit')::numeric,0) || ' $alternative_length_unit' as \"UP\" from height where diff > 0", + "refId": "A", + "select": [ + [ { - "id": "displayName", - "value": "Climate" + "params": [ + "start_km" + ], + "type": "column" } ] - }, - { - "matcher": { - "id": "byName", - "options": "fan_status" - }, - "properties": [ - { - "id": "displayName", - "value": "Fan status" - }, + ], + "sql": { + "columns": [ { - "id": "custom.axisPlacement", - "value": "hidden" - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 31 - }, - "id": 6, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": true + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "table": "drives", + "timeColumn": "start_date", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ { - "datasource": "TeslaMate", - "format": "time_series", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", "group": [], + "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\t$__time(date),\n\tconvert_celsius(outside_temp, '$temp_unit') AS outside_temp_$temp_unit,\n\tconvert_celsius(inside_temp, '$temp_unit') AS inside_temp_$temp_unit,\n\tconvert_celsius(driver_temp_setting, '$temp_unit') as driver_temp_$temp_unit,\n\tconvert_celsius(passenger_temp_setting, '$temp_unit') as passenger_temp_$temp_unit,\n is_climate_on::integer,\n\tfan_status\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC", - "refId": "A", + "rawSql": "WITH height as (SELECT\n\televation-LAG(elevation,1) over ( order BY\n\tdate ASC ) as diff\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC\n\t)\nSELECT ROUND(convert_m(sum(diff), '$alternative_length_unit')::numeric,0) || ' $alternative_length_unit' as \"DOWN\" from height where diff < 0", + "refId": "B", "select": [ [ { "params": [ - "charge_energy_added" + "start_km" ], "type": "column" } ] ], - "table": "charges", - "timeColumn": "date", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "table": "drives", + "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { @@ -1700,13 +2201,17 @@ ] } ], - "title": "Temperatures", - "type": "timeseries" + "title": "Elevation Summary", + "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { + "decimals": 2, "mappings": [ { "options": { @@ -1722,44 +2227,50 @@ "mode": "absolute", "steps": [ { - "color": "super-light-blue" + "color": "light-yellow" } ] }, - "unit": "none" + "unit": "kwatth" }, "overrides": [] }, "gridPos": { - "h": 2, - "w": 12, - "x": 12, - "y": 31 + "h": 3, + "w": 6, + "x": 0, + "y": 32 }, - "id": 16, - "links": [], + "id": 12, "maxDataPoints": 100, "options": { "colorMode": "value", "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", + "justifyMode": "center", + "orientation": "horizontal", "reduceOptions": { "calcs": [ "lastNotNull" ], - "fields": "/.*/", + "fields": "", "values": false }, - "textMode": "value_and_name" + "showPercentChange": false, + "textMode": "value", + "wideLayout": true }, + "pluginVersion": "10.4.0", "targets": [ { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT CONCAT_WS(' - ', round(convert_km(start_km::numeric, '$length_unit')), round(convert_km(end_km::numeric, '$length_unit'))) ||' $length_unit' as \"Odometer\"\nFROM drives d\nWHERE d.id = $drive_id", + "rawSql": "SELECT\n\t(NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) * car.efficiency)\nFROM\n\tdrives d\nJOIN cars car ON car.id = car_id\nWHERE\n\td.id = $drive_id;", "refId": "A", "select": [ [ @@ -1783,15 +2294,19 @@ ] } ], - "transparent": true, + "title": "Energy Used", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "fixedColor": "orange", + "mode": "fixed" }, "mappings": [], "thresholds": { @@ -1799,42 +2314,82 @@ "steps": [ { "color": "green" + }, + { + "color": "yellow", + "value": 200 + }, + { + "color": "red", + "value": 250 } ] - } + }, + "unit": "none" }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "km" + }, + "properties": [ + { + "id": "unit", + "value": "Wh/km" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "mi" + }, + "properties": [ + { + "id": "unit", + "value": "Wh/mi" + } + ] + } + ] }, "gridPos": { - "h": 2, - "w": 12, - "x": 0, - "y": 39 + "h": 3, + "w": 3, + "x": 6, + "y": 32 }, - "id": 20, + "id": 18, "options": { "colorMode": "value", - "graphMode": "none", + "graphMode": "area", "justifyMode": "auto", - "orientation": "vertical", + "orientation": "auto", "reduceOptions": { "calcs": [ - "lastNotNull" + "mean" ], - "fields": "/.*/", + "fields": "", "values": false }, - "text": {}, - "textMode": "value_and_name" + "showPercentChange": false, + "textMode": "value", + "wideLayout": true }, + "pluginVersion": "10.4.0", "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "WITH height as (SELECT\n\televation-LAG(elevation,1) over ( order BY\n\tdate ASC ) as diff\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC\n\t)\n\t\n\nselect convert_m(sum(diff), '$alternative_length_unit') || ' $alternative_length_unit' as \"UP\" from height where diff > 0", + "rawSql": "select\n\t(NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) * car.efficiency) *1000 /\n\t convert_km(distance::numeric, '$length_unit') as \"$length_unit\"\nfrom drives d\nJOIN cars car ON car.id = car_id\nwhere d.id = $drive_id;", "refId": "A", "select": [ [ @@ -1846,6 +2401,23 @@ } ] ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", @@ -1856,16 +2428,98 @@ "type": "macro" } ] + } + ], + "title": "Consumption", + "type": "stat" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "super-light-blue", + "mode": "fixed" + }, + "decimals": 0, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byRegexp", + "options": "/.*_mih/" + }, + "properties": [ + { + "id": "unit", + "value": "velocitymph" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": "/.*_kmh/" + }, + "properties": [ + { + "id": "unit", + "value": "velocitykmh" + } + ] + } + ] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 9, + "y": 32 + }, + "id": 37, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": true }, + "showPercentChange": false, + "textMode": "value", + "wideLayout": false + }, + "pluginVersion": "10.4.0", + "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", "format": "table", "group": [], - "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "WITH height as (SELECT\n\televation-LAG(elevation,1) over ( order BY\n\tdate ASC ) as diff\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC\n\t)\n\t\n\t\nselect convert_m(sum(diff), '$alternative_length_unit') || ' $alternative_length_unit' as \"DOWN\" from height where diff < 0", - "refId": "B", + "rawSql": "SELECT\n\tconvert_km(avg(speed)::numeric, '$length_unit') AS speed_[[length_unit]]h\nFROM positions\nWHERE car_id = $car_id AND $__timeFilter(date)", + "refId": "A", "select": [ [ { @@ -1876,6 +2530,23 @@ } ] ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", @@ -1888,42 +2559,35 @@ ] } ], - "title": "Elevation Summary", + "title": "Avg. Speed", "type": "stat" } ], - "refresh": false, - "schemaVersion": 38, - "style": "dark", + "schemaVersion": 39, "tags": [], "templating": { "list": [ { - "current": { - "selected": false, - "text": "NULL", - "value": "NULL" - }, + "current": {}, "hide": 2, "name": "drive_id", "options": [ { - "selected": true, + "selected": false, "text": "NULL", "value": "NULL" } ], - "query": "3217", + "query": "", "skipUrlSync": false, "type": "textbox" }, { - "current": { - "selected": false, - "text": "C", - "value": "C" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select unit_of_temperature from settings limit 1;", "hide": 2, "includeAll": false, @@ -1942,12 +2606,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "km", - "value": "km" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select unit_of_length from settings limit 1;", "hide": 2, "includeAll": false, @@ -1966,12 +2629,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "1", - "value": "1" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", "hide": 0, "includeAll": false, @@ -1990,12 +2652,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "m", - "value": "m" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select case when unit_of_length = 'km' then 'm' when unit_of_length = 'mi' then 'ft' end from settings limit 1;", "hide": 2, "includeAll": false, @@ -2014,12 +2675,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "ideal", - "value": "ideal" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select preferred_range from settings limit 1;", "hide": 2, "includeAll": false, @@ -2037,12 +2697,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "", - "value": "" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select base_url from settings limit 1;", "hide": 2, "includeAll": false, @@ -2061,12 +2720,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "bar", - "value": "bar" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select unit_of_pressure from settings limit 1;", "hide": 2, "includeAll": false, @@ -2079,41 +2737,36 @@ "skipUrlSync": false, "sort": 0, "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "definition": "SELECT CASE WHEN '$length_unit' = 'km' THEN 'km/h' WHEN '$length_unit' = 'mi' THEN 'mph' END", + "hide": 2, + "includeAll": false, + "multi": false, + "name": "speed_unit", + "options": [], + "query": "SELECT CASE WHEN '$length_unit' = 'km' THEN 'km/h' WHEN '$length_unit' = 'mi' THEN 'mph' END", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" } ] }, - "time": { - "from": "now-12h", - "to": "now" - }, "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] + "hidden": true, + "refresh_intervals": [], + "time_options": [] }, "timezone": "", "title": "Drive Details", "uid": "zm7wN6Zgz", - "version": 2, + "version": 4, "weekStart": "" -} +} \ No newline at end of file diff --git a/grafana/dashboards/visited.json b/grafana/dashboards/visited.json index b1956a243b..720bd4a565 100644 --- a/grafana/dashboards/visited.json +++ b/grafana/dashboards/visited.json @@ -11,13 +11,19 @@ "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" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" } ], "annotations": { @@ -30,6 +36,7 @@ }, "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", "type": "dashboard" @@ -83,7 +90,7 @@ }, { "datasource": { - "type": "postgres", + "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { @@ -118,13 +125,14 @@ "y": 1 }, "id": 2, - "links": [], "maxDataPoints": 10000000, "options": { "basemap": { - "config": {}, + "config": { + "server": "streets" + }, "name": "Layer 0", - "type": "osm-standard" + "type": "esri-xyz" }, "controls": { "mouseWheelZoom": true, @@ -183,7 +191,7 @@ } ], "tooltip": { - "mode": "details" + "mode": "none" }, "view": { "allLayers": true, @@ -193,18 +201,18 @@ "zoom": 15 } }, - "pluginVersion": "10.1.2", + "pluginVersion": "10.4.0", "targets": [ { "datasource": { - "type": "postgres", + "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "hide": false, "rawQuery": true, - "rawSql": "SELECT\n to_timestamp(floor((extract('epoch' FROM date) / 60)) * 60) AT TIME ZONE 'UTC' AS time,\n avg(latitude) as latitude,\n avg(longitude) as longitude\nFROM\n positions\nWHERE\n car_id = $car_id\nAND\n $__timeFilter(date)\nGROUP BY\n 1\nORDER BY\n 1\nASC", + "rawSql": "SELECT\n date_trunc('minute', date) as time,\n avg(latitude) as latitude,\n avg(longitude) as longitude\nFROM\n positions\nWHERE\n car_id = $car_id AND $__timeFilter(date)\nGROUP BY 1\nORDER BY 1", "refId": "Positions", "sql": { "columns": [ @@ -224,13 +232,435 @@ } } ], - "title": "MAP", "type": "geomap" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 5, + "x": 0, + "y": 22 + }, + "id": 5, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/.*/", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "group": [], + "hide": false, + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT ROUND(convert_km((max(end_km) - min(start_km))::numeric, '$length_unit'),0)|| ' $length_unit' as \"Distance Traveled\"\nFROM drives WHERE car_id = $car_id AND $__timeFilter(start_date)", + "refId": "distance traveled", + "select": [ + [ + { + "params": [ + "efficiency" + ], + "type": "column" + } + ] + ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "table": "cars", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "type": "stat" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "light-yellow", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Total energy added" + }, + "properties": [ + { + "id": "unit", + "value": "kwatth" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Total energy used" + }, + "properties": [ + { + "id": "unit", + "value": "kwatth" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Charge Efficiency" + }, + "properties": [ + { + "id": "unit", + "value": "percent" + } + ] + } + ] + }, + "gridPos": { + "h": 2, + "w": 14, + "x": 5, + "y": 22 + }, + "id": 6, + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "fieldOptions": { + "calcs": [ + "mean" + ] + }, + "graphMode": "none", + "justifyMode": "center", + "orientation": "vertical", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n\tsum(charge_energy_added) as \"Total energy added\"\nFROM\n\tcharging_processes\nWHERE\n\tcar_id = $car_id AND $__timeFilter(start_date) AND charge_energy_added > 0.01", + "refId": "Total energy added", + "select": [ + [ + { + "params": [ + "efficiency" + ], + "type": "column" + } + ] + ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "table": "cars", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "SELECT\r\n\tSUM(charge_energy_used) AS \"Total energy used\"\r\nFROM\r\n\tcharging_processes\r\nWHERE\r\n\tcar_id = $car_id AND $__timeFilter(start_date) AND charge_energy_added > 0.01\r\n", + "refId": "Total energy used", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "SELECT\r\n\tSUM(charge_energy_added) * 100 / SUM(charge_energy_used) AS \"Charge Efficiency\"\r\nFROM\r\n\tcharging_processes\r\nWHERE\r\n\tcar_id = $car_id AND $__timeFilter(start_date) AND charge_energy_added > 0.01\r\n", + "refId": "Charge Efficiency", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "type": "stat" + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "description": "", + "fieldConfig": { + "defaults": { + "decimals": 2, + "displayName": "Cost", + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "#c7d0d9", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 2, + "w": 5, + "x": 19, + "y": 22 + }, + "id": 7, + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "fieldOptions": { + "calcs": [ + "lastNotNull" + ] + }, + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": true + }, + "showPercentChange": false, + "textMode": "value_and_name", + "wideLayout": true + }, + "pluginVersion": "10.4.0", + "targets": [ + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "select sum(cost) as \"Cost\" from charging_processes where $__timeFilter(start_date) AND car_id = $car_id;", + "refId": "A", + "select": [ + [ + { + "params": [ + "latitude" + ], + "type": "column" + } + ] + ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, + "table": "addresses", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "type": "stat" } ], "refresh": false, - "schemaVersion": 38, - "style": "dark", + "schemaVersion": 39, "tags": [ "tesla" ], @@ -239,7 +669,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;", @@ -260,12 +690,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "http://localhost:4000", - "value": "http://localhost:4000" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select base_url from settings limit 1;", "hide": 2, "includeAll": false, @@ -282,6 +711,21 @@ "tagsQuery": "", "type": "query", "useTags": false + }, + { + "current": {}, + "definition": "SELECT unit_of_length FROM settings LIMIT 1", + "hide": 2, + "includeAll": false, + "multi": false, + "name": "length_unit", + "options": [], + "query": "SELECT unit_of_length FROM settings LIMIT 1", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" } ] }, @@ -317,6 +761,6 @@ "timezone": "", "title": "Visited", "uid": "RG_DxSmgk", - "version": 11, + "version": 12, "weekStart": "" } \ No newline at end of file diff --git a/website/docs/faq.md b/website/docs/faq.md index 430ecd66f4..f4d7977126 100644 --- a/website/docs/faq.md +++ b/website/docs/faq.md @@ -7,9 +7,8 @@ sidebar_label: FAQ There are multiple apps available to securely generate access tokens yourself, for example: -- [Auth app for Tesla (iOS, macOS)](https://apps.apple.com/us/app/auth-app-for-tesla/id1552058613) -- [Tesla Tokens (Android)](https://play.google.com/store/apps/details?id=net.leveugle.teslatokens) - [Tesla Auth (macOS, Linux, Windows)](https://github.com/adriankumpf/tesla_auth) +- [Auth app for Tesla (iOS, macOS)](https://apps.apple.com/us/app/auth-app-for-tesla/id1552058613) ## Why are no consumption values displayed in Grafana? diff --git a/website/static/screenshots/drive.png b/website/static/screenshots/drive.png index 760ad3a769..ec7db2ffd9 100755 Binary files a/website/static/screenshots/drive.png and b/website/static/screenshots/drive.png differ diff --git a/website/static/screenshots/lifetime_driving_map.png b/website/static/screenshots/lifetime_driving_map.png index 1b3707369e..c274b157f0 100644 Binary files a/website/static/screenshots/lifetime_driving_map.png and b/website/static/screenshots/lifetime_driving_map.png differ