{ "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": 1, "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": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "This dashboard has a table with all the trips you've made between charges sessions, so you can browse the longest or shortest mileage you travel.\n\nYou may also take a look to a specific trip from the initial charge session (before the trip) to the end of the of the charge session (after the trip), through the link in the first column that will take you to the Trips dashboard.", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "filterable": false, "inspect": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "start_date" }, "properties": [ { "id": "displayName", "value": "Start Date" }, { "id": "unit", "value": "dateTimeAsLocal" }, { "id": "links", "value": [ { "targetBlank": true, "title": "View Trip details", "url": "d/FkUpJpQZk?from=${__data.fields.start_date_ts.numeric}&to=${__data.fields.end_date_ts.numeric}" } ] }, { "id": "custom.minWidth", "value": 180 } ] }, { "matcher": { "id": "byName", "options": "distance_km" }, "properties": [ { "id": "displayName", "value": "Distance" }, { "id": "unit", "value": "lengthkm" }, { "id": "decimals", "value": 1 }, { "id": "custom.minWidth", "value": 200 }, { "id": "custom.cellOptions", "value": { "mode": "gradient", "type": "gauge" } }, { "id": "color", "value": { "mode": "continuous-BlPu" } }, { "id": "max", "value": 400 } ] }, { "matcher": { "id": "byName", "options": "distance_mi" }, "properties": [ { "id": "displayName", "value": "Distance" }, { "id": "unit", "value": "lengthmi" }, { "id": "decimals", "value": 1 }, { "id": "custom.minWidth", "value": 200 }, { "id": "custom.cellOptions", "value": { "type": "gauge" } }, { "id": "color", "value": { "mode": "continuous-BlPu" } }, { "id": "max", "value": 400 } ] }, { "matcher": { "id": "byName", "options": "end_date" }, "properties": [ { "id": "custom.minWidth", "value": 180 }, { "id": "displayName", "value": "End Date" }, { "id": "unit", "value": "dateTimeAsLocal" } ] }, { "matcher": { "id": "byName", "options": "duration_min" }, "properties": [ { "id": "displayName", "value": "Duration" }, { "id": "unit", "value": "clocks" }, { "id": "custom.minWidth", "value": 120 }, { "id": "decimals", "value": 1 } ] }, { "matcher": { "id": "byName", "options": "speed_km" }, "properties": [ { "id": "displayName", "value": "Ø Speed" }, { "id": "custom.minWidth", "value": 110 }, { "id": "unit", "value": "velocitykmh" } ] }, { "matcher": { "id": "byName", "options": "speed_mi" }, "properties": [ { "id": "displayName", "value": "Ø Speed" }, { "id": "custom.minWidth", "value": 110 }, { "id": "unit", "value": "velocitymph" } ] }, { "matcher": { "id": "byRegexp", "options": "/.*_ts/" }, "properties": [ { "id": "unit", "value": "short" }, { "id": "decimals", "value": 2 }, { "id": "custom.hidden", "value": true } ] }, { "matcher": { "id": "byRegexp", "options": "/%/" }, "properties": [ { "id": "unit", "value": "percent" }, { "id": "decimals", "value": 0 }, { "id": "custom.minWidth", "value": 75 } ] }, { "matcher": { "id": "byName", "options": "power_max" }, "properties": [ { "id": "displayName", "value": "max Power" }, { "id": "unit", "value": "kwatt" }, { "id": "custom.minWidth", "value": 90 } ] }, { "matcher": { "id": "byName", "options": "speed_max_km" }, "properties": [ { "id": "displayName", "value": "max Speed" }, { "id": "unit", "value": "velocitykmh" }, { "id": "custom.minWidth", "value": 100 } ] }, { "matcher": { "id": "byName", "options": "speed_max_mi" }, "properties": [ { "id": "displayName", "value": "max Speed" }, { "id": "unit", "value": "velocitymph" }, { "id": "custom.minWidth", "value": 90 } ] }, { "matcher": { "id": "byName", "options": "avg_temp_c" }, "properties": [ { "id": "unit", "value": "celsius" }, { "id": "displayName", "value": "Temp" }, { "id": "custom.minWidth", "value": 75 } ] }, { "matcher": { "id": "byName", "options": "avg_temp_f" }, "properties": [ { "id": "displayName", "value": "Temp" }, { "id": "unit", "value": "fahrenheit" }, { "id": "custom.minWidth", "value": 75 } ] }, { "matcher": { "id": "byName", "options": "consumption_kwh_mi" }, "properties": [ { "id": "unit", "value": "Wh/mi" }, { "id": "custom.minWidth", "value": 110 }, { "id": "displayName", "value": "Ø Consumption (gross)" } ] }, { "matcher": { "id": "byName", "options": "consumption_kwh_km" }, "properties": [ { "id": "unit", "value": "Wh/km" }, { "id": "custom.minWidth", "value": 180 }, { "id": "displayName", "value": "Ø Consumption (gross)" } ] }, { "matcher": { "id": "byName", "options": "consumption_kwh" }, "properties": [ { "id": "displayName", "value": "Energy consumed (gross)" }, { "id": "decimals", "value": 1 }, { "id": "custom.minWidth", "value": 196 }, { "id": "unit", "value": "kwatth" } ] }, { "matcher": { "id": "byName", "options": "efficiency" }, "properties": [ { "id": "displayName", "value": "Full Efficiency" }, { "id": "unit", "value": "percentunit" }, { "id": "decimals", "value": 0 }, { "id": "custom.cellOptions", "value": { "mode": "basic", "type": "gauge" } }, { "id": "custom.minWidth", "value": 120 }, { "id": "max", "value": 1 }, { "id": "min", "value": 0 }, { "id": "color", "value": { "mode": "continuous-RdYlGr" } } ] } ] }, "gridPos": { "h": 30, "w": 24, "x": 0, "y": 0 }, "id": 2, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true, "sortBy": [] }, "pluginVersion": "11.5.2", "targets": [ { "alias": "", "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, "rawSql": "WITH \r\ntrip AS (\r\n SELECT start_date sd, end_date ed, distance, duration_min, start_usable_battery_level, end_usable_battery_level, \r\n outside_temp_avg, power_max, speed_max, start_${preferred_range}_range_km, end_${preferred_range}_range_km\r\n FROM drives INNER JOIN (\r\n SELECT drive_id, start_usable_battery_level, end_usable_battery_level\r\n FROM (\r\n select\r\n p.drive_id,\r\n first_value(p.usable_battery_level) over (partition by p.drive_id order by date ROWS BETWEEN unbounded PRECEDING AND unbounded FOLLOWING) as start_usable_battery_level,\r\n last_value(p.usable_battery_level) over (partition by p.drive_id order by date ROWS BETWEEN unbounded PRECEDING AND unbounded FOLLOWING) as end_usable_battery_level\r\n FROM drives d\r\n INNER JOIN positions p ON p.drive_id = d.id\r\n WHERE d.car_id = $car_id\r\n AND $__timeFilter(p.date)\r\n AND d.end_date IS NOT NULL\r\n AND d.duration_min > 0\r\n AND p.ideal_battery_range_km IS NOT NULL\r\n AND p.car_id = $car_id\r\n ) AS pos\r\n GROUP BY 1, 2, 3\r\n ) AS filter_drives ON filter_drives.drive_id = drives.id\r\n),\r\ncp AS (\r\n SELECT car_id, start_date, end_date, COALESCE(LAG(start_date) OVER(ORDER BY start_date DESC), now()) next_date,\r\n lag(start_battery_level) over (order by start_date desc) as next_start_battery_level, end_battery_level\r\n FROM charging_processes WHERE $__timeFilter(start_date) AND car_id = $car_id\r\n),\r\ndriven AS (\r\nSELECT cp.car_id, cp.start_date, cp.end_date, cp.next_date, \r\n MIN(trip.sd) trip_start_date, \r\n MAX(trip.ed) trip_end_date,\r\n SUM(convert_km(trip.distance::numeric, '$length_unit')) AS distance_$length_unit, \r\n MAX(convert_km(trip.speed_max::numeric, '$length_unit')) AS speed_max_$length_unit,\r\n SUM(trip.duration_min) duration_min,\r\n greatest(MAX(trip.start_usable_battery_level), cp.end_battery_level) start_soc, \r\n least(MIN(trip.end_usable_battery_level), cp.next_start_battery_level) end_soc, \r\n AVG(convert_celsius(trip.outside_temp_avg, '$temp_unit')) AS avg_temp_$temp_unit, \r\n MAX(trip.power_max) AS power_max, \r\n convert_km((MAX(trip.start_${preferred_range}_range_km) - MIN(trip.end_${preferred_range}_range_km))::numeric, '$length_unit') AS range_diff_$length_unit \r\n\tFROM cp\tINNER JOIN trip ON trip.sd BETWEEN cp.start_date and cp.next_date\r\n GROUP BY cp.car_id, cp.start_date, cp.end_date, cp.next_date, cp.next_start_battery_level, cp.end_battery_level\r\n)\r\nSELECT \r\n ROUND(EXTRACT(epoch FROM start_date) - 10) * 1000 AS start_date_ts, ROUND(EXTRACT(epoch FROM next_date) + 10) * 1000 AS end_date_ts,\r\n start_date, next_date as end_date,\r\n distance_$length_unit, duration_min * 60 as duration_min, \r\n (distance_$length_unit / duration_min * 60) as speed_$length_unit, \r\n start_soc as \"% Start\", end_soc as \"% End\",\r\n avg_temp_$temp_unit,\r\n power_max,\r\n speed_max_$length_unit,\r\n (range_diff_$length_unit * car.efficiency) as consumption_kwh, \r\n (range_diff_$length_unit * car.efficiency / nullif(distance_$length_unit, 0) * 1000.0) as consumption_kWh_$length_unit,\r\n (distance_$length_unit / nullif(range_diff_$length_unit, 0)) as efficiency\r\nFROM driven\r\nINNER JOIN cars car ON car.id = driven.car_id\r\nWHERE distance_$length_unit >= $min_dist AND (distance_$length_unit / duration_min * 60) >= $min_avg_speed AND duration_min > 0 AND range_diff_$length_unit > 0\r\nORDER BY start_date DESC\r\n", "refId": "A", "select": [ [ { "params": [ "value" ], "type": "column" } ] ], "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 }, "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Long Trips", "type": "table" } ], "preload": false, "refresh": "", "schemaVersion": 40, "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", "includeAll": false, "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, "label": "length unit", "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": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT preferred_range FROM settings LIMIT 1", "hide": 2, "includeAll": false, "name": "preferred_range", "options": [], "query": "SELECT preferred_range FROM settings LIMIT 1", "refresh": 1, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT unit_of_temperature FROM settings LIMIT 1", "hide": 2, "includeAll": false, "name": "temp_unit", "options": [], "query": "SELECT unit_of_temperature FROM settings LIMIT 1", "refresh": 1, "regex": "", "type": "query" }, { "current": { "text": "0", "value": "0" }, "label": "Distance >=", "name": "min_dist", "options": [ { "selected": true, "text": "0", "value": "0" } ], "query": "0", "type": "textbox" }, { "current": { "text": "0", "value": "0" }, "label": "Avg Speed >=", "name": "min_avg_speed", "options": [ { "selected": true, "text": "0", "value": "0" } ], "query": "0", "type": "textbox" } ] }, "time": { "from": "now-1M", "to": "now" }, "timepicker": {}, "timezone": "", "title": "Continuous Trips", "uid": "jchmY8upc6ZRk", "version": 1, "weekStart": "" }