mirror of
https://github.com/netfun2000/hipudding-teslamate.git
synced 2026-02-27 09:44:28 +08:00
* always use ideal_battery_range_km in conditions (to make use of index) * remove deprecated var syntax
1257 lines
33 KiB
JSON
1257 lines
33 KiB
JSON
{
|
|
"__elements": {},
|
|
"__requires": [
|
|
{
|
|
"type": "panel",
|
|
"id": "bargauge",
|
|
"name": "Bar gauge",
|
|
"version": ""
|
|
},
|
|
{
|
|
"type": "grafana",
|
|
"id": "grafana",
|
|
"name": "Grafana",
|
|
"version": "11.0.1"
|
|
},
|
|
{
|
|
"type": "datasource",
|
|
"id": "grafana-postgresql-datasource",
|
|
"name": "PostgreSQL",
|
|
"version": "1.0.0"
|
|
},
|
|
{
|
|
"type": "panel",
|
|
"id": "stat",
|
|
"name": "Stat",
|
|
"version": ""
|
|
}
|
|
],
|
|
"annotations": {
|
|
"list": [
|
|
{
|
|
"builtIn": 1,
|
|
"datasource": {
|
|
"type": "datasource",
|
|
"uid": "grafana"
|
|
},
|
|
"definition": "TeslaMate|U2FsdGVkX1/cEWK+8cz7pjEKXtzJnDN7b21ZDXt1MGneFGPWTLqOPtxKmu02mJPLzi/f29I+NBHd3vi0FB8R4Xn0+GtobWDgk6VAVSBTdSNniOKO8i2WPlhRaOsl2+hG7gnZ7wrf1Th2nxR7f1uYCrbwOek0IzkfLzrkjh7gkr6inT6bbDuJqrmogZajLxmAMrQ6V+/vHxBRGiwjJhgiEeq3hM1q2h04JKkNiZ8RHbsF5Cd/xd8Q9u0JVrZzIrtnhM/SFlaApU7RtRMu8CSj1llTX7WEOj6VDZAMSf+XUAanWdk725kEPN9MNu89o2zEq5P3E3cju8IbbBdPzXLV3oVuzD6/tMnxFToIIV1E/BrpF7s2RtNa8+KJJ1PF8xgs6m+/KTD2hy+WsP0636AgObRAmYg7+qotGrgNvpNPdE0EgrB7WHYlV7R/1q66bcq6tCe51X1Un70k+zo+K6AK0o4B1H6IyMlEVuRH/Fz8QVl9aYu2ztd08RbuKJlYVKpkH+pxVETAO9MclYQ90tzE6TfwDZrQZzsAlMenr4s1ZB1OlFXjLjVjnddnUilzO76cqv4yI2THQEuyQ47nuVQ4gUbx02K59vMQhns3C01JOAYokOaSXe66Y7QYdMlk09Lf|aes-256-cbc",
|
|
"enable": true,
|
|
"hide": true,
|
|
"iconColor": "rgba(0, 211, 255, 1)",
|
|
"name": "Annotations & Alerts",
|
|
"type": "dashboard"
|
|
}
|
|
]
|
|
},
|
|
"editable": true,
|
|
"fiscalYearStartMonth": 0,
|
|
"graphTooltip": 0,
|
|
"id": null,
|
|
"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": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "semi-dark-blue",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "none"
|
|
},
|
|
"overrides": []
|
|
},
|
|
"gridPos": {
|
|
"h": 4,
|
|
"w": 8,
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
"id": 20,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"fieldOptions": {
|
|
"calcs": [
|
|
"sum"
|
|
]
|
|
},
|
|
"graphMode": "area",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"percentChangeColorMode": "standard",
|
|
"reduceOptions": {
|
|
"calcs": [
|
|
"sum"
|
|
],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"textMode": "value",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "11.0.1",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "time_series",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "WITH since as (\n\tSELECT min(start_date) at time zone 'UTC' as date FROM drives\n\tWHERE car_id = $car_id\n\tGROUP BY car_id\n),\n\nactual AS (\n\tSELECT\n\t\tdate_trunc('day', start_date at time zone 'UTC') AS date,\n\t\tcount(*) AS number_of_drives\n\tFROM drives\n\tWHERE car_id = $car_id and $__timeFilter(start_date) and $__timeFilter(end_date) \n\tGROUP BY 1\n),\n\nbase_line AS (\n\tSELECT date from generate_series(date_trunc('day', (select date from since)), date_trunc('day', timestamp with time zone $__timeTo()), '1 day'::interval) date\n)\n\nSELECT\n base_line.date as time,\n\tCOALESCE(actual.number_of_drives, 0) as number_of_drives\nFROM base_line\nLEFT JOIN actual ON actual.date = base_line.date\nWHERE date_trunc('day', timestamp with time zone $__timeFrom()) <= base_line.date\norder by base_line.date\n",
|
|
"refId": "A",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": [
|
|
"latitude"
|
|
],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "addresses",
|
|
"timeColumn": "inserted_at",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"title": "Number of drives",
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "green",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "none"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "distance_km"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "km"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "distance_mi"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "mi"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"gridPos": {
|
|
"h": 4,
|
|
"w": 8,
|
|
"x": 8,
|
|
"y": 0
|
|
},
|
|
"id": 16,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"fieldOptions": {
|
|
"calcs": [
|
|
"sum"
|
|
]
|
|
},
|
|
"graphMode": "area",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"percentChangeColorMode": "standard",
|
|
"reduceOptions": {
|
|
"calcs": [
|
|
"sum"
|
|
],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"textMode": "value",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "11.0.1",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "time_series",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "WITH since as (\n\tSELECT min(start_date) at time zone 'UTC' as date FROM drives\n\tWHERE car_id = $car_id\n\tGROUP BY car_id\n),\n\nactual AS (\n\tSELECT\n\t\tdate_trunc('day', start_date at time zone 'UTC') AS date,\n\t\tsum(distance) AS distance\n\tFROM drives\n\tWHERE car_id = $car_id and $__timeFilter(start_date) and $__timeFilter(end_date) \n\tGROUP BY 1\n),\n\nbase_line AS (\n\tSELECT date from generate_series(date_trunc('day', (select date from since)), date_trunc('day', timestamp with time zone $__timeTo()), '1 day'::interval) date)\n\nSELECT\n base_line.date as time,\n\tconvert_km(COALESCE(actual.distance, 0)::numeric, '$length_unit') as \"distance_$length_unit\"\nFROM base_line\nLEFT JOIN actual ON actual.date = base_line.date\nWHERE date_trunc('day', timestamp with time zone $__timeFrom()) <= base_line.date\norder by base_line.date\n",
|
|
"refId": "A",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": [
|
|
"latitude"
|
|
],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "addresses",
|
|
"timeColumn": "inserted_at",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"title": "$length_unit driven",
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "semi-dark-yellow",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "kwatth"
|
|
},
|
|
"overrides": []
|
|
},
|
|
"gridPos": {
|
|
"h": 4,
|
|
"w": 8,
|
|
"x": 16,
|
|
"y": 0
|
|
},
|
|
"id": 22,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"fieldOptions": {
|
|
"calcs": [
|
|
"sum"
|
|
]
|
|
},
|
|
"graphMode": "area",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"percentChangeColorMode": "standard",
|
|
"reduceOptions": {
|
|
"calcs": [
|
|
"sum"
|
|
],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"textMode": "value",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "11.0.1",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "time_series",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "WITH since as (\n\tSELECT min(start_date) at time zone 'UTC' as date FROM drives\n\tWHERE car_id = $car_id\n\tGROUP BY car_id\n),\n\nactual AS (\n\tSELECT\n\t\tdate_trunc('day', start_date at time zone 'UTC') AS date,\n\t\tsum(NULLIF(GREATEST(start_${preferred_range}_range_km - end_${preferred_range}_range_km, 0), 0) * cars.efficiency) AS energy\n\tFROM drives\n INNER JOIN cars on drives.car_id = cars.id\n\tWHERE car_id = $car_id and $__timeFilter(start_date) and $__timeFilter(end_date) \n\tGROUP BY 1\n),\n\nbase_line AS (\n\tSELECT date from generate_series(date_trunc('day', (select date from since)), date_trunc('day', timestamp with time zone $__timeTo()), '1 day'::interval) date)\n\nSELECT\n base_line.date as time,\n\tcoalesce(energy, 0) as energy\nFROM base_line\nLEFT JOIN actual ON actual.date = base_line.date\nWHERE date_trunc('day', timestamp with time zone $__timeFrom()) <= base_line.date\norder by base_line.date\n",
|
|
"refId": "A",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": [
|
|
"latitude"
|
|
],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "addresses",
|
|
"timeColumn": "inserted_at",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"title": "Energy used",
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"mappings": [
|
|
{
|
|
"options": {
|
|
"match": "null",
|
|
"result": {
|
|
"text": "N/A"
|
|
}
|
|
},
|
|
"type": "special"
|
|
}
|
|
],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "#c7d0d9",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "none"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "distance_km"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "lengthkm"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "distance_mi"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "mi"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"gridPos": {
|
|
"h": 3,
|
|
"w": 8,
|
|
"x": 0,
|
|
"y": 4
|
|
},
|
|
"id": 26,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"fieldOptions": {
|
|
"calcs": [
|
|
"mean"
|
|
]
|
|
},
|
|
"graphMode": "none",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"percentChangeColorMode": "standard",
|
|
"reduceOptions": {
|
|
"calcs": [],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"textMode": "value",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "11.0.1",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "table",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "SELECT convert_km((percentile_cont(0.5) WITHIN GROUP (ORDER BY distance))::numeric, '$length_unit') as \"distance_$length_unit\"\nFROM drives\nWHERE car_id = $car_id AND $__timeFilter(start_date) AND $__timeFilter(end_date);",
|
|
"refId": "A",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": [
|
|
"latitude"
|
|
],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "addresses",
|
|
"timeColumn": "inserted_at",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"title": "Median distance of a drive",
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"default": false,
|
|
"type": "datasource",
|
|
"uid": "-- Dashboard --"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "#c7d0d9",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "none"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "distance_km"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "lengthkm"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "distance_mi"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "mi"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"gridPos": {
|
|
"h": 3,
|
|
"w": 8,
|
|
"x": 8,
|
|
"y": 4
|
|
},
|
|
"id": 8,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"fieldOptions": {
|
|
"calcs": [
|
|
"mean"
|
|
]
|
|
},
|
|
"graphMode": "none",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"percentChangeColorMode": "standard",
|
|
"reduceOptions": {
|
|
"calcs": [
|
|
"mean"
|
|
],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"textMode": "value",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "11.0.1",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "datasource",
|
|
"uid": "-- Dashboard --"
|
|
},
|
|
"panelId": 16,
|
|
"refId": "A"
|
|
}
|
|
],
|
|
"title": "Average distance driven per day",
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"default": false,
|
|
"type": "datasource",
|
|
"uid": "-- Dashboard --"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "#c7d0d9",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "kwatth"
|
|
},
|
|
"overrides": []
|
|
},
|
|
"gridPos": {
|
|
"h": 3,
|
|
"w": 8,
|
|
"x": 16,
|
|
"y": 4
|
|
},
|
|
"id": 14,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"fieldOptions": {
|
|
"calcs": [
|
|
"lastNotNull"
|
|
]
|
|
},
|
|
"graphMode": "none",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"percentChangeColorMode": "standard",
|
|
"reduceOptions": {
|
|
"calcs": [
|
|
"mean"
|
|
],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"textMode": "value",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "11.0.1",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "datasource",
|
|
"uid": "-- Dashboard --"
|
|
},
|
|
"panelId": 22,
|
|
"refId": "A"
|
|
}
|
|
],
|
|
"title": "Average kWh used per day",
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "#c7d0d9",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "none"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "mileage_km"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "km"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "mileage_mi"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "mi"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"gridPos": {
|
|
"h": 3,
|
|
"w": 12,
|
|
"x": 0,
|
|
"y": 7
|
|
},
|
|
"id": 32,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"fieldOptions": {
|
|
"calcs": [
|
|
"lastNotNull"
|
|
]
|
|
},
|
|
"graphMode": "none",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"percentChangeColorMode": "standard",
|
|
"reduceOptions": {
|
|
"calcs": [
|
|
"mean"
|
|
],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"textMode": "value",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "11.0.1",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "table",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "WITH since as (\r\n\tSELECT min(start_date) at time zone 'UTC' as date FROM drives\r\n\tWHERE car_id = $car_id\r\n\tGROUP BY car_id\r\n)\r\n\r\nselect\r\n convert_km(((max(end_km) - min(start_km)) / greatest(extract(days from (timestamp with time zone $__timeTo() - greatest(timestamp with time zone $__timeFrom(), (select date from since)))), 1) * (365/12))::numeric, '$length_unit') as \"mileage_$length_unit\"\r\nfrom drives\r\nwhere car_id = $car_id and $__timeFilter(start_date) and $__timeFilter(end_date)\r\ngroup by car_id",
|
|
"refId": "A",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": [
|
|
"latitude"
|
|
],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "addresses",
|
|
"timeColumn": "inserted_at",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"title": "Extrapolated monthly mileage",
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"default": false,
|
|
"type": "datasource",
|
|
"uid": "-- Dashboard --"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "#c7d0d9",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "none"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "mileage_km"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "km"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "mileage_mi"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "mi"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"gridPos": {
|
|
"h": 3,
|
|
"w": 12,
|
|
"x": 12,
|
|
"y": 7
|
|
},
|
|
"id": 30,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"fieldOptions": {
|
|
"calcs": [
|
|
"lastNotNull"
|
|
]
|
|
},
|
|
"graphMode": "none",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"percentChangeColorMode": "standard",
|
|
"reduceOptions": {
|
|
"calcs": [
|
|
"mean"
|
|
],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"textMode": "value",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "11.0.1",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "datasource",
|
|
"uid": "-- Dashboard --"
|
|
},
|
|
"panelId": 32,
|
|
"refId": "A"
|
|
}
|
|
],
|
|
"title": "Extrapolated annual mileage",
|
|
"transformations": [
|
|
{
|
|
"id": "calculateField",
|
|
"options": {
|
|
"alias": "mileage_km",
|
|
"binary": {
|
|
"left": "mileage_km",
|
|
"operator": "*",
|
|
"right": "12"
|
|
},
|
|
"mode": "binary",
|
|
"reduce": {
|
|
"reducer": "sum"
|
|
},
|
|
"replaceFields": true
|
|
}
|
|
},
|
|
{
|
|
"id": "calculateField",
|
|
"options": {
|
|
"alias": "mileage_mi",
|
|
"binary": {
|
|
"left": "mileage_mi",
|
|
"operator": "*",
|
|
"right": "12"
|
|
},
|
|
"mode": "binary",
|
|
"reduce": {
|
|
"reducer": "sum"
|
|
},
|
|
"replaceFields": true
|
|
}
|
|
}
|
|
],
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"color": {
|
|
"mode": "thresholds"
|
|
},
|
|
"displayName": "$__cell_0",
|
|
"mappings": [],
|
|
"min": 0,
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "semi-dark-blue",
|
|
"value": null
|
|
},
|
|
{
|
|
"color": "light-red",
|
|
"value": 50
|
|
}
|
|
]
|
|
},
|
|
"unit": "none"
|
|
},
|
|
"overrides": []
|
|
},
|
|
"gridPos": {
|
|
"h": 11,
|
|
"w": 24,
|
|
"x": 0,
|
|
"y": 10
|
|
},
|
|
"id": 24,
|
|
"options": {
|
|
"displayMode": "gradient",
|
|
"maxVizHeight": 300,
|
|
"minVizHeight": 16,
|
|
"minVizWidth": 8,
|
|
"namePlacement": "auto",
|
|
"orientation": "horizontal",
|
|
"reduceOptions": {
|
|
"calcs": [
|
|
"mean"
|
|
],
|
|
"fields": "",
|
|
"values": true
|
|
},
|
|
"showUnfilled": true,
|
|
"sizing": "auto",
|
|
"valueMode": "color"
|
|
},
|
|
"pluginVersion": "11.0.1",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "table",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "SELECT * FROM (\nSELECT\n\tCOALESCE(g.name, COALESCE(a.name, nullif(CONCAT_WS(' ', a.road, a.house_number), ''))) as name,\n\tcount(*) AS visited\nFROM drives t\nINNER JOIN addresses a ON end_address_id = a.id\nLEFT JOIN geofences g ON end_geofence_id = g.id\nWHERE t.car_id = $car_id AND $__timeFilter(t.start_date) and $__timeFilter(t.end_date) \nGROUP BY 1\nORDER BY visited DESC)\nWHERE name NOT ILIKE ALL ${exclude_formatted_string:raw}\nLIMIT 10;",
|
|
"refId": "A",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": [
|
|
"latitude"
|
|
],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "addresses",
|
|
"timeColumn": "inserted_at",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"title": "Top 10 Destinations (in this period)",
|
|
"type": "bargauge"
|
|
}
|
|
],
|
|
"refresh": false,
|
|
"schemaVersion": 39,
|
|
"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, RIGHT(vin, 6)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;",
|
|
"hide": 0,
|
|
"includeAll": false,
|
|
"label": "Car",
|
|
"multi": false,
|
|
"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, RIGHT(vin, 6)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"tagValuesQuery": "",
|
|
"tagsQuery": "",
|
|
"type": "query",
|
|
"useTags": false
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "select unit_of_length from settings limit 1;",
|
|
"hide": 2,
|
|
"includeAll": false,
|
|
"multi": false,
|
|
"name": "length_unit",
|
|
"options": [],
|
|
"query": "select unit_of_length from settings limit 1;",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"tagValuesQuery": "",
|
|
"tagsQuery": "",
|
|
"type": "query",
|
|
"useTags": false
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "select preferred_range from settings limit 1;",
|
|
"hide": 2,
|
|
"includeAll": false,
|
|
"label": "",
|
|
"multi": false,
|
|
"name": "preferred_range",
|
|
"options": [],
|
|
"query": "select preferred_range from settings limit 1;",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"tagValuesQuery": "",
|
|
"tagsQuery": "",
|
|
"type": "query",
|
|
"useTags": false
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "select base_url from settings limit 1;",
|
|
"hide": 2,
|
|
"includeAll": false,
|
|
"label": "",
|
|
"multi": false,
|
|
"name": "base_url",
|
|
"options": [],
|
|
"query": "select base_url from settings limit 1;",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"tagValuesQuery": "",
|
|
"tagsQuery": "",
|
|
"type": "query",
|
|
"useTags": false
|
|
},
|
|
{
|
|
"current": {
|
|
"selected": false,
|
|
"text": "",
|
|
"value": ""
|
|
},
|
|
"description": "Comma separated list of locations to exclude. Ex: home, work",
|
|
"hide": 0,
|
|
"label": "Exclude locations",
|
|
"name": "exclude",
|
|
"options": [
|
|
{
|
|
"selected": true,
|
|
"text": "",
|
|
"value": ""
|
|
}
|
|
],
|
|
"query": "",
|
|
"skipUrlSync": false,
|
|
"type": "textbox"
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "WITH splits AS (\n SELECT unnest(string_to_array('$exclude', ', ')) AS part\n),\nsplit_strings AS (\n\tSELECT part AS part\n\tFROM (VALUES (NULL)) AS v(dummy)\n\tLEFT JOIN splits ON TRUE\n),\nexclude_string AS (\n\tSELECT array_to_string(array_agg(case when part is null then '''''' else '''%' || part || '%''' end), ', ') AS formatted_string\n\tFROM split_strings\n)\nSELECT '(ARRAY[' || formatted_string || '])' FROM exclude_string",
|
|
"hide": 2,
|
|
"includeAll": false,
|
|
"multi": false,
|
|
"name": "exclude_formatted_string",
|
|
"options": [],
|
|
"query": "WITH splits AS (\n SELECT unnest(string_to_array('$exclude', ', ')) AS part\n),\nsplit_strings AS (\n\tSELECT part AS part\n\tFROM (VALUES (NULL)) AS v(dummy)\n\tLEFT JOIN splits ON TRUE\n),\nexclude_string AS (\n\tSELECT array_to_string(array_agg(case when part is null then '''''' else '''%' || part || '%''' end), ', ') AS formatted_string\n\tFROM split_strings\n)\nSELECT '(ARRAY[' || formatted_string || '])' FROM exclude_string",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"type": "query"
|
|
}
|
|
]
|
|
},
|
|
"time": {
|
|
"from": "now-1y",
|
|
"to": "now"
|
|
},
|
|
"timepicker": {
|
|
"hidden": false,
|
|
"refresh_intervals": [
|
|
"5s",
|
|
"10s",
|
|
"30s",
|
|
"1m",
|
|
"5m",
|
|
"15m",
|
|
"30m",
|
|
"1h",
|
|
"2h",
|
|
"1d"
|
|
],
|
|
"time_options": [
|
|
"5m",
|
|
"15m",
|
|
"1h",
|
|
"6h",
|
|
"12h",
|
|
"24h",
|
|
"2d",
|
|
"7d",
|
|
"30d"
|
|
]
|
|
},
|
|
"timezone": "",
|
|
"title": "Drive Stats",
|
|
"uid": "_7WkNSyWk",
|
|
"version": 14,
|
|
"weekStart": ""
|
|
} |