1377 lines
54 KiB
JSON
1377 lines
54 KiB
JSON
{
|
|
"__elements": {},
|
|
"__requires": [
|
|
{
|
|
"type": "panel",
|
|
"id": "geomap",
|
|
"name": "Geomap",
|
|
"version": ""
|
|
},
|
|
{
|
|
"type": "grafana",
|
|
"id": "grafana",
|
|
"name": "Grafana",
|
|
"version": "10.4.0"
|
|
},
|
|
{
|
|
"type": "datasource",
|
|
"id": "grafana-postgresql-datasource",
|
|
"name": "PostgreSQL",
|
|
"version": "1.0.0"
|
|
},
|
|
{
|
|
"type": "panel",
|
|
"id": "stat",
|
|
"name": "Stat",
|
|
"version": ""
|
|
},
|
|
{
|
|
"type": "panel",
|
|
"id": "timeseries",
|
|
"name": "Time series",
|
|
"version": ""
|
|
}
|
|
],
|
|
"annotations": {
|
|
"list": [
|
|
{
|
|
"$$hashKey": "object:24",
|
|
"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",
|
|
"target": {
|
|
"limit": 100,
|
|
"matchAny": false,
|
|
"tags": [],
|
|
"type": "dashboard"
|
|
},
|
|
"type": "dashboard"
|
|
}
|
|
]
|
|
},
|
|
"editable": true,
|
|
"fiscalYearStartMonth": 0,
|
|
"graphTooltip": 1,
|
|
"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"
|
|
},
|
|
{
|
|
"asDropdown": true,
|
|
"icon": "external link",
|
|
"includeVars": false,
|
|
"keepTime": false,
|
|
"tags": ["TeslamateCustomDashboards"],
|
|
"targetBlank": false,
|
|
"title": "Custom Dashboards",
|
|
"tooltip": "",
|
|
"type": "dashboards",
|
|
"url": ""
|
|
}
|
|
],
|
|
"liveNow": false,
|
|
"panels": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"description": "This dashboard is meant to analize a drive based on a date you select, then you can pass the pointer over the lines in graph to see data details and a blue point in the map tranking the route. With this option you can analized a specific point location in the map, to see the speed, power, SOC, elevation and if battery heater was on.\n\nBe aware that the drive you select in the dropdown list from the top could be outside the time range of the Timeline graph, if its the case you have to click on the \"Zoom to data\" button on the graph in order to update it.\n\nTip: On Grafana you can press \"h\" to get a keyboard shortcuts if you want to change the current Zoom out time range or use the mouse to select/change the time range.",
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"color": {
|
|
"mode": "palette-classic"
|
|
},
|
|
"custom": {
|
|
"axisBorderShow": false,
|
|
"axisCenteredZero": true,
|
|
"axisColorMode": "text",
|
|
"axisLabel": "",
|
|
"axisPlacement": "left",
|
|
"barAlignment": 0,
|
|
"drawStyle": "line",
|
|
"fillOpacity": 0,
|
|
"gradientMode": "none",
|
|
"hideFrom": {
|
|
"legend": false,
|
|
"tooltip": false,
|
|
"viz": false
|
|
},
|
|
"insertNulls": false,
|
|
"lineInterpolation": "smooth",
|
|
"lineWidth": 1,
|
|
"pointSize": 5,
|
|
"scaleDistribution": {
|
|
"type": "linear"
|
|
},
|
|
"showPoints": "never",
|
|
"spanNulls": true,
|
|
"stacking": {
|
|
"group": "A",
|
|
"mode": "none"
|
|
},
|
|
"thresholdsStyle": {
|
|
"mode": "off"
|
|
}
|
|
},
|
|
"links": [],
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "green",
|
|
"value": null
|
|
},
|
|
{
|
|
"color": "red",
|
|
"value": 80
|
|
}
|
|
]
|
|
},
|
|
"unit": "none"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "battery_heater"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "displayName",
|
|
"value": "Battery heater (On/Off)"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "power"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "displayName",
|
|
"value": "Power (kW)"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "speed_kmh"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "displayName",
|
|
"value": "Speed (km/h)"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "speed_mih"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "displayName",
|
|
"value": "Speed (mi/h)"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "soc"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "displayName",
|
|
"value": "SOC (%)"
|
|
},
|
|
{
|
|
"id": "color",
|
|
"value": {
|
|
"fixedColor": "purple",
|
|
"mode": "fixed"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "Battery heater (On/Off)"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "color",
|
|
"value": {
|
|
"fixedColor": "semi-dark-red",
|
|
"mode": "fixed"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "Power (kW)"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "color",
|
|
"value": {
|
|
"fixedColor": "semi-dark-orange",
|
|
"mode": "fixed"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byRegexp",
|
|
"options": "/elevation_*/"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "displayName",
|
|
"value": "Elevation"
|
|
},
|
|
{
|
|
"id": "color",
|
|
"value": {
|
|
"fixedColor": "text",
|
|
"mode": "fixed"
|
|
}
|
|
},
|
|
{
|
|
"id": "custom.axisPlacement",
|
|
"value": "right"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "elevation_ft"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "lengthft"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "elevation_m"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "lengthm"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"gridPos": {
|
|
"h": 17,
|
|
"w": 15,
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
"hideTimeOverride": false,
|
|
"id": 8,
|
|
"options": {
|
|
"legend": {
|
|
"calcs": [],
|
|
"displayMode": "list",
|
|
"placement": "bottom",
|
|
"showLegend": true
|
|
},
|
|
"tooltip": {
|
|
"mode": "multi",
|
|
"sort": "none"
|
|
}
|
|
},
|
|
"pluginVersion": "8.5.15",
|
|
"targets": [
|
|
{
|
|
"alias": "",
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "time_series",
|
|
"group": [],
|
|
"hide": false,
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "WITH journey AS (SELECT start_date, end_date FROM drives WHERE id = $journey)\nSELECT\n\t$__time(date),\n\tAVG(convert_km(speed::numeric, '$length_unit')) AS speed_[[length_unit]]h,\n\tAVG(power) AS Power,\n\tAVG(battery_level) AS SOC,\n\tAVG(battery_heater::integer * 100) AS battery_heater,\n\tAVG(ROUND(convert_m(elevation, '$alternative_length_unit'))) AS elevation_[[alternative_length_unit]]\nFROM\n\tpositions, journey\nWHERE\n car_id = $car_id AND (date BETWEEN journey.start_date AND journey.end_date)\nGROUP BY 1 \nORDER BY\n\tdate ASC",
|
|
"refId": "Power",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": ["id"],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "charging",
|
|
"timeColumn": "Datum",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"title": "Drive",
|
|
"type": "timeseries"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"color": {
|
|
"fixedColor": "red",
|
|
"mode": "fixed"
|
|
},
|
|
"custom": {
|
|
"hideFrom": {
|
|
"legend": false,
|
|
"tooltip": false,
|
|
"viz": false
|
|
}
|
|
},
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "green",
|
|
"value": null
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"overrides": []
|
|
},
|
|
"gridPos": {
|
|
"h": 20,
|
|
"w": 9,
|
|
"x": 15,
|
|
"y": 0
|
|
},
|
|
"id": 18,
|
|
"maxDataPoints": 50000,
|
|
"options": {
|
|
"basemap": {
|
|
"config": {
|
|
"server": "streets"
|
|
},
|
|
"name": "Layer 0",
|
|
"type": "esri-xyz"
|
|
},
|
|
"controls": {
|
|
"mouseWheelZoom": true,
|
|
"showAttribution": true,
|
|
"showDebug": false,
|
|
"showMeasure": false,
|
|
"showScale": false,
|
|
"showZoom": true
|
|
},
|
|
"layers": [
|
|
{
|
|
"config": {
|
|
"arrow": 0,
|
|
"style": {
|
|
"color": {
|
|
"fixed": "dark-blue"
|
|
},
|
|
"lineWidth": 2,
|
|
"opacity": 1,
|
|
"rotation": {
|
|
"fixed": 0,
|
|
"max": 360,
|
|
"min": -360,
|
|
"mode": "mod"
|
|
},
|
|
"size": {
|
|
"fixed": 3,
|
|
"max": 15,
|
|
"min": 2
|
|
},
|
|
"symbol": {
|
|
"field": "",
|
|
"fixed": "img/icons/marker/triangle.svg",
|
|
"mode": "fixed"
|
|
},
|
|
"symbolAlign": {
|
|
"horizontal": "center",
|
|
"vertical": "center"
|
|
},
|
|
"textConfig": {
|
|
"fontSize": 12,
|
|
"offsetX": 0,
|
|
"offsetY": 0,
|
|
"textAlign": "center",
|
|
"textBaseline": "middle"
|
|
}
|
|
}
|
|
},
|
|
"location": {
|
|
"mode": "auto"
|
|
},
|
|
"name": "route",
|
|
"opacity": 1,
|
|
"tooltip": true,
|
|
"type": "route"
|
|
}
|
|
],
|
|
"tooltip": {
|
|
"mode": "none"
|
|
},
|
|
"view": {
|
|
"allLayers": true,
|
|
"id": "fit",
|
|
"lat": 0,
|
|
"lon": 0,
|
|
"zoom": 15
|
|
}
|
|
},
|
|
"pluginVersion": "10.4.0",
|
|
"targets": [
|
|
{
|
|
"alias": "",
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "time_series",
|
|
"group": [
|
|
{
|
|
"params": ["$__interval", "none"],
|
|
"type": "time"
|
|
}
|
|
],
|
|
"hide": false,
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "WITH journey AS (SELECT start_date, end_date FROM drives WHERE id = $journey)\nSELECT\n $__time(date), latitude, longitude\nFROM positions, journey\nWHERE\n car_id = $car_id AND (date BETWEEN journey.start_date AND journey.end_date)\nORDER BY date ASC",
|
|
"refId": "A",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": ["lat"],
|
|
"type": "column"
|
|
},
|
|
{
|
|
"params": ["avg"],
|
|
"type": "aggregate"
|
|
},
|
|
{
|
|
"params": ["lat"],
|
|
"type": "alias"
|
|
}
|
|
],
|
|
[
|
|
{
|
|
"params": ["lng"],
|
|
"type": "column"
|
|
},
|
|
{
|
|
"params": ["avg"],
|
|
"type": "aggregate"
|
|
},
|
|
{
|
|
"params": ["lat"],
|
|
"type": "alias"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
]
|
|
},
|
|
"table": "pos",
|
|
"timeColumn": "Datum",
|
|
"timeColumnType": "datetime",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"type": "geomap"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"description": "",
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"mappings": [
|
|
{
|
|
"options": {
|
|
"match": "null",
|
|
"result": {
|
|
"text": "N/A"
|
|
}
|
|
},
|
|
"type": "special"
|
|
}
|
|
],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "light-purple",
|
|
"value": null
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"overrides": [
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "sec_diff"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "displayName",
|
|
"value": "Duration"
|
|
},
|
|
{
|
|
"id": "unit",
|
|
"value": "clocks"
|
|
},
|
|
{
|
|
"id": "decimals",
|
|
"value": 1
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "km"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "displayName",
|
|
"value": "Consumption"
|
|
},
|
|
{
|
|
"id": "unit",
|
|
"value": "Wh/km"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "mi"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "displayName",
|
|
"value": "Consumption"
|
|
},
|
|
{
|
|
"id": "unit",
|
|
"value": "Wh/mi"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"gridPos": {
|
|
"h": 3,
|
|
"w": 5,
|
|
"x": 0,
|
|
"y": 17
|
|
},
|
|
"id": 14,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"graphMode": "none",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"reduceOptions": {
|
|
"calcs": ["lastNotNull"],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"text": {
|
|
"titleSize": 16
|
|
},
|
|
"textMode": "value_and_name",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "10.4.0",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"format": "table",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "SELECT ((DATE_PART('day', end_date - start_date) * 24 + \n DATE_PART('hour', end_date - start_date)) * 60 +\n DATE_PART('minute', end_date - start_date)) * 60 +\n DATE_PART('second', end_date - start_date) as sec_diff\nFROM drives\nWHERE drives.id = $journey;",
|
|
"refId": "Duration",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": ["latitude"],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"table": "addresses",
|
|
"timeColumn": "inserted_at",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "table",
|
|
"group": [],
|
|
"hide": false,
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "select\n\t(NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) * car.efficiency) *1000 /\n\t convert_km(distance::numeric, '$length_unit') as \"$length_unit\"\nfrom drives d\nJOIN cars car ON car.id = car_id\nwhere d.id = $journey;",
|
|
"refId": "Consumption",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": ["start_km"],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "drives",
|
|
"timeColumn": "start_date",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"description": "",
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"decimals": 2,
|
|
"mappings": [
|
|
{
|
|
"options": {
|
|
"match": "null",
|
|
"result": {
|
|
"text": "N/A"
|
|
}
|
|
},
|
|
"type": "special"
|
|
}
|
|
],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "light-blue",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "none"
|
|
},
|
|
"overrides": [
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "km"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "lengthkm"
|
|
},
|
|
{
|
|
"id": "displayName",
|
|
"value": "Distance"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "mi"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "lengthmi"
|
|
},
|
|
{
|
|
"id": "displayName",
|
|
"value": "Distance"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "speed_mih"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "velocitymph"
|
|
},
|
|
{
|
|
"id": "displayName",
|
|
"value": "Avg Speed"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"matcher": {
|
|
"id": "byName",
|
|
"options": "speed_kmh"
|
|
},
|
|
"properties": [
|
|
{
|
|
"id": "unit",
|
|
"value": "velocitykmh"
|
|
},
|
|
{
|
|
"id": "displayName",
|
|
"value": "Avg Speed"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"gridPos": {
|
|
"h": 3,
|
|
"w": 4,
|
|
"x": 5,
|
|
"y": 17
|
|
},
|
|
"id": 12,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"graphMode": "none",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"reduceOptions": {
|
|
"calcs": [],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"text": {
|
|
"titleSize": 16
|
|
},
|
|
"textMode": "auto",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "10.4.0",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"format": "table",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "select convert_km(distance::numeric, '$length_unit') as \"$length_unit\" from drives where id = $journey;",
|
|
"refId": "Distance",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": ["latitude"],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"table": "addresses",
|
|
"timeColumn": "inserted_at",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"format": "table",
|
|
"group": [],
|
|
"hide": false,
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "WITH journey AS (SELECT start_date, end_date FROM drives WHERE id = $journey)\nSELECT\n\tAVG(convert_km(speed::numeric, '$length_unit')) AS speed_[[length_unit]]h\nFROM\n\tpositions, journey\nWHERE\n car_id = $car_id AND (date BETWEEN journey.start_date AND journey.end_date)",
|
|
"refId": "Speed",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": ["start_km"],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"table": "drives",
|
|
"timeColumn": "start_date",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"type": "stat"
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"fieldConfig": {
|
|
"defaults": {
|
|
"decimals": 2,
|
|
"displayName": "Energy used",
|
|
"mappings": [
|
|
{
|
|
"options": {
|
|
"match": "null",
|
|
"result": {
|
|
"text": "N/A"
|
|
}
|
|
},
|
|
"type": "special"
|
|
}
|
|
],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "semi-dark-orange",
|
|
"value": null
|
|
}
|
|
]
|
|
},
|
|
"unit": "kwatth"
|
|
},
|
|
"overrides": []
|
|
},
|
|
"gridPos": {
|
|
"h": 3,
|
|
"w": 3,
|
|
"x": 9,
|
|
"y": 17
|
|
},
|
|
"id": 16,
|
|
"maxDataPoints": 100,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"graphMode": "none",
|
|
"justifyMode": "auto",
|
|
"orientation": "horizontal",
|
|
"reduceOptions": {
|
|
"calcs": ["lastNotNull"],
|
|
"fields": "",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"text": {
|
|
"titleSize": 16
|
|
},
|
|
"textMode": "value",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "10.4.0",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"format": "table",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "SELECT\n\t(NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) * car.efficiency)\nFROM\n\tdrives d\nJOIN cars car ON car.id = car_id\nWHERE\n\td.id = $journey;",
|
|
"refId": "A",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": ["latitude"],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"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": {
|
|
"color": {
|
|
"mode": "thresholds"
|
|
},
|
|
"mappings": [],
|
|
"thresholds": {
|
|
"mode": "absolute",
|
|
"steps": [
|
|
{
|
|
"color": "green",
|
|
"value": null
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"overrides": []
|
|
},
|
|
"gridPos": {
|
|
"h": 3,
|
|
"w": 3,
|
|
"x": 12,
|
|
"y": 17
|
|
},
|
|
"id": 10,
|
|
"options": {
|
|
"colorMode": "value",
|
|
"graphMode": "none",
|
|
"justifyMode": "center",
|
|
"orientation": "vertical",
|
|
"reduceOptions": {
|
|
"calcs": ["lastNotNull"],
|
|
"fields": "/.*/",
|
|
"values": false
|
|
},
|
|
"showPercentChange": false,
|
|
"text": {
|
|
"titleSize": 16
|
|
},
|
|
"textMode": "value_and_name",
|
|
"wideLayout": true
|
|
},
|
|
"pluginVersion": "10.4.0",
|
|
"targets": [
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "table",
|
|
"group": [],
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "WITH height as (SELECT\n\televation-LAG(elevation,1) over ( order BY\n\tdate ASC ) as diff\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND (date BETWEEN (SELECT start_date FROM drives WHERE id = $journey) AND (SELECT end_date FROM drives WHERE id = $journey))\nORDER BY\n\tdate ASC\n\t)\nselect ROUND(convert_m(sum(diff), '$alternative_length_unit')::numeric,0) || ' $alternative_length_unit' as \"Up\" from height where diff > 0",
|
|
"refId": "A",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": ["start_km"],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "drives",
|
|
"timeColumn": "start_date",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"editorMode": "code",
|
|
"format": "table",
|
|
"group": [],
|
|
"hide": false,
|
|
"metricColumn": "none",
|
|
"rawQuery": true,
|
|
"rawSql": "WITH height as (SELECT\n\televation-LAG(elevation,1) over ( order BY\n\tdate ASC ) as diff\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND (date BETWEEN (SELECT start_date FROM drives WHERE id = $journey) AND (SELECT end_date FROM drives WHERE id = $journey))\nORDER BY\n\tdate ASC\n\t)\n\t\n\t\nselect ROUND(convert_m(sum(diff), '$alternative_length_unit')::numeric,0) || ' $alternative_length_unit' as \"Down\" from height where diff < 0",
|
|
"refId": "B",
|
|
"select": [
|
|
[
|
|
{
|
|
"params": ["start_km"],
|
|
"type": "column"
|
|
}
|
|
]
|
|
],
|
|
"sql": {
|
|
"columns": [
|
|
{
|
|
"parameters": [],
|
|
"type": "function"
|
|
}
|
|
],
|
|
"groupBy": [
|
|
{
|
|
"property": {
|
|
"type": "string"
|
|
},
|
|
"type": "groupBy"
|
|
}
|
|
],
|
|
"limit": 50
|
|
},
|
|
"table": "drives",
|
|
"timeColumn": "start_date",
|
|
"timeColumnType": "timestamp",
|
|
"where": [
|
|
{
|
|
"name": "$__timeFilter",
|
|
"params": [],
|
|
"type": "macro"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"title": "Elevation",
|
|
"type": "stat"
|
|
}
|
|
],
|
|
"refresh": "",
|
|
"schemaVersion": 39,
|
|
"tags": ["TeslamateCustomDashboards"],
|
|
"templating": {
|
|
"list": [
|
|
{
|
|
"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,
|
|
"type": "query"
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "select case when unit_of_length = 'km' then 'm' when unit_of_length = 'mi' then 'ft' end from settings limit 1;",
|
|
"hide": 2,
|
|
"includeAll": false,
|
|
"multi": false,
|
|
"name": "alternative_length_unit",
|
|
"options": [],
|
|
"query": "select case when unit_of_length = 'km' then 'm' when unit_of_length = 'mi' then 'ft' end from settings limit 1;",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"type": "query"
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
|
|
"hide": 0,
|
|
"includeAll": false,
|
|
"label": "Car",
|
|
"multi": false,
|
|
"name": "car_id",
|
|
"options": [],
|
|
"query": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"tagValuesQuery": "",
|
|
"tagsQuery": "",
|
|
"type": "query",
|
|
"useTags": false
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "SELECT TO_CHAR(start_date, 'YYYY') as year FROM drives\nWHERE car_id = $car_id\nGROUP BY 1\nORDER BY 1 DESC;",
|
|
"hide": 0,
|
|
"includeAll": false,
|
|
"multi": false,
|
|
"name": "Year",
|
|
"options": [],
|
|
"query": "SELECT TO_CHAR(start_date, 'YYYY') as year FROM drives\nWHERE car_id = $car_id\nGROUP BY 1\nORDER BY 1 DESC;",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"type": "query"
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "(SELECT TO_CHAR(start_date, 'MM') as month FROM drives WHERE car_id = $car_id ORDER BY start_date DESC LIMIT 1)\nUNION ALL\n(SELECT TO_CHAR(start_date, 'MM') as month FROM drives WHERE car_id = $car_id AND TO_CHAR(start_date, 'YYYY') = '$Year'\nGROUP BY 1\nORDER BY 1);",
|
|
"hide": 0,
|
|
"includeAll": false,
|
|
"multi": false,
|
|
"name": "Month",
|
|
"options": [],
|
|
"query": "(SELECT TO_CHAR(start_date, 'MM') as month FROM drives WHERE car_id = $car_id ORDER BY start_date DESC LIMIT 1)\nUNION ALL\n(SELECT TO_CHAR(start_date, 'MM') as month FROM drives WHERE car_id = $car_id AND TO_CHAR(start_date, 'YYYY') = '$Year'\nGROUP BY 1\nORDER BY 1);",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"type": "query"
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "(SELECT TO_CHAR(start_date, 'DD') as day FROM drives WHERE car_id = $car_id ORDER BY start_date DESC LIMIT 1)\nUNION ALL\n(SELECT TO_CHAR(start_date, 'DD') as day FROM drives \nWHERE car_id = $car_id AND TO_CHAR(start_date, 'YYYY') = '$Year' AND TO_CHAR(start_date, 'MM') = '$Month'\nGROUP BY 1 ORDER BY 1);",
|
|
"hide": 0,
|
|
"includeAll": false,
|
|
"multi": false,
|
|
"name": "Day",
|
|
"options": [],
|
|
"query": "(SELECT TO_CHAR(start_date, 'DD') as day FROM drives WHERE car_id = $car_id ORDER BY start_date DESC LIMIT 1)\nUNION ALL\n(SELECT TO_CHAR(start_date, 'DD') as day FROM drives \nWHERE car_id = $car_id AND TO_CHAR(start_date, 'YYYY') = '$Year' AND TO_CHAR(start_date, 'MM') = '$Month'\nGROUP BY 1 ORDER BY 1);",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"type": "query"
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "WITH data AS (\n SELECT\n drives.id as drive_id,\n start_date,\n COALESCE(start_geofence.name, CONCAT_WS(', ', COALESCE(start_address.name, nullif(CONCAT_WS(' ', start_address.road, start_address.house_number), '')), start_address.city)) AS start_address,\n COALESCE(end_geofence.name, CONCAT_WS(', ', COALESCE(end_address.name, nullif(CONCAT_WS(' ', end_address.road, end_address.house_number), '')), end_address.city)) AS end_address\n FROM drives\n LEFT JOIN addresses start_address ON start_address_id = start_address.id\n LEFT JOIN addresses end_address ON end_address_id = end_address.id\n LEFT JOIN positions start_position ON start_position_id = start_position.id\n LEFT JOIN positions end_position ON end_position_id = end_position.id\n LEFT JOIN geofences start_geofence ON start_geofence_id = start_geofence.id\n LEFT JOIN geofences end_geofence ON end_geofence_id = end_geofence.id\n LEFT JOIN cars car ON car.id = drives.car_id\n WHERE drives.car_id = $car_id AND start_date::date = '$Year-$Month-$Day' AND distance > 0 \n ORDER BY start_date DESC\n)\nSELECT\n 'route=\"' || to_char(start_date:: timestamp, 'YYYY-MM-DD') || ' ' || start_address || ' ---> ' || end_address || '\" id=\"' || drive_id || '\"'AS journey\nFROM data;",
|
|
"hide": 0,
|
|
"includeAll": false,
|
|
"label": "Journey",
|
|
"multi": false,
|
|
"name": "journey",
|
|
"options": [],
|
|
"query": "WITH data AS (\n SELECT\n drives.id as drive_id,\n start_date,\n COALESCE(start_geofence.name, CONCAT_WS(', ', COALESCE(start_address.name, nullif(CONCAT_WS(' ', start_address.road, start_address.house_number), '')), start_address.city)) AS start_address,\n COALESCE(end_geofence.name, CONCAT_WS(', ', COALESCE(end_address.name, nullif(CONCAT_WS(' ', end_address.road, end_address.house_number), '')), end_address.city)) AS end_address\n FROM drives\n LEFT JOIN addresses start_address ON start_address_id = start_address.id\n LEFT JOIN addresses end_address ON end_address_id = end_address.id\n LEFT JOIN positions start_position ON start_position_id = start_position.id\n LEFT JOIN positions end_position ON end_position_id = end_position.id\n LEFT JOIN geofences start_geofence ON start_geofence_id = start_geofence.id\n LEFT JOIN geofences end_geofence ON end_geofence_id = end_geofence.id\n LEFT JOIN cars car ON car.id = drives.car_id\n WHERE drives.car_id = $car_id AND start_date::date = '$Year-$Month-$Day' AND distance > 0 \n ORDER BY start_date DESC\n)\nSELECT\n 'route=\"' || to_char(start_date:: timestamp, 'YYYY-MM-DD') || ' ' || start_address || ' ---> ' || end_address || '\" id=\"' || drive_id || '\"'AS journey\nFROM data;",
|
|
"refresh": 1,
|
|
"regex": "/route=\"(?<text>[^\"]+)|id=\"(?<value>[^\"]+)/g",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"type": "query"
|
|
},
|
|
{
|
|
"current": {},
|
|
"datasource": {
|
|
"type": "grafana-postgresql-datasource",
|
|
"uid": "TeslaMate"
|
|
},
|
|
"definition": "select preferred_range from settings limit 1;",
|
|
"hide": 2,
|
|
"includeAll": false,
|
|
"multi": false,
|
|
"name": "preferred_range",
|
|
"options": [],
|
|
"query": "select preferred_range from settings limit 1;",
|
|
"refresh": 1,
|
|
"regex": "",
|
|
"skipUrlSync": false,
|
|
"sort": 0,
|
|
"type": "query"
|
|
}
|
|
]
|
|
},
|
|
"time": {
|
|
"from": "now-15m",
|
|
"to": "now"
|
|
},
|
|
"timepicker": {
|
|
"hidden": true,
|
|
"refresh_intervals": []
|
|
},
|
|
"timezone": "",
|
|
"title": "Tracking Drives",
|
|
"uid": "jchmX8upc6ZRk",
|
|
"version": 6,
|
|
"weekStart": ""
|
|
}
|