{ "annotations": { "list": [ { "builtIn": 1, "datasource": "-- Grafana --", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "editable": true, "gnetId": null, "graphTooltip": 0, "iteration": 1598013087999, "links": [ { "icon": "dashboard", "tags": [], "title": "TeslaMate", "tooltip": "", "type": "link", "url": "[[base_url:raw]]" }, { "asDropdown": true, "icon": "external link", "tags": [ "tesla" ], "title": "Dashboards", "type": "dashboards" } ], "panels": [ { "collapsed": false, "datasource": "TeslaMate", "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "id": 10, "panels": [], "repeat": "car_id", "scopedVars": { "car_id": { "selected": true, "text": "1", "value": "1" } }, "title": "$car_id", "type": "row" }, { "cacheTimeout": null, "datasource": "TeslaMate", "fieldConfig": { "defaults": { "custom": {}, "decimals": 0, "mappings": [], "nullValueMode": "connected", "thresholds": { "mode": "absolute", "steps": [ { "color": "#c7d0d9", "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": 8, "x": 0, "y": 1 }, "id": 4, "interval": null, "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "reduceOptions": { "calcs": [ "mean" ], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "7.2.1", "scopedVars": { "car_id": { "selected": true, "text": "1", "value": "1" } }, "targets": [ { "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "select \n sum((start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km) * cars.efficiency) / sum(distance) * 1000 * \n CASE WHEN '$length_unit' = 'km' THEN 1\n WHEN '$length_unit' = 'mi' THEN 1.60934\n END 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" } ] ], "table": "addresses", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "timeFrom": null, "timeShift": null, "title": "Consumption (net)", "type": "stat" }, { "cacheTimeout": null, "datasource": "TeslaMate", "fieldConfig": { "defaults": { "custom": {}, "decimals": 0, "mappings": [], "nullValueMode": "connected", "thresholds": { "mode": "absolute", "steps": [ { "color": "#c7d0d9", "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": 8, "x": 8, "y": 1 }, "id": 8, "interval": null, "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "reduceOptions": { "calcs": [ "mean" ], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "7.2.1", "scopedVars": { "car_id": { "selected": true, "text": "1", "value": "1" } }, "targets": [ { "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 / distance * 1000 *\n CASE WHEN '$length_unit' = 'km' THEN 1\n WHEN '$length_unit' = 'mi' THEN 1.60934\n END AS \"consumption_$length_unit\"\nFROM\n\td2\n\tLEFT JOIN cars c ON c.id = car_id", "refId": "A", "select": [ [ { "params": [ "latitude" ], "type": "column" } ] ], "table": "addresses", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "timeFrom": null, "timeShift": null, "title": "Consumption (gross) ", "type": "stat" }, { "cacheTimeout": null, "datasource": "TeslaMate", "fieldConfig": { "defaults": { "custom": {}, "decimals": 0, "mappings": [], "nullValueMode": "connected", "thresholds": { "mode": "absolute", "steps": [ { "color": "#c7d0d9", "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": 8, "x": 16, "y": 1 }, "id": 6, "interval": null, "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "reduceOptions": { "calcs": [ "mean" ], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "7.2.1", "scopedVars": { "car_id": { "selected": true, "text": "1", "value": "1" } }, "targets": [ { "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "select convert_km(sum(distance)::numeric, '$length_unit') as \"distance_$length_unit\" \nfrom drives \nwhere car_id = $car_id;", "refId": "A", "select": [ [ { "params": [ "latitude" ], "type": "column" } ] ], "table": "addresses", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "timeFrom": null, "timeShift": null, "title": "Logged Distance", "type": "stat" }, { "datasource": "TeslaMate", "fieldConfig": { "defaults": { "custom": { "align": null, "filterable": false }, "mappings": [], "max": 100, "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "outside_temp_c" }, "properties": [ { "id": "displayName", "value": "Temperature" }, { "id": "unit", "value": "celsius" }, { "id": "custom.width", "value": 125 } ] }, { "matcher": { "id": "byName", "options": "outside_temp_f" }, "properties": [ { "id": "displayName", "value": "Temperature" }, { "id": "unit", "value": "fahrenheit" }, { "id": "custom.width", "value": 125 } ] }, { "matcher": { "id": "byName", "options": "efficiency" }, "properties": [ { "id": "displayName", "value": "Efficiency" }, { "id": "unit", "value": "percentunit" }, { "id": "decimals", "value": 1 }, { "id": "custom.displayMode", "value": "lcd-gauge" }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { "color": "super-light-orange", "value": null }, { "color": "light-orange", "value": 0.65 }, { "color": "light-green", "value": 0.99 } ] } }, { "id": "max", "value": 1.15 } ] }, { "matcher": { "id": "byName", "options": "consumption_km" }, "properties": [ { "id": "displayName", "value": "Consumption" }, { "id": "unit", "value": "Wh/km" }, { "id": "custom.width", "value": 200 } ] }, { "matcher": { "id": "byName", "options": "consumption_mi" }, "properties": [ { "id": "displayName", "value": "Consumption" }, { "id": "unit", "value": "Wh/mi" }, { "id": "custom.width", "value": 200 } ] }, { "matcher": { "id": "byName", "options": "total_distance_km" }, "properties": [ { "id": "displayName", "value": "$length_unit" }, { "id": "unit", "value": "km" }, { "id": "custom.width", "value": 200 } ] }, { "matcher": { "id": "byName", "options": "total_distance_mi" }, "properties": [ { "id": "displayName", "value": "$length_unit" }, { "id": "unit", "value": "mi" }, { "id": "custom.width", "value": 200 } ] }, { "matcher": { "id": "byName", "options": "avg_speed_km" }, "properties": [ { "id": "displayName", "value": "Speed" }, { "id": "unit", "value": "velocitykmh" }, { "id": "custom.width", "value": 200 } ] }, { "matcher": { "id": "byName", "options": "avg_speed_mi" }, "properties": [ { "id": "displayName", "value": "Speed" }, { "id": "unit", "value": "velocitymph" }, { "id": "custom.width", "value": 200 } ] } ] }, "gridPos": { "h": 12, "w": 24, "x": 0, "y": 4 }, "id": 2, "links": [], "options": { "showHeader": true, "sortBy": [ { "desc": true, "displayName": "Temperature" } ] }, "pluginVersion": "7.2.1", "scopedVars": { "car_id": { "selected": true, "text": "1", "value": "1" } }, "targets": [ { "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "WITH t AS (\n\tSELECT\n\t CASE WHEN '$temp_unit' = 'C' THEN ROUND(cast(outside_temp_avg AS numeric) / 5, 0) * 5 \n\t\t\t WHEN '$temp_unit' = 'F' THEN ROUND(cast(convert_celsius(outside_temp_avg, '$temp_unit') AS numeric) / 10, 0) * 10\n\t\tEND AS outside_temp,\n\t\tsum(start_ideal_range_km - end_ideal_range_km) AS total_ideal_range,\n\t\tsum(start_rated_range_km - end_rated_range_km) AS total_rated_range,\n\t\tsum(distance) AS total_distance,\n\t\tsum(duration_min) as duration,\n\t\tcar_id\n\tFROM\n\t\tdrives\n\tWHERE\n\t\tdistance IS NOT NULL\n\t\tAND car_id = $car_id\n\t\tAND convert_km(distance::numeric, '$length_unit') >= $min_distance \n\t\tAND start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km > 0.1\n\tGROUP BY\n\t\t1,\n\t\tcar_id\n)\n\nSELECT\n\toutside_temp as outside_temp_$temp_unit,\n total_distance / total_[[preferred_range]]_range AS efficiency,\n\ttotal_[[preferred_range]]_range / total_distance * c.efficiency * 1000 * \n CASE \n WHEN '$length_unit' = 'km' THEN 1 \n WHEN '$length_unit' = 'mi' THEN 1.60934 \n END AS consumption_$length_unit,\n convert_km(total_distance::numeric, '$length_unit') as total_distance_$length_unit,\n\t(total_distance / duration) * 60 / (CASE \n WHEN '$length_unit' = 'km' THEN 1 \n WHEN '$length_unit' = 'mi' THEN 1.60934 \n END) avg_speed_$length_unit\nFROM\n\tt\nJOIN cars c ON t.car_id = c.id\nWHERE outside_temp IS NOT NULL\norder by 1 desc\n", "refId": "A", "select": [ [ { "params": [ "latitude" ], "type": "column" } ] ], "table": "addresses", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "timeFrom": null, "timeShift": null, "title": "Temperature – Efficiency", "type": "table" }, { "cacheTimeout": null, "datasource": "TeslaMate", "fieldConfig": { "defaults": { "custom": {}, "decimals": 0, "mappings": [], "nullValueMode": "connected", "thresholds": { "mode": "absolute", "steps": [ { "color": "#c7d0d9", "value": null } ] }, "unit": "short" }, "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": 5, "w": 2, "x": 0, "y": 16 }, "id": 14, "interval": null, "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", "fieldOptions": { "calcs": [ "mean" ] }, "graphMode": "none", "justifyMode": "auto", "orientation": "horizontal", "reduceOptions": { "calcs": [ "mean" ], "fields": "", "values": false }, "textMode": "value" }, "pluginVersion": "7.2.1", "scopedVars": { "car_id": { "selected": true, "text": "1", "value": "1" } }, "targets": [ { "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n\tCASE WHEN '$length_unit' = 'km' THEN efficiency\n\t WHEN '$length_unit' = 'mi' THEN efficiency * 1.60934\n\tEND * 1000 as \"efficiency_$length_unit\"\nFROM\n\tcars\nWHERE\n\tid = $car_id;", "refId": "A", "select": [ [ { "params": [ "charge_energy_added" ], "type": "column" } ] ], "table": "charges", "timeColumn": "date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "timeFrom": null, "timeShift": null, "title": "Current $preferred_range efficiency", "type": "stat" }, { "datasource": "TeslaMate", "fieldConfig": { "defaults": { "custom": { "align": null, "filterable": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "efficiency_km" }, "properties": [ { "id": "displayName", "value": "Efficiency" }, { "id": "unit", "value": "Wh/km" } ] }, { "matcher": { "id": "byName", "options": "efficiency_mi" }, "properties": [ { "id": "displayName", "value": "Efficiency" }, { "id": "unit", "value": "Wh/mi" } ] } ] }, "gridPos": { "h": 5, "w": 11, "x": 2, "y": 16 }, "id": 12, "options": { "showHeader": true }, "pluginVersion": "7.2.1", "scopedVars": { "car_id": { "selected": true, "text": "1", "value": "1" } }, "targets": [ { "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n round((charge_energy_added / NULLIF(end_ideal_range_km - start_ideal_range_km, 0))::numeric *\n\t CASE WHEN '$length_unit' = 'km' THEN 1.0\n\t WHEN '$length_unit' = 'mi' THEN 1.60934\n\t END, 3) * 1000 as \"efficiency_$length_unit\",\n count(*) as count\nFROM\n charging_processes\nWHERE \n car_id = $car_id\n AND duration_min > 10\n AND end_battery_level <= 95\n AND start_ideal_range_km IS NOT NULL\n AND end_ideal_range_km IS NOT NULL\n AND charge_energy_added > 0\nGROUP BY\n 1\nORDER BY\n 2 DESC\nLIMIT 3", "refId": "A", "select": [ [ { "params": [ "charge_energy_added" ], "type": "column" } ] ], "table": "charges", "timeColumn": "date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "timeFrom": null, "timeShift": null, "title": "Derived ideal efficiencies", "type": "table" }, { "datasource": "TeslaMate", "fieldConfig": { "defaults": { "custom": { "align": null, "filterable": false }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "efficiency_km" }, "properties": [ { "id": "unit", "value": "Wh/km" }, { "id": "displayName", "value": "Efficiency" } ] }, { "matcher": { "id": "byName", "options": "efficiency_mi" }, "properties": [ { "id": "displayName", "value": "Efficiency" }, { "id": "unit", "value": "Wh/mi" } ] } ] }, "gridPos": { "h": 5, "w": 11, "x": 13, "y": 16 }, "id": 15, "options": { "showHeader": true }, "pluginVersion": "7.2.1", "scopedVars": { "car_id": { "selected": true, "text": "1", "value": "1" } }, "targets": [ { "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, "rawSql": "SELECT\n round((charge_energy_added / NULLIF(end_rated_range_km - start_rated_range_km, 0))::numeric *\n\t CASE WHEN '$length_unit' = 'km' THEN 1.0\n\t WHEN '$length_unit' = 'mi' THEN 1.60934\n\t END, 3) * 1000 as \"efficiency_$length_unit\",\n\tcount(*) as count\nFROM\n charging_processes\nWHERE \n car_id = $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\nGROUP BY\n 1\nORDER BY\n 2 DESC\nLIMIT 3", "refId": "A", "select": [ [ { "params": [ "charge_energy_added" ], "type": "column" } ] ], "table": "charges", "timeColumn": "date", "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } ] } ], "timeFrom": null, "timeShift": null, "title": "Derived rated efficiencies", "type": "table" } ], "schemaVersion": 26, "style": "dark", "tags": [ "tesla" ], "templating": { "list": [ { "allValue": null, "current": { "selected": false, "text": "1", "value": "1" }, "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": "", "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": "", "multi": false, "name": "temp_unit", "options": [], "query": "select unit_of_temperature from settings limit 1;", "refresh": 1, "regex": "", "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", "tags": [], "tagsQuery": "", "type": "query", "useTags": false }, { "allValue": null, "current": { "selected": false, "text": "km", "value": "km" }, "datasource": "TeslaMate", "definition": "select unit_of_length from settings limit 1;", "hide": 2, "includeAll": false, "label": "", "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": "ideal", "value": "ideal" }, "datasource": "TeslaMate", "definition": "select preferred_range from settings limit 1;", "hide": 2, "includeAll": false, "label": null, "multi": false, "name": "preferred_range", "options": [], "query": "select preferred_range from settings limit 1;", "refresh": 1, "regex": "", "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", "tags": [], "tagsQuery": "", "type": "query", "useTags": false }, { "allValue": null, "current": { "selected": true, "text": "1", "value": "1" }, "hide": 0, "includeAll": false, "label": "min. distance per drive", "multi": false, "name": "min_distance", "options": [ { "selected": true, "text": "1", "value": "1" }, { "selected": false, "text": "5", "value": "5" }, { "selected": false, "text": "10", "value": "10" }, { "selected": false, "text": "25", "value": "25" }, { "selected": false, "text": "50", "value": "50" } ], "query": "1, 5, 10, 25, 50", "queryValue": "", "skipUrlSync": false, "type": "custom" }, { "allValue": null, "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, "label": "", "multi": false, "name": "base_url", "options": [], "query": "select base_url from settings limit 1;", "refresh": 1, "regex": "", "skipUrlSync": false, "sort": 0, "tagValuesQuery": "", "tags": [], "tagsQuery": "", "type": "query", "useTags": false } ] }, "time": { "from": "now-6h", "to": "now" }, "timepicker": { "hidden": true, "refresh_intervals": [ "5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d" ], "time_options": [ "5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d" ] }, "timezone": "", "title": "Efficiency", "uid": "fu4SiQgWz", "version": 1 }