{ "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" } ] }, "description": "A current drive overview of your car", "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, "id": 3, "links": [ { "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": "" }, { "asDropdown": false, "icon": "info", "includeVars": false, "keepTime": false, "tags": [], "targetBlank": false, "title": "Current Drive", "tooltip": "Adjust to current drive", "type": "link", "url": "d/jchmkOuP_Fggz/current-drive-view?kiosk&var-car_id=${car_id}&from=${current_drive_start_time}&to=${current_drive_end_time}&var-current_drive=${current_drive}&var-BatteryCapacity=${BatteryCapacity}&var-efficiency=${efficiency}&var-preferred_range=${preferred_range}&var-length_unit=${length_unit}&var-temp_unit=${temp_unit}&var-alternative_length_unit=${alternative_length_unit}" } ], "panels": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "This is a special dashboard to load while driving. When you open this dashboard it will show the last 15 minutes, but you should click the \"Current Drive\" button at the top right corner, to enter in Kiosk mode:\n\n - If you are driving, you will see the information from the start time of the current drive until now and it will refesh automatically every 30 seconds.\n\n - If you are just browsing (not driving) you will see the information of the last drive.", "fieldConfig": { "defaults": { "color": { "mode": "fixed" }, "custom": { "axisBorderShow": false, "axisCenteredZero": true, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 5, "gradientMode": "hue", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "smooth", "lineStyle": { "fill": "solid" }, "lineWidth": 1, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "never", "spanNulls": true, "stacking": { "group": "A", "mode": "normal" }, "thresholdsStyle": { "mode": "line" } }, "links": [], "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "transparent", "value": null } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "Battery heater" }, "properties": [ { "id": "unit", "value": "bool_on_off" }, { "id": "custom.axisPlacement", "value": "hidden" }, { "id": "color", "value": { "fixedColor": "semi-dark-red", "mode": "fixed" } } ] }, { "matcher": { "id": "byName", "options": "power" }, "properties": [ { "id": "displayName", "value": "Power" }, { "id": "color", "value": { "fixedColor": "dark-orange", "mode": "fixed", "seriesBy": "last" } }, { "id": "unit", "value": "kwatt" }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { "color": "transparent", "value": null }, { "color": "dark-green", "value": 0 } ] } } ] }, { "matcher": { "id": "byName", "options": "elevation_m" }, "properties": [ { "id": "displayName", "value": "Elevation" }, { "id": "unit", "value": "lengthm" } ] }, { "matcher": { "id": "byName", "options": "speed_kmh" }, "properties": [ { "id": "color", "value": { "fixedColor": "light-blue", "mode": "fixed" } }, { "id": "unit", "value": "velocitykmh" }, { "id": "displayName", "value": "Speed" }, { "id": "custom.axisPlacement", "value": "hidden" } ] }, { "matcher": { "id": "byName", "options": "speed_mih" }, "properties": [ { "id": "color", "value": { "fixedColor": "light-blue", "mode": "fixed" } }, { "id": "unit", "value": "velocitymih" }, { "id": "displayName", "value": "Speed" }, { "id": "custom.axisPlacement", "value": "hidden" } ] }, { "matcher": { "id": "byName", "options": "elevation_ft" }, "properties": [ { "id": "unit", "value": "lengthft" }, { "id": "displayName", "value": "Elevation" } ] } ] }, "gridPos": { "h": 11, "w": 16, "x": 0, "y": 0 }, "id": 26, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "hideZeros": false, "mode": "multi", "sort": "none" } }, "pluginVersion": "11.5.2", "targets": [ { "alias": "", "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "time_series", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\t$__time(date),\n\tavg(power) AS Power,\n\tavg(battery_heater::integer) AS \"Battery heater\",\n\tavg(convert_km(speed::numeric, '$length_unit')) AS speed_${length_unit}h\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nGROUP BY 1 \nORDER BY\n\tdate ASC", "refId": "Power", "select": [ [ { "params": [ "id" ], "type": "column" } ] ], "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 }, "table": "charging", "timeColumn": "Datum", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "format": "time_series", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\t$__time(date),\n\tAVG(ROUND(convert_m(elevation, '$alternative_length_unit'))) AS elevation_${alternative_length_unit}\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nGROUP BY 1 \nORDER BY\n\tdate ASC", "refId": "Elevation", "select": [ [ { "params": [ "start_km" ], "type": "column" } ] ], "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Drive", "type": "timeseries" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "color": { "fixedColor": "red", "mode": "thresholds" }, "custom": { "hideFrom": { "legend": false, "tooltip": false, "viz": false } }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] } }, "overrides": [] }, "gridPos": { "h": 21, "w": 8, "x": 16, "y": 0 }, "id": 33, "maxDataPoints": 50000, "options": { "basemap": { "config": {}, "name": "Layer 0", "type": "osm-standard" }, "controls": { "mouseWheelZoom": true, "showAttribution": true, "showDebug": false, "showMeasure": false, "showScale": false, "showZoom": true }, "layers": [ { "config": { "showLegend": false, "style": { "color": { "fixed": "transparent" }, "opacity": 0, "rotation": { "fixed": 0, "max": 360, "min": -360, "mode": "mod" }, "size": { "fixed": 3, "max": 15, "min": 2 }, "symbol": { "fixed": "img/icons/marker/circle.svg", "mode": "fixed" }, "symbolAlign": { "horizontal": "center", "vertical": "center" }, "textConfig": { "fontSize": 12, "offsetX": 0, "offsetY": 0, "textAlign": "center", "textBaseline": "middle" } } }, "location": { "mode": "auto" }, "name": "Temp Fix Grafana Issue #89777", "tooltip": false, "type": "markers" }, { "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": "11.5.2", "targets": [ { "alias": "", "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "time_series", "group": [ { "params": [ "$__interval", "none" ], "type": "time" } ], "hide": false, "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", "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" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ] }, "table": "pos", "timeColumn": "Datum", "timeColumnType": "datetime", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "", "type": "geomap" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "efficiency_km" }, "properties": [ { "id": "unit", "value": "Wh/km" } ] }, { "matcher": { "id": "byName", "options": "efficiency_mi" }, "properties": [ { "id": "unit", "value": "Wh/mi" } ] } ] }, "gridPos": { "h": 4, "w": 2, "x": 0, "y": 11 }, "id": 32, "options": { "colorMode": "value", "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "auto", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT $efficiency * 10 / convert_km(1, '$length_unit') as \"efficiency_$length_unit\"", "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": "Efficiency", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "", "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "decimals": 0, "mappings": [], "max": 49, "min": 0, "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "light-orange", "value": null } ] }, "unit": "kwatth" }, "overrides": [] }, "gridPos": { "h": 4, "w": 2, "x": 2, "y": 11 }, "id": 35, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "orientation": "vertical", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "alias": "kWh Added", "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT $BatteryCapacity AS \"Battery Capacity\"", "refId": "B", "select": [ [ { "params": [ "start_km" ], "type": "column" } ] ], "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 }, "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Battery Capacity", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "yellow", "value": null } ] } }, "overrides": [ { "matcher": { "id": "byRegexp", "options": ".*_km" }, "properties": [ { "id": "unit", "value": "Wh/km" } ] }, { "matcher": { "id": "byRegexp", "options": ".*_mi" }, "properties": [ { "id": "unit", "value": "Wh/mi" } ] } ] }, "gridPos": { "h": 4, "w": 4, "x": 4, "y": 11 }, "id": 24, "options": { "colorMode": "value", "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "mean" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "auto", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "with drives_start_event as (\n\n select\n 'drive_start' as event, start_date as date, start_${preferred_range}_range_km as range, start_km as odometer, car_id\n from drives\n where car_id = $car_id and $__timeFilter(start_date) and 48 <= extract(hour FROM to_timestamp(${__to:date:seconds}) - to_timestamp(${__from:date:seconds}))\n\n),\n\ndrives_end_event as (\n\n select\n 'drive_end' as event, end_date as date, end_${preferred_range}_range_km as range, end_km as odometer, car_id\n from drives\n where car_id = $car_id and $__timeFilter(end_date) and 48 <= extract(hour FROM to_timestamp(${__to:date:seconds}) - to_timestamp(${__from:date:seconds}))\n\n),\n\ncharging_processes_start_event as (\n\n select\n 'charging_process_start' as event, start_date as date, start_${preferred_range}_range_km as range, p.odometer, cp.car_id\n from charging_processes cp\n inner join positions p on cp.position_id = p.id\n where cp.car_id = $car_id and $__timeFilter(start_date) and 48 <= extract(hour FROM to_timestamp(${__to:date:seconds}) - to_timestamp(${__from:date:seconds}))\n\n),\n\ncharging_processes_end_event as (\n\n select\n 'charging_process_end' as event, end_date as date, end_${preferred_range}_range_km as range, p.odometer, cp.car_id\n from charging_processes cp\n inner join positions p on cp.position_id = p.id\n where cp.car_id = $car_id and $__timeFilter(end_date) and 48 <= extract(hour FROM to_timestamp(${__to:date:seconds}) - to_timestamp(${__from:date:seconds}))\n\n),\n\npositions as (\n\n select\n case\n when drive_id is not null and lead(drive_id) over w is not null then 'drive_start'\n else 'something'\n end as event,\n date, ${preferred_range}_battery_range_km as range, p.odometer, p.car_id\n from positions p\n where ideal_battery_range_km is not null and car_id = $car_id and $__timeFilter(date) and 48 > extract(hour FROM to_timestamp(${__to:date:seconds}) - to_timestamp(${__from:date:seconds}))\n window w as (order by date)\n\n),\n\ncombined as (\n\n select * from drives_start_event\n union all\n select * from drives_end_event\n union all\n select * from charging_processes_start_event\n union all\n select * from charging_processes_end_event\n union all\n select * from positions\n\n),\n\nfinal as (\n\n select\n car_id,\n lead(odometer) over w - odometer as distance,\n case when event != 'drive_start' then greatest(range - lead(range) over w, 0) else range - lead(range) over w end as range_loss\n from combined\n window w as (order by date asc)\n\n)\n\nselect\n (sum(range_loss) * c.efficiency * 1000) / nullif(convert_km(sum(distance)::numeric, '$length_unit'), 0) as consumption_$length_unit\nfrom final\n inner join cars c on car_id = c.id\ngroup by c.efficiency", "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": "Ø Consumption (gross)", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "color": { "mode": "continuous-GrYlRd" }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byRegexp", "options": "/.*_f/" }, "properties": [ { "id": "unit", "value": "fahrenheit" } ] }, { "matcher": { "id": "byRegexp", "options": "/.*_c/" }, "properties": [ { "id": "unit", "value": "celsius" } ] }, { "matcher": { "id": "byRegexp", "options": "/outdoor*/" }, "properties": [ { "id": "displayName", "value": "Outdoor" } ] }, { "matcher": { "id": "byRegexp", "options": "/inside*/" }, "properties": [ { "id": "displayName", "value": "Inside" } ] }, { "matcher": { "id": "byRegexp", "options": "/driver*/" }, "properties": [ { "id": "displayName", "value": "Driver" } ] } ] }, "gridPos": { "h": 4, "w": 4, "x": 8, "y": 11 }, "id": 34, "options": { "colorMode": "value", "graphMode": "area", "justifyMode": "center", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "mean" ], "fields": "", "values": false }, "showPercentChange": false, "text": {}, "textMode": "auto", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "time_series", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(outside_temp, '$temp_unit')) as outdoor_$temp_unit \r\nFROM positions \r\nWHERE car_id = $car_id AND outside_temp IS NOT NULL AND $__timeFilter(date)\r\nGROUP BY date\r\nORDER BY date", "refId": "Outdoor", "select": [ [ { "params": [ "value" ], "type": "column" } ] ], "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 }, "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "time_series", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(inside_temp, '$temp_unit')) as inside_$temp_unit \r\nFROM positions \r\nWHERE car_id = $car_id AND outside_temp IS NOT NULL AND $__timeFilter(date)\r\nGROUP BY date\r\nORDER BY date", "refId": "Inside", "select": [ [ { "params": [ "value" ], "type": "column" } ] ], "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 }, "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "time_series", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT $__timeGroupAlias(date,$__interval), avg(convert_celsius(driver_temp_setting, '$temp_unit')) as driver_$temp_unit \r\nFROM positions \r\nWHERE car_id = $car_id AND outside_temp IS NOT NULL AND $__timeFilter(date)\r\nGROUP BY date\r\nORDER BY date", "refId": "Driver", "select": [ [ { "params": [ "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": "", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 1, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "super-light-blue", "value": null } ] }, "unit": "clocks" }, "overrides": [] }, "gridPos": { "h": 4, "w": 4, "x": 12, "y": 11 }, "id": 36, "options": { "colorMode": "value", "graphMode": "none", "justifyMode": "auto", "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "sum" ], "fields": "", "values": false }, "showPercentChange": false, "text": {}, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "alias": "Elapsed Time", "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "metricColumn": "none", "orderByTime": "ASC", "policy": "default", "rawQuery": true, "rawSql": "SELECT ${__to:date:seconds} - ${__from:date:seconds}", "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ "utc" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 }, "tags": [], "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Elapsed", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 1, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "#c7d0d9", "value": null } ] }, "unit": "lengthkm" }, "overrides": [ { "matcher": { "id": "byName", "options": "distance_km" }, "properties": [ { "id": "unit", "value": "km" } ] }, { "matcher": { "id": "byName", "options": "distance_mi" }, "properties": [ { "id": "unit", "value": "mi" } ] } ] }, "gridPos": { "h": 4, "w": 4, "x": 0, "y": 15 }, "id": 27, "links": [ { "targetBlank": true, "title": "Mileage", "url": "/d/NjtMTFggz/mileage?" } ], "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "first" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT convert_km((max(odometer) - min(odometer))::numeric, '$length_unit') as \"distance_$length_unit\"\n FROM positions\n WHERE $__timeFilter(date) AND ideal_battery_range_km is not null", "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": "Distance", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 0, "mappings": [ { "options": { "match": "null", "result": { "text": "N/A" } }, "type": "special" } ], "thresholds": { "mode": "absolute", "steps": [ { "color": "#c7d0d9", "value": null } ] }, "unit": "none" }, "overrides": [ { "matcher": { "id": "byName", "options": "speed_kmh" }, "properties": [ { "id": "unit", "value": "velocitykmh" } ] }, { "matcher": { "id": "byName", "options": "speed_mih" }, "properties": [ { "id": "unit", "value": "velocitymph" } ] } ] }, "gridPos": { "h": 4, "w": 4, "x": 4, "y": 15 }, "id": 37, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "first" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "mean" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "time_series", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n $__timeGroupAlias(date,$__interval),\n\tAVG(convert_km(speed::numeric, '$length_unit')) AS speed_${length_unit}h\nFROM\n\tpositions\nWHERE\n $__timeFilter(date) AND car_id = $car_id\nGROUP BY 1", "refId": "A", "select": [ [ { "params": [ "value" ], "type": "column" } ] ], "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 }, "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Average Speed", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 0, "mappings": [ { "options": { "match": "null", "result": { "text": "N/A" } }, "type": "special" } ], "thresholds": { "mode": "absolute", "steps": [ { "color": "#c7d0d9", "value": null } ] }, "unit": "none" }, "overrides": [ { "matcher": { "id": "byName", "options": "range_km" }, "properties": [ { "id": "unit", "value": "lengthkm" } ] }, { "matcher": { "id": "byName", "options": "range_mi" }, "properties": [ { "id": "unit", "value": "lengthmi" } ] } ] }, "gridPos": { "h": 4, "w": 4, "x": 8, "y": 15 }, "id": 14, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "first" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "mean" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "time_series", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT $__timeGroupAlias(date,$__interval),\n avg(convert_km(${preferred_range}_battery_range_km, '$length_unit')) as range_$length_unit\nFROM positions\nWHERE $__timeFilter(date) AND car_id=$car_id AND ${preferred_range}_battery_range_km is not null\nGROUP BY 1 ORDER BY 1 DESC LIMIT 1", "refId": "A", "select": [ [ { "params": [ "value" ], "type": "column" } ] ], "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 }, "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Current Range ($preferred_range)", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 0, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "#c7d0d9", "value": null } ] }, "unit": "none" }, "overrides": [ { "matcher": { "id": "byName", "options": "odometer_km" }, "properties": [ { "id": "unit", "value": "km" } ] }, { "matcher": { "id": "byName", "options": "odometer_mi" }, "properties": [ { "id": "unit", "value": "mi" } ] } ] }, "gridPos": { "h": 4, "w": 4, "x": 12, "y": 15 }, "id": 6, "links": [ { "targetBlank": true, "title": "Mileage", "url": "/d/NjtMTFggz/mileage?" } ], "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "first" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "mean" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "time_series", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "select $__time(date), convert_km(odometer::numeric, '$length_unit') as \"odometer_$length_unit\"\nfrom positions \nwhere drive_id = $current_drive \norder by date desc \nlimit 1;", "refId": "A", "select": [ [ { "params": [ "value" ], "type": "column" } ] ], "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 }, "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Odometer", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "decimals": 1, "mappings": [], "max": 100, "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "dark-red", "value": null }, { "color": "semi-dark-green", "value": 20 }, { "color": "semi-dark-orange", "value": 80 }, { "color": "light-blue", "value": 100 } ] }, "unit": "%" }, "overrides": [] }, "gridPos": { "h": 2, "w": 8, "x": 0, "y": 19 }, "id": 29, "options": { "displayMode": "lcd", "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": false }, "maxVizHeight": 300, "minVizHeight": 10, "minVizWidth": 0, "namePlacement": "auto", "orientation": "horizontal", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "showUnfilled": true, "sizing": "auto", "text": {}, "valueMode": "color" }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "format": "table", "group": [], "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "measurement": "%", "metricColumn": "none", "orderByTime": "ASC", "policy": "default", "rawQuery": true, "rawSql": "(SELECT battery_level, date\nFROM positions\nWHERE car_id = $car_id\nORDER BY date DESC\nLIMIT 1)\nUNION\nSELECT battery_level, date\nFROM charges c\nJOIN charging_processes p ON p.id = c.charging_process_id\nWHERE $__timeFilter(date) AND p.car_id = $car_id\nORDER BY date DESC\nLIMIT 1", "refId": "SOC", "resultFormat": "time_series", "select": [ [ { "params": [ "start_km" ], "type": "column" } ] ], "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "", "type": "bargauge" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "decimals": 1, "mappings": [], "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "dark-red", "value": null }, { "color": "dark-green", "value": 7.84 }, { "color": "semi-dark-orange", "value": 31.36 }, { "color": "light-blue", "value": 35.28 } ] }, "unit": "kwatth" }, "overrides": [] }, "gridPos": { "h": 2, "w": 8, "x": 8, "y": 19 }, "id": 31, "options": { "displayMode": "gradient", "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": false }, "maxVizHeight": 300, "minVizHeight": 10, "minVizWidth": 0, "namePlacement": "auto", "orientation": "horizontal", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "/^kwh$/", "values": false }, "showUnfilled": true, "sizing": "auto", "text": {}, "valueMode": "color" }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "format": "table", "group": [], "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "measurement": "%", "metricColumn": "none", "policy": "default", "rawQuery": true, "rawSql": "(SELECT battery_level * $BatteryCapacity / 100 as kWh, date, $BatteryCapacity as Total\nFROM positions\nWHERE car_id = $car_id\nORDER BY date DESC\nLIMIT 1)\nUNION\nSELECT battery_level * $BatteryCapacity / 100 as kWh, date, $BatteryCapacity as Total\nFROM charges c\nJOIN charging_processes p ON p.id = c.charging_process_id\nWHERE $__timeFilter(date) AND p.car_id = $car_id\nORDER BY date DESC\nLIMIT 1", "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ "start_km" ], "type": "column" } ] ], "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "", "type": "bargauge" } ], "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, "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 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": {}, "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 case when unit_of_length = 'km' then 'm' when unit_of_length = 'mi' then 'ft' end from settings limit 1;", "hide": 2, "includeAll": false, "name": "alternative_length_unit", "options": [], "query": "select case when unit_of_length = 'km' then 'm' when unit_of_length = 'mi' then 'ft' end from settings limit 1;", "refresh": 1, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT drive_id FROM positions WHERE car_id = $car_id AND drive_id IS NOT NULL ORDER BY date DESC LIMIT 1;", "hide": 2, "includeAll": false, "name": "current_drive", "options": [], "query": "SELECT drive_id FROM positions WHERE car_id = $car_id AND drive_id IS NOT NULL ORDER BY date DESC LIMIT 1;", "refresh": 2, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT \n (round(extract(epoch FROM start_date) - 10) * 1000) AS start_date_ts\n FROM drives \n WHERE id = $current_drive", "hide": 2, "includeAll": false, "name": "current_drive_start_time", "options": [], "query": "SELECT \n (round(extract(epoch FROM start_date) - 10) * 1000) AS start_date_ts\n FROM drives \n WHERE id = $current_drive", "refresh": 2, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT \n CASE WHEN end_date IS NULL THEN 'now&refresh=10s' \n ELSE CAST(round(extract(epoch FROM end_date) - 10) * 1000 AS VARCHAR(100)) END\n FROM drives\n WHERE id = $current_drive", "hide": 2, "includeAll": false, "name": "current_drive_end_time", "options": [], "query": "SELECT \n CASE WHEN end_date IS NULL THEN 'now&refresh=10s' \n ELSE CAST(round(extract(epoch FROM end_date) - 10) * 1000 AS VARCHAR(100)) END\n FROM drives\n WHERE id = $current_drive", "refresh": 2, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT\n AVG(Capacity) AS Capacity\nFROM (\n SELECT \n c.rated_battery_range_km * $efficiency / c.usable_battery_level AS Capacity\n FROM charging_processes cp\n INNER JOIN charges c ON c.charging_process_id = cp.id \n WHERE\n cp.car_id = $car_id\n AND cp.end_date IS NOT NULL\n AND cp.charge_energy_added >= $efficiency\n AND c.usable_battery_level > 0\n ORDER BY cp.end_date DESC, c.date DESC\n LIMIT 100\n)", "hide": 2, "includeAll": false, "name": "BatteryCapacity", "options": [], "query": "SELECT\n AVG(Capacity) AS Capacity\nFROM (\n SELECT \n c.rated_battery_range_km * $efficiency / c.usable_battery_level AS Capacity\n FROM charging_processes cp\n INNER JOIN charges c ON c.charging_process_id = cp.id \n WHERE\n cp.car_id = $car_id\n AND cp.end_date IS NOT NULL\n AND cp.charge_energy_added >= $efficiency\n AND c.usable_battery_level > 0\n ORDER BY cp.end_date DESC, c.date DESC\n LIMIT 100\n)", "refresh": 2, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT\n COALESCE(derived_efficiency, car_efficiency) AS efficiency\nFROM (\n SELECT\n ROUND((charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric, 3) * 100 AS derived_efficiency,\n COUNT(*) as count,\n cars.id as car_id,\n cars.efficiency * 100 AS car_efficiency\n FROM cars\n LEFT JOIN charging_processes ON\n cars.id = charging_processes.car_id \n AND duration_min > 10\n AND end_battery_level <= 95\n AND start_rated_range_km IS NOT NULL\n AND end_rated_range_km IS NOT NULL\n AND charge_energy_added > 0\n WHERE cars.id = $car_id\n GROUP BY 1, 3, 4\n ORDER BY 2 DESC\n LIMIT 1\n)", "hide": 2, "includeAll": false, "name": "efficiency", "options": [], "query": "SELECT\n COALESCE(derived_efficiency, car_efficiency) AS efficiency\nFROM (\n SELECT\n ROUND((charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric, 3) * 100 AS derived_efficiency,\n COUNT(*) as count,\n cars.id as car_id,\n cars.efficiency * 100 AS car_efficiency\n FROM cars\n LEFT JOIN charging_processes ON\n cars.id = charging_processes.car_id \n AND duration_min > 10\n AND end_battery_level <= 95\n AND start_rated_range_km IS NOT NULL\n AND end_rated_range_km IS NOT NULL\n AND charge_energy_added > 0\n WHERE cars.id = $car_id\n GROUP BY 1, 3, 4\n ORDER BY 2 DESC\n LIMIT 1\n)", "refresh": 2, "regex": "", "type": "query" } ] }, "time": { "from": "now-15m", "to": "now" }, "timepicker": {}, "timezone": "", "title": "Current Drive View", "uid": "jchmkOuP_Fggz", "version": 3, "weekStart": "" }