{ "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- Grafana --" }, "definition": "TeslaMate|U2FsdGVkX1/cEWK+8cz7pjEKXtzJnDN7b21ZDXt1MGneFGPWTLqOPtxKmu02mJPLzi/f29I+NBHd3vi0FB8R4Xn0+GtobWDgk6VAVSBTdSNniOKO8i2WPlhRaOsl2+hG7gnZ7wrf1Th2nxR7f1uYCrbwOek0IzkfLzrkjh7gkr6inT6bbDuJqrmogZajLxmAMrQ6V+/vHxBRGiwjJhgiEeq3hM1q2h04JKkNiZ8RHbsF5Cd/xd8Q9u0JVrZzIrtnhM/SFlaApU7RtRMu8CSj1llTX7WEOj6VDZAMSf+XUAanWdk725kEPN9MNu89o2zEq5P3E3cju8IbbBdPzXLV3oVuzD6/tMnxFToIIV1E/BrpF7s2RtNa8+KJJ1PF8xgs6m+/KTD2hy+WsP0636AgObRAmYg7+qotGrgNvpNPdE0EgrB7WHYlV7R/1q66bcq6tCe51X1Un70k+zo+K6AK0o4B1H6IyMlEVuRH/Fz8QVl9aYu2ztd08RbuKJlYVKpkH+pxVETAO9MclYQ90tzE6TfwDZrQZzsAlMenr4s1ZB1OlFXjLjVjnddnUilzO76cqv4yI2THQEuyQ47nuVQ4gUbx02K59vMQhns3C01JOAYokOaSXe66Y7QYdMlk09Lf|aes-256-cbc", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, "id": 14, "links": [ { "icon": "dashboard", "tags": [], "title": "TeslaMate", "tooltip": "", "type": "link", "url": "${base_url:raw}" }, { "asDropdown": true, "icon": "external link", "tags": [ "tesla" ], "title": "Dashboards", "type": "dashboards" }, { "asDropdown": true, "icon": "external link", "includeVars": false, "keepTime": false, "tags": [ "TeslamateCustomDashboards" ], "targetBlank": false, "title": "Custom Dashboards", "tooltip": "", "type": "dashboards", "url": "" } ], "panels": [ { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "id": 4, "panels": [], "repeat": "car_id", "title": "$car_id", "type": "row" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "", "fieldConfig": { "defaults": { "custom": { "align": "left", "cellOptions": { "type": "auto" }, "filterable": false, "inspect": false, "width": 120 }, "mappings": [], "noValue": "--", "thresholds": { "mode": "percentage", "steps": [ { "color": "red", "value": 0 }, { "color": "#EAB839", "value": 50 }, { "color": "green", "value": 90 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "Time driven" }, "properties": [ { "id": "unit", "value": "dtdurations" }, { "id": "custom.align", "value": "auto" }, { "id": "custom.width" }, { "id": "decimals", "value": 1 }, { "id": "custom.width", "value": 180 } ] }, { "matcher": { "id": "byName", "options": "Period" }, "properties": [ { "id": "custom.width", "value": 160 }, { "id": "links", "value": [ { "targetBlank": true, "title": "Trip", "url": "d/FkUpJpQZk/trip?from=${__data.fields.date_from}&to=${__data.fields.date_to}&var-car_id=$car_id" } ] } ] }, { "matcher": { "id": "byName", "options": "Driving Efficiency" }, "properties": [ { "id": "unit", "value": "percentunit" }, { "id": "custom.cellOptions", "value": { "mode": "lcd", "type": "gauge" } }, { "id": "custom.align", "value": "auto" }, { "id": "custom.width" }, { "id": "max", "value": 1.15 }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { "color": "super-light-orange", "value": 0 }, { "color": "light-orange", "value": 0.65 }, { "color": "light-green", "value": 0.99 } ] } }, { "id": "min", "value": 0 } ] }, { "matcher": { "id": "byName", "options": "# of Drives" }, "properties": [ { "id": "links", "value": [ { "targetBlank": true, "title": "Drives", "url": "d/Y8upc6ZRk/drives?from=${__data.fields.date_from}&to=${__data.fields.date_to}&var-car_id=$car_id" } ] }, { "id": "custom.align", "value": "auto" }, { "id": "custom.width", "value": 100 } ] }, { "matcher": { "id": "byRegexp", "options": "/sum_distance_km/" }, "properties": [ { "id": "unit", "value": "km" }, { "id": "displayName", "value": "Distance" }, { "id": "custom.align", "value": "auto" } ] }, { "matcher": { "id": "byRegexp", "options": "/sum_distance_mi/" }, "properties": [ { "id": "displayName", "value": "Distance" }, { "id": "unit", "value": "mi" }, { "id": "custom.align", "value": "auto" } ] }, { "matcher": { "id": "byName", "options": "date_from" }, "properties": [ { "id": "custom.hidden", "value": true } ] }, { "matcher": { "id": "byName", "options": "date_to" }, "properties": [ { "id": "custom.hidden", "value": true } ] } ] }, "gridPos": { "h": 14, "w": 9, "x": 0, "y": 1 }, "id": 10, "maxPerRow": 2, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "frameIndex": 1, "showHeader": true, "sortBy": [ { "desc": true, "displayName": "Starting at" } ] }, "pluginVersion": "12.1.1", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH data AS (\nSELECT\n duration_min > 1 AND\n distance > 1 AND\n ( \n start_position.usable_battery_level IS NULL OR\n (end_position.battery_level - end_position.usable_battery_level) = 0 \n ) AS is_sufficiently_precise,\n NULLIF(GREATEST(start_ideal_range_km - end_ideal_range_km, 0), 0) AS range_diff,\n date_trunc('$period', timezone('$__timezone', start_date)) as local_period,\n drives.*\nFROM drives\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)\nSELECT\n EXTRACT(EPOCH FROM local_period)*1000 AS date_from,\n EXTRACT(EPOCH FROM (local_period + interval '1 $period'))*1000 AS date_to,\n CASE '$period'\n WHEN 'month' THEN to_char(local_period, 'YYYY Month')\n WHEN 'year' THEN to_char(local_period, 'YYYY')\n WHEN 'week' THEN 'week ' || to_char(local_period, 'WW') || ' starting ' || to_char(local_period, 'YYYY-MM-DD')\n ELSE to_char(local_period, 'YYYY-MM-DD')\n END AS display,\n local_period AS date,\n sum(duration_min)*60 AS sum_duration_h, \n convert_km(max(end_km)::integer - min(start_km)::integer, '$length_unit') AS sum_distance_$length_unit,\n count(*) AS cnt,\n sum(distance)/sum(range_diff) AS efficiency\nFROM data WHERE\n car_id = $car_id AND\n $__timeFilter(start_date)\nGROUP BY date\nORDER BY date desc", "refId": "A", "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": "Stats per ${period}", "transformations": [ { "id": "organize", "options": { "excludeByName": { "date": true }, "includeByName": {}, "indexByName": { "cnt": 4, "date": 1, "date_from": 6, "date_to": 7, "display": 0, "efficiency": 5, "sum_distance_km": 3, "sum_distance_mi": 3, "sum_duration_h": 2 }, "renameByName": { "cnt": "# of Drives", "date": "", "date_from": "", "date_to": "", "display": "Period", "efficiency": "Driving Efficiency", "sum_distance_km": "", "sum_distance_mi": "", "sum_duration_h": "Time driven" } } } ], "type": "table" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "With this dashboard you may analyze your mileage and number of drives by year, month, week or day.\n\nThe dashboard shows a table with the selected period, time driven, distance, number of drives and efficiency then a bar chart to have a better look for comparison.", "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "axisSoftMin": 0, "fillOpacity": 80, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "lineWidth": 1, "scaleDistribution": { "type": "linear" }, "thresholdsStyle": { "mode": "off" } }, "mappings": [], "noValue": "--", "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": 0 } ] } }, "overrides": [ { "matcher": { "id": "byRegexp", "options": "/sum_distance_km/" }, "properties": [ { "id": "unit", "value": "km" }, { "id": "displayName", "value": "Distance" } ] }, { "matcher": { "id": "byRegexp", "options": "/sum_distance_mi/" }, "properties": [ { "id": "displayName", "value": "Distance" }, { "id": "unit", "value": "mi" } ] }, { "matcher": { "id": "byName", "options": "cnt" }, "properties": [ { "id": "unit", "value": "drives" }, { "id": "custom.axisPlacement", "value": "hidden" }, { "id": "displayName", "value": "Count" } ] } ] }, "gridPos": { "h": 14, "w": 15, "x": 9, "y": 1 }, "id": 27, "options": { "barRadius": 0, "barWidth": 0.97, "fullHighlight": false, "groupWidth": 0.7, "legend": { "calcs": [ "max", "min" ], "displayMode": "list", "placement": "bottom", "showLegend": true }, "orientation": "auto", "showValue": "always", "stacking": "none", "tooltip": { "hideZeros": false, "mode": "single", "sort": "none" }, "xTickLabelRotation": 0, "xTickLabelSpacing": 0 }, "pluginVersion": "12.1.1", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH data AS (\nSELECT\n duration_min > 1 AND\n distance > 1 AND\n ( \n start_position.usable_battery_level IS NULL OR\n (end_position.battery_level - end_position.usable_battery_level) = 0 \n ) AS is_sufficiently_precise,\n NULLIF(GREATEST(start_ideal_range_km - end_ideal_range_km, 0), 0) AS range_diff,\n date_trunc('$period', timezone('$__timezone', start_date)) as local_period,\n drives.*\nFROM drives\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)\nSELECT\n EXTRACT(EPOCH FROM local_period)*1000 AS date_from,\n EXTRACT(EPOCH FROM (local_period + interval '1 $period'))*1000 AS date_to,\n CASE '$period'\n WHEN 'month' THEN to_char(local_period, 'YYYY Month')\n WHEN 'year' THEN to_char(local_period, 'YYYY')\n WHEN 'week' THEN 'week ' || to_char(local_period, 'WW') || ' starting ' || to_char(local_period, 'YYYY-MM-DD')\n ELSE to_char(local_period, 'YYYY-MM-DD')\n END AS \"Period\",\n local_period AS date,\n sum(duration_min)*60 AS sum_duration_h, \n convert_km(max(end_km)::integer - min(start_km)::integer, '$length_unit') AS sum_distance_$length_unit,\n count(*) AS cnt,\n sum(distance)/sum(range_diff) AS efficiency\nFROM data WHERE\n car_id = $car_id AND\n $__timeFilter(start_date)\nGROUP BY date\nORDER BY date", "refId": "A", "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": "${length_unit} & drives per ${period}", "transformations": [ { "id": "filterFieldsByName", "options": { "include": { "names": [ "Period", "sum_distance_mi", "cnt", "sum_distance_km" ] } } } ], "type": "barchart" } ], "preload": false, "refresh": "", "schemaVersion": 41, "tags": [ "TeslamateCustomDashboards" ], "templating": { "list": [ { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT\n id as __value,\n CASE WHEN COUNT(id) OVER (PARTITION BY name) > 1 AND name IS NOT NULL THEN CONCAT(name, ' - ', RIGHT(vin, 6)) ELSE COALESCE(name, CONCAT('VIN ', vin)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;", "hide": 2, "includeAll": true, "label": "Car", "name": "car_id", "options": [], "query": "SELECT\n id as __value,\n CASE WHEN COUNT(id) OVER (PARTITION BY name) > 1 AND name IS NOT NULL THEN CONCAT(name, ' - ', RIGHT(vin, 6)) ELSE COALESCE(name, CONCAT('VIN ', vin)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;", "refresh": 1, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "select unit_of_length from settings limit 1;", "hide": 2, "includeAll": false, "name": "length_unit", "options": [], "query": "select unit_of_length from settings limit 1;", "refresh": 1, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "select base_url from settings limit 1;", "hide": 2, "includeAll": false, "name": "base_url", "options": [], "query": "select base_url from settings limit 1;", "refresh": 1, "regex": "", "type": "query" }, { "current": { "text": "month", "value": "month" }, "includeAll": false, "label": "Period", "name": "period", "options": [ { "selected": true, "text": "month", "value": "month" }, { "selected": false, "text": "year", "value": "year" }, { "selected": false, "text": "day", "value": "day" }, { "selected": false, "text": "week", "value": "week" } ], "query": "month,year,day,week", "type": "custom" } ] }, "time": { "from": "now-6M", "to": "now" }, "timepicker": {}, "timezone": "", "title": "Mileage Stats", "uid": "jchmNjtMTFx", "version": 8 }