Skip to content

Commit

Permalink
try to calculate charge rate for cars that are not able to display it
Browse files Browse the repository at this point in the history
  • Loading branch information
tillsteinbach committed Sep 16, 2021
1 parent 29f9d56 commit 473ab8d
Showing 1 changed file with 3 additions and 55 deletions.
58 changes: 3 additions & 55 deletions grafana/dashboards/vwsfriend/VWsFriend/overview.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"editable": true,
"gnetId": null,
"graphTooltip": 1,
"iteration": 1631790306211,
"iteration": 1631796965176,
"links": [
{
"asDropdown": true,
Expand Down Expand Up @@ -1743,7 +1743,7 @@
"targets": [
{
"alias": "Charge Power",
"format": "time_series",
"format": "table",
"group": [],
"groupBy": [
{
Expand All @@ -1766,7 +1766,7 @@
"query": "",
"queryType": "randomWalk",
"rawQuery": true,
"rawSql": "SELECT\n \"carCapturedTimestamp\" AS \"time\",\n \"chargePower_kW\" AS \"Charge Power\"\nFROM charges\nWHERE\n $__timeFilter(\"carCapturedTimestamp\") AND\n vehicle_vin = '$VIN'\nORDER BY 1 ",
"rawSql": "(SELECT\r\n \"carCapturedTimestamp\" AS \"time\",\r\n \"chargePower_kW\" AS \"Charge Power\",\r\n \"chargeRate_kmph\" AS \"Charge Rate\"\r\nFROM charges\r\nWHERE\r\n $__timeFilter(\"carCapturedTimestamp\") AND\r\n vehicle_vin = '$VIN'\r\nORDER BY \"carCapturedTimestamp\")\r\nUNION ALL\r\n(SELECT\r\n \"carCapturedTimestamp\" AS \"time\",\r\n CASE WHEN \"chargingState\" = 'CHARGING' THEN \"delta\"::decimal*( CASE WHEN vehicles.\"carType\" = 'ELECTRIC' THEN vehicle_settings.\"primary_capacity\"::NUMERIC\r\n ELSE vehicle_settings.\"secondary_capacity\"::NUMERIC END::decimal/100::decimal) / (EXTRACT(epoch FROM \"timedelta\") / 3600)\r\n ELSE NULL END AS \"Charge Power\",\r\n CASE WHEN \"chargingState\" = 'CHARGING' THEN \"deltakm\"::decimal / (EXTRACT(epoch FROM \"timedelta\") / 3600)\r\n ELSE NULL END AS \"Charge Rate\"\r\nFROM\r\n (SELECT *,\r\n DATE_TRUNC('minute', \"carCapturedTimestamp\") AS \"batteryTime\",\r\n (\"carCapturedTimestamp\" - LAG(\"carCapturedTimestamp\") OVER (ORDER BY \"carCapturedTimestamp\")) AS \"timedelta\",\r\n (\"currentSOC_pct\" - LAG(\"currentSOC_pct\") OVER (ORDER BY \"carCapturedTimestamp\")) AS \"delta\",\r\n (\"cruisingRangeElectric_km\" - LAG(\"cruisingRangeElectric_km\") OVER (ORDER BY \"carCapturedTimestamp\")) AS \"deltakm\"\r\nFROM\r\n battery\r\nWHERE\r\n $__timeFilter(\"carCapturedTimestamp\") AND\r\n vehicle_vin = '$VIN'\r\nORDER BY \"carCapturedTimestamp\") AS delta\r\nLEFT JOIN\r\n(\r\nSELECT\r\n\"chargingState\",\r\nDATE_TRUNC('minute', charges.\"carCapturedTimestamp\") AS \"chargeTime\"\r\nFROM charges\r\nWHERE\r\n $__timeFilter(\"carCapturedTimestamp\") AND\r\n vehicle_vin = '$VIN') as charging ON \"chargeTime\" = \"batteryTime\"\r\nLEFT JOIN vehicles ON delta.vehicle_vin = vehicles.vin\r\nLEFT JOIN vehicle_settings ON delta.vehicle_vin = vehicle_settings.vehicle_vin\r\nWHERE\r\n \"delta\" > 0 AND\r\n NOT EXISTS (SELECT 1 FROM charges WHERE \"chargePower_kW\" IS NOT NULL AND \"chargeRate_kmph\" IS NOT NULL AND $__timeFilter(\"carCapturedTimestamp\") AND vehicle_vin = '$VIN' LIMIT 1)\r\nORDER BY \"carCapturedTimestamp\")",
"refId": "A",
"resultFormat": "time_series",
"select": [
Expand All @@ -1792,58 +1792,6 @@
"type": "macro"
}
]
},
{
"alias": "Charge Rate",
"format": "time_series",
"group": [],
"groupBy": [
{
"params": [
"$__interval"
],
"type": "time"
},
{
"params": [
"previous"
],
"type": "fill"
}
],
"hide": false,
"measurement": "",
"metricColumn": "none",
"orderByTime": "ASC",
"policy": "default",
"query": "",
"rawQuery": true,
"rawSql": "SELECT\n \"carCapturedTimestamp\" AS \"time\",\n \"chargeRate_kmph\" AS \"Charge Rate\"\nFROM charges\nWHERE\n $__timeFilter(\"carCapturedTimestamp\") AND\n vehicle_vin = '$VIN'\nORDER BY 1 ",
"refId": "B",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"value"
],
"type": "field"
},
{
"params": [],
"type": "mean"
}
]
],
"tags": [],
"timeColumn": "time",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"thresholds": [],
Expand Down

0 comments on commit 473ab8d

Please sign in to comment.