Files
archived-hipudding-teslamate/grafana/dashboards/vampire-drain.json
2025-02-22 09:13:42 +01:00

677 lines
20 KiB
JSON

{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [
{
"icon": "dashboard",
"tags": [],
"title": "TeslaMate",
"tooltip": "",
"type": "link",
"url": "${base_url:raw}"
},
{
"asDropdown": true,
"icon": "external link",
"tags": [
"tesla"
],
"title": "Dashboards",
"type": "dashboards"
}
],
"panels": [
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 4,
"panels": [],
"repeat": "car_id",
"title": "$car_id",
"type": "row"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": "auto",
"cellOptions": {
"type": "auto"
},
"inspect": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "start_date"
},
"properties": [
{
"id": "displayName",
"value": "Start"
},
{
"id": "unit",
"value": "dateTimeAsLocal"
},
{
"id": "links",
"value": [
{
"targetBlank": false,
"title": "",
"url": "/d/zm7wN6Zgz/drive-details?from=${__data.fields.start_date_ts.numeric}&to=${__data.fields.end_date_ts.numeric}"
}
]
},
{
"id": "custom.minWidth",
"value": 180
}
]
},
{
"matcher": {
"id": "byName",
"options": "end_date"
},
"properties": [
{
"id": "displayName",
"value": "End"
},
{
"id": "unit",
"value": "dateTimeAsLocal"
},
{
"id": "custom.minWidth",
"value": 180
}
]
},
{
"matcher": {
"id": "byName",
"options": "range_diff_km"
},
"properties": [
{
"id": "displayName",
"value": "Range loss"
},
{
"id": "unit",
"value": "lengthkm"
},
{
"id": "decimals",
"value": 2
},
{
"id": "custom.minWidth",
"value": 95
}
]
},
{
"matcher": {
"id": "byName",
"options": "duration"
},
"properties": [
{
"id": "displayName",
"value": "Period"
},
{
"id": "unit",
"value": "s"
},
{
"id": "decimals",
"value": 1
},
{
"id": "custom.cellOptions",
"value": {
"type": "color-text"
}
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "rgb(133, 142, 133)",
"value": null
},
{
"color": "#56A64B",
"value": 43200
}
]
}
},
{
"id": "custom.minWidth",
"value": 100
}
]
},
{
"matcher": {
"id": "byName",
"options": "range_lost_per_hour_km"
},
"properties": [
{
"id": "displayName",
"value": "Ø Range loss / h"
},
{
"id": "unit",
"value": "lengthkm"
},
{
"id": "decimals",
"value": 2
},
{
"id": "custom.minWidth",
"value": 135
}
]
},
{
"matcher": {
"id": "byRegexp",
"options": "/.*_ts/"
},
"properties": [
{
"id": "custom.hidden",
"value": true
}
]
},
{
"matcher": {
"id": "byName",
"options": "standby"
},
"properties": [
{
"id": "displayName",
"value": "Standby"
},
{
"id": "unit",
"value": "percentunit"
},
{
"id": "custom.cellOptions",
"value": {
"type": "color-text"
}
},
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "#FF7383",
"value": null
},
{
"color": "#FFB357",
"value": 0.3
},
{
"color": "#56A64B",
"value": 0.85
}
]
}
},
{
"id": "decimals",
"value": 0
},
{
"id": "custom.minWidth",
"value": 75
}
]
},
{
"matcher": {
"id": "byName",
"options": "consumption"
},
"properties": [
{
"id": "displayName",
"value": "Energy drained"
},
{
"id": "unit",
"value": "kwatth"
},
{
"id": "decimals",
"value": 2
},
{
"id": "custom.minWidth",
"value": 125
}
]
},
{
"matcher": {
"id": "byName",
"options": "avg_power"
},
"properties": [
{
"id": "displayName",
"value": "Ø Power"
},
{
"id": "unit",
"value": "watt"
},
{
"id": "decimals",
"value": 1
},
{
"id": "custom.minWidth",
"value": 80
}
]
},
{
"matcher": {
"id": "byName",
"options": "range_lost_per_hour_mi"
},
"properties": [
{
"id": "displayName",
"value": "Ø Range loss / h"
},
{
"id": "unit",
"value": "lengthmi"
},
{
"id": "decimals",
"value": 2
},
{
"id": "custom.minWidth",
"value": 135
}
]
},
{
"matcher": {
"id": "byName",
"options": "range_diff_mi"
},
"properties": [
{
"id": "displayName",
"value": "Range loss"
},
{
"id": "unit",
"value": "lengthmi"
},
{
"id": "decimals",
"value": 2
},
{
"id": "custom.minWidth",
"value": 95
}
]
},
{
"matcher": {
"id": "byName",
"options": "soc_diff"
},
"properties": [
{
"id": "displayName",
"value": "SoC Diff"
},
{
"id": "unit",
"value": "percent"
},
{
"id": "custom.minWidth",
"value": 80
}
]
},
{
"matcher": {
"id": "byName",
"options": "has_reduced_range"
},
"properties": [
{
"id": "displayName",
"value": " "
},
{
"id": "custom.align",
"value": "center"
},
{
"id": "mappings",
"value": [
{
"options": {
"0": {
"color": "transparent",
"index": 1,
"text": " "
},
"1": {
"color": "dark-blue",
"index": 0,
"text": "❄"
}
},
"type": "value"
}
]
},
{
"id": "links",
"value": [
{
"title": "In cold weather, the estimated range loss cannot be estimated correctly and is therefore hidden.",
"url": ""
}
]
},
{
"id": "custom.width",
"value": 50
}
]
}
]
},
"gridPos": {
"h": 23,
"w": 24,
"x": 0,
"y": 1
},
"id": 2,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true
},
"pluginVersion": "11.5.2",
"targets": [
{
"alias": "",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"editorMode": "code",
"format": "table",
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "with merge as (\n SELECT \n c.start_date AS start_date,\n c.end_date AS end_date,\n c.start_ideal_range_km AS start_ideal_range_km,\n c.end_ideal_range_km AS end_ideal_range_km,\n c.start_rated_range_km AS start_rated_range_km,\n c.end_rated_range_km AS end_rated_range_km,\n start_battery_level,\n end_battery_level,\n p.usable_battery_level AS start_usable_battery_level,\n NULL AS end_usable_battery_level,\n p.odometer AS start_km,\n p.odometer AS end_km\n FROM charging_processes c\n JOIN positions p ON c.position_id = p.id\n WHERE c.car_id = $car_id AND $__timeFilter(start_date)\n UNION\n SELECT \n d.start_date AS start_date,\n d.end_date AS end_date,\n d.start_ideal_range_km AS start_ideal_range_km,\n d.end_ideal_range_km AS end_ideal_range_km,\n d.start_rated_range_km AS start_rated_range_km,\n d.end_rated_range_km AS end_rated_range_km,\n start_position.battery_level AS start_battery_level,\n end_position.battery_level AS end_battery_level,\n start_position.usable_battery_level AS start_usable_battery_level,\n end_position.usable_battery_level AS end_usable_battery_level,\n d.start_km AS start_km,\n d.end_km AS end_km\n FROM drives d\n JOIN positions start_position ON d.start_position_id = start_position.id\n JOIN positions end_position ON d.end_position_id = end_position.id\n WHERE d.car_id = $car_id AND $__timeFilter(start_date)\n), \nv as (\n SELECT\n lag(t.end_date) OVER w AS start_date,\n t.start_date AS end_date,\n lag(t.end_${preferred_range}_range_km) OVER w AS start_range,\n t.start_${preferred_range}_range_km AS end_range,\n lag(t.end_km) OVER w AS start_km,\n t.start_km AS end_km,\n EXTRACT(EPOCH FROM age(t.start_date, lag(t.end_date) OVER w)) AS duration,\n lag(t.end_battery_level) OVER w AS start_battery_level,\n lag(t.end_usable_battery_level) OVER w AS start_usable_battery_level,\n\t\tstart_battery_level AS end_battery_level,\n\t\tstart_usable_battery_level AS end_usable_battery_level,\n\t\tstart_battery_level > COALESCE(start_usable_battery_level, start_battery_level) AS has_reduced_range\n FROM merge t\n WINDOW w AS (ORDER BY t.start_date ASC)\n ORDER BY start_date DESC\n)\n\nSELECT\n round(extract(epoch FROM v.start_date)) * 1000 AS start_date_ts,\n round(extract(epoch FROM v.end_date)) * 1000 AS end_date_ts,\n -- Columns\n v.start_date,\n v.end_date,\n v.duration,\n (coalesce(s_asleep.sleep, 0) + coalesce(s_offline.sleep, 0)) / v.duration as standby,\n\t-greatest(v.start_battery_level - v.end_battery_level, 0) as soc_diff,\n\tCASE WHEN has_reduced_range THEN 1 ELSE 0 END as has_reduced_range,\n\tconvert_km(CASE WHEN has_reduced_range THEN NULL ELSE (v.start_range - v.end_range)::numeric END, '$length_unit') AS range_diff_$length_unit,\n CASE WHEN has_reduced_range THEN NULL ELSE (v.start_range - v.end_range) * c.efficiency END AS consumption,\n CASE WHEN has_reduced_range THEN NULL ELSE ((v.start_range - v.end_range) * c.efficiency) / (v.duration / 3600) * 1000 END as avg_power,\n convert_km(CASE WHEN has_reduced_range THEN NULL ELSE ((v.start_range - v.end_range) / (v.duration / 3600))::numeric END, '$length_unit') AS range_lost_per_hour_${length_unit}\nFROM v,\n LATERAL (\n SELECT EXTRACT(EPOCH FROM sum(age(s.end_date, s.start_date))) as sleep\n FROM states s\n WHERE\n state = 'asleep' AND\n v.start_date <= s.start_date AND s.end_date <= v.end_date AND\n s.car_id = $car_id\n ) s_asleep,\n LATERAL (\n SELECT EXTRACT(EPOCH FROM sum(age(s.end_date, s.start_date))) as sleep\n FROM states s\n WHERE\n state = 'offline' AND\n v.start_date <= s.start_date AND s.end_date <= v.end_date AND\n s.car_id = $car_id\n ) s_offline\nJOIN cars c ON c.id = $car_id\nWHERE\n v.duration > ($duration * 60 * 60)\n AND v.start_range - v.end_range >= 0\n AND v.end_km - v.start_km < 1;",
"refId": "A",
"select": [
[
{
"params": [
"value"
],
"type": "column"
}
]
],
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"timeColumn": "time",
"where": [
{
"name": "$__timeFilter",
"params": [],
"type": "macro"
}
]
}
],
"title": "Vampire Drain",
"transformations": [
{
"id": "merge",
"options": {
"reducers": []
}
}
],
"type": "table"
}
],
"preload": false,
"refresh": "",
"schemaVersion": 40,
"tags": [
"tesla"
],
"templating": {
"list": [
{
"current": {},
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "SELECT\n id as __value,\n CASE WHEN COUNT(id) OVER (PARTITION BY name) > 1 AND name IS NOT NULL THEN CONCAT(name, ' - ', RIGHT(vin, 6)) ELSE COALESCE(name, CONCAT('VIN ', vin)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;",
"hide": 2,
"includeAll": true,
"label": "Car",
"name": "car_id",
"options": [],
"query": "SELECT\n id as __value,\n CASE WHEN COUNT(id) OVER (PARTITION BY name) > 1 AND name IS NOT NULL THEN CONCAT(name, ' - ', RIGHT(vin, 6)) ELSE COALESCE(name, CONCAT('VIN ', vin)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;",
"refresh": 1,
"regex": "",
"type": "query"
},
{
"current": {
"text": "6",
"value": "6"
},
"includeAll": false,
"label": "min. Idle Time (h)",
"name": "duration",
"options": [
{
"selected": false,
"text": "0",
"value": "0"
},
{
"selected": false,
"text": "1",
"value": "1"
},
{
"selected": false,
"text": "3",
"value": "3"
},
{
"selected": true,
"text": "6",
"value": "6"
},
{
"selected": false,
"text": "12",
"value": "12"
},
{
"selected": false,
"text": "18",
"value": "18"
},
{
"selected": false,
"text": "24",
"value": "24"
}
],
"query": "0,1,3,6,12,18,24",
"type": "custom"
},
{
"current": {},
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select unit_of_length from settings limit 1;",
"hide": 2,
"includeAll": false,
"name": "length_unit",
"options": [],
"query": "select unit_of_length from settings limit 1;",
"refresh": 1,
"regex": "",
"type": "query"
},
{
"current": {},
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select preferred_range from settings limit 1;",
"hide": 2,
"includeAll": false,
"name": "preferred_range",
"options": [],
"query": "select preferred_range from settings limit 1;",
"refresh": 1,
"regex": "",
"type": "query"
},
{
"current": {},
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "TeslaMate"
},
"definition": "select base_url from settings limit 1;",
"hide": 2,
"includeAll": false,
"name": "base_url",
"options": [],
"query": "select base_url from settings limit 1;",
"refresh": 1,
"regex": "",
"type": "query"
}
]
},
"time": {
"from": "now-90d",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Vampire Drain",
"uid": "zhHx2Fggk",
"version": 1,
"weekStart": ""
}