{ "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": 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": [ { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "id": 12, "panels": [], "title": "Summary", "type": "row" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "light-yellow", "value": null } ] }, "unit": "kwatth" }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 0, "y": 1 }, "id": 10, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\tsum(charge_energy_used)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id;\n", "refId": "A", "select": [ [ { "params": [ "efficiency" ], "type": "column" } ] ], "table": "cars", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Total Energy Used", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "light-yellow", "value": null } ] }, "unit": "kwatth" }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 3, "y": 1 }, "id": 33, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\tsum(charge_energy_used)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND cost = 0;\n", "refId": "A", "select": [ [ { "params": [ "efficiency" ], "type": "column" } ] ], "table": "cars", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Free Energy used", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "light-yellow", "value": null } ] }, "unit": "kwatth" }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 6, "y": 1 }, "id": 64, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH energy as(\r\nSELECT\r\n\tsum(charge_energy_used) AS charged_kWh\r\nFROM\r\n\tcharging_processes\r\nWHERE\r\n\t$__timeFilter(end_date)\r\n\tAND car_id = $car_id),\r\nsince as (\r\n\tSELECT date FROM positions\r\n\tWHERE car_id = $car_id\r\n\tORDER BY date ASC\r\n\tLIMIT 1\r\n)\r\nSELECT (energy.charged_kWh / $distance_driven) as \"kwh_per_$length_unit\" FROM energy", "refId": "A", "select": [ [ { "params": [ "efficiency" ], "type": "column" } ] ], "table": "cars", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "kWh per $length_unit", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "light-yellow", "value": null } ] }, "unit": "times" }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 9, "y": 1 }, "id": 38, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\tcount(*)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND charge_energy_used > 0.01\n\tAND car_id = $car_id;", "refId": "A", "select": [ [ { "params": [ "efficiency" ], "type": "column" } ] ], "table": "cars", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "# of Charges", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "For this section, it's important that you have geo-fences called \"Home\" and \"Work\" if you want to see a bar with the energy charged on those places.", "fieldConfig": { "defaults": { "color": { "mode": "continuous-GrYlRd" }, "mappings": [], "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "text", "value": null } ] }, "unit": "kwatth" }, "overrides": [] }, "gridPos": { "h": 12, "w": 6, "x": 12, "y": 1 }, "id": 49, "options": { "displayMode": "gradient", "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": false }, "maxVizHeight": 300, "minVizHeight": 10, "minVizWidth": 0, "namePlacement": "auto", "orientation": "vertical", "reduceOptions": { "calcs": [], "fields": "/^energy$/", "values": true }, "showUnfilled": false, "sizing": "auto", "valueMode": "color" }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT location, SUM(charge_energy_used) AS Energy\r\nFROM (\r\nSELECT\r\n CASE\r\n WHEN COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.display_name), '')))) ILIKE '%Home%' THEN COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.display_name), ''))))\r\n\t WHEN COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.display_name), '')))) ILIKE '%Work%' THEN COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.display_name), ''))))\r\n\t WHEN COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.display_name), '')))) ILIKE '%supercharger%' OR charges.fast_charger_brand = 'Tesla' THEN 'Superchargers'\r\n\t ELSE 'Other'\r\n END AS location, charge_energy_used\r\nFROM\r\n\tcharging_processes c\r\nLEFT JOIN addresses address ON c.address_id = address.id\r\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\r\nLEFT JOIN charges ON charges.charging_process_id = c.id AND charges.date = c.end_date\r\nWHERE\r\n\t car_id = $car_id\r\n\tAND $__timeFilter(end_date)\r\n\tAND c.charge_energy_used > 0\r\n) ChargeLocations\r\nGROUP BY location\r\nORDER BY Energy 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": "Main locations", "type": "bargauge" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "This dashboard is meant to have a look of all the charges in a given period (last 10 years by default). You can see the distance driven, number of charges, total charging cost, etc., both in summary or in separated lists.\n\nYou can expand/collapse the rows as needed.\n\nFrom the Monthly Stats row, you will have a table with links to other Teslamate Dashboards to have a look on a specific period, charge or trip.", "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { "hideFrom": { "legend": false, "tooltip": false, "viz": false } }, "decimals": 2, "mappings": [], "unit": "kwatth" }, "overrides": [ { "matcher": { "id": "byName", "options": "AC" }, "properties": [ { "id": "color", "value": { "fixedColor": "semi-dark-green", "mode": "fixed" } } ] }, { "matcher": { "id": "byName", "options": "DC" }, "properties": [ { "id": "color", "value": { "fixedColor": "light-orange", "mode": "fixed" } } ] } ] }, "gridPos": { "h": 12, "w": 6, "x": 18, "y": 1 }, "id": 51, "maxDataPoints": 3, "options": { "displayLabels": [ "name", "percent", "value" ], "legend": { "displayMode": "list", "placement": "bottom", "showLegend": false }, "pieType": "pie", "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "tooltip": { "hideZeros": false, "mode": "single", "sort": "none" } }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "format": "time_series", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH data AS (\n SELECT\n\t\tcp.id,\n\t\tcp.charge_energy_used,\n\t\tCASE WHEN NULLIF(mode() within group (order by charger_phases),0) is null THEN 'DC'\n\t\t\t\t ELSE 'AC'\n\t\tEND AS current\n\tFROM charging_processes cp\n RIGHT JOIN charges ON cp.id = charges.charging_process_id\n WHERE\n\t cp.car_id = $car_id\n\t AND cp.charge_energy_used > 0.01\n\t AND $__timeFilter(start_date)\n GROUP BY 1,2\n)\nSELECT\n\tnow() AS time,\n\tsum(charge_energy_used) AS value,\n\tcurrent AS metric\nFROM data\nGROUP BY 3\nORDER BY metric DESC;", "refId": "A", "select": [ [ { "params": [ "latitude" ], "type": "column" } ] ], "table": "addresses", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Summary AC/DC Energy Used", "type": "piechart" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "Share of Energy added at $geofence projected on Total Distance driven.\n\nThis is not considering specific distance driven with actual consumption after charging at $geofence.\n\nUse the dropdown at the top to choose the Geofence to display energy added from.", "fieldConfig": { "defaults": { "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] }, "unit": "none" }, "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": 3, "w": 3, "x": 0, "y": 4 }, "id": 66, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "sum" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "sum" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH free_energy AS (\r\nSELECT sum(charge_energy_used) AS free_charged_kWh\r\nFROM charging_processes cp\r\nINNER JOIN geofences g ON g.id = cp.geofence_id\r\nWHERE\r\n\t$__timeFilter(end_date)\r\n\tAND car_id = $car_id AND g.name = '$geofence'\r\nGROUP BY g.name),\r\nenergy as(\r\nSELECT\r\n\tsum(charge_energy_used) AS charged_kWh\r\nFROM\r\n\tcharging_processes\r\nWHERE\r\n\t$__timeFilter(end_date)\r\n\tAND car_id = $car_id\r\n)\r\nSELECT ($distance_driven * free_energy.free_charged_kWh / energy.charged_kWh) as \"distance_$length_unit\" FROM energy, free_energy", "refId": "A", "select": [ [ { "params": [ "latitude" ], "type": "column" } ] ], "table": "addresses", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "approx. Distance powered by $geofence", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "Share of Energy added for free projected on Total Distance driven.\n\nThis is not considering specific distance driven with actual consumption after charging for free.", "fieldConfig": { "defaults": { "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] }, "unit": "none" }, "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": 3, "w": 3, "x": 3, "y": 4 }, "id": 65, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "sum" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "sum" ], "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": "WITH free_energy AS (\r\nSELECT sum(charge_energy_used) AS free_charged_kWh\r\nFROM charging_processes\r\nWHERE\r\n\t$__timeFilter(end_date)\r\n\tAND car_id = $car_id\r\n\tAND cost = 0),\r\nenergy as(\r\nSELECT\r\n\tsum(charge_energy_used) AS charged_kWh\r\nFROM\r\n\tcharging_processes\r\nWHERE\r\n\t$__timeFilter(end_date)\r\n\tAND car_id = $car_id\r\n)\r\nSELECT ($distance_driven * free_energy.free_charged_kWh / energy.charged_kWh) as \"distance_$length_unit\" FROM energy, free_energy", "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" } ] } ], "title": "approx. Distance driven for free", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "Share of Energy added at SuC projected on Total Distance driven.\n\nThis is not considering specific distance driven with actual consumption after charging at SuC.", "fieldConfig": { "defaults": { "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] }, "unit": "none" }, "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": 3, "w": 3, "x": 6, "y": 4 }, "id": 67, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "sum" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "sum" ], "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": "WITH suc_data AS (\r\n\tSELECT c.charging_process_id\r\n\tFROM charges c\r\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\r\n\tLEFT JOIN addresses addr ON addr.id = cp.address_id\r\n\tLEFT JOIN geofences geo ON geo.id = geofence_id\r\n\tWHERE \r\n cp.car_id = $car_id AND c.fast_charger_present\r\n\t\tAND (COALESCE(geo.name, CONCAT_WS(', ', COALESCE(addr.name, nullif(CONCAT_WS(' ', addr.display_name), '')))) ILIKE '%supercharger%' OR c.fast_charger_brand = 'Tesla')\r\n AND $__timeFilter(end_date)\r\n\tGROUP BY 1\r\n), suc_energy AS (\r\n SELECT coalesce(sum(charge_energy_used), 0) AS charged_kWh\r\n FROM charging_processes cp\r\n INNER JOIN suc_data ON suc_data.charging_process_id = cp.id\r\n), energy AS(\r\n SELECT\r\n\t sum(charge_energy_used) AS charged_kWh\r\n FROM charging_processes\r\n WHERE $__timeFilter(end_date)\tAND car_id = $car_id\r\n)\r\nSELECT ($distance_driven * suc_energy.charged_kWh / energy.charged_kWh) as \"distance_$length_unit\" FROM energy, suc_energy;\r\n", "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" } ] } ], "title": "approx. Distance powered by SuC", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "", "fieldConfig": { "defaults": { "decimals": 0, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] }, "unit": "none" }, "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": 3, "w": 3, "x": 9, "y": 4 }, "id": 36, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "sum" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "percentChangeColorMode": "standard", "reduceOptions": { "calcs": [ "sum" ], "fields": "", "values": false }, "showPercentChange": false, "textMode": "value", "wideLayout": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT $distance_driven as \"distance_$length_unit\"", "refId": "A", "select": [ [ { "params": [ "latitude" ], "type": "column" } ] ], "table": "addresses", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Total Distance driven", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 2, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "super-light-blue", "value": null } ] } }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 0, "y": 7 }, "id": 56, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n $ACCost\n", "refId": "A", "select": [ [ { "params": [ "start_km" ], "type": "column" } ] ], "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "AC Charging Cost", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 2, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "super-light-blue", "value": null } ] } }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 3, "y": 7 }, "id": 44, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n $DCCost\n", "refId": "A", "select": [ [ { "params": [ "start_km" ], "type": "column" } ] ], "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "DC Charging Cost", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 2, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "super-light-blue", "value": null } ] } }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 6, "y": 7 }, "id": 14, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n $SucCost", "refId": "A", "select": [ [ { "params": [ "start_km" ], "type": "column" } ] ], "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "SuC Charging Cost", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 2, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "super-light-blue", "value": null } ] } }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 9, "y": 7 }, "id": 27, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n $TotalCost\n", "refId": "A", "select": [ [ { "params": [ "start_km" ], "type": "column" } ] ], "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Total Charging Cost", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "decimals": 2, "displayName": "", "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "light-orange", "value": null } ] } }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 0, "y": 10 }, "id": 40, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT (\n SELECT sum(cost)\n FROM charging_processes\n WHERE $__timeFilter(end_date) AND car_id = $car_id\n) / $distance_driven * 100", "refId": "A", "select": [ [ { "params": [ "efficiency" ], "type": "column" } ] ], "table": "cars", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Ø Cost per 100 $length_unit", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "decimals": 2, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "light-orange", "value": null } ] } }, "overrides": [] }, "gridPos": { "h": 3, "w": 3, "x": 3, "y": 10 }, "id": 42, "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" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT (\n SELECT sum(cost)\n FROM charging_processes\n WHERE $__timeFilter(end_date) AND car_id = $car_id\n) / (\n SELECT sum(greatest(charge_energy_used, charge_energy_used))\n FROM charging_processes\n WHERE $__timeFilter(end_date) AND car_id = $car_id\n)", "refId": "A", "select": [ [ { "params": [ "value" ], "type": "column" } ] ], "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "Ø Cost per kWh", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "Net is the efficiency while driving", "fieldConfig": { "defaults": { "decimals": 0, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "light-orange", "value": null } ] }, "unit": "none" }, "overrides": [ { "matcher": { "id": "byName", "options": "consumption_km" }, "properties": [ { "id": "unit", "value": "Wh/km" } ] }, { "matcher": { "id": "byName", "options": "consumption_mi" }, "properties": [ { "id": "unit", "value": "Wh/mi" } ] } ] }, "gridPos": { "h": 3, "w": 3, "x": 6, "y": 10 }, "id": 69, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "select \n sum((start_${preferred_range}_range_km - end_${preferred_range}_range_km) * cars.efficiency) / convert_km(sum(distance)::numeric, '$length_unit') * 1000 as \"consumption_$length_unit\"\nfrom drives \ninner join cars on cars.id = car_id\nwhere \n distance is not null and\n start_${preferred_range}_range_km - end_${preferred_range}_range_km >= 0.1 and\n 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" } ] } ], "title": "Ø Consumption (net)", "type": "stat" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "Gross is all consumption (including while idle, phantom drains, sentry mode, etc)", "fieldConfig": { "defaults": { "decimals": 0, "mappings": [], "noValue": "0", "thresholds": { "mode": "absolute", "steps": [ { "color": "light-orange", "value": null } ] }, "unit": "none" }, "overrides": [ { "matcher": { "id": "byName", "options": "consumption_km" }, "properties": [ { "id": "unit", "value": "Wh/km" } ] }, { "matcher": { "id": "byName", "options": "consumption_mi" }, "properties": [ { "id": "unit", "value": "Wh/mi" } ] } ] }, "gridPos": { "h": 3, "w": 3, "x": 9, "y": 10 }, "id": 71, "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "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": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH d1 AS (\n\tSELECT\n\t\tc.car_id,\n\t\tlag(end_${preferred_range}_range_km) OVER (ORDER BY start_date) - start_${preferred_range}_range_km AS range_loss,\n\t\tp.odometer - lag(p.odometer) OVER (ORDER BY start_date) AS distance\n\tFROM\n\t\tcharging_processes c\n\tLEFT JOIN positions p ON p.id = c.position_id \n\tWHERE\n\t end_date IS NOT NULL AND\n\t c.car_id = $car_id\n\tORDER BY\n\t\tstart_date\n),\nd2 AS (\nSELECT\n\tcar_id,\n\tsum(range_loss) AS range_loss,\n\tsum(distance) AS distance\nFROM\n\td1\nWHERE\n\tdistance >= 0 AND range_loss >= 0\nGROUP BY\n\tcar_id\n)\nSELECT\nrange_loss * c.efficiency / convert_km(distance::numeric, '$length_unit') * 1000 AS \"consumption_$length_unit\"\nFROM\n\td2\n\tLEFT JOIN cars c ON c.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" } ] } ], "title": "Ø Consumption (gross) ", "type": "stat" }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 13 }, "id": 60, "panels": [], "title": "Top 10 Charges", "type": "row" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "location" }, "properties": [ { "id": "displayName", "value": "Location" } ] }, { "matcher": { "id": "byName", "options": "charge_energy_used" }, "properties": [ { "id": "displayName", "value": "Charged" }, { "id": "custom.width", "value": 110 }, { "id": "custom.align", "value": "right" }, { "id": "unit", "value": "kwatth" }, { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "Cost" }, "properties": [ { "id": "custom.width", "value": 110 }, { "id": "decimals", "value": 2 } ] } ] }, "gridPos": { "h": 12, "w": 6, "x": 0, "y": 14 }, "id": 46, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n SUM(charge_energy_used) as charge_energy_used, \n\tsum(coalesce(cost, 0.0)) as \"Cost\"\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND charge_energy_used > 0\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_used) DESC\nLIMIT 10;", "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": "Top 10 General Charging Stations (Charged)", "type": "table" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "location" }, "properties": [ { "id": "displayName", "value": "Location" } ] }, { "matcher": { "id": "byName", "options": "charge_energy_used" }, "properties": [ { "id": "displayName", "value": "Charged" }, { "id": "custom.width", "value": 110 }, { "id": "custom.align", "value": "right" }, { "id": "unit", "value": "kwatth" }, { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "Cost" }, "properties": [ { "id": "custom.width", "value": 110 }, { "id": "decimals", "value": 2 } ] } ] }, "gridPos": { "h": 12, "w": 6, "x": 6, "y": 14 }, "id": 4, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n sum(charge_energy_used) as charge_energy_used,\n\tsum(coalesce(cost, 0.0)) as \"Cost\"\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND cost > 0\n\tAND charge_energy_used > 0\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_used) DESC\nLIMIT 10;", "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": "Top 10 Paid Stations (Charged)", "type": "table" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "location" }, "properties": [ { "id": "displayName", "value": "Location" } ] }, { "matcher": { "id": "byName", "options": "charge_energy_used" }, "properties": [ { "id": "displayName", "value": "Charged" }, { "id": "custom.width", "value": 110 }, { "id": "custom.align", "value": "right" }, { "id": "unit", "value": "kwatth" }, { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "Cost" }, "properties": [ { "id": "custom.width", "value": 110 }, { "id": "decimals", "value": 2 } ] } ] }, "gridPos": { "h": 12, "w": 6, "x": 12, "y": 14 }, "id": 34, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n sum(charge_energy_used) as charge_energy_used,\n\tsum(coalesce(cost, 0.0)) as \"Cost\"\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nLEFT JOIN charges ON charges.charging_process_id = c.id AND charges.date = c.end_date\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND charge_energy_used > 0\n\tAND (COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.display_name), '')))) ILIKE '%supercharger%' OR charges.fast_charger_brand = 'Tesla')\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_used) DESC\nLIMIT 10;", "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": "Top 10 SuperCharger Stations (Charged)", "type": "table" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "location" }, "properties": [ { "id": "displayName", "value": "Location" } ] }, { "matcher": { "id": "byName", "options": "charge_energy_used" }, "properties": [ { "id": "displayName", "value": "Charged" }, { "id": "custom.width", "value": 120 }, { "id": "custom.align", "value": "right" }, { "id": "unit", "value": "kwatth" }, { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "Cost" }, "properties": [ { "id": "custom.width", "value": 110 }, { "id": "decimals", "value": 2 } ] } ] }, "gridPos": { "h": 12, "w": 6, "x": 18, "y": 14 }, "id": 32, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n SUM(charge_energy_used) as charge_energy_used,\n\tsum(coalesce(cost, 0.0)) as \"Cost\"\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND charge_energy_used > 0\n\tAND cost = 0\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_used) DESC\nLIMIT 10;", "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": "Top 10 Free Stations (Charged)", "type": "table" }, { "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 26 }, "id": 62, "panels": [], "title": "Monthly Stats", "type": "row" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "", "fieldConfig": { "defaults": { "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "filterable": false, "inspect": false }, "mappings": [], "noValue": "--", "thresholds": { "mode": "absolute", "steps": [ { "color": "red" } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "Time driven" }, "properties": [ { "id": "unit", "value": "dtdurations" }, { "id": "decimals", "value": 1 }, { "id": "custom.minWidth", "value": 170 } ] }, { "matcher": { "id": "byName", "options": "Period" }, "properties": [ { "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" } ] }, { "id": "custom.minWidth", "value": 195 } ] }, { "matcher": { "id": "byName", "options": "Driving Efficiency" }, "properties": [ { "id": "unit", "value": "percentunit" }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { "color": "super-light-orange" }, { "color": "light-orange", "value": 0.65 }, { "color": "light-green", "value": 0.99 } ] } }, { "id": "max", "value": 1.15 }, { "id": "custom.cellOptions", "value": { "mode": "lcd", "type": "gauge" } }, { "id": "decimals" } ] }, { "matcher": { "id": "byName", "options": "Energy used" }, "properties": [ { "id": "decimals", "value": 1 }, { "id": "links", "value": [ { "targetBlank": true, "title": "Charging stats", "url": "/d/-pkIkhmRz/charging-stats?from=${__data.fields.date_from}&to=${__data.fields.date_to}&var-car_id=$car_id" } ] }, { "id": "unit", "value": "kwatth" }, { "id": "custom.minWidth", "value": 120 } ] }, { "matcher": { "id": "byName", "options": "Ø Energy used / Charge" }, "properties": [ { "id": "unit", "value": "kwatth" }, { "id": "decimals", "value": 1 }, { "id": "custom.minWidth", "value": 190 } ] }, { "matcher": { "id": "byName", "options": "Costs" }, "properties": [ { "id": "decimals", "value": 2 }, { "id": "custom.minWidth", "value": 75 } ] }, { "matcher": { "id": "byName", "options": "# of Charges" }, "properties": [ { "id": "links", "value": [ { "targetBlank": true, "title": "Charges", "url": "/d/TSmNYvRRk/charges?from=${__data.fields.date_from}&to=${__data.fields.date_to}&var-car_id=$car_id" } ] }, { "id": "custom.minWidth", "value": 110 } ] }, { "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.minWidth", "value": 95 } ] }, { "matcher": { "id": "byRegexp", "options": "/sum_distance_km/" }, "properties": [ { "id": "unit", "value": "km" }, { "id": "displayName", "value": "Distance" }, { "id": "custom.minWidth", "value": 100 } ] }, { "matcher": { "id": "byRegexp", "options": "/avg_outside_temp_c/" }, "properties": [ { "id": "unit", "value": "celsius" }, { "id": "displayName", "value": "Ø Temp" }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { "color": "super-light-blue" }, { "color": "super-light-green", "value": 10 }, { "color": "super-light-red", "value": 20 } ] } }, { "id": "custom.cellOptions", "value": { "type": "color-text" } }, { "id": "custom.minWidth", "value": 80 } ] }, { "matcher": { "id": "byRegexp", "options": "/sum_distance_mi/" }, "properties": [ { "id": "displayName", "value": "Distance" }, { "id": "unit", "value": "mi" }, { "id": "custom.minWidth", "value": 100 } ] }, { "matcher": { "id": "byRegexp", "options": "/consumption_net_mi/" }, "properties": [ { "id": "unit", "value": "Wh/mi" }, { "id": "custom.width", "value": 170 }, { "id": "displayName", "value": "Ø Consumption (net)" } ] }, { "matcher": { "id": "byRegexp", "options": "/consumption_gross_mi/" }, "properties": [ { "id": "displayName", "value": "Ø Consumption (gross)" }, { "id": "unit", "value": "Wh/mi" }, { "id": "custom.width", "value": 190 } ] }, { "matcher": { "id": "byRegexp", "options": "/consumption_net_km/" }, "properties": [ { "id": "displayName", "value": "Ø Consumption (net)" }, { "id": "unit", "value": "Wh/km" }, { "id": "custom.width", "value": 170 } ] }, { "matcher": { "id": "byRegexp", "options": "/consumption_gross_km/" }, "properties": [ { "id": "displayName", "value": "Ø Consumption (gross)" }, { "id": "unit", "value": "Wh/km" }, { "id": "custom.width", "value": 190 } ] }, { "matcher": { "id": "byRegexp", "options": "/avg_outside_temp_f/" }, "properties": [ { "id": "displayName", "value": "Ø Temp" }, { "id": "unit", "value": "fahrenheit" }, { "id": "custom.cellOptions", "value": { "type": "color-text" } }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { "color": "super-light-blue" }, { "color": "super-light-green", "value": 50 }, { "color": "super-light-red", "value": 68 } ] } }, { "id": "custom.minWidth", "value": 80 } ] }, { "matcher": { "id": "byName", "options": "date_from" }, "properties": [ { "id": "custom.hidden", "value": true } ] }, { "matcher": { "id": "byName", "options": "date_to" }, "properties": [ { "id": "custom.hidden", "value": true } ] }, { "matcher": { "id": "byName", "options": "Ø Cost / kWh" }, "properties": [ { "id": "decimals", "value": 2 }, { "id": "mappings", "value": [ { "options": { "NaN": { "index": 0, "text": "--" } }, "type": "value" } ] }, { "id": "custom.minWidth", "value": 115 } ] }, { "matcher": { "id": "byName", "options": "Ø Cost / 100 km" }, "properties": [ { "id": "decimals", "value": 2 }, { "id": "custom.minWidth", "value": 135 }, { "id": "mappings", "value": [ { "options": { "NaN": { "index": 0, "text": "--" } }, "type": "value" } ] } ] }, { "matcher": { "id": "byName", "options": "Consumption OH" }, "properties": [ { "id": "custom.minWidth", "value": 140 }, { "id": "unit", "value": "percentunit" }, { "id": "decimals", "value": 0 }, { "id": "mappings", "value": [ { "options": { "NaN": { "index": 0, "text": "--" } }, "type": "value" } ] } ] } ] }, "gridPos": { "h": 15, "w": 24, "x": 0, "y": 27 }, "id": 72, "options": { "cellHeight": "sm", "footer": { "countRows": false, "enablePagination": true, "fields": "", "reducer": [ "sum" ], "show": false }, "frameIndex": 1, "showHeader": true, "sortBy": [ { "desc": true, "displayName": "Starting at" } ] }, "pluginVersion": "11.4.0", "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_${preferred_range}_range_km - end_${preferred_range}_range_km, 0), 0) AS range_diff,\n date_trunc('month', timezone('UTC', start_date), '$__timezone') as date,\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 date)*1000 AS date_from,\n EXTRACT(EPOCH FROM date + interval '1 month')*1000 AS date_to,\n to_char(date, 'YYYY Month') AS display,\n 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 convert_celsius(avg(outside_temp_avg), '$temp_unit') AS avg_outside_temp_$temp_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", "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" } ] }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH data AS (\n SELECT\n charging_processes.*,\n \tdate_trunc('month', timezone('UTC', start_date), '$__timezone') as date\n FROM charging_processes)\nSELECT\n EXTRACT(EPOCH FROM date)*1000 AS date_from,\n EXTRACT(EPOCH FROM date + interval '1 month')*1000 AS date_to,\n to_char(date, 'YYYY Month') AS display,\n date,\n sum(greatest(charge_energy_added,charge_energy_used)) AS sum_energy_used_kwh,\n sum(greatest(charge_energy_added,charge_energy_used)) / count(*) AS avg_energy_charged_kwh,\n sum(cost) AS cost_charges,\n count(*) AS cnt_charges\nFROM data WHERE\n car_id = $car_id AND\n $__timeFilter(start_date) AND\n (charge_energy_added IS NULL OR charge_energy_added > 0.1)\nGROUP BY date", "refId": "B", "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": "table", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, "rawSql": "WITH data AS (\n SELECT\n drives.*,\n date_trunc('month', timezone('UTC', start_date), '$__timezone') as date\n FROM drives)\nSELECT\n EXTRACT(EPOCH FROM date)*1000 AS date_from,\n EXTRACT(EPOCH FROM date + interval '1 month')*1000 AS date_to,\n to_char(date, 'YYYY Month') AS display,\n date,\n sum(GREATEST(start_${preferred_range}_range_km - end_${preferred_range}_range_km, 0) * car.efficiency * 1000) / \n convert_km(sum(distance)::numeric, '$length_unit') as consumption_net_$length_unit\nFROM data\nJOIN cars car ON car.id = car_id\nWHERE\n car_id = $car_id AND\n $__timeFilter(start_date)\nGROUP BY date", "refId": "C", "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": "table", "hide": false, "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)\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)\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)\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)\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\n),\n\nfinal as (\n\n select\n car_id,\n date_trunc('month', timezone('UTC', date), '$__timezone') as date,\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 EXTRACT(EPOCH FROM date)*1000 AS date_from,\n EXTRACT(EPOCH FROM date + interval '1 month')*1000 AS date_to,\n to_char(date, 'YYYY Month') AS display,\n date,\n (sum(range_loss) * c.efficiency * 1000) / nullif(convert_km(sum(distance)::numeric, '$length_unit'), 0) as consumption_gross_$length_unit\nfrom final\n inner join cars c on car_id = c.id\ngroup by 1, 2, 3, 4, c.efficiency", "refId": "D", "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 } } ], "title": "Stats per Month", "transformations": [ { "id": "merge", "options": {} }, { "id": "seriesToColumns", "options": { "byField": "date" } }, { "id": "sortBy", "options": { "fields": {}, "sort": [ { "desc": true, "field": "date" } ] } }, { "id": "calculateField", "options": { "alias": "avg_cost_kwh", "binary": { "left": "cost_charges", "operator": "/", "reducer": "sum", "right": "sum_energy_used_kwh" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "avg_cost_km_temp", "binary": { "left": "cost_charges", "operator": "/", "reducer": "sum", "right": "sum_distance_km" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "avg_cost_mi_temp", "binary": { "left": "cost_charges", "operator": "/", "reducer": "sum", "right": "sum_distance_mi" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "avg_cost_km", "binary": { "left": "avg_cost_km_temp", "operator": "*", "right": "100" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "avg_cost_mi", "binary": { "left": "avg_cost_mi_temp", "operator": "*", "right": "100" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "overhead_pct_km_temp", "binary": { "left": "consumption_net_km", "operator": "/", "right": "consumption_gross_km" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "overhead_pct_km", "binary": { "left": "1", "operator": "-", "right": "overhead_pct_km_temp" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "overhead_pct_mi_temp", "binary": { "left": "consumption_net_mi", "operator": "/", "right": "consumption_gross_mi" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "overhead_pct_mi", "binary": { "left": "1", "operator": "-", "right": "overhead_pct_mi_temp" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "organize", "options": { "excludeByName": { "avg_cost_km_temp": true, "avg_cost_mi_temp": true, "date": true, "overhead_pct_km_temp": true, "overhead_pct_mi_temp": true }, "includeByName": {}, "indexByName": { "avg_cost_km": 12, "avg_cost_kwh": 11, "avg_cost_mi": 12, "avg_energy_charged_kwh": 8, "avg_outside_temp_c": 4, "avg_outside_temp_f": 4, "cnt": 5, "cnt_charges": 10, "consumption_gross_km": 14, "consumption_gross_mi": 14, "consumption_net_km": 13, "consumption_net_mi": 13, "cost_charges": 9, "date": 1, "date_from": 15, "date_to": 16, "display": 0, "efficiency": 6, "overhead_pct_km": 17, "overhead_pct_mi": 17, "sum_distance_km": 3, "sum_distance_mi": 3, "sum_duration_h": 2, "sum_energy_used_kwh": 7 }, "renameByName": { "avg_cost_km": "Ø Cost / 100 km", "avg_cost_kwh": "Ø Cost / kWh", "avg_cost_mi": "Ø Cost / 100 mi", "avg_energy_charged_kwh": "Ø Energy used / Charge", "avg_outside_temp_c": "", "avg_outside_temp_f": "", "cnt": "# of Drives", "cnt_charges": "# of Charges", "consumption_gross_km": "", "consumption_gross_mi": "", "consumption_net_km": "", "consumption_net_mi": "", "cost_charges": "Costs", "date": "", "date_from": "", "date_to": "", "display": "Period", "efficiency": "Driving Efficiency", "overhead_pct_km": "Consumption OH", "overhead_pct_mi": "Consumption OH", "sum_distance_km": "", "sum_distance_mi": "", "sum_duration_h": "Time driven", "sum_energy_used_kwh": "Energy used" } } } ], "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, RIGHT(vin, 6)) 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, RIGHT(vin, 6)) 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 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 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\n\tcoalesce(sum(cost), 0)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id;\n\t", "hide": 2, "includeAll": false, "name": "TotalCost", "options": [], "query": "SELECT\n\tcoalesce(sum(cost), 0)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id;\n\t", "refresh": 2, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "WITH data AS (\n\tSELECT c.charging_process_id \n\tFROM charges c\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\n\tLEFT JOIN addresses addr ON addr.id = cp.address_id\n\tLEFT JOIN geofences geo ON geo.id = geofence_id\n\tWHERE \n\t cp.car_id = $car_id AND c.fast_charger_present\n\t\tAND (COALESCE(geo.name, CONCAT_WS(', ', COALESCE(addr.name, nullif(CONCAT_WS(' ', addr.display_name), '')))) ILIKE '%supercharger%' OR c.fast_charger_brand = 'Tesla')\n\tGROUP BY 1\n)\nSELECT\n coalesce(sum(cp.cost), 0)\nFROM\n\tcharging_processes cp, data\nWHERE\n $__timeFilter(end_date)\n AND cp.id IN (data.charging_process_id);", "hide": 2, "includeAll": false, "name": "SucCost", "options": [], "query": "WITH data AS (\n\tSELECT c.charging_process_id \n\tFROM charges c\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\n\tLEFT JOIN addresses addr ON addr.id = cp.address_id\n\tLEFT JOIN geofences geo ON geo.id = geofence_id\n\tWHERE \n\t cp.car_id = $car_id AND c.fast_charger_present\n\t\tAND (COALESCE(geo.name, CONCAT_WS(', ', COALESCE(addr.name, nullif(CONCAT_WS(' ', addr.display_name), '')))) ILIKE '%supercharger%' OR c.fast_charger_brand = 'Tesla')\n\tGROUP BY 1\n)\nSELECT\n coalesce(sum(cp.cost), 0)\nFROM\n\tcharging_processes cp, data\nWHERE\n $__timeFilter(end_date)\n AND cp.id IN (data.charging_process_id);", "refresh": 2, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "WITH data AS (\n\tSELECT c.charging_process_id \n\tFROM charges c\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\n\tWHERE \n cp.car_id = $car_id AND c.fast_charger_present\n\tGROUP BY 1\n)\nSELECT\n coalesce(sum(cp.cost) - $SucCost , 0)\t\nFROM\n\tcharging_processes cp, data\nWHERE\n $__timeFilter(end_date)\n AND cp.id IN (data.charging_process_id);", "hide": 2, "includeAll": false, "name": "DCCost", "options": [], "query": "WITH data AS (\n\tSELECT c.charging_process_id \n\tFROM charges c\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\n\tWHERE \n cp.car_id = $car_id AND c.fast_charger_present\n\tGROUP BY 1\n)\nSELECT\n coalesce(sum(cp.cost) - $SucCost , 0)\t\nFROM\n\tcharging_processes cp, data\nWHERE\n $__timeFilter(end_date)\n AND cp.id IN (data.charging_process_id);", "refresh": 2, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "WITH data AS (\n\tSELECT c.charging_process_id \n\tFROM charges c\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\n\tWHERE \n\t\tcp.car_id = $car_id AND c.charger_voltage != 2\n AND c.fast_charger_present IS NOT true\n GROUP BY 1\n)\nSELECT\n coalesce(sum(cp.cost) , 0)\nFROM\n\tcharging_processes cp, data\nWHERE\n $__timeFilter(end_date)\n AND cp.cost IS NOT NULL\n AND cp.id IN (data.charging_process_id);", "hide": 2, "includeAll": false, "name": "ACCost", "options": [], "query": "WITH data AS (\n\tSELECT c.charging_process_id \n\tFROM charges c\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\n\tWHERE \n\t\tcp.car_id = $car_id AND c.charger_voltage != 2\n AND c.fast_charger_present IS NOT true\n GROUP BY 1\n)\nSELECT\n coalesce(sum(cp.cost) , 0)\nFROM\n\tcharging_processes cp, data\nWHERE\n $__timeFilter(end_date)\n AND cp.cost IS NOT NULL\n AND cp.id IN (data.charging_process_id);", "refresh": 2, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT ROUND(convert_km((max(end_km) - min(start_km))::numeric, '$length_unit'),0) as \"Mileage\"\nFROM drives WHERE car_id = $car_id AND $__timeFilter(end_date)", "hide": 2, "includeAll": false, "name": "distance_driven", "options": [], "query": "SELECT ROUND(convert_km((max(end_km) - min(start_km))::numeric, '$length_unit'),0) as \"Mileage\"\nFROM drives WHERE car_id = $car_id AND $__timeFilter(end_date)", "refresh": 2, "regex": "", "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 name FROM geofences ORDER BY id", "description": "Geofence to display energy added at", "includeAll": false, "label": "Geofence", "name": "geofence", "options": [], "query": "SELECT name FROM geofences ORDER BY id", "refresh": 1, "regex": "", "type": "query" } ] }, "time": { "from": "now-10y", "to": "now" }, "timepicker": { "refresh_intervals": [] }, "timezone": "", "title": "Charging Costs Stats", "uid": "jchmDdLe5uFVk", "version": 1, "weekStart": "" }