diff --git a/grafana/dashboards/projected-range.json b/grafana/dashboards/projected-range.json index 31f7912ac1..4414645bbf 100644 --- a/grafana/dashboards/projected-range.json +++ b/grafana/dashboards/projected-range.json @@ -27,7 +27,6 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, - "id": null, "links": [ { "icon": "dashboard", @@ -157,7 +156,6 @@ "y": 1 }, "id": 2, - "links": [], "options": { "legend": { "calcs": [ @@ -326,7 +324,6 @@ "y": 22 }, "id": 6, - "links": [], "options": { "legend": { "calcs": [ @@ -348,12 +345,13 @@ { "alias": "", "datasource": "TeslaMate", + "editorMode": "code", "format": "time_series", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\t$__timeGroup(date,[[interval]]) AS time,\n\tconvert_km(sum([[preferred_range]]_battery_range_km) / sum(coalesce(usable_battery_level,battery_level)) * 100, '$length_unit') AS \"Projected Range (using usable_battery_level) [$length_unit]\",\n\tconvert_km(sum([[preferred_range]]_battery_range_km) / sum(battery_level) * 100, '$length_unit') AS \"Projected Range (using battery_level)[$length_unit]\"\nFROM\n\t(\n select battery_level, usable_battery_level, date,\n rated_battery_range_km, ideal_battery_range_km, outside_temp\n from positions\n where\n car_id = $car_id and $__timeFilter(date) and ideal_battery_range_km is not null\n union all\n select battery_level, coalesce(usable_battery_level,battery_level) as usable_battery_level, date,\n rated_battery_range_km, ideal_battery_range_km, outside_temp\n from charges c\n join\n charging_processes p ON p.id = c.charging_process_id \n where\n $__timeFilter(date) and p.car_id = $car_id\n ) as data\n\nGROUP BY\n\t1\nORDER BY\n\t1,2 DESC", + "rawSql": "SELECT\n\t$__timeGroup(date,[[interval]]) AS time,\n\tconvert_km((sum([[preferred_range]]_battery_range_km) / sum(battery_level) * 100 ) - (sum([[preferred_range]]_battery_range_km) / sum(battery_level) * 100 * (avg(battery_level)-avg(coalesce(usable_battery_level,battery_level)))/100 ), '$length_unit') AS \"Projected Range (using usable_battery_level) [$length_unit]\",\n\tconvert_km(max([[preferred_range]]_battery_range_km) / max(battery_level) * 100, '$length_unit') AS \"Projected Range (using battery_level)[$length_unit]\"\nFROM\n\t(\n select battery_level, usable_battery_level, date,\n rated_battery_range_km, ideal_battery_range_km, outside_temp\n from positions\n where\n car_id = $car_id and $__timeFilter(date) and ideal_battery_range_km is not null\n union all\n select battery_level, coalesce(usable_battery_level,battery_level) as usable_battery_level, date,\n rated_battery_range_km, ideal_battery_range_km, outside_temp\n from charges c\n join\n charging_processes p ON p.id = c.charging_process_id \n where\n $__timeFilter(date) and p.car_id = $car_id\n ) as data\n\nGROUP BY\n\t1\nORDER BY\n\t1,2 DESC", "refId": "A", "select": [ [ @@ -365,6 +363,23 @@ } ] ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, "timeColumn": "time", "where": [ { @@ -524,7 +539,6 @@ "y": 43 }, "id": 5, - "links": [], "options": { "legend": { "calcs": [ @@ -546,12 +560,13 @@ { "alias": "", "datasource": "TeslaMate", + "editorMode": "code", "format": "time_series", "group": [], "hide": false, "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\t$__timeGroup(date,[[interval]]) AS time,\n\tconvert_km(sum([[preferred_range]]_battery_range_km) / sum(coalesce(usable_battery_level,battery_level)) * 100, '$length_unit') AS \"Projected Range (using usable_battery_level) [$length_unit]\",\n\tconvert_km(sum([[preferred_range]]_battery_range_km) / sum(battery_level) * 100, '$length_unit') AS \"Projected Range (using battery_level) [$length_unit]\"\nFROM\n\t(\n select battery_level, usable_battery_level, date,\n rated_battery_range_km, ideal_battery_range_km, outside_temp\n from positions\n where\n car_id = $car_id and $__timeFilter(date) and ideal_battery_range_km is not null\n union all\n select battery_level, coalesce(usable_battery_level,battery_level) as usable_battery_level, date,\n rated_battery_range_km, ideal_battery_range_km, outside_temp\n from charges c\n join\n charging_processes p ON p.id = c.charging_process_id \n where\n $__timeFilter(date) and p.car_id = $car_id\n ) as data\n\nGROUP BY\n\t1\nORDER BY\n\t1,2 DESC", + "rawSql": "\nSELECT\n\t$__timeGroup(date,[[interval]]) AS time,\n\tconvert_km((sum([[preferred_range]]_battery_range_km) / sum(battery_level) * 100 ) - (sum([[preferred_range]]_battery_range_km) / sum(battery_level) * 100 * (avg(battery_level)-avg(coalesce(usable_battery_level,battery_level)))/100 ), '$length_unit') AS \"Projected Range (using usable_battery_level) [$length_unit]\",\n\tconvert_km(max([[preferred_range]]_battery_range_km) / max(battery_level) * 100, '$length_unit') AS \"Projected Range (using battery_level)[$length_unit]\"\nFROM\n\t(\n select battery_level, usable_battery_level, date,\n rated_battery_range_km, ideal_battery_range_km, outside_temp\n from positions\n where\n car_id = $car_id and $__timeFilter(date) and ideal_battery_range_km is not null\n union all\n select battery_level, coalesce(usable_battery_level,battery_level) as usable_battery_level, date,\n rated_battery_range_km, ideal_battery_range_km, outside_temp\n from charges c\n join\n charging_processes p ON p.id = c.charging_process_id \n where\n $__timeFilter(date) and p.car_id = $car_id\n ) as data\n\nGROUP BY\n\t1\nORDER BY\n\t1,2 DESC", "refId": "A", "select": [ [ @@ -563,6 +578,23 @@ } ] ], + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + }, "timeColumn": "time", "where": [ { @@ -607,14 +639,18 @@ } ], "refresh": "", - "schemaVersion": 36, + "schemaVersion": 39, "tags": [ "tesla" ], "templating": { "list": [ { - "current": {}, + "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, @@ -634,7 +670,11 @@ "useTags": false }, { - "current": {}, + "current": { + "selected": false, + "text": "mi", + "value": "mi" + }, "datasource": "TeslaMate", "definition": "select unit_of_length from settings limit 1;", "hide": 2, @@ -654,7 +694,11 @@ "useTags": false }, { - "current": {}, + "current": { + "selected": false, + "text": "rated", + "value": "rated" + }, "datasource": "TeslaMate", "definition": "select preferred_range from settings limit 1;", "hide": 2, @@ -673,7 +717,11 @@ "useTags": false }, { - "current": {}, + "current": { + "selected": false, + "text": "C", + "value": "C" + }, "datasource": "TeslaMate", "definition": "select unit_of_temperature from settings limit 1;", "hide": 2, @@ -795,6 +843,6 @@ "timezone": "", "title": "Projected Range", "uid": "riqUfXgRz", - "version": 1, + "version": 2, "weekStart": "" -} \ No newline at end of file +}