Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projected Range fix (using usable_battery_level) #3859

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 61 additions & 13 deletions grafana/dashboards/projected-range.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"id": null,
"links": [
{
"icon": "dashboard",
Expand Down Expand Up @@ -157,7 +156,6 @@
"y": 1
},
"id": 2,
"links": [],
"options": {
"legend": {
"calcs": [
Expand Down Expand Up @@ -326,7 +324,6 @@
"y": 22
},
"id": 6,
"links": [],
"options": {
"legend": {
"calcs": [
Expand All @@ -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": [
[
Expand All @@ -365,6 +363,23 @@
}
]
],
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"timeColumn": "time",
"where": [
{
Expand Down Expand Up @@ -524,7 +539,6 @@
"y": 43
},
"id": 5,
"links": [],
"options": {
"legend": {
"calcs": [
Expand All @@ -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": [
[
Expand All @@ -563,6 +578,23 @@
}
]
],
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"timeColumn": "time",
"where": [
{
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -795,6 +843,6 @@
"timezone": "",
"title": "Projected Range",
"uid": "riqUfXgRz",
"version": 1,
"version": 2,
"weekStart": ""
}
}
Loading