diff --git a/dashboards/Charging Tops.json b/dashboards/Charging Tops.json index d3e0e9e..497f37f 100644 --- a/dashboards/Charging Tops.json +++ b/dashboards/Charging Tops.json @@ -1,41 +1,4 @@ { - "__inputs": [ - { - "name": "DS_TESLAMATE", - "label": "TeslaMate", - "description": "", - "type": "datasource", - "pluginId": "postgres", - "pluginName": "PostgreSQL" - } - ], - "__elements": [], - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "8.5.6" - }, - { - "type": "datasource", - "id": "postgres", - "name": "PostgreSQL", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - } - ], "annotations": { "list": [ { @@ -59,8 +22,8 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, - "id": null, - "iteration": 1670759662773, + "id": 24, + "iteration": 1672336265337, "links": [ { "icon": "dashboard", @@ -98,17 +61,109 @@ "type": "row" }, { - "datasource": { - "type": "postgres", - "uid": "${DS_TESLAMATE}" + "datasource": "TeslaMate", + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "light-orange", + "value": null + } + ] + }, + "unit": "kwatth" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 7, + "x": 0, + "y": 1 + }, + "id": 10, + "links": [], + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "fieldOptions": { + "calcs": [ + "mean" + ] + }, + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "value" }, + "pluginVersion": "8.5.6", + "targets": [ + { + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "SELECT\n\tsum(charge_energy_added)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id;\n", + "refId": "A", + "select": [ + [ + { + "params": [ + "efficiency" + ], + "type": "column" + } + ] + ], + "table": "cars", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Charged in total", + "type": "stat" + }, + { + "datasource": "TeslaMate", "fieldConfig": { "defaults": { + "color": { + "mode": "thresholds" + }, "custom": { - "align": "auto", - "displayMode": "auto", - "inspect": false + "axisLabel": "", + "axisPlacement": "hidden", + "axisSoftMin": 0, + "fillOpacity": 80, + "gradientMode": "hue", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + } }, + "decimals": 2, "mappings": [], "thresholds": { "mode": "absolute", @@ -116,102 +171,177 @@ { "color": "green", "value": null - }, - { - "color": "red", - "value": 80 } ] - } + }, + "unit": "kwatth" }, "overrides": [ { "matcher": { "id": "byName", - "options": "location" + "options": "AC" }, "properties": [ { - "id": "displayName", - "value": "Location" + "id": "color", + "value": { + "fixedColor": "#73BF69", + "mode": "fixed" + } } ] }, { "matcher": { "id": "byName", - "options": "charge_energy_added" + "options": "DC" }, "properties": [ { - "id": "displayName", - "value": "Charged" - }, - { - "id": "custom.width", - "value": 120 - }, + "id": "color", + "value": { + "fixedColor": "#FADE2A", + "mode": "fixed" + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 7, + "y": 1 + }, + "id": 46, + "links": [], + "maxDataPoints": 3, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "groupWidth": 1, + "legend": { + "calcs": [ + "sum" + ], + "displayMode": "list", + "placement": "right" + }, + "orientation": "horizontal", + "showValue": "always", + "stacking": "none", + "tooltip": { + "mode": "single", + "sort": "none" + }, + "xTickLabelRotation": 0, + "xTickLabelSpacing": 0 + }, + "pluginVersion": "8.5.6", + "targets": [ + { + "format": "time_series", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "WITH data AS (\n SELECT\n\t\tcp.id,\n\t\tcp.charge_energy_added,\n\t\tCASE WHEN NULLIF(mode() within group (order by charger_phases),0) is null THEN 'DC'\n\t\t\t\t ELSE 'AC'\n\t\tEND AS current\n\tFROM charging_processes cp\n RIGHT JOIN charges ON cp.id = charges.charging_process_id\n WHERE\n\t cp.car_id = $car_id\n\t AND cp.charge_energy_added > 0.01\n\t AND $__timeFilter(start_date)\n GROUP BY 1,2\n)\nSELECT\n\tnow() AS time,\n\tsum(charge_energy_added) AS value,\n\tcurrent AS metric\nFROM data\nGROUP BY 3\nORDER BY metric DESC;", + "refId": "A", + "select": [ + [ { - "id": "custom.align", - "value": "left" + "params": [ + "latitude" + ], + "type": "column" } ] - }, - { - "matcher": { - "id": "byName", - "options": "cost" - }, - "properties": [ + ], + "table": "addresses", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "AC/DC – Energy added", + "type": "barchart" + }, + { + "datasource": "TeslaMate", + "fieldConfig": { + "defaults": { + "decimals": 2, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ { - "id": "custom.hidden", - "value": true + "color": "red", + "value": null } ] - } - ] + }, + "unit": "€" + }, + "overrides": [] }, "gridPos": { - "h": 12, + "h": 3, "w": 9, - "x": 0, + "x": 15, "y": 1 }, - "id": 4, + "id": 27, + "links": [], + "maxDataPoints": 100, "options": { - "footer": { - "fields": "", - "reducer": [ - "sum" + "colorMode": "value", + "fieldOptions": { + "calcs": [ + "mean" + ] + }, + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" ], - "show": false + "fields": "", + "values": false }, - "showHeader": true + "textMode": "value" }, "pluginVersion": "8.5.6", "targets": [ { - "datasource": { - "type": "postgres", - "uid": "${DS_TESLAMATE}" - }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n\tCASE\n WHEN SUM(charge_energy_added) < 1000 THEN SUM(charge_energy_added)::NUMERIC(4,0)::VARCHAR || ' kWh' \n WHEN SUM(charge_energy_added) < 1000000 THEN (SUM(charge_energy_added) / 1000)::NUMERIC(9, 3)::VARCHAR || ' MWh' \n WHEN SUM(charge_energy_added) >= 1000000 THEN (SUM(charge_energy_added) / 1000000)::NUMERIC(9, 3)::VARCHAR || ' GWh' \n END as charge_energy_added, sum(cost) as cost\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND cost > 0\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_added) DESC\nLIMIT 10;", + "rawSql": "SELECT\n\tsum(cost)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id;", "refId": "A", "select": [ [ { "params": [ - "value" + "latitude" ], "type": "column" } ] ], - "timeColumn": "time", + "table": "addresses", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", @@ -221,13 +351,13 @@ ] } ], - "title": "Top Payment Stations (Charged)", - "type": "table" + "title": "Total Charging Cost", + "type": "stat" }, { "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "fieldConfig": { "defaults": { @@ -236,7 +366,7 @@ "mode": "absolute", "steps": [ { - "color": "#c7d0d9", + "color": "green", "value": null } ] @@ -247,11 +377,11 @@ }, "gridPos": { "h": 3, - "w": 5, - "x": 9, - "y": 1 + "w": 7, + "x": 0, + "y": 4 }, - "id": 10, + "id": 33, "links": [], "maxDataPoints": 100, "options": { @@ -276,11 +406,15 @@ "pluginVersion": "8.5.6", "targets": [ { + "datasource": { + "type": "postgres", + "uid": "PC98BA2F4D77E1A42" + }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\tsum(charge_energy_added)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id;\n", + "rawSql": "SELECT\n\tsum(charge_energy_added)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND cost = 0;\n", "refId": "A", "select": [ [ @@ -301,131 +435,170 @@ "params": [], "type": "macro" } - ], - "datasource": { - "type": "postgres", - "uid": "${DS_TESLAMATE}" - } + ] } ], - "title": "Charged in total", + "title": "Free charged in total", "type": "stat" }, { "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "fieldConfig": { "defaults": { - "custom": { - "align": "auto", - "displayMode": "auto", - "inspect": false - }, + "decimals": 2, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green", + "color": "#c7d0d9", "value": null - }, - { - "color": "red", - "value": 80 } ] - } + }, + "unit": "€" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "location" - }, - "properties": [ + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 15, + "y": 4 + }, + "id": 14, + "links": [], + "maxDataPoints": 100, + "options": { + "colorMode": "value", + "fieldOptions": { + "calcs": [ + "mean" + ] + }, + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "value" + }, + "pluginVersion": "8.5.6", + "targets": [ + { + "datasource": "TeslaMate", + "format": "table", + "group": [], + "metricColumn": "none", + "rawQuery": true, + "rawSql": "WITH data AS (\n\tSELECT c.charging_process_id \n\tFROM charges c\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\n\tLEFT JOIN addresses addr ON addr.id = cp.address_id\n\tLEFT JOIN geofences geo ON geo.id = geofence_id\n\tWHERE \n\t\tc.fast_charger_present IS true\n\t\tAND c.charger_voltage = 2\n\t\tAND cp.car_id = $car_id\n\t\tAND (addr.name LIKE '%Supercharger%' OR geo.name LIKE '%Supercharger%')\n\tGROUP BY 1\n)\nSELECT\n\tsum(cp.cost) as total\nFROM\n\tcharging_processes cp, data\nWHERE\n $__timeFilter(end_date)\n AND cp.cost IS NOT NULL\n AND cp.id IN (data.charging_process_id);", + "refId": "A", + "select": [ + [ { - "id": "displayName", - "value": "Location" + "params": [ + "latitude" + ], + "type": "column" } ] - }, - { - "matcher": { - "id": "byName", - "options": "charge_energy_added" - }, - "properties": [ - { - "id": "displayName", - "value": "Charged" - }, - { - "id": "custom.width", - "value": 120 - }, + ], + "table": "addresses", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", + "where": [ + { + "name": "$__timeFilter", + "params": [], + "type": "macro" + } + ] + } + ], + "title": "Charging Cost at SuC", + "type": "stat" + }, + { + "datasource": { + "type": "postgres", + "uid": "PC98BA2F4D77E1A42" + }, + "fieldConfig": { + "defaults": { + "decimals": 2, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ { - "id": "custom.align", - "value": "left" + "color": "#c7d0d9", + "value": null } ] }, - { - "matcher": { - "id": "byName", - "options": "cost" - }, - "properties": [ - { - "id": "custom.hidden", - "value": true - } - ] - } - ] + "unit": "€" + }, + "overrides": [] }, "gridPos": { - "h": 12, - "w": 9, - "x": 14, - "y": 1 + "h": 3, + "w": 3, + "x": 18, + "y": 4 }, - "id": 32, + "id": 40, + "links": [], + "maxDataPoints": 100, "options": { - "footer": { - "fields": "", - "reducer": [ - "sum" + "colorMode": "value", + "fieldOptions": { + "calcs": [ + "mean" + ] + }, + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" ], - "show": false + "fields": "", + "values": false }, - "showHeader": true + "textMode": "value" }, "pluginVersion": "8.5.6", "targets": [ { - "datasource": { - "type": "postgres", - "uid": "${DS_TESLAMATE}" - }, + "datasource": "TeslaMate", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n\tCASE\n WHEN SUM(charge_energy_added) < 1000 THEN SUM(charge_energy_added)::NUMERIC(4,0)::VARCHAR || ' kWh' \n WHEN SUM(charge_energy_added) < 1000000 THEN (SUM(charge_energy_added) / 1000)::NUMERIC(9, 3)::VARCHAR || ' MWh' \n WHEN SUM(charge_energy_added) >= 1000000 THEN (SUM(charge_energy_added) / 1000000)::NUMERIC(9, 3)::VARCHAR || ' GWh' \n END as charge_energy_added, sum(cost) as cost\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND cost = 0\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_added) DESC\nLIMIT 10;", + "rawSql": "WITH data AS (\n\tSELECT c.charging_process_id \n\tFROM charges c\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\n\tLEFT JOIN addresses addr ON addr.id = cp.address_id\n\tLEFT JOIN geofences geo ON geo.id = geofence_id\n\tWHERE \n\t\tc.fast_charger_present IS true\n\t\tAND c.charger_voltage = 2\n\t\tAND cp.car_id = $car_id\n\t\tAND (addr.name NOT LIKE '%Supercharger%' OR geo.name NOT LIKE '%Supercharger%')\n\tGROUP BY 1\n)\nSELECT\n\tsum(cp.cost) as total\nFROM\n\tcharging_processes cp, data\nWHERE\n $__timeFilter(end_date)\n AND cp.cost IS NOT NULL\n AND cp.id IN (data.charging_process_id);", "refId": "A", "select": [ [ { "params": [ - "value" + "latitude" ], "type": "column" } ] ], - "timeColumn": "time", + "table": "addresses", + "timeColumn": "inserted_at", + "timeColumnType": "timestamp", "where": [ { "name": "$__timeFilter", @@ -435,16 +608,17 @@ ] } ], - "title": "Top Free Stations (Charged)", - "type": "table" + "title": "Cost in other DC", + "type": "stat" }, { "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "fieldConfig": { "defaults": { + "decimals": 2, "mappings": [], "thresholds": { "mode": "absolute", @@ -455,17 +629,17 @@ } ] }, - "unit": "kwatth" + "unit": "€" }, "overrides": [] }, "gridPos": { "h": 3, - "w": 5, - "x": 9, + "w": 3, + "x": 21, "y": 4 }, - "id": 33, + "id": 47, "links": [], "maxDataPoints": 100, "options": { @@ -490,27 +664,24 @@ "pluginVersion": "8.5.6", "targets": [ { - "datasource": { - "type": "postgres", - "uid": "${DS_TESLAMATE}" - }, + "datasource": "TeslaMate", "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\tsum(charge_energy_added)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND cost = 0;\n", + "rawSql": "WITH data AS (\n\tSELECT c.charging_process_id \n\tFROM charges c\n\tLEFT JOIN charging_processes cp ON cp.id = c.charging_process_id\n\tWHERE \n\t\tc.fast_charger_present IS NOT true\n\t\tAND c.charger_voltage != 2\n\t\tAND cp.car_id = $car_id\n\tGROUP BY 1\n)\nSELECT\n\tsum(cp.cost) as total\nFROM\n\tcharging_processes cp, data\nWHERE\n $__timeFilter(end_date)\n AND cp.cost IS NOT NULL\n AND cp.id IN (data.charging_process_id);", "refId": "A", "select": [ [ { "params": [ - "efficiency" + "latitude" ], "type": "column" } ] ], - "table": "cars", + "table": "addresses", "timeColumn": "inserted_at", "timeColumnType": "timestamp", "where": [ @@ -522,173 +693,251 @@ ] } ], - "title": "Free charged in total", + "title": "AC Charging Cost", "type": "stat" }, { "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "fieldConfig": { "defaults": { - "decimals": 2, + "custom": { + "align": "auto", + "displayMode": "auto", + "inspect": false + }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "#c7d0d9", + "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] - }, - "unit": "€" + } }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "location" + }, + "properties": [ + { + "id": "displayName", + "value": "Location" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "charge_energy_added" + }, + "properties": [ + { + "id": "displayName", + "value": "Charged" + }, + { + "id": "custom.width", + "value": 120 + }, + { + "id": "custom.align", + "value": "left" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "cost" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] }, "gridPos": { - "h": 3, - "w": 5, - "x": 9, + "h": 12, + "w": 8, + "x": 0, "y": 7 }, - "id": 27, - "links": [], - "maxDataPoints": 100, + "id": 32, "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "mean" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], + "footer": { "fields": "", - "values": false + "reducer": [ + "sum" + ], + "show": false }, - "textMode": "value" + "showHeader": true }, "pluginVersion": "8.5.6", "targets": [ { + "datasource": { + "type": "postgres", + "uid": "PC98BA2F4D77E1A42" + }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\tsum(cost)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id;", + "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n\tCASE\n WHEN SUM(charge_energy_added) < 1000 THEN SUM(charge_energy_added)::NUMERIC(4,0)::VARCHAR || ' kWh' \n WHEN SUM(charge_energy_added) < 1000000 THEN (SUM(charge_energy_added) / 1000)::NUMERIC(9, 3)::VARCHAR || ' MWh' \n WHEN SUM(charge_energy_added) >= 1000000 THEN (SUM(charge_energy_added) / 1000000)::NUMERIC(9, 3)::VARCHAR || ' GWh' \n END as charge_energy_added, sum(cost) as cost\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND cost = 0\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_added) DESC\nLIMIT 10;", "refId": "A", "select": [ [ { "params": [ - "latitude" + "value" ], "type": "column" } ] ], - "table": "addresses", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", + "timeColumn": "time", "where": [ { "name": "$__timeFilter", "params": [], "type": "macro" } - ], - "datasource": { - "type": "postgres", - "uid": "${DS_TESLAMATE}" - } + ] } ], - "title": "Total Charging Cost", - "type": "stat" + "title": "Top Free Stations", + "type": "table" }, { "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "fieldConfig": { "defaults": { - "decimals": 2, + "custom": { + "align": "auto", + "displayMode": "auto", + "inspect": false + }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "#c7d0d9", + "color": "green", "value": null + }, + { + "color": "red", + "value": 80 } ] - }, - "unit": "€" + } }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "location" + }, + "properties": [ + { + "id": "displayName", + "value": "Location" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "charge_energy_added" + }, + "properties": [ + { + "id": "displayName", + "value": "Charged" + }, + { + "id": "custom.width", + "value": 120 + }, + { + "id": "custom.align", + "value": "left" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "cost" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] }, "gridPos": { - "h": 3, - "w": 5, - "x": 9, - "y": 10 + "h": 12, + "w": 8, + "x": 8, + "y": 7 }, - "id": 14, - "links": [], - "maxDataPoints": 100, + "id": 34, "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "mean" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], + "footer": { "fields": "", - "values": false + "reducer": [ + "sum" + ], + "show": false }, - "textMode": "value" + "showHeader": true }, "pluginVersion": "8.5.6", "targets": [ { "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\tsum(cp.cost)\nFROM\n\tcharging_processes cp\nLEFT JOIN \n\taddresses addr ON addr.id = address_id\nLEFT JOIN\n geofences geo ON geo.id = geofence_id\nWHERE\n $__timeFilter(end_date)\n AND (addr.name LIKE '%Supercharger%' OR geo.name LIKE '%Supercharger%')\n\tAND cp.cost IS NOT NULL\n\tAND cp.car_id = $car_id;", + "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n\tCASE\n WHEN SUM(charge_energy_added) < 1000 THEN SUM(charge_energy_added)::NUMERIC(4,0)::VARCHAR || ' kWh' \n WHEN SUM(charge_energy_added) < 1000000 THEN (SUM(charge_energy_added) / 1000)::NUMERIC(9, 3)::VARCHAR || ' MWh' \n WHEN SUM(charge_energy_added) >= 1000000 THEN (SUM(charge_energy_added) / 1000000)::NUMERIC(9, 3)::VARCHAR || ' GWh' \n END as charge_energy_added, sum(cost) as cost\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND (address.display_name LIKE '%Supercharger%' OR address.name LIKE '%Supercharger%')\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_added) DESC\nLIMIT 10;", "refId": "A", "select": [ [ { "params": [ - "latitude" + "value" ], "type": "column" } ] ], - "table": "addresses", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", + "timeColumn": "time", "where": [ { "name": "$__timeFilter", @@ -698,13 +947,13 @@ ] } ], - "title": "Charging Cost at SuC", - "type": "stat" + "title": "Top SuperCharger Stations", + "type": "table" }, { "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "fieldConfig": { "defaults": { @@ -726,7 +975,8 @@ "value": 80 } ] - } + }, + "unit": " €" }, "overrides": [ { @@ -757,7 +1007,7 @@ }, { "id": "custom.align", - "value": "left" + "value": "right" } ] }, @@ -769,7 +1019,15 @@ "properties": [ { "id": "custom.hidden", - "value": true + "value": false + }, + { + "id": "displayName", + "value": "Cost" + }, + { + "id": "custom.width", + "value": 120 } ] } @@ -777,11 +1035,11 @@ }, "gridPos": { "h": 12, - "w": 9, - "x": 0, - "y": 13 + "w": 8, + "x": 16, + "y": 7 }, - "id": 34, + "id": 4, "options": { "footer": { "fields": "", @@ -797,13 +1055,13 @@ { "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "format": "table", "group": [], "metricColumn": "none", "rawQuery": true, - "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n\tCASE\n WHEN SUM(charge_energy_added) < 1000 THEN SUM(charge_energy_added)::NUMERIC(4,0)::VARCHAR || ' kWh' \n WHEN SUM(charge_energy_added) < 1000000 THEN (SUM(charge_energy_added) / 1000)::NUMERIC(9, 3)::VARCHAR || ' MWh' \n WHEN SUM(charge_energy_added) >= 1000000 THEN (SUM(charge_energy_added) / 1000000)::NUMERIC(9, 3)::VARCHAR || ' GWh' \n END as charge_energy_added, sum(cost) as cost\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND (address.display_name LIKE '%Supercharger%' OR address.name LIKE '%Supercharger%')\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_added) DESC\nLIMIT 10;", + "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS location,\n\tCASE\n WHEN SUM(charge_energy_added) < 1000 THEN SUM(charge_energy_added)::NUMERIC(4,0)::VARCHAR || ' kWh' \n WHEN SUM(charge_energy_added) < 1000000 THEN (SUM(charge_energy_added) / 1000)::NUMERIC(9, 3)::VARCHAR || ' MWh' \n WHEN SUM(charge_energy_added) >= 1000000 THEN (SUM(charge_energy_added) / 1000000)::NUMERIC(9, 3)::VARCHAR || ' GWh' \n END as charge_energy_added, sum(cost) as cost\nFROM\n\tcharging_processes c\nLEFT JOIN addresses address ON c.address_id = address.id\nLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n\t$__timeFilter(end_date)\n\tAND car_id = $car_id\n\tAND cost > 0\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_added) DESC\nLIMIT 10;", "refId": "A", "select": [ [ @@ -825,7 +1083,7 @@ ] } ], - "title": "Top SuperCharger Stations (Charged)", + "title": "Top Payment Stations", "type": "table" } ], @@ -838,10 +1096,14 @@ "templating": { "list": [ { - "current": {}, + "current": { + "selected": false, + "text": "All", + "value": "$__all" + }, "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", "hide": 2, @@ -861,10 +1123,14 @@ "useTags": false }, { - "current": {}, + "current": { + "selected": false, + "text": "http://192.168.2.249:4000", + "value": "http://192.168.2.249:4000" + }, "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "definition": "select base_url from settings limit 1;", "hide": 2, @@ -884,10 +1150,14 @@ "useTags": false }, { - "current": {}, + "current": { + "selected": false, + "text": "km", + "value": "km" + }, "datasource": { "type": "postgres", - "uid": "${DS_TESLAMATE}" + "uid": "PC98BA2F4D77E1A42" }, "definition": "select unit_of_length from settings limit 1;", "hide": 2, @@ -940,6 +1210,6 @@ "timezone": "", "title": "Charging Tops", "uid": "DdLe5uFVk", - "version": 11, + "version": 12, "weekStart": "" } \ No newline at end of file diff --git a/screenshots/charging_tops.png b/screenshots/charging_tops.png index 64044c9..5059ea2 100644 Binary files a/screenshots/charging_tops.png and b/screenshots/charging_tops.png differ