{ "annotations": { "list": [ { "builtIn": 1, "datasource": "-- Grafana --", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "target": { "limit": 100, "matchAny": false, "tags": [], "type": "dashboard" }, "type": "dashboard" } ] }, "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, "iteration": 1642773094880, "links": [ { "icon": "dashboard", "tags": [], "title": "TeslaMate", "type": "link", "url": "[[base_url:raw]]" }, { "asDropdown": true, "icon": "external link", "tags": ["tesla"], "title": "Dashboards", "type": "dashboards" } ], "liveNow": false, "panels": [ { "collapsed": false, "datasource": "TeslaMate", "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "id": 4, "panels": [], "repeat": "car_id", "title": "$car_id", "type": "row" }, { "datasource": "TeslaMate", "description": "", "fieldConfig": { "defaults": { "custom": { "align": "left", "displayMode": "auto", "filterable": false, "width": 120 }, "mappings": [], "noValue": "--", "thresholds": { "mode": "percentage", "steps": [ { "color": "red", "value": null }, { "color": "#EAB839", "value": 50 }, { "color": "green", "value": 90 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "Time driven" }, "properties": [ { "id": "unit", "value": "clocks" }, { "id": "decimals", "value": 1 } ] }, { "matcher": { "id": "byName", "options": "Period" }, "properties": [ { "id": "custom.width", "value": 195 }, { "id": "links", "value": [ { "targetBlank": true, "title": "Trip", "url": "d/FkUpJpQZk/trip?from=${__data.fields.date_from}&to=${__data.fields.date_to}&var-car_id=$car_id" } ] } ] }, { "matcher": { "id": "byName", "options": "Efficiency" }, "properties": [ { "id": "unit", "value": "percentunit" }, { "id": "custom.displayMode", "value": "color-text" }, { "id": "thresholds", "value": { "mode": "percentage", "steps": [ { "color": "super-light-orange", "value": null }, { "color": "light-orange", "value": 65 }, { "color": "light-green", "value": 99 } ] } }, { "id": "max", "value": 1 } ] }, { "matcher": { "id": "byName", "options": "Energy charged" }, "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" } ] }, { "matcher": { "id": "byName", "options": "Avg charged" }, "properties": [ { "id": "unit", "value": "kwatth" }, { "id": "decimals", "value": 1 } ] }, { "matcher": { "id": "byName", "options": "Costs" }, "properties": [ { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "# 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" } ] } ] }, { "matcher": { "id": "byName", "options": "# 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" } ] } ] }, { "matcher": { "id": "byRegexp", "options": "/sum_distance_km/" }, "properties": [ { "id": "unit", "value": "km" }, { "id": "displayName", "value": "Distance" } ] }, { "matcher": { "id": "byRegexp", "options": "/avg_outside_temp_c/" }, "properties": [ { "id": "unit", "value": "celsius" }, { "id": "displayName", "value": "Temperature" }, { "id": "custom.displayMode", "value": "color-text" }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { "color": "super-light-blue", "value": null }, { "color": "super-light-green", "value": 10 }, { "color": "super-light-red", "value": 20 } ] } } ] }, { "matcher": { "id": "byRegexp", "options": "/sum_distance_mi/" }, "properties": [ { "id": "displayName", "value": "Distance" }, { "id": "unit", "value": "mi" } ] }, { "matcher": { "id": "byRegexp", "options": "/efficiency_net_mi/" }, "properties": [ { "id": "displayName", "value": "Avg consumption (drives)" }, { "id": "unit", "value": "Wh/mi" }, { "id": "custom.width" } ] }, { "matcher": { "id": "byRegexp", "options": "/efficiency_charged_net_mi/" }, "properties": [ { "id": "displayName", "value": "Avg consumption (charges)" }, { "id": "unit", "value": "Wh/mi" }, { "id": "custom.width" } ] }, { "matcher": { "id": "byRegexp", "options": "/.* at/" }, "properties": [ { "id": "unit", "value": "dateTimeAsLocal" }, { "id": "custom.width" } ] }, { "matcher": { "id": "byRegexp", "options": "/efficiency_net_km/" }, "properties": [ { "id": "displayName", "value": "Avg consumption (drives)" }, { "id": "unit", "value": "Wh/km" }, { "id": "custom.width" } ] }, { "matcher": { "id": "byRegexp", "options": "/efficiency_charged_net_km/" }, "properties": [ { "id": "displayName", "value": "Avg consumption (charges)" }, { "id": "unit", "value": "Wh/km" }, { "id": "custom.width" } ] }, { "matcher": { "id": "byRegexp", "options": "/avg_outside_temp_f/" }, "properties": [ { "id": "displayName", "value": "Temperature" }, { "id": "unit", "value": "fahrenheit" }, { "id": "custom.cellOptions", "value": { "type": "color-text" } }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { "color": "super-light-blue", "value": null }, { "color": "super-light-green", "value": 50 }, { "color": "super-light-red", "value": 68 } ] } } ] }, { "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": "Avg cost per kWh" }, "properties": [ { "id": "custom.width", "value": 137 } ] } ] }, "gridPos": { "h": 18, "w": 24, "x": 0, "y": 1 }, "id": 2, "maxPerRow": 2, "options": { "footer": { "fields": "", "reducer": ["sum"], "show": false }, "frameIndex": 1, "showHeader": true, "sortBy": [ { "desc": true, "displayName": "Starting at" } ] }, "pluginVersion": "10.4.1", "repeatDirection": "h", "targets": [ { "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH data AS (\nSELECT\n duration_min > 1 AND\n distance > 1 AND\n ( \n start_position.usable_battery_level IS NULL OR\n (end_position.battery_level - end_position.usable_battery_level) = 0 \n ) AS is_sufficiently_precise,\n NULLIF(GREATEST(start_ideal_range_km - end_ideal_range_km, 0), 0) AS range_diff,\n date_trunc('$period', TIMEZONE('$__timezone', TIMEZONE('UTC', start_date))) 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 TIMEZONE('$__timezone', date))*1000 AS date_from,\n EXTRACT(EPOCH FROM (TIMEZONE('$__timezone', date) + ('1 ' || '$period')::INTERVAL))*1000 AS date_to,\n CASE '$period'\n WHEN 'month' THEN to_char(date, 'YYYY Month')\n WHEN 'year' THEN to_char(date, 'YYYY')\n WHEN 'week' THEN 'week ' || to_char(date, 'WW') || ' starting ' || to_char(date, 'YYYY-MM-DD')\n ELSE to_char(date, 'YYYY-MM-DD')\n END AS display,\n TIMEZONE('$__timezone', date) AS date,\n sum(duration_min)*60 AS sum_duration_h, \n convert_km(max(end_km)::integer - min(start_km)::integer, '$length_unit') AS sum_distance_$length_unit,\n 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\nORDER BY date", "refId": "A", "select": [ [ { "params": ["start_km"], "type": "column" } ] ], "table": "drives", "timeColumn": "start_date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] }, { "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH data AS (\n SELECT\n charging_processes.*,\n \tdate_trunc('$period', TIMEZONE('$__timezone', TIMEZONE('UTC', start_date))) as date\n FROM charging_processes)\nSELECT\n EXTRACT(EPOCH FROM TIMEZONE('$__timezone', date))*1000 AS date_from,\n EXTRACT(EPOCH FROM (TIMEZONE('$__timezone', date) + ('1 ' || '$period')::INTERVAL))*1000 AS date_to,\n CASE '$period'\n WHEN 'month' THEN to_char(date, 'YYYY Month')\n WHEN 'year' THEN to_char(date, 'YYYY')\n WHEN 'week' THEN 'week ' || to_char(date, 'WW') || ' starting ' || to_char(date, 'YYYY-MM-DD')\n ELSE to_char(date, 'YYYY-MM-DD')\n END AS display,\n TIMEZONE('$__timezone', date) AS date,\n sum(greatest(charge_energy_added,charge_energy_used)) AS sum_consumption_kwh,\n sum(greatest(charge_energy_added,charge_energy_used)) / count(*) AS avg_consumption_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\nORDER BY date", "refId": "B", "select": [ [ { "params": ["value"], "type": "column" } ] ], "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] }, { "format": "table", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, "rawSql": "WITH data AS (\n SELECT\n drives.*,\n date_trunc('$period', TIMEZONE('$__timezone', TIMEZONE('UTC', start_date))) as date\n FROM drives)\nSELECT\n EXTRACT(EPOCH FROM TIMEZONE('$__timezone', date))*1000 AS date_from,\n EXTRACT(EPOCH FROM (TIMEZONE('$__timezone', date) + ('1 ' || '$period')::INTERVAL))*1000 AS date_to,\n CASE '$period'\n WHEN 'month' THEN to_char(date, 'YYYY Month')\n WHEN 'year' THEN to_char(date, 'YYYY')\n WHEN 'week' THEN 'week ' || to_char(date, 'WW') || ' starting ' || to_char(date, 'YYYY-MM-DD')\n ELSE to_char(date, 'YYYY-MM-DD')\n END AS display,\n TIMEZONE('$__timezone', date) AS 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 efficiency_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\nORDER BY date", "refId": "C", "select": [ [ { "params": ["value"], "type": "column" } ] ], "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "title": "per ${period}", "transformations": [ { "id": "merge", "options": {} }, { "id": "seriesToColumns", "options": { "byField": "date" } }, { "id": "calculateField", "options": { "alias": "efficiency_charged_net_km_temp", "binary": { "left": "sum_consumption_kwh", "operator": "/", "reducer": "sum", "right": "sum_distance_km" }, "mode": "binary", "reduce": { "reducer": "sum" }, "replaceFields": false } }, { "id": "calculateField", "options": { "alias": "efficiency_charged_net_km", "binary": { "left": "efficiency_charged_net_km_temp", "operator": "*", "reducer": "sum", "right": "1000" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "efficiency_charged_net_mi_temp", "binary": { "left": "sum_consumption_kwh", "operator": "/", "reducer": "sum", "right": "sum_distance_mi" }, "mode": "binary", "reduce": { "reducer": "sum" }, "replaceFields": false } }, { "id": "calculateField", "options": { "alias": "efficiency_charged_net_mi", "binary": { "left": "efficiency_charged_net_mi_temp", "operator": "*", "reducer": "sum", "right": "1000" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "avg_cost_kwh", "binary": { "left": "cost_charges", "operator": "/", "reducer": "sum", "right": "sum_consumption_kwh" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "avg_cost_km", "binary": { "left": "cost_charges", "operator": "/", "reducer": "sum", "right": "sum_distance_km" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "calculateField", "options": { "alias": "avg_cost_mi", "binary": { "left": "cost_charges", "operator": "/", "reducer": "sum", "right": "sum_distance_mi" }, "mode": "binary", "reduce": { "reducer": "sum" } } }, { "id": "organize", "options": { "excludeByName": { "date": false, "date_from": false, "date_to": false, "efficiency_charged_net_km_temp": true, "efficiency_charged_net_mi_temp": true, "timezone": true }, "indexByName": { "avg_consumption_kwh": 9, "avg_cost_km": 19, "avg_cost_mi": 20, "avg_cost_kwh": 11, "avg_outside_temp_c": 5, "avg_outside_temp_f": 5, "cnt": 6, "cnt_charges": 11, "cost_charges": 10, "date": 1, "date_from": 17, "date_to": 18, "display": 0, "efficiency": 7, "efficiency_charged_net_km": 15, "efficiency_charged_net_mi": 16, "efficiency_net_km": 13, "efficiency_net_mi": 14, "sum_consumption_kwh": 8, "sum_distance_km": 3, "sum_distance_mi": 4, "sum_duration_h": 2 }, "renameByName": { "avg_consumption_kwh": "Avg charged", "avg_cost_km": "Avg cost per km", "avg_cost_mi": "Avg cost per mi", "avg_cost_kwh": "Avg cost per kWh", "avg_outside_temp_c": "", "cnt": "# drives", "cnt_charges": "# charges", "cost_charges": "Costs", "date": "Starting at", "date_from": "", "date_to": "", "display": "Period", "efficiency": "Efficiency", "efficiency_net_km": "", "sum_consumption_kwh": "Energy charged", "sum_distance_km": "", "sum_duration_h": "Time driven" } } } ], "type": "table" } ], "refresh": false, "schemaVersion": 39, "style": "dark", "tags": ["tesla"], "templating": { "list": [ { "current": { "selected": false, "text": "All", "value": "$__all" }, "datasource": "TeslaMate", "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", "hide": 2, "includeAll": true, "label": "Car", "multi": false, "name": "car_id", "options": [], "query": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", "refresh": 1, "regex": "", "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", "tagsQuery": "", "type": "query", "useTags": false }, { "current": { "selected": false, "text": "km", "value": "km" }, "datasource": "TeslaMate", "definition": "select unit_of_length from settings limit 1;", "hide": 2, "includeAll": false, "label": "length unit", "multi": false, "name": "length_unit", "options": [], "query": "select unit_of_length from settings limit 1;", "refresh": 1, "regex": "", "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", "tags": [], "tagsQuery": "", "type": "query", "useTags": false }, { "allValue": null, "current": { "selected": false, "text": "C", "value": "C" }, "datasource": "TeslaMate", "definition": "select unit_of_temperature from settings limit 1;", "hide": 2, "includeAll": false, "label": "temperature unit", "multi": false, "name": "temp_unit", "options": [], "query": "select unit_of_temperature from settings limit 1;", "refresh": 1, "regex": "", "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", "tagsQuery": "", "type": "query", "useTags": false }, { "current": { "selected": true, "text": "month", "value": "month" }, "hide": 0, "includeAll": false, "label": "Period", "multi": false, "name": "period", "options": [ { "selected": false, "text": "day", "value": "day" }, { "selected": false, "text": "week", "value": "week" }, { "selected": true, "text": "month", "value": "month" }, { "selected": false, "text": "year", "value": "year" } ], "query": "day,week,month,year", "queryValue": "", "skipUrlSync": false, "type": "custom" }, { "current": { "selected": false, "text": "ideal", "value": "ideal" }, "datasource": "TeslaMate", "definition": "select preferred_range from settings limit 1;", "hide": 2, "includeAll": false, "multi": false, "name": "preferred_range", "options": [], "query": "select preferred_range from settings limit 1;", "refresh": 1, "regex": "", "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", "tagsQuery": "", "type": "query", "useTags": false }, { "current": { "selected": false, "text": "http://localhost:4000", "value": "http://localhost:4000" }, "datasource": "TeslaMate", "definition": "select base_url from settings limit 1;", "hide": 2, "includeAll": false, "multi": false, "name": "base_url", "options": [], "query": "select base_url from settings limit 1;", "refresh": 1, "regex": "", "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", "tagsQuery": "", "type": "query", "useTags": false } ] }, "time": { "from": "now-10y", "to": "now" }, "timepicker": { "refresh_intervals": [ "5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d" ] }, "timezone": "browser", "title": "Statistics", "uid": "1EZnXszMl", "version": 2, "weekStart": "" }