Show max power draw

This commit is contained in:
Adrian Kumpf
2020-04-14 15:29:32 +02:00
parent 74920519ed
commit c3348da859
2 changed files with 98 additions and 14 deletions
+83 -7
View File
@@ -2,6 +2,7 @@
"annotations": {
"list": [
{
"$$hashKey": "object:24",
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
@@ -15,8 +16,7 @@
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": null,
"iteration": 1569697795137,
"iteration": 1586855296897,
"links": [
{
"icon": "dashboard",
@@ -38,6 +38,7 @@
],
"panels": [
{
"datasource": null,
"gridPos": {
"h": 1,
"w": 24,
@@ -69,7 +70,6 @@
},
"id": 2,
"links": [],
"options": {},
"pageSize": 100,
"scopedVars": {
"car_id": {
@@ -81,12 +81,14 @@
"scroll": true,
"showHeader": true,
"sort": {
"col": 6,
"col": 16,
"desc": true
},
"styles": [
{
"$$hashKey": "object:391",
"alias": "Date",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -106,7 +108,9 @@
"unit": "short"
},
{
"$$hashKey": "object:392",
"alias": "Consumption",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -122,7 +126,9 @@
"unit": "kwatth"
},
{
"$$hashKey": "object:393",
"alias": "km",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -138,7 +144,9 @@
"unit": "lengthkm"
},
{
"$$hashKey": "object:394",
"alias": "kWh",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -154,7 +162,9 @@
"unit": "kwatth"
},
{
"$$hashKey": "object:395",
"alias": "Start",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -176,7 +186,9 @@
"unit": "short"
},
{
"$$hashKey": "object:396",
"alias": "Destination",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -197,7 +209,9 @@
"valueMaps": []
},
{
"$$hashKey": "object:397",
"alias": "Temp",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -213,7 +227,9 @@
"unit": "celsius"
},
{
"$$hashKey": "object:398",
"alias": "Duration",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -232,7 +248,9 @@
"unit": "m"
},
{
"$$hashKey": "object:399",
"alias": "Efficiency",
"align": "auto",
"colorMode": "value",
"colors": [
"#FFA6B0",
@@ -251,7 +269,9 @@
"unit": "percentunit"
},
{
"$$hashKey": "object:400",
"alias": "",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -267,7 +287,9 @@
"unit": "short"
},
{
"$$hashKey": "object:401",
"alias": "Speed",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -283,7 +305,9 @@
"unit": "velocitykmh"
},
{
"$$hashKey": "object:402",
"alias": "",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -299,7 +323,9 @@
"unit": "short"
},
{
"$$hashKey": "object:403",
"alias": "mi",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -315,7 +341,9 @@
"unit": "lengthmi"
},
{
"$$hashKey": "object:404",
"alias": "Temp",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -331,7 +359,9 @@
"unit": "fahrenheit"
},
{
"$$hashKey": "object:405",
"alias": "Speed",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -347,7 +377,9 @@
"unit": "velocitymph"
},
{
"$$hashKey": "object:406",
"alias": "",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -363,7 +395,9 @@
"unit": "short"
},
{
"$$hashKey": "object:407",
"alias": "",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -379,7 +413,9 @@
"unit": "short"
},
{
"$$hashKey": "object:408",
"alias": "",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -395,7 +431,9 @@
"unit": "short"
},
{
"$$hashKey": "object:409",
"alias": "Date",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -415,7 +453,9 @@
"unit": "short"
},
{
"$$hashKey": "object:410",
"alias": "",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -431,7 +471,9 @@
"unit": "percent"
},
{
"$$hashKey": "object:411",
"alias": "",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -447,7 +489,9 @@
"unit": "percent"
},
{
"$$hashKey": "object:412",
"alias": " ",
"align": "auto",
"colorMode": "value",
"colors": [
"#3274D9",
@@ -463,17 +507,21 @@
"unit": "short",
"valueMaps": [
{
"$$hashKey": "object:671",
"text": "❄",
"value": "1"
},
{
"$$hashKey": "object:672",
"text": "",
"value": "0"
}
]
},
{
"$$hashKey": "object:413",
"alias": "",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
@@ -489,18 +537,38 @@
"unit": "short"
},
{
"$$hashKey": "object:683",
"alias": "",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"decimals": 2,
"pattern": "/.*/",
"mappingType": 1,
"pattern": "",
"thresholds": [],
"type": "number",
"unit": "short"
},
{
"$$hashKey": "object:414",
"alias": "max Power",
"align": "auto",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"decimals": 0,
"pattern": "power_max",
"thresholds": [],
"type": "number",
"unit": "kwatt"
}
],
"targets": [
@@ -510,7 +578,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "WITH data AS (\n SELECT\n round(extract(epoch FROM start_date)) * 1000 AS start_date_ts,\n round(extract(epoch FROM end_date)) * 1000 AS end_date_ts,\n car.id as car_id,\n CASE WHEN start_geofence.id IS NULL THEN CONCAT('new?lat=', start_position.latitude, '&lng=', start_position.longitude)\n WHEN start_geofence.id IS NOT NULL THEN CONCAT(start_geofence.id, '/edit')\n END as start_path,\n CASE WHEN end_geofence.id IS NULL THEN CONCAT('new?lat=', end_position.latitude, '&lng=', end_position.longitude)\n WHEN end_geofence.id IS NOT NULL THEN CONCAT(end_geofence.id, '/edit')\n END as end_path,\n TO_CHAR((duration_min * INTERVAL '1 minute'), 'HH24:MI') as duration_str,\n drives.id as drive_id,\n -- Columns\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 duration_min,\n distance,\n start_position.usable_battery_level as start_usable_battery_level,\n start_position.battery_level as start_battery_level,\n end_position.usable_battery_level as end_usable_battery_level,\n end_position.battery_level as end_battery_level,\n start_position.battery_level != start_position.usable_battery_level OR end_position.battery_level != end_position.usable_battery_level as reduced_range,\n duration_min > 1 AND distance > 1 AND ( \n start_position.usable_battery_level IS NULL OR\n -- ((start_position.battery_level - start_position.usable_battery_level) = (end_position.battery_level - end_position.usable_battery_level)) OR\n (end_position.battery_level - end_position.usable_battery_level) = 0 \n ) as is_sufficiently_precise,\n NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) as range_diff,\n car.efficiency as car_efficiency,\n outside_temp_avg,\n distance / NULLIF(duration_min, 0) * 60 AS avg_speed\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 $__timeFilter(start_date) AND drives.car_id = $car_id\n ORDER BY start_date DESC\n)\nSELECT\n start_date_ts,\n end_date_ts,\n car_id,\n start_path,\n end_path,\n duration_str,\n drive_id,\n -- Columns\n start_date as start_date_[[length_unit]],\n start_address,\n end_address,\n duration_min,\n convert_km(distance, '$length_unit') AS distance_$length_unit,\n start_battery_level as \"% Start\",\n end_battery_level as \"% End\",\n convert_celsius(outside_temp_avg, '$temp_unit') AS outside_temp_$temp_unit,\n convert_km(avg_speed, '$length_unit') AS speed_avg_$length_unit,\n reduced_range as has_reduced_range,\n range_diff * car_efficiency as \"consumption_kWh\",\n CASE WHEN is_sufficiently_precise THEN range_diff * car_efficiency / distance * 100 * CASE WHEN '$length_unit' = 'km' THEN 1\n WHEN '$length_unit' = 'mi' THEN 1.60934\n END\n END AS consumption_kWh_100,\n CASE WHEN is_sufficiently_precise THEN distance / range_diff\n ELSE NULL\n END AS efficiency\nFROM data;",
"rawSql": "WITH data AS (\n SELECT\n round(extract(epoch FROM start_date)) * 1000 AS start_date_ts,\n round(extract(epoch FROM end_date)) * 1000 AS end_date_ts,\n car.id as car_id,\n CASE WHEN start_geofence.id IS NULL THEN CONCAT('new?lat=', start_position.latitude, '&lng=', start_position.longitude)\n WHEN start_geofence.id IS NOT NULL THEN CONCAT(start_geofence.id, '/edit')\n END as start_path,\n CASE WHEN end_geofence.id IS NULL THEN CONCAT('new?lat=', end_position.latitude, '&lng=', end_position.longitude)\n WHEN end_geofence.id IS NOT NULL THEN CONCAT(end_geofence.id, '/edit')\n END as end_path,\n TO_CHAR((duration_min * INTERVAL '1 minute'), 'HH24:MI') as duration_str,\n drives.id as drive_id,\n -- Columns\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 duration_min,\n distance,\n start_position.usable_battery_level as start_usable_battery_level,\n start_position.battery_level as start_battery_level,\n end_position.usable_battery_level as end_usable_battery_level,\n end_position.battery_level as end_battery_level,\n start_position.battery_level != start_position.usable_battery_level OR end_position.battery_level != end_position.usable_battery_level as reduced_range,\n duration_min > 1 AND distance > 1 AND ( \n start_position.usable_battery_level IS NULL OR\n -- ((start_position.battery_level - start_position.usable_battery_level) = (end_position.battery_level - end_position.usable_battery_level)) OR\n (end_position.battery_level - end_position.usable_battery_level) = 0 \n ) as is_sufficiently_precise,\n NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) as range_diff,\n car.efficiency as car_efficiency,\n outside_temp_avg,\n distance / NULLIF(duration_min, 0) * 60 AS avg_speed,\n power_max\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 $__timeFilter(start_date) AND drives.car_id = $car_id\n ORDER BY start_date DESC\n)\nSELECT\n start_date_ts,\n end_date_ts,\n car_id,\n start_path,\n end_path,\n duration_str,\n drive_id,\n -- Columns\n start_date as start_date_[[length_unit]],\n start_address,\n end_address,\n duration_min,\n convert_km(distance, '$length_unit') AS distance_$length_unit,\n start_battery_level as \"% Start\",\n end_battery_level as \"% End\",\n convert_celsius(outside_temp_avg, '$temp_unit') AS outside_temp_$temp_unit,\n convert_km(avg_speed, '$length_unit') AS speed_avg_$length_unit,\n power_max,\n reduced_range as has_reduced_range,\n range_diff * car_efficiency as \"consumption_kWh\",\n CASE WHEN is_sufficiently_precise THEN range_diff * car_efficiency / distance * 100 * CASE WHEN '$length_unit' = 'km' THEN 1\n WHEN '$length_unit' = 'mi' THEN 1.60934\n END\n END AS consumption_kWh_100,\n CASE WHEN is_sufficiently_precise THEN distance / range_diff\n ELSE NULL\n END AS efficiency\nFROM data;",
"refId": "A",
"select": [
[
@@ -537,7 +605,7 @@
"type": "table"
}
],
"schemaVersion": 21,
"schemaVersion": 22,
"style": "dark",
"tags": [
"tesla"
@@ -555,6 +623,7 @@
"definition": "SELECT name AS __text, id AS __value FROM cars;",
"hide": 2,
"includeAll": true,
"index": -1,
"label": "Car",
"multi": false,
"name": "car_id",
@@ -580,6 +649,7 @@
"definition": "select unit_of_temperature from settings limit 1;",
"hide": 2,
"includeAll": false,
"index": -1,
"label": "temperature unit",
"multi": false,
"name": "temp_unit",
@@ -605,6 +675,7 @@
"definition": "select unit_of_length from settings limit 1;",
"hide": 2,
"includeAll": false,
"index": -1,
"label": "length unit",
"multi": false,
"name": "length_unit",
@@ -630,6 +701,7 @@
"definition": "select preferred_range from settings limit 1;",
"hide": 2,
"includeAll": false,
"index": -1,
"label": "",
"multi": false,
"name": "preferred_range",
@@ -655,6 +727,7 @@
"definition": "select base_url from settings limit 1;",
"hide": 2,
"includeAll": false,
"index": -1,
"label": "",
"multi": false,
"name": "base_url",
@@ -704,5 +777,8 @@
"timezone": "",
"title": "Drives",
"uid": "Y8upc6ZRk",
"variables": {
"list": []
},
"version": 1
}
+15 -7
View File
@@ -2,6 +2,7 @@
"annotations": {
"list": [
{
"$$hashKey": "object:31",
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
@@ -15,7 +16,7 @@
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"iteration": 1583173648060,
"iteration": 1586855689842,
"links": [
{
"icon": "dashboard",
@@ -208,7 +209,6 @@
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"options": {},
"postfix": " $length_unit",
"postfixFontSize": "50%",
"prefix": "",
@@ -316,7 +316,6 @@
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"options": {},
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
@@ -413,10 +412,12 @@
"mappingType": 1,
"mappingTypes": [
{
"$$hashKey": "object:144",
"name": "value to text",
"value": 1
},
{
"$$hashKey": "object:145",
"name": "range to text",
"value": 2
}
@@ -424,7 +425,6 @@
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"options": {},
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
@@ -451,7 +451,7 @@
"group": [],
"metricColumn": "none",
"rawQuery": true,
"rawSql": "select duration_min * 60 from drives where id = $drive_id;",
"rawSql": "SELECT extract(epoch FROM (end_position.date - start_position.date))\nFROM drives\nLEFT JOIN positions start_position ON start_position_id = start_position.id\nLEFT JOIN positions end_position ON end_position_id = end_position.id\nWHERE drives.id = $drive_id;",
"refId": "A",
"select": [
[
@@ -483,6 +483,7 @@
"valueFontSize": "70%",
"valueMaps": [
{
"$$hashKey": "object:147",
"op": "=",
"text": "N/A",
"value": "null"
@@ -503,7 +504,6 @@
"lineColor": "red",
"links": [],
"maxDataPoints": 50000,
"options": {},
"pointColor": "royalblue",
"targets": [
{
@@ -885,7 +885,6 @@
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"options": {},
"pluginVersion": "6.6.0",
"postfix": " $length_unit",
"postfixFontSize": "50%",
@@ -990,6 +989,7 @@
"definition": "select unit_of_temperature from settings limit 1;",
"hide": 2,
"includeAll": false,
"index": -1,
"label": "",
"multi": false,
"name": "temp_unit",
@@ -1015,6 +1015,7 @@
"definition": "select unit_of_length from settings limit 1;",
"hide": 2,
"includeAll": false,
"index": -1,
"label": "",
"multi": false,
"name": "length_unit",
@@ -1041,6 +1042,7 @@
"definition": "SELECT name AS __text, id AS __value FROM cars;",
"hide": 0,
"includeAll": false,
"index": -1,
"label": "Car",
"multi": false,
"name": "car_id",
@@ -1066,6 +1068,7 @@
"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,
"index": -1,
"label": "",
"multi": false,
"name": "alternative_length_unit",
@@ -1091,6 +1094,7 @@
"definition": "select preferred_range from settings limit 1;",
"hide": 2,
"includeAll": false,
"index": -1,
"label": null,
"multi": false,
"name": "preferred_range",
@@ -1116,6 +1120,7 @@
"definition": "select base_url from settings limit 1;",
"hide": 2,
"includeAll": false,
"index": -1,
"label": "",
"multi": false,
"name": "base_url",
@@ -1165,5 +1170,8 @@
"timezone": "",
"title": "Drive Details",
"uid": "zm7wN6Zgz",
"variables": {
"list": []
},
"version": 1
}