Skip to content
Open
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
112 changes: 110 additions & 2 deletions grafana/dashboards/internal/drive-details.json
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,7 @@
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT\n\tconvert_km(avg(speed)::numeric, '$length_unit') AS speed_${length_unit}h\nFROM positions\nWHERE car_id = $car_id AND $__timeFilter(date)",
"rawSql": "SELECT convert_km((distance / NULLIF(EXTRACT(EPOCH FROM end_date - start_date), 0) * 3600)::numeric, '$length_unit') AS speed_${length_unit}h\nFROM drives\nWHERE id = $drive_id",
"refId": "A",
"sql": {
"columns": [
Expand All @@ -2405,6 +2405,114 @@
],
"title": "Ø Speed",
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "super-light-blue",
"mode": "fixed"
},
"decimals": 0,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byRegexp",
"options": "/.*_mih/"
},
"properties": [
{
"id": "unit",
"value": "velocitymph"
}
]
},
{
"matcher": {
"id": "byRegexp",
"options": "/.*_kmh/"
},
"properties": [
{
"id": "unit",
"value": "velocitykmh"
}
]
}
]
},
"gridPos": {
"h": 3,
"w": 3,
"x": 9,
"y": 34
},
"id": 41,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"percentChangeColorMode": "standard",
"reduceOptions": {
"calcs": [
"mean"
],
"fields": "",
"values": true
},
"showPercentChange": false,
"textMode": "value",
"wideLayout": false
},
"pluginVersion": "13.0.1+security-01",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "WITH pts AS (\n\tSELECT speed, EXTRACT(EPOCH FROM (LEAD(date) OVER (ORDER BY date) - date)) AS dt\n\tFROM positions\n\tWHERE drive_id = $drive_id AND speed > 0\n)\n-- Time-weighted average while moving: speed > 0 excludes standstill so parked\n-- time doesn't pull the average down. Cap gaps at 60s to avoid stream dropouts.\nSELECT\n\tconvert_km((SUM(speed * dt) / NULLIF(SUM(dt), 0))::numeric, '$length_unit') AS speed_${length_unit}h\nFROM pts\nWHERE dt BETWEEN 0 AND 60",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "Ø Moving Speed",
"type": "stat"
}
],
"preload": false,
Expand Down Expand Up @@ -2579,4 +2687,4 @@
"uid": "zm7wN6Zgz",
"version": 1,
"weekStart": ""
}
}
Loading