Files
mg4/k8s/grafana/dashboards/consumption.json
T
nilsandClaude Opus 5.5 f3de272c69 Grafana: map zooms to the route; plain hyphens in titles
- "Where the car was" fits the route again: in Grafana's fit view the
  zoom value is the maximum zoom, and 6 held it at country level. Now
  15 with 10 % padding. Checked by rendering the Live dashboard with a
  simulated 10 km drive.
- Dashboard titles use "-" instead of an em dash: "MG4 - Live",
  "MG4 - Consumption", "MG4 - Charging".
- SPECS.md: Grafana keeps its state in SQLite on its PVC, which is why
  it runs as one replica with Recreate; high availability needs
  PostgreSQL or MySQL first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
2026-10-17 21:59:17 +02:00

416 lines
11 KiB
JSON

{
"uid": "mg4-consumption",
"title": "MG4 - Consumption",
"description": "Daily consumption, summed from the chunks the car sends while driving.",
"tags": [
"mg4"
],
"timezone": "browser",
"editable": false,
"graphTooltip": 1,
"schemaVersion": 39,
"version": 1,
"time": {
"from": "now-30d",
"to": "now"
},
"refresh": "",
"templating": {
"list": [
{
"name": "installationId",
"label": "Car",
"type": "query",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"query": "import \"influxdata/influxdb/schema\"\nschema.tagValues(bucket: \"mg4\", tag: \"installationId\", start: -400d)",
"definition": "installationId tag values",
"refresh": 1,
"includeAll": false,
"multi": false,
"current": {},
"hide": 0,
"sort": 1
}
]
},
"annotations": {
"list": []
},
"panels": [
{
"id": 1,
"type": "stat",
"title": "Distance",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 5,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"query": "from(bucket: \"mg4\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"consumption_chunk\" and r.installationId == \"${installationId}\" and r._field == \"km\")\n |> group()\n |> sum()"
}
],
"fieldConfig": {
"defaults": {
"unit": "suffix: km",
"color": {
"mode": "fixed",
"fixedColor": "#E0424C"
},
"decimals": 1
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "none",
"textMode": "value"
}
},
{
"id": 2,
"type": "stat",
"title": "Energy used",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"gridPos": {
"x": 5,
"y": 0,
"w": 5,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"query": "from(bucket: \"mg4\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"consumption_chunk\" and r.installationId == \"${installationId}\" and r._field == \"kwh\")\n |> group()\n |> sum()"
}
],
"fieldConfig": {
"defaults": {
"unit": "kwatth",
"color": {
"mode": "fixed",
"fixedColor": "#E0424C"
},
"decimals": 2
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "none",
"textMode": "value"
}
},
{
"id": 3,
"type": "stat",
"title": "Average",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"gridPos": {
"x": 10,
"y": 0,
"w": 5,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"query": "from(bucket: \"mg4\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"consumption_chunk\" and r.installationId == \"${installationId}\" and (r._field == \"km\" or r._field == \"kwh\"))\n |> group(columns: [\"_field\"])\n |> sum()\n |> group()\n |> pivot(rowKey: [], columnKey: [\"_field\"], valueColumn: \"_value\")\n |> map(fn: (r) => ({efficiency: if r.km >= 1.0 then r.kwh * 100.0 / r.km else 0.0}))"
}
],
"fieldConfig": {
"defaults": {
"unit": "suffix: kWh/100 km",
"color": {
"mode": "fixed",
"fixedColor": "#E0424C"
},
"decimals": 1
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "none",
"textMode": "value"
},
"description": "kWh/100 km over the selected range."
},
{
"id": 4,
"type": "stat",
"title": "Lifetime distance",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"gridPos": {
"x": 15,
"y": 0,
"w": 5,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"query": "from(bucket: \"mg4\")\n |> range(start: 0)\n |> filter(fn: (r) => r._measurement == \"consumption_chunk\" and r.installationId == \"${installationId}\" and r._field == \"km\")\n |> group()\n |> sum()"
}
],
"fieldConfig": {
"defaults": {
"unit": "suffix: km",
"color": {
"mode": "fixed",
"fixedColor": "#E0424C"
},
"decimals": 0
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "none",
"textMode": "value"
}
},
{
"id": 5,
"type": "stat",
"title": "Battery health (SoH)",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"gridPos": {
"x": 20,
"y": 0,
"w": 4,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"query": "from(bucket: \"mg4\")\n |> range(start: 0)\n |> filter(fn: (r) => r._measurement == \"consumption_chunk\" and r.installationId == \"${installationId}\" and r._field == \"sohPercent\")\n |> group()\n |> last()\n |> keep(columns: [\"_value\"])"
}
],
"fieldConfig": {
"defaults": {
"unit": "percent",
"color": {
"mode": "fixed",
"fixedColor": "#E0424C"
},
"decimals": 1
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "none",
"textMode": "value"
},
"description": "The manual SoH entered in the car's Consumption tab."
},
{
"id": 6,
"type": "barchart",
"title": "Energy per day",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"gridPos": {
"x": 0,
"y": 4,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"query": "from(bucket: \"mg4\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"consumption_chunk\" and r.installationId == \"${installationId}\" and r._field == \"kwh\")\n |> group(columns: [\"date\"])\n |> sum()\n |> group()\n |> map(fn: (r) => ({date: r.date, kwh: r._value}))\n |> sort(columns: [\"date\"])"
}
],
"fieldConfig": {
"defaults": {
"unit": "kwatth",
"color": {
"mode": "fixed",
"fixedColor": "#E0424C"
}
},
"overrides": []
},
"options": {
"xField": "date",
"showValue": "never",
"legend": {
"showLegend": false
},
"xTickLabelRotation": -45
}
},
{
"id": 7,
"type": "barchart",
"title": "Distance per day",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"gridPos": {
"x": 12,
"y": 4,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"query": "from(bucket: \"mg4\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"consumption_chunk\" and r.installationId == \"${installationId}\" and r._field == \"km\")\n |> group(columns: [\"date\"])\n |> sum()\n |> group()\n |> map(fn: (r) => ({date: r.date, km: r._value}))\n |> sort(columns: [\"date\"])"
}
],
"fieldConfig": {
"defaults": {
"unit": "suffix: km",
"color": {
"mode": "fixed",
"fixedColor": "#E0424C"
}
},
"overrides": []
},
"options": {
"xField": "date",
"showValue": "never",
"legend": {
"showLegend": false
},
"xTickLabelRotation": -45
}
},
{
"id": 8,
"type": "barchart",
"title": "Efficiency per day (kWh/100 km)",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"gridPos": {
"x": 0,
"y": 13,
"w": 24,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "influxdb",
"uid": "mg4-influxdb"
},
"query": "from(bucket: \"mg4\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r._measurement == \"consumption_chunk\" and r.installationId == \"${installationId}\" and (r._field == \"km\" or r._field == \"kwh\"))\n |> group(columns: [\"date\", \"_field\"])\n |> sum()\n |> group()\n |> pivot(rowKey: [\"date\"], columnKey: [\"_field\"], valueColumn: \"_value\")\n |> filter(fn: (r) => r.km >= 1.0)\n |> map(fn: (r) => ({date: r.date, efficiency: r.kwh * 100.0 / r.km}))\n |> sort(columns: [\"date\"])"
}
],
"fieldConfig": {
"defaults": {
"unit": "suffix: kWh/100 km",
"color": {
"mode": "fixed",
"fixedColor": "#E0424C"
}
},
"overrides": []
},
"options": {
"xField": "date",
"showValue": "never",
"legend": {
"showLegend": false
},
"xTickLabelRotation": -45
}
}
]
}