From e8a7247e8a427f4dc127898c112270d25162c874 Mon Sep 17 00:00:00 2001 From: Matthias Wirtz Date: Sun, 16 Jun 2024 16:59:06 +0200 Subject: [PATCH] Remove LFP Dashboards --- CHANGELOG.md | 1 + grafana/dashboards/battery-health-lfp.json | 1512 ------------- grafana/dashboards/battery-health.json | 108 +- grafana/dashboards/charge-level.json | 137 +- grafana/dashboards/charging-stats-lfp.json | 2276 -------------------- grafana/dashboards/charging-stats.json | 488 ++++- grafana/dashboards/overview-lfp.json | 1699 --------------- grafana/dashboards/overview.json | 494 ++++- grafana/datasource.yml | 32 +- 9 files changed, 990 insertions(+), 5757 deletions(-) delete mode 100644 grafana/dashboards/battery-health-lfp.json delete mode 100644 grafana/dashboards/charging-stats-lfp.json delete mode 100644 grafana/dashboards/overview-lfp.json diff --git a/CHANGELOG.md b/CHANGELOG.md index bf50d28b99..68e258ec58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Projected Range fix (using usable_battery_level) (#3859 -@woyteck1) - Update and fix timeline dashboard (#3951 -@jheredianet) - Remove A lot of empty space on the drive graph (#3950 -@jheredianet) +- Integrate LFP specific dashboards into regular dashboards (#3966 - @swiffer) #### Translations diff --git a/grafana/dashboards/battery-health-lfp.json b/grafana/dashboards/battery-health-lfp.json deleted file mode 100644 index b6afd03739..0000000000 --- a/grafana/dashboards/battery-health-lfp.json +++ /dev/null @@ -1,1512 +0,0 @@ -{ - "__elements": [], - "__requires": [ - { - "type": "panel", - "id": "bargauge", - "name": "Bar gauge", - "version": "" - }, - { - "type": "panel", - "id": "gauge", - "name": "Gauge", - "version": "" - }, - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "8.5.15" - }, - { - "type": "panel", - "id": "piechart", - "name": "Pie chart", - "version": "" - }, - { - "type": "datasource", - "id": "postgres", - "name": "PostgreSQL", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": { - "type": "grafana", - "uid": "-- Grafana --" - }, - "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, - "iteration": 1681039491922, - "links": [ - { - "icon": "dashboard", - "tags": [], - "title": "TeslaMate", - "tooltip": "", - "type": "link", - "url": "[[base_url:raw]]" - }, - { - "asDropdown": true, - "icon": "external link", - "tags": [ - "tesla" - ], - "title": "Dashboards", - "type": "dashboards" - } - ], - "liveNow": false, - "panels": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "description": "**Usable (now)** is the estimated current battery capacity. \n\n**Usable (new)** is the estimated Battery Capacity since you begun to use Teslamate. That's why, the more data you have logged from your brand new car the better. ", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 1, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "super-light-blue", - "value": null - } - ] - }, - "unit": "kwatth" - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 6, - "x": 0, - "y": 0 - }, - "id": 13, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "8.5.15", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT \n CASE WHEN $custom_kwh_new > 0 THEN $custom_kwh_new ELSE ('$aux'::json -> 'MaxCapacity')::text::float END as \"Usable (new)\", \n ('$aux'::json -> 'CurrentCapacity')::text::float as \"Usable (now)\",\n ('$aux'::json -> 'CurrentCapacity')::text::float - CASE WHEN $custom_kwh_new > 0 THEN $custom_kwh_new ELSE ('$aux'::json -> 'MaxCapacity')::text::float END as \"Difference\"\n \n \n \n \n \n \n ", - "refId": "A", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Battery Capacity", - "type": "stat" - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 1, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "super-light-blue", - "value": null - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/.*_km/" - }, - "properties": [ - { - "id": "unit", - "value": "lengthkm" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/.*_mi/" - }, - "properties": [ - { - "id": "unit", - "value": "lengthmi" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/maxrange_.*/" - }, - "properties": [ - { - "id": "displayName", - "value": "Max range (new)" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/currentrange_.*/" - }, - "properties": [ - { - "id": "displayName", - "value": "Max range (now)" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/range_lost.*/" - }, - "properties": [ - { - "id": "displayName", - "value": "Range lost" - } - ] - } - ] - }, - "gridPos": { - "h": 6, - "w": 6, - "x": 6, - "y": 0 - }, - "id": 14, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "8.5.15", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT \n CASE WHEN $custom_max_range > 0 THEN $custom_max_range ELSE ('$aux'::json -> 'MaxRange')::text::float END as \"maxrange_$length_unit\",\n ('$aux'::json -> 'CurrentRange')::text::float as \"currentrange_$length_unit\",\n CASE WHEN $custom_max_range > 0 THEN $custom_max_range ELSE ('$aux'::json -> 'MaxRange')::text::float END - ('$aux'::json -> 'CurrentRange')::text::float as \"range_lost_$length_unit\"", - "refId": "A", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Ranges", - "type": "stat" - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "super-light-blue", - "value": null - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 6, - "x": 12, - "y": 0 - }, - "id": 32, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "/.*/", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "8.5.15", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT ROUND(convert_km((max(odometer) - min(odometer))::numeric, '$length_unit'),0)|| ' $length_unit' as \"Logged\"\nfrom positions where car_id = $car_id;", - "refId": "DistanceLogged", - "select": [ - [ - { - "params": [ - "efficiency" - ], - "type": "column" - } - ] - ], - "table": "cars", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "rawQuery": true, - "rawSql": "select ROUND(convert_km(ROUND(odometer::numeric,0), '$length_unit'),0) || ' $length_unit' as \"Odometer\"\nfrom positions \nwhere car_id = $car_id\norder by date desc \nlimit 1;", - "refId": "Odometer", - "select": [ - [ - { - "params": [ - "efficiency" - ], - "type": "column" - } - ] - ], - "table": "cars", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Mileage", - "type": "stat" - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "description": "", - "fieldConfig": { - "defaults": { - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "light-yellow", - "value": null - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Total energy added" - }, - "properties": [ - { - "id": "unit", - "value": "kwatth" - } - ] - } - ] - }, - "gridPos": { - "h": 6, - "w": 6, - "x": 18, - "y": 0 - }, - "id": 36, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "mean" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "8.5.15", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\tsum(charge_energy_added) as \"Total energy added\"\nFROM\n\tcharging_processes\nWHERE\n\tcar_id = $car_id;", - "refId": "A", - "select": [ - [ - { - "params": [ - "efficiency" - ], - "type": "column" - } - ] - ], - "table": "cars", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\tround(ceil(sum(charge_energy_added) / ('$aux'::json -> 'MaxCapacity')::text::numeric),0) AS \"Estimated charging cycles\"\nFROM charging_processes WHERE car_id = $car_id;", - "refId": "B", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Battery Stats", - "type": "stat" - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "description": "This dashboard is meant to have a look of the Battery health based on the data logged in Teslamate. So, the more data you have logged from your brand new car the better.\n\n**Degradation** is just an estimated value to have a reference, measured on **usable battery level** of every charging session with enough kWh added (in order to avoid dirty data form the sample), calculated according to the rated efficiency of the car.", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 1, - "mappings": [], - "max": 100, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "#EAB839", - "value": 10 - }, - { - "color": "red", - "value": 20 - }, - { - "color": "dark-red", - "value": 30 - } - ] - }, - "unit": "%" - }, - "overrides": [] - }, - "gridPos": { - "h": 7, - "w": 6, - "x": 0, - "y": 6 - }, - "id": 17, - "options": { - "orientation": "auto", - "reduceOptions": { - "calcs": [], - "fields": "/^greatest$/", - "values": false - }, - "showThresholdLabels": false, - "showThresholdMarkers": true - }, - "pluginVersion": "8.5.15", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT GREATEST(0, 100.0 - (('$aux'::json -> 'CurrentCapacity')::text::float * 100.0 / CASE WHEN $custom_kwh_new > 0 THEN $custom_kwh_new ELSE ('$aux'::json -> 'MaxCapacity')::text::float END))\n\n", - "refId": "A", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Estimated Degradation", - "type": "gauge" - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 1, - "mappings": [], - "max": 100, - "min": 1, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "light-red", - "value": null - }, - { - "color": "#EAB839", - "value": 80 - }, - { - "color": "light-green", - "value": 90 - } - ] - }, - "unit": "%" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 6, - "y": 6 - }, - "id": 12, - "options": { - "displayMode": "gradient", - "minVizHeight": 10, - "minVizWidth": 0, - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "showUnfilled": true - }, - "pluginVersion": "8.5.15", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT \n LEAST(100, (100 - GREATEST(0, 100.0 - (('$aux'::json -> 'CurrentCapacity')::text::float * 100.0 / CASE WHEN $custom_kwh_new > 0 THEN $custom_kwh_new ELSE ('$aux'::json -> 'MaxCapacity')::text::float END)))) as \"Battery Health (%)\"\n \n", - "refId": "A", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Battery Health", - "type": "bargauge" - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "description": "Estimated charging cycles are based on the whole energy added to the battery. So the more data you logged the better. \n", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "super-light-blue", - "value": null - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 7, - "w": 6, - "x": 12, - "y": 6 - }, - "id": 29, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "/.*/", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "8.5.15", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT \n round(('$aux'::json -> 'LastChargekWhAdded')::text::numeric,1) || ' kWh' as \"Last Energy added\",\n round(('$aux'::json -> 'LastMileageAdded')::text::numeric,1) || ' $length_unit' as \"Last Range added\"", - "refId": "LastChanging", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Charges", - "type": "stat" - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - } - }, - "decimals": 2, - "mappings": [], - "unit": "kwatth" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "AC" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "semi-dark-green", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "DC" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "light-orange", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 7, - "w": 6, - "x": 18, - "y": 6 - }, - "id": 34, - "links": [], - "maxDataPoints": 3, - "options": { - "displayLabels": [ - "name", - "percent", - "value" - ], - "legend": { - "displayMode": "hidden", - "placement": "bottom" - }, - "pieType": "pie", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "8.5.6", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "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 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": [ - [ - { - "params": [ - "latitude" - ], - "type": "column" - } - ] - ], - "table": "addresses", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Summary AC/DC Energy Added", - "type": "piechart" - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 1, - "mappings": [], - "max": 100, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "dark-red", - "value": null - }, - { - "color": "semi-dark-green", - "value": 20 - } - ] - }, - "unit": "%" - }, - "overrides": [] - }, - "gridPos": { - "h": 2, - "w": 6, - "x": 6, - "y": 9 - }, - "id": 25, - "options": { - "displayMode": "lcd", - "minVizHeight": 10, - "minVizWidth": 0, - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "showUnfilled": true, - "text": {} - }, - "pluginVersion": "8.5.15", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "groupBy": [ - { - "params": [ - "$__interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "measurement": "%", - "metricColumn": "none", - "orderByTime": "ASC", - "policy": "default", - "rawQuery": true, - "rawSql": "(SELECT usable_battery_level, date\r\nFROM positions\r\nWHERE car_id = $car_id\r\nORDER BY date DESC\r\nLIMIT 1)\r\nUNION\r\nSELECT usable_battery_level, date\r\nFROM charges c\r\nJOIN charging_processes p ON p.id = c.charging_process_id\r\nWHERE p.car_id = $car_id\r\nORDER BY date DESC\r\nLIMIT 1", - "refId": "SOC", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Current SOC", - "type": "bargauge" - }, - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 1, - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "dark-red", - "value": null - }, - { - "color": "dark-green", - "value": 7.84 - }, - { - "color": "semi-dark-orange", - "value": 31.36 - }, - { - "color": "light-blue", - "value": 35.28 - } - ] - }, - "unit": "kwatth" - }, - "overrides": [] - }, - "gridPos": { - "h": 2, - "w": 6, - "x": 6, - "y": 11 - }, - "id": 27, - "options": { - "displayMode": "gradient", - "minVizHeight": 10, - "minVizWidth": 0, - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "/^kwh$/", - "values": false - }, - "showUnfilled": true, - "text": {} - }, - "pluginVersion": "8.5.15", - "targets": [ - { - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "format": "table", - "group": [], - "groupBy": [ - { - "params": [ - "$__interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "measurement": "%", - "metricColumn": "none", - "orderByTime": "ASC", - "policy": "default", - "rawQuery": true, - "rawSql": "(SELECT usable_battery_level * ('$aux'::json -> 'CurrentCapacity')::text::float / 100 as kWh, date, ('$aux'::json -> 'CurrentCapacity')::text::float as Total\nFROM positions\nWHERE car_id = $car_id\nORDER BY date DESC\nLIMIT 1)\nUNION\nSELECT battery_level * ('$aux'::json -> 'CurrentCapacity')::text::float / 100 as kWh, date, ('$aux'::json -> 'CurrentCapacity')::text::float as Total\nFROM charges c\nJOIN charging_processes p ON p.id = c.charging_process_id\nWHERE p.car_id = $car_id\nORDER BY date DESC\nLIMIT 1", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Current Capacity", - "type": "bargauge" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "pointSize": { - "fixed": 6 - }, - "scaleDistribution": { - "type": "linear" - }, - "show": "points" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byFrameRefID", - "options": "Median" - }, - "properties": [ - { - "id": "custom.lineWidth", - "value": 2 - }, - { - "id": "custom.show", - "value": "lines" - }, - { - "id": "custom.lineStyle", - "value": { - "fill": "solid" - } - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 13 - }, - "id": 28, - "links": [], - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "series": [ - { - "pointColor": { - "field": "kWh" - }, - "x": "odometer", - "y": "kWh" - }, - { - "pointColor": { - "fixed": "dark-red" - }, - "x": "M-Odometer", - "y": "M-kWh" - } - ], - "seriesMapping": "manual", - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "pluginVersion": "8.5.6", - "targets": [ - { - "alias": "", - "datasource": "TeslaMate", - "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT convert_km(AVG(p.odometer)::numeric,'$length_unit') AS odometer, \r\n\tAVG(c.rated_battery_range_km) * ('$aux'::json -> 'RatedEfficiency')::text::float / AVG(c.usable_battery_level) AS \"kWh\",\r\n\tMAX(cp.id) AS id,\r\n\tto_char(cp.end_date, 'YYYY-MM-dd') AS Title\r\n\tFROM charging_processes cp\r\n\t\tJOIN (SELECT charging_process_id, MAX(date) as date\tFROM charges GROUP BY charging_process_id) AS last_charges\tON cp.id = last_charges.charging_process_id\r\n\t\tINNER JOIN charges c\r\n\t\tON c.charging_process_id = cp.id AND c.date = last_charges.date\r\n\t\tINNER JOIN positions p ON p.id = cp.position_id\r\n\tWHERE cp.car_id = $car_id\r\n\t\tAND cp.end_date IS NOT NULL\r\n\t\tAND cp.end_rated_range_km > cp.start_rated_range_km\r\n\tGROUP BY 4", - "refId": "Projected Range", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "column" - } - ] - ], - "timeColumn": "time", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - }, - { - "alias": "", - "datasource": "TeslaMate", - "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT \n ROUND(MIN(convert_km(p.odometer::numeric,'$length_unit')),0) AS \"M-Odometer\",\n\tROUND(PERCENTILE_CONT(0.5) WITHIN GROUP(ORDER BY c.rated_battery_range_km * ('$aux'::json -> 'RatedEfficiency')::text::float / c.usable_battery_level)::numeric,1) AS \"M-kWh\",\n\tto_char(cp.end_date, 'YYYYMM') || CASE WHEN to_char(cp.end_date, 'DD')::int <= 15 THEN '1' ELSE '2' END AS Title\n\tFROM charging_processes cp\n\t\tJOIN (SELECT charging_process_id, MAX(date) as date\tFROM charges GROUP BY charging_process_id) AS last_charges\tON cp.id = last_charges.charging_process_id\n\t\tINNER JOIN charges c\n\t\tON c.charging_process_id = cp.id AND c.date = last_charges.date\n\t\tINNER JOIN positions p ON p.id = cp.position_id\n\tWHERE cp.car_id = $car_id\n\t\tAND cp.end_date IS NOT NULL\n\t\tAND cp.end_rated_range_km > cp.start_rated_range_km\n\tGROUP BY 3", - "refId": "Median", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Battery Capacity by Mileage", - "type": "xychart" - } - ], - "refresh": "", - "schemaVersion": 36, - "style": "dark", - "tags": [ - "tesla" - ], - "templating": { - "list": [ - { - "current": {}, - "datasource": { - "type": "postgres", - "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": "postgres", - "uid": "TeslaMate" - }, - "definition": "select unit_of_length from settings limit 1;", - "hide": 2, - "includeAll": false, - "label": "", - "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": "postgres", - "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": {}, - "datasource": { - "type": "postgres", - "uid": "TeslaMate" - }, - "definition": "-- CONCATENATED JOIN QUERIES TO IMPROVE PERFORMANCE\nWITH\naux\tAS\n(\n\tSELECT cp.charge_energy_added,\n\t\tcp.car_id, cp.charge_energy_added / (cp.end_rated_range_km - cp.start_rated_range_km) * 100.0 AS rated_efficiency,\n\t\t(cp.end_rated_range_km - cp.start_rated_range_km) AS added_range_km\n\tFROM charging_processes cp\n\t\tJOIN (SELECT charging_process_id, MAX(date) as date\n\t\tFROM charges\n\t\tGROUP BY charging_process_id) AS last_charges\n\t\tON cp.id = last_charges.charging_process_id\n\t\tINNER JOIN charges c\n\t\tON c.charging_process_id = cp.id AND c.date = last_charges.date\n\tWHERE cp.car_id = $car_id\n\t\tAND cp.end_date IS NOT NULL\n\t\tAND cp.end_rated_range_km > cp.start_rated_range_km\n\tORDER BY cp.end_date DESC \n\tLIMIT 1\n), \nCurrentCapacity\t AS\n(\n\tSELECT AVG(Capacity) AS CurrentCapacity FROM\n (SELECT (100.0 * cp.charge_energy_added) / (GREATEST(1,MAX(usable_battery_level) - MIN(usable_battery_level))) AS Capacity\t\n FROM charging_processes cp\n\t INNER JOIN charges c\tON cp.id = c.charging_process_id\n INNER JOIN aux ON cp.car_id = aux.car_id\n\t WHERE cp.car_id = $car_id AND cp.charge_energy_added >= aux.rated_efficiency AND cp.end_date >= date_trunc('month', current_date - interval '1 month') \n GROUP BY cp.charge_energy_added, cp.end_date\n ) AS lastEstimatedCapacity\n), \nMaxCapacity AS\n(\n\tSELECT MAX(c.rated_battery_range_km * cars.efficiency * 100.0 / c.usable_battery_level) AS MaxCapacity\n\tFROM charging_processes cp\n\t\tJOIN (SELECT charging_process_id, MAX(date) as date\n\t\tFROM charges\n\t\tGROUP BY charging_process_id) AS last_charges\n\t\tON cp.id = last_charges.charging_process_id\n\t\tINNER JOIN charges c\n\t\tON c.charging_process_id = cp.id AND c.date = last_charges.date\n\t\tINNER JOIN cars ON cp.car_id = cars.id\n\tWHERE cp.car_id = $car_id\n\t\tAND cp.end_date IS NOT NULL\n\t\tAND cp.end_rated_range_km > cp.start_rated_range_km\n\t\tAND c.charge_energy_added >= cars. Efficiency\n), \nCurrentRange AS\n(\n SELECT\n\t\tfloor(extract(epoch from date)/86400)*86400 AS timecurrent,\n\t\tsum(rated_battery_range_km) / sum(usable_battery_level) * 100 AS rated_range_km\n\tFROM (\n\t\tSELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c \n\t\tJOIN charging_processes p ON p.id = c.charging_process_id \n\t\tWHERE p.car_id = $car_id AND usable_battery_level IS NOT NULL) AS data\n\tGROUP BY 1\n\tORDER BY 1 DESC\n\tLIMIT 1\n), \nMaxRange AS\n(\n SELECT\n\t\tfloor(extract(epoch from date)/86400)*86400 AS time,\n\t\tsum(rated_battery_range_km) / sum(usable_battery_level) * 100 AS max_rated_range_km\n\tFROM (\n\t\tSELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c \n\t\tJOIN charging_processes p ON p.id = c.charging_process_id \n\t\tWHERE p.car_id = $car_id AND usable_battery_level IS NOT NULL) AS data\n\tGROUP BY 1\n\tORDER BY 2 DESC\n\tLIMIT 1\n) \nSELECT CONCAT('{\"LastChargekWhAdded\": ', aux.charge_energy_added, \n ', \"LastMileageAdded\" : ', convert_km(aux.added_range_km,'$length_unit'),\n ', \"MaxRange\": ', convert_km(MaxRange.max_rated_range_km,'$length_unit'),\n ', \"CurrentRange\": ',convert_km(CurrentRange.rated_range_km,'$length_unit'),\n ', \"MaxCapacity\": ', MaxCapacity.MaxCapacity,\n ', \"CurrentCapacity\": ',CurrentCapacity.CurrentCapacity,\n ', \"RatedEfficiency\": ',aux.rated_efficiency, '}') \nFROM MaxRange, CurrentRange, Aux, MaxCapacity, CurrentCapacity;\n-- The following query is the result of many tests and hours of work. This panel is for your own personal use. \n-- If you think you can improve it and contribute, please create a pull request and do not take it to your repository, \n-- much less upload it to another repository as if the original idea were yours, nor do you share it on social media\n-- without mentioning the author. Respect the ingenuity and work of others. Cheers!\n-- 16/04/2023\n-- By @jheredianet - Twitter: @juanheredia", - "hide": 2, - "includeAll": false, - "multi": false, - "name": "aux", - "options": [], - "query": "-- CONCATENATED JOIN QUERIES TO IMPROVE PERFORMANCE\nWITH\naux\tAS\n(\n\tSELECT cp.charge_energy_added,\n\t\tcp.car_id, cp.charge_energy_added / (cp.end_rated_range_km - cp.start_rated_range_km) * 100.0 AS rated_efficiency,\n\t\t(cp.end_rated_range_km - cp.start_rated_range_km) AS added_range_km\n\tFROM charging_processes cp\n\t\tJOIN (SELECT charging_process_id, MAX(date) as date\n\t\tFROM charges\n\t\tGROUP BY charging_process_id) AS last_charges\n\t\tON cp.id = last_charges.charging_process_id\n\t\tINNER JOIN charges c\n\t\tON c.charging_process_id = cp.id AND c.date = last_charges.date\n\tWHERE cp.car_id = $car_id\n\t\tAND cp.end_date IS NOT NULL\n\t\tAND cp.end_rated_range_km > cp.start_rated_range_km\n\tORDER BY cp.end_date DESC \n\tLIMIT 1\n), \nCurrentCapacity\t AS\n(\n\tSELECT AVG(Capacity) AS CurrentCapacity FROM\n (SELECT (100.0 * cp.charge_energy_added) / (GREATEST(1,MAX(usable_battery_level) - MIN(usable_battery_level))) AS Capacity\t\n FROM charging_processes cp\n\t INNER JOIN charges c\tON cp.id = c.charging_process_id\n INNER JOIN aux ON cp.car_id = aux.car_id\n\t WHERE cp.car_id = $car_id AND cp.charge_energy_added >= aux.rated_efficiency AND cp.end_date >= date_trunc('month', current_date - interval '1 month') \n GROUP BY cp.charge_energy_added, cp.end_date\n ) AS lastEstimatedCapacity\n), \nMaxCapacity AS\n(\n\tSELECT MAX(c.rated_battery_range_km * cars.efficiency * 100.0 / c.usable_battery_level) AS MaxCapacity\n\tFROM charging_processes cp\n\t\tJOIN (SELECT charging_process_id, MAX(date) as date\n\t\tFROM charges\n\t\tGROUP BY charging_process_id) AS last_charges\n\t\tON cp.id = last_charges.charging_process_id\n\t\tINNER JOIN charges c\n\t\tON c.charging_process_id = cp.id AND c.date = last_charges.date\n\t\tINNER JOIN cars ON cp.car_id = cars.id\n\tWHERE cp.car_id = $car_id\n\t\tAND cp.end_date IS NOT NULL\n\t\tAND cp.end_rated_range_km > cp.start_rated_range_km\n\t\tAND c.charge_energy_added >= cars. Efficiency\n), \nCurrentRange AS\n(\n SELECT\n\t\tfloor(extract(epoch from date)/86400)*86400 AS timecurrent,\n\t\tsum(rated_battery_range_km) / sum(usable_battery_level) * 100 AS rated_range_km\n\tFROM (\n\t\tSELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c \n\t\tJOIN charging_processes p ON p.id = c.charging_process_id \n\t\tWHERE p.car_id = $car_id AND usable_battery_level IS NOT NULL) AS data\n\tGROUP BY 1\n\tORDER BY 1 DESC\n\tLIMIT 1\n), \nMaxRange AS\n(\n SELECT\n\t\tfloor(extract(epoch from date)/86400)*86400 AS time,\n\t\tsum(rated_battery_range_km) / sum(usable_battery_level) * 100 AS max_rated_range_km\n\tFROM (\n\t\tSELECT battery_level, usable_battery_level, date, rated_battery_range_km from charges c \n\t\tJOIN charging_processes p ON p.id = c.charging_process_id \n\t\tWHERE p.car_id = $car_id AND usable_battery_level IS NOT NULL) AS data\n\tGROUP BY 1\n\tORDER BY 2 DESC\n\tLIMIT 1\n) \nSELECT CONCAT('{\"LastChargekWhAdded\": ', aux.charge_energy_added, \n ', \"LastMileageAdded\" : ', convert_km(aux.added_range_km,'$length_unit'),\n ', \"MaxRange\": ', convert_km(MaxRange.max_rated_range_km,'$length_unit'),\n ', \"CurrentRange\": ',convert_km(CurrentRange.rated_range_km,'$length_unit'),\n ', \"MaxCapacity\": ', MaxCapacity.MaxCapacity,\n ', \"CurrentCapacity\": ',CurrentCapacity.CurrentCapacity,\n ', \"RatedEfficiency\": ',aux.rated_efficiency, '}') \nFROM MaxRange, CurrentRange, Aux, MaxCapacity, CurrentCapacity;\n-- The following query is the result of many tests and hours of work. This panel is for your own personal use. \n-- If you think you can improve it and contribute, please create a pull request and do not take it to your repository, \n-- much less upload it to another repository as if the original idea were yours, nor do you share it on social media\n-- without mentioning the author. Respect the ingenuity and work of others. Cheers!\n-- 16/04/2023\n-- By @jheredianet - Twitter: @juanheredia", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "type": "query" - }, - { - "current": { - "selected": false, - "text": "0", - "value": "0" - }, - "description": "Set the capacity of your car battery when it was new, in case you started using Teslamate after a while of having it. If not, leave it at 0, it will be calculated with the data that is logged in Teslamate", - "hide": 0, - "label": "Custom Battery Capacity (kWh) when new", - "name": "custom_kwh_new", - "options": [ - { - "selected": true, - "text": "0", - "value": "0" - } - ], - "query": "0", - "skipUrlSync": false, - "type": "textbox" - }, - { - "current": { - "selected": false, - "text": "0", - "value": "0" - }, - "description": "Set the max range to 100% of your car when it was new, in case you started using Teslamate after a while of having it. If not, leave it at 0, the degradation will be calculated with the data that is logged in Teslamate", - "hide": 0, - "label": "Custom Max Range when new", - "name": "custom_max_range", - "options": [ - { - "selected": true, - "text": "0", - "value": "0" - } - ], - "query": "0", - "skipUrlSync": false, - "type": "textbox" - } - ] - }, - - "timepicker": { - "hidden": true, - "refresh_intervals": [] - }, - "timezone": "browser", - "title": "Battery Health - LFP", - "uid": "DuertWeceu", - "version": 7, - "weekStart": "" -} diff --git a/grafana/dashboards/battery-health.json b/grafana/dashboards/battery-health.json index ae0a7c061c..dfa7a2ac43 100644 --- a/grafana/dashboards/battery-health.json +++ b/grafana/dashboards/battery-health.json @@ -149,7 +149,7 @@ "textMode": "value_and_name", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -296,7 +296,7 @@ "textMode": "value_and_name", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -381,7 +381,7 @@ "textMode": "value_and_name", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -603,6 +603,7 @@ "values": false }, "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" } @@ -723,7 +724,7 @@ "showThresholdMarkers": true, "sizing": "auto" }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -822,7 +823,7 @@ "sizing": "auto", "valueMode": "color" }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -947,7 +948,7 @@ "textMode": "value_and_name", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -1159,20 +1160,8 @@ "mode": "absolute", "steps": [ { - "color": "dark-red", + "color": "transparent", "value": null - }, - { - "color": "semi-dark-green", - "value": 20 - }, - { - "color": "semi-dark-orange", - "value": 80 - }, - { - "color": "light-blue", - "value": 100 } ] }, @@ -1206,7 +1195,7 @@ "text": {}, "valueMode": "color" }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -1257,9 +1246,74 @@ "type": "macro" } ] + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "SELECT\r\n 0 as lowest,\r\n 20 as lower,\r\n CASE\r\n WHEN substring(vin, 7, 1) = 'F'\r\n THEN 100\r\n ELSE 81\r\n END as upper\r\nfrom cars ", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], "title": "Current SOC", + "transformations": [ + { + "id": "configFromData", + "options": { + "applyTo": { + "id": "byFrameRefID", + "options": "SOC" + }, + "configRefId": "A", + "mappings": [ + { + "fieldName": "lower", + "handlerArguments": { + "threshold": { + "color": "green" + } + }, + "handlerKey": "threshold1" + }, + { + "fieldName": "upper", + "handlerArguments": { + "threshold": { + "color": "orange" + } + }, + "handlerKey": "threshold1" + }, + { + "fieldName": "lowest", + "handlerKey": "threshold1" + } + ] + } + } + ], "type": "bargauge" }, { @@ -1335,7 +1389,7 @@ "textMode": "value", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -1435,7 +1489,7 @@ "text": {}, "valueMode": "color" }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "datasource": { @@ -1611,6 +1665,7 @@ ], "seriesMapping": "manual", "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" } @@ -1882,12 +1937,17 @@ } ] }, - "timepicker": { + "time": { + "from": "now-6h", + "to": "now" + }, + "timeRangeUpdatedDuringEditOrView": false, + "timepicker": { "hidden": true }, "timezone": "browser", "title": "Battery Health", "uid": "jchmRiqUfXgTM", - "version": 18, + "version": 5, "weekStart": "" } \ No newline at end of file diff --git a/grafana/dashboards/charge-level.json b/grafana/dashboards/charge-level.json index 937009e623..0caa8ec545 100644 --- a/grafana/dashboards/charge-level.json +++ b/grafana/dashboards/charge-level.json @@ -1,4 +1,25 @@ { + "__elements": {}, + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "11.0.0" + }, + { + "type": "datasource", + "id": "grafana-postgresql-datasource", + "name": "PostgreSQL", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + } + ], "annotations": { "list": [ { @@ -21,7 +42,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "iteration": 1656100496202, + "id": null, "links": [ { "icon": "dashboard", @@ -59,13 +80,19 @@ "type": "row" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "Charge Level", "axisPlacement": "auto", "barAlignment": 0, @@ -77,6 +104,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "stepAfter", "lineWidth": 1, "pointSize": 5, @@ -101,17 +129,9 @@ "thresholds": { "mode": "absolute", "steps": [ - { - "color": "green", - "value": null - }, { "color": "transparent", - "value": 20 - }, - { - "color": "green", - "value": 80 + "value": null } ] }, @@ -126,7 +146,6 @@ "y": 1 }, "id": 2, - "links": [], "options": { "legend": { "calcs": [ @@ -135,9 +154,11 @@ "min" ], "displayMode": "table", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { + "maxHeight": 600, "mode": "multi", "sort": "none" } @@ -146,7 +167,10 @@ "targets": [ { "alias": "", - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "format": "time_series", "group": [], "hide": false, @@ -172,27 +196,86 @@ "type": "macro" } ] + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "SELECT\r\n 20 as lower,\r\n CASE\r\n WHEN substring(vin, 7, 1) = 'F'\r\n THEN 100\r\n ELSE 80\r\n END as upper\r\nfrom cars ", + "refId": "B", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], "title": "Charge Level", + "transformations": [ + { + "id": "configFromData", + "options": { + "applyTo": { + "id": "byFrameRefID", + "options": "A" + }, + "configRefId": "B", + "mappings": [ + { + "fieldName": "lower", + "handlerArguments": { + "threshold": { + "color": "green" + } + }, + "handlerKey": "threshold1" + }, + { + "fieldName": "upper", + "handlerArguments": { + "threshold": { + "color": "green" + } + }, + "handlerKey": "threshold1" + } + ] + } + } + ], "type": "timeseries" } ], "refresh": false, - "schemaVersion": 36, - "style": "dark", + "schemaVersion": 39, "tags": [ "tesla" ], "templating": { "list": [ { - "current": { - "selected": false, - "text": "All", - "value": "$__all" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", "hide": 2, "includeAll": true, @@ -211,12 +294,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "http://localhost:4000", - "value": "http://localhost:4000" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select base_url from settings limit 1;", "hide": 2, "includeAll": false, @@ -240,6 +322,7 @@ "from": "now-7d", "to": "now" }, + "timeRangeUpdatedDuringEditOrView": false, "timepicker": { "refresh_intervals": [ "5s", @@ -270,4 +353,4 @@ "uid": "WopVO_mgz", "version": 1, "weekStart": "" -} +} \ No newline at end of file diff --git a/grafana/dashboards/charging-stats-lfp.json b/grafana/dashboards/charging-stats-lfp.json deleted file mode 100644 index 83ed795728..0000000000 --- a/grafana/dashboards/charging-stats-lfp.json +++ /dev/null @@ -1,2276 +0,0 @@ -{ - "annotations": { - "list": [ - { - "$$hashKey": "object:75", - "builtIn": 1, - "datasource": "-- Grafana --", - "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, - "links": [ - { - "icon": "dashboard", - "tags": [], - "title": "TeslaMate", - "tooltip": "", - "type": "link", - "url": "[[base_url:raw]]" - }, - { - "asDropdown": true, - "icon": "external link", - "tags": [ - "tesla" - ], - "title": "Dashboards", - "type": "dashboards" - } - ], - "liveNow": false, - "panels": [ - { - "collapsed": false, - "datasource": "TeslaMate", - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 12, - "panels": [], - "repeat": "car_id", - "title": "$car_id", - "type": "row" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#c7d0d9", - "value": null - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 5, - "x": 0, - "y": 1 - }, - "id": 8, - "maxDataPoints": 100, - "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "mean" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "value", - "wideLayout": true - }, - "pluginVersion": "10.4.0", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\tcount(*)\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND charge_energy_added > 0.01\n\tAND car_id = $car_id;", - "refId": "A", - "select": [ - [ - { - "params": [ - "efficiency" - ], - "type": "column" - } - ] - ], - "table": "cars", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Number of Charges", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#c7d0d9", - "value": null - } - ] - }, - "unit": "kwatth" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 5, - "x": 5, - "y": 1 - }, - "id": 10, - "maxDataPoints": 100, - "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "mean" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "value", - "wideLayout": true - }, - "pluginVersion": "10.4.0", - "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": { - "decimals": 2, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#c7d0d9", - "value": null - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 3, - "x": 10, - "y": 1 - }, - "id": 14, - "maxDataPoints": 100, - "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "mean" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "value", - "wideLayout": true - }, - "pluginVersion": "10.4.0", - "targets": [ - { - "datasource": "TeslaMate", - "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\nJOIN\n charges char ON char.charging_process_id = cp.id AND char.date = end_date\t\nWHERE\n $__timeFilter(end_date)\n AND (addr.name ILIKE '%supercharger%' OR geo.name ILIKE '%supercharger%' OR char.fast_charger_brand = 'Tesla')\n\tAND cp.cost IS NOT NULL\n\tAND cp.car_id = $car_id;", - - "refId": "A", - "select": [ - [ - { - "params": [ - "latitude" - ], - "type": "column" - } - ] - ], - "table": "addresses", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Charging Cost at SuC", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "decimals": 2, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#c7d0d9", - "value": null - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 3, - "x": 13, - "y": 1 - }, - "id": 27, - "maxDataPoints": 100, - "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "mean" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "value", - "wideLayout": true - }, - "pluginVersion": "10.4.0", - "targets": [ - { - "datasource": "TeslaMate", - "editorMode": "code", - "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;", - "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": "Total Charging Cost", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "decimals": 2, - "displayName": "", - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#d8d9da", - "value": null - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 16, - "y": 1 - }, - "id": 26, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "10.4.0", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT (\n SELECT sum(cost)\n FROM charging_processes\n WHERE $__timeFilter(end_date) AND car_id = $car_id\n) / (\n\tSELECT convert_km((max(odometer) - min(odometer))::numeric, '$length_unit')\n\tFROM positions\n\tWHERE $__timeFilter(date) AND car_id = $car_id\n) * 100", - "refId": "A", - "select": [ - [ - { - "params": [ - "efficiency" - ], - "type": "column" - } - ] - ], - "table": "cars", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Cost per 100 $length_unit", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 2, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#d8d9da", - "value": null - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 18, - "y": 1 - }, - "id": 31, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "10.4.0", - "targets": [ - { - "datasource": "TeslaMate", - "editorMode": "code", - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT (\n SELECT sum(cost)\n FROM charging_processes\n WHERE $__timeFilter(end_date) AND car_id = $car_id\n) / (\n SELECT sum(greatest(charge_energy_added, charge_energy_used))\n FROM charging_processes\n WHERE $__timeFilter(end_date) AND car_id = $car_id\n)", - "refId": "A", - "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": "Average Cost per kWh", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 2, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#d8d9da", - "value": null - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 20, - "y": 1 - }, - "id": 33, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "10.4.0", - "targets": [ - { - "datasource": "TeslaMate", - "editorMode": "code", - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH data AS (\n SELECT\n\t\tcp.id,\n cp.cost,\n cp.end_date,\n cp.car_id,\n cp.charge_energy_added,\n cp.charge_energy_used,\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 $__timeFilter(end_date)\n GROUP BY 1\n)\nSELECT (\n SELECT \n sum(cost)\n FROM data\n WHERE $__timeFilter(end_date) AND car_id = $car_id AND current = 'DC'\n)/(\n SELECT sum(greatest(charge_energy_added, charge_energy_used))\n FROM data\n WHERE $__timeFilter(end_date) AND car_id = $car_id AND current = 'DC'\n )", - "refId": "A", - "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": "DC Avg Cost per kWh", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 2, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#d8d9da", - "value": null - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 22, - "y": 1 - }, - "id": 32, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showPercentChange": false, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "10.4.0", - "targets": [ - { - "datasource": "TeslaMate", - "editorMode": "code", - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH data AS (\n SELECT\n\t\tcp.id,\n cp.cost,\n cp.end_date,\n cp.car_id,\n cp.charge_energy_added,\n cp.charge_energy_used,\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 $__timeFilter(end_date)\n GROUP BY 1\n)\nSELECT (\n SELECT \n sum(cost)\n FROM data\n WHERE $__timeFilter(end_date) AND car_id = $car_id AND current = 'AC'\n)/(\n SELECT sum(greatest(charge_energy_added, charge_energy_used))\n FROM data\n WHERE $__timeFilter(end_date) AND car_id = $car_id AND current = 'AC'\n )", - "refId": "A", - "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": "AC Avg Cost per kWh", - "type": "stat" - }, - { - "cards": {}, - "color": { - "cardColor": "#b4ff00", - "colorScale": "linear", - "colorScheme": "interpolateGreens", - "exponent": 0.5, - "min": 0, - "mode": "opacity" - }, - "dataFormat": "timeseries", - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "custom": { - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "scaleDistribution": { - "type": "linear" - } - } - }, - "overrides": [] - }, - "gridPos": { - "h": 6, - "w": 12, - "x": 0, - "y": 4 - }, - "heatmap": {}, - "hideZeroBuckets": false, - "highlightCards": true, - "id": 15, - "legend": { - "show": false - }, - "options": { - "calculate": true, - "calculation": { - "yBuckets": { - "mode": "size", - "value": "10.00001" - } - }, - "cellGap": 2, - "cellValues": {}, - "color": { - "exponent": 0.5, - "fill": "#b4ff00", - "min": 0, - "mode": "opacity", - "reverse": false, - "scale": "exponential", - "scheme": "Oranges", - "steps": 128 - }, - "exemplars": { - "color": "rgba(255,0,255,0.7)" - }, - "filterValues": { - "le": 1e-9 - }, - "legend": { - "show": false - }, - "rowsFrame": { - "layout": "auto" - }, - "showValue": "never", - "tooltip": { - "mode": "single", - "showColorScale": false, - "yHistogram": false - }, - "yAxis": { - "axisPlacement": "left", - "max": "100", - "reverse": false, - "unit": "short" - } - }, - "pluginVersion": "10.4.0", - "reverseYBuckets": false, - "targets": [ - { - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\t$__time(start_date),\n\tstart_battery_level,\n\tend_battery_level\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(start_date)\n\tAND duration_min > 3\n\tAND car_id = $car_id\nORDER BY\n\tstart_date;", - "refId": "A", - "select": [ - [ - { - "params": [ - "charge_energy_added" - ], - "type": "column" - } - ] - ], - "table": "charges", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "timeFrom": "6M", - "title": "Charge Heatmap", - "tooltip": { - "show": true, - "showHistogram": false - }, - "type": "heatmap", - "xAxis": { - "show": true - }, - "yAxis": { - "format": "short", - "logBase": 1, - "max": "100", - "show": true - }, - "yBucketBound": "auto", - "yBucketSize": 10.00001 - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 35, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line" - } - }, - "mappings": [], - "max": 100, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "dark-green", - "value": null - }, - { - "color": "transparent", - "value": 20 - }, - { - "color": "dark-green", - "value": 80 - } - ] - }, - "unit": "percent" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Start SOC" - }, - "properties": [ - { - "id": "custom.lineWidth", - "value": 0 - }, - { - "id": "custom.fillBelowTo", - "value": "End SOC" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "End SOC" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#73BF69", - "mode": "fixed" - } - }, - { - "id": "custom.fillBelowTo", - "value": "Start SOC" - }, - { - "id": "custom.lineWidth", - "value": 0 - } - ] - } - ] - }, - "gridPos": { - "h": 6, - "w": 12, - "x": 12, - "y": 4 - }, - "id": 16, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "tooltip": { - "mode": "multi", - "sort": "desc" - } - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "datasource": "TeslaMate", - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH charges AS (\n\tSELECT\n\t\tstart_date,\n\t\tstart_battery_level,\n\t\tend_battery_level,\n\t\tp.odometer,\n\t\tCOALESCE(\n\t\t\tLAG(p.odometer) OVER (\n\t\t\t\tORDER BY cp.start_date\n\t\t\t),\n\t\t\tp.odometer\n\t\t) as odometer_prev\n\tFROM\n\t\tcharging_processes cp\n\tJOIN positions p\n\tON p.id = cp.position_id\n\tWHERE\n\t\t$__timeFilter(cp.start_date)\n\t\tAND cp.duration_min > 3\n\t\tAND cp.car_id = $car_id\n)\nSELECT\n\tMIN(start_date) as time,\n\tMIN(start_battery_level) as \"Start SOC\",\n\tMAX(end_battery_level) as \"End SOC\"\nFROM charges\nGROUP BY\n\tCASE WHEN odometer - odometer_prev < 2 THEN odometer_prev ELSE odometer END\nORDER BY\n\ttime;", - "refId": "A", - "select": [ - [ - { - "params": [ - "charge_energy_added" - ], - "type": "column" - } - ] - ], - "table": "charges", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "timeFrom": "6M", - "title": "Charge Delta", - "type": "timeseries" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - } - }, - "decimals": 0, - "mappings": [], - "unit": "kwatth" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "AC" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#73BF69", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "DC" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FADE2A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 13, - "w": 5, - "x": 0, - "y": 10 - }, - "id": 18, - "maxDataPoints": 3, - "options": { - "displayLabels": [ - "name" - ], - "legend": { - "calcs": [], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "values": [ - "value", - "percent" - ] - }, - "pieType": "pie", - "reduceOptions": { - "calcs": [ - "sum" - ], - "fields": "", - "values": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "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": [ - [ - { - "params": [ - "latitude" - ], - "type": "column" - } - ] - ], - "table": "addresses", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "AC/DC - kWh", - "type": "piechart" - }, - { - "datasource": "TeslaMate", - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "continuous-reds" - }, - "custom": { - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "pct" - }, - "properties": [ - { - "id": "unit", - "value": "percent" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "chg_total" - }, - "properties": [ - { - "id": "unit", - "value": "kwatth" - } - ] - } - ] - }, - "gridPos": { - "h": 13, - "w": 14, - "x": 5, - "y": 10 - }, - "id": 24, - "maxDataPoints": 1, - "options": { - "basemap": { - "config": {}, - "name": "Layer 0", - "tooltip": true, - "type": "osm-standard" - }, - "controls": { - "mouseWheelZoom": true, - "showAttribution": true, - "showDebug": false, - "showMeasure": false, - "showScale": false, - "showZoom": true - }, - "layers": [ - { - "config": { - "showLegend": false, - "style": { - "color": { - "field": "pct", - "fixed": "red" - }, - "opacity": 0.4, - "rotation": { - "fixed": 0, - "max": 360, - "min": -360, - "mode": "mod" - }, - "size": { - "field": "chg_total", - "fixed": 5, - "max": 30, - "min": 5 - }, - "symbol": { - "fixed": "img/icons/marker/circle.svg", - "mode": "fixed" - }, - "symbolAlign": { - "horizontal": "center", - "vertical": "center" - }, - "text": { - "field": "chg_total", - "fixed": "", - "mode": "field" - }, - "textConfig": { - "fontSize": 12, - "offsetX": 15, - "offsetY": 0, - "textAlign": "left", - "textBaseline": "middle" - } - } - }, - "location": { - "mode": "auto" - }, - "name": "Charge location", - "tooltip": true, - "type": "markers" - } - ], - "tooltip": { - "mode": "details" - }, - "view": { - "allLayers": true, - "id": "fit", - "lat": 0, - "lon": 0, - "zoom": 15 - } - }, - "pluginVersion": "10.4.0", - "targets": [ - { - "datasource": "TeslaMate", - "editorMode": "code", - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH charge_data AS (\r\nSELECT COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS loc_nm\r\n, AVG(position.latitude) AS latitude\r\n, AVG(position.longitude) AS longitude\r\n, sum(charge.charge_energy_added) AS chg_total\r\n, count(*) as charges\r\nFROM charging_processes charge\r\nLEFT JOIN addresses address ON charge.address_id = address.id\r\nLEFT JOIN positions position ON charge.position_id = position.id\r\nLEFT JOIN geofences geofence ON charge.geofence_id = geofence.id\r\nWHERE $__timeFilter(charge.start_date) \r\nAND charge.car_id = $car_id\r\nGROUP BY COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city))\r\n) \r\nSELECT loc_nm\r\n\t,latitude\r\n\t,longitude\r\n\t,chg_total\r\n\t,chg_total * 1.0 / (SELECT sum(chg_total) FROM charge_data) * 100 AS pct\r\n\t,charges\r\nFROM charge_data", - "refId": "A", - "select": [ - [ - { - "params": [ - "efficiency" - ], - "type": "column" - } - ] - ], - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - }, - "table": "cars", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Charging heat map by kWh", - "type": "geomap" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - } - }, - "decimals": 1, - "mappings": [], - "unit": "dtdurations" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "AC" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#73BF69", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "DC" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FADE2A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 13, - "w": 5, - "x": 19, - "y": 10 - }, - "id": 20, - "maxDataPoints": 3, - "options": { - "displayLabels": [ - "name" - ], - "legend": { - "calcs": [], - "displayMode": "table", - "placement": "bottom", - "showLegend": true, - "values": [ - "value", - "percent" - ] - }, - "pieType": "pie", - "reduceOptions": { - "calcs": [ - "sum" - ], - "fields": "", - "values": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH data AS (\n SELECT\n\t\tcp.id,\n\t\tcp.duration_min,\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(duration_min) * 60 AS value,\n\tcurrent AS metric\nFROM data\nGROUP BY 3\nORDER BY metric DESC;", - "refId": "A", - "select": [ - [ - { - "params": [ - "latitude" - ], - "type": "column" - } - ] - ], - "table": "addresses", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "AC/DC - Duration", - "type": "piechart" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "continuous-RdYlGr", - "seriesBy": "last" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "pointSize": { - "fixed": 3 - }, - "scaleDistribution": { - "type": "linear" - }, - "show": "points" - }, - "fieldMinMax": false, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byFrameRefID", - "options": "A" - }, - "properties": [ - { - "id": "links", - "value": [ - { - "title": "Show charge details", - "url": "d/BHhxFeZRz?from=${__data.fields.start_date.numeric}&to=${__data.fields.end_date.numeric}&var-car_id=${car_id}&var-charging_process_id=${__data.fields.charging_process_id.numeric}" - } - ] - } - ] - } - ] - }, - "gridPos": { - "h": 16, - "w": 24, - "x": 0, - "y": 23 - }, - "id": 29, - "options": { - "dims": { - "exclude": [ - "charging_process_id" - ], - "frame": 0 - }, - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "series": [ - { - "pointColor": { - "field": "Power [kW]" - }, - "x": "SOC [%]", - "y": "Power [kW]" - }, - { - "pointColor": { - "field": "B - Avg Power [kW]" - }, - "pointSize": { - "fixed": 15, - "max": 100, - "min": 1 - }, - "x": "B - SOC [%]", - "y": "B - Avg Power [kW]" - } - ], - "seriesMapping": "manual", - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "pluginVersion": "7.5.11", - "targets": [ - { - "alias": "", - "datasource": "TeslaMate", - "editorMode": "code", - "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\r\n c.battery_level as \"SOC [%]\",\r\n round(avg(c.charger_power), 0) as \"Power [kW]\",\r\n c.charging_process_id as \"charging_process_id\",\r\n p.start_date as \"start_date\",\r\n p.end_date as \"end_date\",\r\n COALESCE(g.name, a.name) || ' ' || to_char(c.date, 'YYYY-MM-dd') as \"Charge\"\r\nFROM\r\n charges c\r\nJOIN charging_processes p ON p.id = c.charging_process_id \r\nJOIN addresses a ON a.id = p.address_id\r\nLEFT JOIN geofences g ON g.id = p.geofence_id\r\nWHERE\r\n $__timeFilter(date)\r\n AND p.car_id = $car_id\r\n AND charger_power > 0\r\n AND c.fast_charger_present\r\nGROUP BY c.battery_level, c.charging_process_id, a.name, g.name, p,start_date, p.end_date, to_char(c.date, 'YYYY-MM-dd')", - "refId": "A", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "column" - } - ] - ], - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - }, - "timeColumn": "time", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - }, - { - "datasource": "TeslaMate", - "format": "table", - "group": [], - "hide": false, - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n c.battery_level as \"B - SOC [%]\",\n PERCENTILE_CONT(0.5) WITHIN GROUP(ORDER BY charger_power) as \"B - Avg Power [kW]\"\nFROM\n charges c\njoin\n charging_processes p ON p.id = c.charging_process_id \nWHERE\n $__timeFilter(date)\n AND p.car_id = $car_id\n AND charger_power > 0\n AND c.fast_charger_present\nGROUP BY battery_level", - "refId": "B", - "select": [ - [ - { - "params": [ - "efficiency" - ], - "type": "column" - } - ] - ], - "table": "cars", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "DC Charging Curve", - "type": "xychart" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "soc" - }, - "properties": [ - { - "id": "custom.width", - "value": 70 - }, - { - "id": "displayName", - "value": "SOC" - }, - { - "id": "custom.cellOptions", - "value": { - "type": "color-text" - } - }, - { - "id": "unit", - "value": "percent" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "n" - }, - "properties": [ - { - "id": "displayName", - "value": "# of Charges" - }, - { - "id": "custom.cellOptions", - "value": { - "mode": "gradient", - "type": "gauge" - } - }, - { - "id": "max" - }, - { - "id": "min", - "value": 0 - } - ] - } - ] - }, - "gridPos": { - "h": 18, - "w": 3, - "x": 0, - "y": 39 - }, - "id": 2, - "options": { - "footer": { - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [] - }, - "pluginVersion": "8.5.6", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\tROUND(end_battery_level / 5, 0) * 5 AS SOC,\n\tcount(*) AS n\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND duration_min > 3\n\tAND car_id = $car_id\nGROUP BY\n\tROUND(end_battery_level / 5, 0) * 5\nORDER BY\n\tSOC DESC", - "refId": "A", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "column" - } - ] - ], - "timeColumn": "time", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Charge Stats", - "type": "table" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "soc" - }, - "properties": [ - { - "id": "displayName", - "value": "SOC" - }, - { - "id": "unit", - "value": "percent" - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "red" - }, - { - "color": "#EAB839", - "value": 10 - }, - { - "color": "green", - "value": 20 - } - ] - } - }, - { - "id": "custom.cellOptions", - "value": { - "type": "color-text" - } - }, - { - "id": "custom.width", - "value": 70 - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "n" - }, - "properties": [ - { - "id": "displayName", - "value": "# of Discharges" - }, - { - "id": "custom.cellOptions", - "value": { - "mode": "gradient", - "type": "gauge" - } - }, - { - "id": "min", - "value": 0 - } - ] - } - ] - }, - "gridPos": { - "h": 18, - "w": 3, - "x": 3, - "y": 39 - }, - "id": 13, - "options": { - "footer": { - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [] - }, - "pluginVersion": "8.5.6", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\tROUND(start_battery_level / 5, 0) * 5 AS SOC,\n\tcount(*) AS n\nFROM\n\tcharging_processes\nWHERE\n\t$__timeFilter(end_date)\n\tAND duration_min > 3\n\tAND car_id = $car_id\nGROUP BY\n 1\nORDER BY\n\tSOC DESC", - "refId": "A", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "column" - } - ] - ], - "timeColumn": "time", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Discharge Stats", - "type": "table" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "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" - } - ] - } - ] - }, - "gridPos": { - "h": 18, - "w": 9, - "x": 6, - "y": 39 - }, - "id": 4, - "options": { - "footer": { - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true - }, - "pluginVersion": "8.5.6", - "targets": [ - { - "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\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\nGROUP BY\n\t1\nORDER BY\n\tSUM(charge_energy_added) DESC\nLIMIT 17;", - "refId": "A", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "column" - } - ] - ], - "timeColumn": "time", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Top Charging Stations (Charged)", - "type": "table" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "location" - }, - "properties": [ - { - "id": "displayName", - "value": "Location" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "cost" - }, - "properties": [ - { - "id": "displayName", - "value": "Cost" - }, - { - "id": "custom.width", - "value": 120 - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align", - "value": "left" - } - ] - } - ] - }, - "gridPos": { - "h": 18, - "w": 9, - "x": 15, - "y": 39 - }, - "id": 6, - "options": { - "footer": { - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true - }, - "pluginVersion": "8.5.6", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\tCOALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, CONCAT_WS(' ', address.road, address.house_number)), address.city)) AS location,\n\tsum(cost) as cost\nFROM\n\tcharging_processes c\n\tLEFT JOIN addresses address ON c.address_id = address.id\n\tLEFT JOIN geofences geofence ON geofence_id = geofence.id\nWHERE\n $__timeFilter(end_date) AND\n\tcar_id = $car_id AND\n\tCOST IS NOT NULL\nGROUP BY\n\t1\nORDER BY\n\t2 DESC NULLS LAST\nLIMIT 17;", - "refId": "A", - "select": [ - [ - { - "params": [ - "efficiency" - ], - "type": "column" - } - ] - ], - "table": "cars", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Top Charging Stations (Cost)", - "type": "table" - } - ], - "refresh": false, - "schemaVersion": 39, - "tags": [ - "tesla" - ], - "templating": { - "list": [ - { - "current": { - "selected": false, - "text": "All", - "value": "$__all" - }, - "datasource": "TeslaMate", - "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", - "hide": 2, - "includeAll": true, - "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": { - "selected": false, - "text": "http://localhost:4000", - "value": "http://localhost:4000" - }, - "datasource": "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": "km", - "value": "km" - }, - "datasource": "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 - } - ] - }, - "time": { - "from": "now-10y", - "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": "Charging Stats - LFP", - "uid": "UcjFKmUtpt", - "version": 2, - "weekStart": "" -} diff --git a/grafana/dashboards/charging-stats.json b/grafana/dashboards/charging-stats.json index 44f9bbc1b5..73ffe73a6a 100644 --- a/grafana/dashboards/charging-stats.json +++ b/grafana/dashboards/charging-stats.json @@ -1,4 +1,61 @@ { + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "geomap", + "name": "Geomap", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "11.0.0" + }, + { + "type": "datasource", + "id": "grafana-postgresql-datasource", + "name": "PostgreSQL", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "heatmap", + "name": "Heatmap", + "version": "" + }, + { + "type": "panel", + "id": "piechart", + "name": "Pie chart", + "version": "" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + }, + { + "type": "panel", + "id": "xychart", + "name": "XY Chart", + "version": "" + } + ], "annotations": { "list": [ { @@ -22,6 +79,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, + "id": null, "links": [ { "icon": "dashboard", @@ -59,7 +117,10 @@ "type": "row" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "mappings": [], @@ -105,7 +166,7 @@ "textMode": "value", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -133,14 +194,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Number of Charges", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "mappings": [], @@ -186,7 +254,7 @@ "textMode": "value", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -214,14 +282,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Charged in total", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "decimals": 2, @@ -268,16 +343,18 @@ "textMode": "value", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "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\nJOIN\n charges char ON char.charging_process_id = cp.id AND char.date = end_date\t\nWHERE\n $__timeFilter(end_date)\n AND (addr.name ILIKE '%supercharger%' OR geo.name ILIKE '%supercharger%' OR char.fast_charger_brand = 'Tesla')\n\tAND cp.cost IS NOT NULL\n\tAND cp.car_id = $car_id;", - "refId": "A", "select": [ [ @@ -305,7 +382,10 @@ "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "decimals": 2, @@ -352,7 +432,7 @@ "textMode": "value", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -380,14 +460,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Total Charging Cost", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "decimals": 2, @@ -428,7 +515,7 @@ "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -456,14 +543,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Cost per 100 $length_unit", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -506,7 +600,7 @@ "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -524,14 +618,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Average Cost per kWh", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -574,10 +675,13 @@ "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "editorMode": "code", "format": "table", "group": [], @@ -618,7 +722,10 @@ "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -661,10 +768,13 @@ "textMode": "auto", "wideLayout": true }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "editorMode": "code", "format": "table", "group": [], @@ -715,7 +825,10 @@ "mode": "opacity" }, "dataFormat": "timeseries", - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "custom": { @@ -778,6 +891,7 @@ }, "showValue": "never", "tooltip": { + "maxHeight": 600, "mode": "single", "showColorScale": false, "yHistogram": false @@ -789,7 +903,7 @@ "unit": "short" } }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "reverseYBuckets": false, "targets": [ { @@ -818,7 +932,11 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "timeFrom": "6M", @@ -841,7 +959,10 @@ "yBucketSize": 10.00001 }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -885,17 +1006,9 @@ "thresholds": { "mode": "absolute", "steps": [ - { - "color": "dark-green", - "value": null - }, { "color": "transparent", - "value": 20 - }, - { - "color": "dark-green", - "value": 80 + "value": null } ] }, @@ -958,6 +1071,7 @@ "showLegend": false }, "tooltip": { + "maxHeight": 600, "mode": "multi", "sort": "desc" } @@ -965,7 +1079,10 @@ "pluginVersion": "8.5.4", "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "format": "time_series", "group": [], "metricColumn": "none", @@ -992,14 +1109,78 @@ "type": "macro" } ] + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "SELECT\r\n 20 as lower,\r\n CASE\r\n WHEN substring(vin, 7, 1) = 'F'\r\n THEN 100\r\n ELSE 80\r\n END as upper\r\nfrom cars ", + "refId": "B", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], "timeFrom": "6M", "title": "Charge Delta", + "transformations": [ + { + "id": "configFromData", + "options": { + "applyTo": { + "id": "byFrameRefID", + "options": "A" + }, + "configRefId": "B", + "mappings": [ + { + "fieldName": "lower", + "handlerArguments": { + "threshold": { + "color": "green" + } + }, + "handlerKey": "threshold1" + }, + { + "fieldName": "upper", + "handlerArguments": { + "threshold": { + "color": "green" + } + }, + "handlerKey": "threshold1" + } + ] + } + } + ], "type": "timeseries" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -1080,6 +1261,7 @@ "values": false }, "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" } @@ -1111,14 +1293,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "AC/DC - kWh", "type": "piechart" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "description": "", "fieldConfig": { "defaults": { @@ -1257,10 +1446,13 @@ "zoom": 15 } }, - "pluginVersion": "10.4.0", + "pluginVersion": "11.0.0", "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "editorMode": "code", "format": "table", "group": [], @@ -1311,7 +1503,10 @@ "type": "geomap" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -1392,6 +1587,7 @@ "values": false }, "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" } @@ -1423,14 +1619,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "AC/DC - Duration", "type": "piechart" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -1535,6 +1738,7 @@ ], "seriesMapping": "manual", "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" } @@ -1543,7 +1747,10 @@ "targets": [ { "alias": "", - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "editorMode": "code", "format": "table", "group": [], @@ -1589,7 +1796,10 @@ ] }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "format": "table", "group": [], "hide": false, @@ -1623,7 +1833,10 @@ "type": "xychart" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "custom": { @@ -1638,7 +1851,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null } ] } @@ -1664,25 +1878,6 @@ "type": "color-text" } }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "yellow", - "value": 80 - }, - { - "color": "red", - "value": 91 - } - ] - } - }, { "id": "unit", "value": "percent" @@ -1725,7 +1920,9 @@ }, "id": 2, "options": { + "cellHeight": "sm", "footer": { + "countRows": false, "fields": "", "reducer": [ "sum" @@ -1735,9 +1932,13 @@ "showHeader": true, "sortBy": [] }, - "pluginVersion": "8.5.6", + "pluginVersion": "11.0.0", "targets": [ { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "format": "table", "group": [], "metricColumn": "none", @@ -1762,13 +1963,72 @@ "type": "macro" } ] + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "SELECT\r\n CASE\r\n WHEN substring(vin, 7, 1) = 'F'\r\n THEN 100\r\n ELSE 81\r\n END as high,\r\n CASE\r\n WHEN substring(vin, 7, 1) = 'F'\r\n THEN 100\r\n ELSE 91\r\n END as highest\r\nfrom cars ", + "refId": "B", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], "title": "Charge Stats", + "transformations": [ + { + "id": "configFromData", + "options": { + "applyTo": { + "id": "byName", + "options": "soc" + }, + "configRefId": "B", + "mappings": [ + { + "fieldName": "high", + "handlerArguments": { + "threshold": { + "color": "yellow" + } + }, + "handlerKey": "threshold1" + }, + { + "fieldName": "highest", + "handlerKey": "threshold1" + } + ] + } + } + ], "type": "table" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "custom": { @@ -1783,7 +2043,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -1813,7 +2074,8 @@ "mode": "absolute", "steps": [ { - "color": "red" + "color": "red", + "value": null }, { "color": "#EAB839", @@ -1871,7 +2133,9 @@ }, "id": 13, "options": { + "cellHeight": "sm", "footer": { + "countRows": false, "fields": "", "reducer": [ "sum" @@ -1881,7 +2145,7 @@ "showHeader": true, "sortBy": [] }, - "pluginVersion": "8.5.6", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -1907,14 +2171,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Discharge Stats", "type": "table" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "custom": { @@ -1929,7 +2200,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -1981,7 +2253,9 @@ }, "id": 4, "options": { + "cellHeight": "sm", "footer": { + "countRows": false, "fields": "", "reducer": [ "sum" @@ -1990,7 +2264,7 @@ }, "showHeader": true }, - "pluginVersion": "8.5.6", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -2016,14 +2290,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Top Charging Stations (Charged)", "type": "table" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "custom": { @@ -2038,7 +2319,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -2094,7 +2376,9 @@ }, "id": 6, "options": { + "cellHeight": "sm", "footer": { + "countRows": false, "fields": "", "reducer": [ "sum" @@ -2103,7 +2387,7 @@ }, "showHeader": true }, - "pluginVersion": "8.5.6", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -2131,7 +2415,11 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Top Charging Stations (Cost)", @@ -2146,12 +2434,11 @@ "templating": { "list": [ { - "current": { - "selected": false, - "text": "All", - "value": "$__all" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", "hide": 2, "includeAll": true, @@ -2170,12 +2457,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "http://localhost:4000", - "value": "http://localhost:4000" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select base_url from settings limit 1;", "hide": 2, "includeAll": false, @@ -2194,12 +2480,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "km", - "value": "km" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select unit_of_length from settings limit 1;", "hide": 2, "includeAll": false, @@ -2222,6 +2507,7 @@ "from": "now-10y", "to": "now" }, + "timeRangeUpdatedDuringEditOrView": false, "timepicker": { "hidden": false, "refresh_intervals": [ @@ -2251,6 +2537,6 @@ "timezone": "", "title": "Charging Stats", "uid": "-pkIkhmRz", - "version": 5, + "version": 4, "weekStart": "" -} +} \ No newline at end of file diff --git a/grafana/dashboards/overview-lfp.json b/grafana/dashboards/overview-lfp.json deleted file mode 100644 index 4d042a562e..0000000000 --- a/grafana/dashboards/overview-lfp.json +++ /dev/null @@ -1,1699 +0,0 @@ -{ - "annotations": { - "list": [ - { - "$$hashKey": "object:286", - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "target": { - "limit": 100, - "matchAny": false, - "tags": [], - "type": "dashboard" - }, - "type": "dashboard" - } - ] - }, - "description": "A high level overview of your car", - "editable": true, - "fiscalYearStartMonth": 0, - "graphTooltip": 1, - "iteration": 1656103268002, - "links": [ - { - "icon": "dashboard", - "tags": [], - "title": "TeslaMate", - "tooltip": "", - "type": "link", - "url": "[[base_url:raw]]" - }, - { - "asDropdown": true, - "icon": "external link", - "tags": [ - "tesla" - ], - "title": "Dashboards", - "type": "dashboards" - } - ], - "liveNow": false, - "panels": [ - { - "collapsed": false, - "datasource": "TeslaMate", - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 0 - }, - "id": 18, - "panels": [], - "repeat": "car_id", - "title": "$car_id", - "type": "row" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "displayName": "", - "mappings": [], - "max": 100, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "light-red", - "value": null - }, - { - "color": "semi-dark-yellow", - "value": 10 - }, - { - "color": "semi-dark-green", - "value": 20 - } - ] - }, - "unit": "percent" - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 3, - "x": 0, - "y": 1 - }, - "id": 4, - "options": { - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "showThresholdLabels": false, - "showThresholdMarkers": true - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "(SELECT battery_level, date\nFROM positions\nWHERE car_id = $car_id\nORDER BY date DESC\nLIMIT 1)\nUNION\nSELECT battery_level, date\nFROM charges c\nJOIN charging_processes p ON p.id = c.charging_process_id\nWHERE $__timeFilter(date) AND p.car_id = $car_id\nORDER BY date DESC\nLIMIT 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "battery_level" - ], - "type": "column" - } - ] - ], - "table": "positions", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [] - } - ], - "title": "Battery Level", - "type": "gauge" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 0, - "mappings": [], - "max": 260, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "semi-dark-green", - "value": null - } - ] - }, - "unit": "volt" - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 3, - "x": 3, - "y": 1 - }, - "id": 10, - "links": [], - "options": { - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "firstNotNull" - ], - "fields": "", - "values": false - }, - "showThresholdLabels": false, - "showThresholdMarkers": true - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH charging_process AS (\n SELECT id, end_date\n FROM charging_processes\n WHERE car_id = $car_id\n ORDER BY start_date DESC\n LIMIT 1\n)\nSELECT\n $__time(date),\n CASE WHEN charging_process.end_date IS NULL THEN charger_voltage\n ELSE 0\n END AS \"Charging Voltage [V]\"\nFROM charges, charging_process\nWHERE charging_process.id = charging_process_id\nORDER BY date DESC\nLIMIT 1;", - "refId": "A", - "select": [ - [ - { - "params": [ - "outside_temp" - ], - "type": "column" - } - ] - ], - "table": "positions", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Charging Voltage", - "type": "gauge" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 0, - "mappings": [], - "max": 170, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "semi-dark-green", - "value": null - } - ] - }, - "unit": "kwatt" - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 3, - "x": 6, - "y": 1 - }, - "id": 11, - "options": { - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "firstNotNull" - ], - "fields": "", - "values": false - }, - "showThresholdLabels": false, - "showThresholdMarkers": true - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH charging_process AS (\n SELECT id, end_date\n FROM charging_processes\n WHERE car_id = $car_id\n ORDER BY start_date DESC\n LIMIT 1\n)\nSELECT\n $__time(date),\n CASE WHEN charging_process.end_date IS NULL THEN charger_power\n ELSE 0\n END AS \"Power [kW]\"\nFROM charges, charging_process\nWHERE charging_process.id = charging_process_id\nORDER BY date DESC\nLIMIT 1;", - "refId": "A", - "select": [ - [ - { - "params": [ - "outside_temp" - ], - "type": "column" - } - ] - ], - "table": "positions", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Charging kW", - "type": "gauge" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "max": 100, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "percent" - }, - "overrides": [] - }, - "gridPos": { - "h": 7, - "w": 15, - "x": 9, - "y": 1 - }, - "id": 13, - "links": [ - { - "targetBlank": true, - "title": "Drive details", - "url": "/d/zm7wN6Zgz/drive-details?orgId=1" - } - ], - "options": { - "legend": { - "calcs": [ - "max", - "min" - ], - "displayMode": "list", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "datasource": "TeslaMate", - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT $__time(date), battery_level AS \"SOC\"\nFROM (\n\tSELECT battery_level, date\n\tFROM positions\n\tWHERE car_id = $car_id AND $__timeFilter(date)\n\tUNION ALL\n\tSELECT battery_level, date\n\tFROM charges c \n JOIN charging_processes p ON p.id = c.charging_process_id\n\tWHERE $__timeFilter(date) AND p.car_id = $car_id) AS data\nORDER BY date ASC;", - "refId": "A", - "select": [ - [ - { - "params": [ - "latitude" - ], - "type": "column" - } - ] - ], - "table": "positions", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Charge Level", - "type": "timeseries" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "decimals": 0, - "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": "range_km" - }, - "properties": [ - { - "id": "unit", - "value": "lengthkm" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "range_mi" - }, - "properties": [ - { - "id": "unit", - "value": "lengthmi" - } - ] - } - ] - }, - "gridPos": { - "h": 3, - "w": 3, - "x": 0, - "y": 5 - }, - "id": 14, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "first" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "textMode": "value" - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT $__time(date), range as \"range_$length_unit\"\nFROM (\n\t(SELECT date, convert_km([[preferred_range]]_battery_range_km, '$length_unit') AS range\n\tFROM positions\n\tWHERE car_id = $car_id AND [[preferred_range]]_battery_range_km IS NOT NULL\n ORDER BY date DESC\n\tLIMIT 1)\n\tUNION ALL\n\t(SELECT date, convert_km([[preferred_range]]_battery_range_km, '$length_unit') AS range\n\tFROM charges c\n\tJOIN charging_processes p ON p.id = c.charging_process_id\n\tWHERE p.car_id = $car_id\n\tORDER BY date DESC\n\tLIMIT 1)\n) AS data\nORDER BY date DESC\nLIMIT 1;", - "refId": "A", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "column" - } - ] - ], - "timeColumn": "time", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Range", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": ".*_km" - }, - "properties": [ - { - "id": "unit", - "value": "Wh/km" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": ".*_mi" - }, - "properties": [ - { - "id": "unit", - "value": "Wh/mi" - } - ] - } - ] - }, - "gridPos": { - "h": 3, - "w": 3, - "x": 3, - "y": 5 - }, - "id": 22, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n sum(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0) * car.efficiency * 1000) / \n convert_km(sum(distance)::numeric, '$length_unit') as \"consumption_$length_unit\"\nFROM drives\nJOIN cars car ON car.id = car_id\nWHERE $__timeFilter(start_date) AND car_id = $car_id", - "refId": "A", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Net", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": ".*_km" - }, - "properties": [ - { - "id": "unit", - "value": "Wh/km" - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": ".*_mi" - }, - "properties": [ - { - "id": "unit", - "value": "Wh/mi" - } - ] - } - ] - }, - "gridPos": { - "h": 3, - "w": 3, - "x": 6, - "y": 5 - }, - "id": 24, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH d AS (\n\tSELECT\n\t\tc.car_id,\n\t\tlag(end_[[preferred_range]]_range_km) OVER (ORDER BY start_date) - start_[[preferred_range]]_range_km AS range_loss,\n\t\tp.odometer - lag(p.odometer) OVER (ORDER BY start_date) AS distance\n\tFROM charging_processes c\n\tLEFT JOIN positions p ON p.id = c.position_id \n\tWHERE\n\t end_date IS NOT NULL AND\n\t c.car_id = $car_id AND\n\t $__timeFilter(start_date)\n\tORDER BY start_date\n),\n\nrange_loss_between_charges AS (\n SELECT sum(range_loss) AS range_loss\n FROM d\n WHERE distance >= 0 AND range_loss >= 0\n GROUP BY car_id\n),\n\ncharge_dates AS (\n\tSELECT\n\t\tmin(start_date) as first_charge,\n\t\tmax(end_date) as last_charge\n\tFROM\n\t\tcharging_processes\n\tWHERE\n\t\tend_date IS NOT NULL\n\t\tAND car_id = $car_id\n\t\tAND $__timeFilter(start_date)\n),\n\nrange_loss_before_first_charge AS (\n\tSELECT\n\t\tmax([[preferred_range]]_battery_range_km) - min([[preferred_range]]_battery_range_km) AS range_loss\n\tFROM positions, charge_dates\n\tWHERE\n\t\tcar_id = $car_id\n\t\tAND $__timeFilter(date)\n\t\tAND ((select first_charge from charge_dates) is null OR date < (select first_charge from charge_dates))\n),\n\nrange_loss_after_last_charge AS (\n\tSELECT\n\t\tmax([[preferred_range]]_battery_range_km) - min([[preferred_range]]_battery_range_km) AS range_loss\n\tFROM positions, charge_dates\n\tWHERE\n\t\tcar_id = $car_id\n\t\tAND $__timeFilter(date)\n\t\tAND date > (select last_charge from charge_dates)\t\n),\n\ntotal_range_loss AS (\n SELECT sum(range_loss) as range_loss\n FROM (\n SELECT range_loss FROM range_loss_between_charges\n UNION ALL\n SELECT range_loss FROM range_loss_before_first_charge\n UNION ALL\n SELECT range_loss FROM range_loss_after_last_charge\n ) r\n),\n\ndistance AS (\n SELECT max(odometer) - min(odometer) as distance\n FROM positions\n WHERE car_id = $car_id AND $__timeFilter(date)\n)\n\nSELECT \n NULLIF(range_loss, 0) * (c.efficiency * 1000) / convert_km(NULLIF(distance::numeric, 0), '$length_unit') as \"consumption_$length_unit\"\nFROM total_range_loss, distance\nLEFT JOIN cars c ON c.id = $car_id", - "refId": "A", - "select": [ - [ - { - "params": [ - "start_km" - ], - "type": "column" - } - ] - ], - "table": "drives", - "timeColumn": "start_date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Gross", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#c7d0d9", - "value": null - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "version" - }, - "properties": [ - { - "id": "unit", - "value": "string" - } - ] - } - ] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 0, - "y": 8 - }, - "id": 2, - "links": [ - { - "targetBlank": true, - "title": "Updates", - "url": "/d/IiC07mgWz/updates?orgId=1" - } - ], - "maxDataPoints": 100, - "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "first" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "/^version$/", - "values": true - }, - "textMode": "value" - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "select split_part(version, ' ', 1) as version \nfrom updates \nwhere car_id = $car_id \norder by start_date desc \nlimit 1", - "refId": "A", - "select": [ - [ - { - "params": [ - "efficiency" - ], - "type": "column" - } - ] - ], - "table": "cars", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Firmware", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "decimals": 0, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#c7d0d9", - "value": null - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "odometer_km" - }, - "properties": [ - { - "id": "unit", - "value": "km" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "odometer_mi" - }, - "properties": [ - { - "id": "unit", - "value": "mi" - } - ] - } - ] - }, - "gridPos": { - "h": 3, - "w": 5, - "x": 4, - "y": 8 - }, - "id": 6, - "links": [ - { - "targetBlank": true, - "title": "Mileage", - "url": "/d/NjtMTFggz/mileage?orgId=1" - } - ], - "maxDataPoints": 100, - "options": { - "colorMode": "value", - "fieldOptions": { - "calcs": [ - "first" - ] - }, - "graphMode": "none", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "mean" - ], - "fields": "", - "values": false - }, - "textMode": "value" - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "select $__time(date), convert_km(odometer::numeric, '$length_unit') as \"odometer_$length_unit\"\nfrom positions \nwhere car_id = $car_id \norder by date desc \nlimit 1;", - "refId": "A", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "column" - } - ] - ], - "timeColumn": "time", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Odometer", - "type": "stat" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "stepAfter", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Charging Voltage [V]" - }, - "properties": [ - { - "id": "min", - "value": 0 - }, - { - "id": "max", - "value": 250 - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "charger_power" - }, - "properties": [ - { - "id": "displayName", - "value": "Power" - }, - { - "id": "unit", - "value": "kwatt" - }, - { - "id": "custom.axisPlacement", - "value": "hidden" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "battery_heater" - }, - "properties": [ - { - "id": "displayName", - "value": "Battery heater" - }, - { - "id": "custom.axisPlacement", - "value": "hidden" - }, - { - "id": "unit", - "value": "bool_on_off" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "charger_actual_current" - }, - "properties": [ - { - "id": "displayName", - "value": "Current" - }, - { - "id": "unit", - "value": "amp" - }, - { - "id": "custom.axisPlacement", - "value": "hidden" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "charge_energy_added" - }, - "properties": [ - { - "id": "displayName", - "value": "Energy added" - }, - { - "id": "unit", - "value": "kwatth" - } - ] - } - ] - }, - "gridPos": { - "h": 7, - "w": 15, - "x": 9, - "y": 8 - }, - "id": 15, - "links": [ - { - "targetBlank": true, - "title": "Charging Details", - "url": "/d/BHhxFeZRz/charge-details?orgId=1" - } - ], - "options": { - "legend": { - "calcs": [ - "max", - "min" - ], - "displayMode": "list", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "datasource": "TeslaMate", - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n $__time(date),\n charger_power,\n (case when battery_heater_on then 1 else 0 end) as battery_heater,\n charger_actual_current,\n c.charge_energy_added\nFROM\n charges c\njoin\n charging_processes p ON p.id = c.charging_process_id \nWHERE\n $__timeFilter(date) and\n p.car_id = $car_id\nORDER BY\n date ASC", - "refId": "B", - "select": [ - [ - { - "params": [ - "latitude" - ], - "type": "column" - } - ] - ], - "table": "positions", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - }, - { - "format": "time_series", - "group": [], - "hide": false, - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n $__time(date),\n charger_voltage as \"Charging Voltage [V]\"\nFROM\n charges c\njoin\n charging_processes p ON p.id = c.charging_process_id \nWHERE\n $__timeFilter(date) and\n p.car_id = $car_id\nORDER BY\n date ASC", - "refId": "C", - "select": [ - [ - { - "params": [ - "latitude" - ], - "type": "column" - } - ] - ], - "table": "positions", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Charging Details", - "type": "timeseries" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 0, - "mappings": [], - "max": 100, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "semi-dark-green", - "value": null - } - ] - }, - "unit": "degree" - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 3, - "x": 0, - "y": 11 - }, - "id": 16, - "options": { - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "firstNotNull" - ], - "fields": "", - "values": false - }, - "showThresholdLabels": false, - "showThresholdMarkers": true - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n\t$__time(date),\n\tconvert_celsius(driver_temp_setting, '$temp_unit') as \"Driver Temperature [°$temp_unit]\"\nFROM positions\nWHERE driver_temp_setting IS NOT NULL AND car_id = $car_id AND date AT TIME ZONE 'Etc/UTC' >= (NOW() - interval '60m')\nORDER BY date DESC\nLIMIT 1;", - "refId": "A", - "select": [ - [ - { - "params": [ - "outside_temp" - ], - "type": "column" - } - ] - ], - "table": "positions", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Driver Temp", - "type": "gauge" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 0, - "mappings": [], - "max": 100, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "semi-dark-green", - "value": null - } - ] - }, - "unit": "degree" - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 3, - "x": 3, - "y": 11 - }, - "id": 8, - "options": { - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "firstNotNull" - ], - "fields": "", - "values": false - }, - "showThresholdLabels": false, - "showThresholdMarkers": true - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH last_position AS (\n\tSELECT date, convert_celsius(outside_temp, '$temp_unit') AS \"Outside Temperature [°$temp_unit]\"\n\tFROM positions\n\tWHERE car_id = $car_id AND outside_temp IS NOT NULL AND date AT TIME ZONE 'Etc/UTC' >= (NOW() - interval '60m')\n\tORDER BY date DESC\n\tLIMIT 1\n),\nlast_charge AS (\n\tSELECT date, convert_celsius(outside_temp, '$temp_unit') AS \"Outside Temperature [°$temp_unit]\"\n\tFROM charges\n\tJOIN charging_processes ON charges.charging_process_id = charging_processes.id\n\tWHERE car_id = $car_id AND outside_temp IS NOT NULL AND date AT TIME ZONE 'Etc/UTC' >= (NOW() - interval '60m')\n\tORDER BY date DESC\n\tLIMIT 1\n)\nSELECT * FROM last_position\nUNION ALL\nSELECT * FROM last_charge\nORDER BY date DESC\nLIMIT 1;", - "refId": "A", - "select": [ - [ - { - "params": [ - "outside_temp" - ], - "type": "column" - } - ] - ], - "table": "positions", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Outside Temp", - "type": "gauge" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "decimals": 0, - "mappings": [], - "max": 100, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "semi-dark-green", - "value": null - } - ] - }, - "unit": "degree" - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 3, - "x": 6, - "y": 11 - }, - "id": 9, - "options": { - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "firstNotNull" - ], - "fields": "", - "values": false - }, - "showThresholdLabels": false, - "showThresholdMarkers": true - }, - "pluginVersion": "8.5.4", - "targets": [ - { - "format": "table", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "SELECT\n date,\n convert_celsius(inside_temp, '$temp_unit') AS \"Inside Temperature [°$temp_unit]\"\nFROM positions\nWHERE\n car_id = $car_id\n and inside_temp is not null AND date AT TIME ZONE 'Etc/UTC' >= (NOW() - interval '60m')\norder by date desc\nlimit 1 ", - "refId": "A", - "select": [ - [ - { - "params": [ - "outside_temp" - ], - "type": "column" - } - ] - ], - "table": "positions", - "timeColumn": "date", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "Inside Temp", - "type": "gauge" - }, - { - "datasource": "TeslaMate", - "fieldConfig": { - "defaults": { - "color": { - "mode": "continuous-GrYlRd" - }, - "custom": { - "fillOpacity": 100, - "lineWidth": 0, - "spanNulls": false - }, - "mappings": [ - { - "options": { - "0": { - "color": "#6ED0E0", - "index": 0, - "text": "online" - }, - "1": { - "color": "#8F3BB8", - "index": 1, - "text": "driving" - }, - "2": { - "color": "#F2CC0C", - "index": 2, - "text": "charging" - }, - "3": { - "color": "#FFB357", - "index": 3, - "text": "offline" - }, - "4": { - "color": "#56A64B", - "index": 4, - "text": "asleep" - }, - "5": { - "color": "#6ED0E0", - "index": 5, - "text": "online" - }, - "6": { - "color": "#E02F44", - "index": 6, - "text": "updating" - }, - "null": { - "index": 7, - "text": "N/A" - } - }, - "type": "value" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 5, - "w": 24, - "x": 0, - "y": 15 - }, - "id": 20, - "links": [ - { - "title": "States", - "url": "/d/xo4BNRkZz/states" - } - ], - "options": { - "alignValue": "center", - "legend": { - "displayMode": "list", - "placement": "bottom" - }, - "mergeValues": true, - "rowHeight": 0.9, - "showValue": "auto", - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "format": "time_series", - "group": [], - "metricColumn": "none", - "rawQuery": true, - "rawSql": "WITH states AS (\n SELECT\n unnest(ARRAY [start_date + interval '1 second', end_date]) AS date,\n unnest(ARRAY [2, 0]) AS state\n FROM charging_processes\n WHERE\n car_id = $car_id AND \n ($__timeFrom() :: timestamp - interval '30 day') < start_date AND \n (end_date < ($__timeTo() :: timestamp + interval '30 day') OR end_date IS NULL)\n UNION\n SELECT\n unnest(ARRAY [start_date + interval '1 second', end_date]) AS date,\n unnest(ARRAY [1, 0]) AS state\n FROM drives\n WHERE\n car_id = $car_id AND \n ($__timeFrom() :: timestamp - interval '30 day') < start_date AND \n (end_date < ($__timeTo() :: timestamp + interval '30 day') OR end_date IS NULL)\n UNION\n SELECT\n start_date AS date,\n CASE\n WHEN state = 'offline' THEN 3\n WHEN state = 'asleep' THEN 4\n WHEN state = 'online' THEN 5\n END AS state\n FROM states\n WHERE\n car_id = $car_id AND \n ($__timeFrom() :: timestamp - interval '30 day') < start_date AND \n (end_date < ($__timeTo() :: timestamp + interval '30 day') OR end_date IS NULL)\n UNION\n SELECT\n unnest(ARRAY [start_date + interval '1 second', end_date]) AS date,\n unnest(ARRAY [6, 0]) AS state\n FROM updates\n WHERE\n car_id = $car_id AND \n ($__timeFrom() :: timestamp - interval '30 day') < start_date AND \n (end_date < ($__timeTo() :: timestamp + interval '30 day') OR end_date IS NULL)\n)\nSELECT date AS \"time\", state\nFROM states\nWHERE \n date IS NOT NULL AND\n ($__timeFrom() :: timestamp - interval '30 day') < date AND \n date < ($__timeTo() :: timestamp + interval '30 day') \nORDER BY date ASC, state ASC;", - "refId": "A", - "select": [ - [ - { - "params": [ - "latitude" - ], - "type": "column" - } - ] - ], - "table": "geofences", - "timeColumn": "inserted_at", - "timeColumnType": "timestamp", - "where": [ - { - "name": "$__timeFilter", - "params": [], - "type": "macro" - } - ] - } - ], - "title": "States", - "type": "state-timeline" - } - ], - "refresh": "30s", - "schemaVersion": 36, - "style": "dark", - "tags": [ - "tesla" - ], - "templating": { - "list": [ - { - "current": { - "selected": false, - "text": "All", - "value": "$__all" - }, - "datasource": "TeslaMate", - "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", - "hide": 2, - "includeAll": true, - "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": { - "selected": false, - "text": "km", - "value": "km" - }, - "datasource": "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": { - "selected": false, - "text": "C", - "value": "C" - }, - "datasource": "TeslaMate", - "definition": "select unit_of_temperature from settings limit 1;", - "hide": 2, - "includeAll": false, - "multi": false, - "name": "temp_unit", - "options": [], - "query": "select unit_of_temperature from settings limit 1;", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "current": { - "selected": false, - "text": "ideal", - "value": "ideal" - }, - "datasource": "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": { - "selected": false, - "text": "http://localhost:4000", - "value": "http://localhost:4000" - }, - "datasource": "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 - } - ] - }, - "time": { - "from": "now-24h", - "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": "Overview - LFP", - "uid": "EVzVGnwSq", - "version": 1, - "weekStart": "" -} diff --git a/grafana/dashboards/overview.json b/grafana/dashboards/overview.json index 92ca0e60e5..7795ab372d 100644 --- a/grafana/dashboards/overview.json +++ b/grafana/dashboards/overview.json @@ -1,4 +1,43 @@ { + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "gauge", + "name": "Gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "11.0.0" + }, + { + "type": "datasource", + "id": "grafana-postgresql-datasource", + "name": "PostgreSQL", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "state-timeline", + "name": "State timeline", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + } + ], "annotations": { "list": [ { @@ -23,7 +62,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, - "iteration": 1656103268002, + "id": null, "links": [ { "icon": "dashboard", @@ -61,7 +100,10 @@ "type": "row" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -75,24 +117,8 @@ "mode": "absolute", "steps": [ { - "color": "light-red", + "color": "transparent", "value": null - }, - { - "color": "semi-dark-yellow", - "value": 10 - }, - { - "color": "semi-dark-green", - "value": 20 - }, - { - "color": "semi-dark-yellow", - "value": 81 - }, - { - "color": "light-red", - "value": 91 } ] }, @@ -108,6 +134,8 @@ }, "id": 4, "options": { + "minVizHeight": 75, + "minVizWidth": 75, "orientation": "auto", "reduceOptions": { "calcs": [ @@ -117,11 +145,16 @@ "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "sizing": "auto" }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "format": "table", "group": [], "metricColumn": "none", @@ -142,13 +175,99 @@ "timeColumn": "date", "timeColumnType": "timestamp", "where": [] + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "SELECT\r\n 0 as lowest,\r\n 10 as low,\r\n 20 as mid,\r\n CASE\r\n WHEN substring(vin, 7, 1) = 'F'\r\n THEN 100\r\n ELSE 81\r\n END as high,\r\n CASE\r\n WHEN substring(vin, 7, 1) = 'F'\r\n THEN 100\r\n ELSE 91\r\n END as highest\r\nfrom cars ", + "refId": "B", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], "title": "Battery Level", + "transformations": [ + { + "id": "configFromData", + "options": { + "applyTo": { + "id": "byFrameRefID", + "options": "A" + }, + "configRefId": "B", + "mappings": [ + { + "fieldName": "lowest", + "handlerKey": "threshold1" + }, + { + "fieldName": "low", + "handlerArguments": { + "threshold": { + "color": "yellow" + } + }, + "handlerKey": "threshold1" + }, + { + "fieldName": "mid", + "handlerArguments": { + "threshold": { + "color": "green" + } + }, + "handlerKey": "threshold1" + }, + { + "fieldName": "high", + "handlerArguments": { + "threshold": { + "color": "yellow" + } + }, + "handlerKey": "threshold1" + }, + { + "fieldName": "highest", + "handlerArguments": { + "threshold": { + "color": "red" + } + }, + "handlerKey": "threshold1" + } + ] + } + } + ], "type": "gauge" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -178,8 +297,9 @@ "y": 1 }, "id": 10, - "links": [], "options": { + "minVizHeight": 75, + "minVizWidth": 75, "orientation": "auto", "reduceOptions": { "calcs": [ @@ -189,9 +309,10 @@ "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "sizing": "auto" }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { "format": "time_series", @@ -219,22 +340,29 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Charging Voltage", "type": "gauge" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "decimals": 0, + "fieldMinMax": false, "mappings": [], - "max": 250, "min": 0, "thresholds": { "mode": "absolute", @@ -257,6 +385,8 @@ }, "id": 11, "options": { + "minVizHeight": 75, + "minVizWidth": 75, "orientation": "auto", "reduceOptions": { "calcs": [ @@ -266,11 +396,16 @@ "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "sizing": "auto" }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "format": "table", "group": [], "metricColumn": "none", @@ -297,19 +432,68 @@ "type": "macro" } ] + }, + { + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "SELECT\r\n CASE\r\n WHEN substring(vin, 7, 1) = 'F'\r\n THEN 170\r\n ELSE 250\r\n END as max_charging_kw\r\nfrom cars ", + "refId": "B", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], "title": "Charging kW", + "transformations": [ + { + "id": "configFromData", + "options": { + "configRefId": "B", + "mappings": [ + { + "fieldName": "max_charging_kw", + "handlerKey": "max" + } + ] + } + } + ], "type": "gauge" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -321,6 +505,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", "lineWidth": 1, "pointSize": 5, @@ -378,9 +563,11 @@ "min" ], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { + "maxHeight": 600, "mode": "multi", "sort": "none" } @@ -388,7 +575,10 @@ "pluginVersion": "8.5.4", "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "format": "time_series", "group": [], "metricColumn": "none", @@ -421,7 +611,10 @@ "type": "timeseries" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "decimals": 0, @@ -481,7 +674,6 @@ "y": 5 }, "id": 14, - "links": [], "maxDataPoints": 100, "options": { "colorMode": "value", @@ -500,9 +692,11 @@ "fields": "", "values": false }, - "textMode": "value" + "showPercentChange": false, + "textMode": "value", + "wideLayout": true }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { "format": "time_series", @@ -528,14 +722,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Range", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "mappings": [], @@ -595,9 +796,11 @@ "fields": "", "values": false }, - "textMode": "auto" + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -625,14 +828,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Net", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "mappings": [], @@ -692,9 +902,11 @@ "fields": "", "values": false }, - "textMode": "auto" + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -722,14 +934,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Gross", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "mappings": [], @@ -791,9 +1010,11 @@ "fields": "/^version$/", "values": true }, - "textMode": "value" + "showPercentChange": false, + "textMode": "value", + "wideLayout": true }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -821,14 +1042,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Firmware", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "decimals": 0, @@ -903,9 +1131,11 @@ "fields": "", "values": false }, - "textMode": "value" + "showPercentChange": false, + "textMode": "value", + "wideLayout": true }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { "format": "time_series", @@ -931,20 +1161,30 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Odometer", "type": "stat" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -956,6 +1196,7 @@ "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "stepAfter", "lineWidth": 1, "pointSize": 5, @@ -1104,9 +1345,11 @@ "min" ], "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "tooltip": { + "maxHeight": 600, "mode": "multi", "sort": "none" } @@ -1114,7 +1357,10 @@ "pluginVersion": "8.5.4", "targets": [ { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "format": "time_series", "group": [], "metricColumn": "none", @@ -1169,14 +1415,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Charging Details", "type": "timeseries" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -1207,6 +1460,8 @@ }, "id": 16, "options": { + "minVizHeight": 75, + "minVizWidth": 75, "orientation": "auto", "reduceOptions": { "calcs": [ @@ -1216,9 +1471,10 @@ "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "sizing": "auto" }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -1246,14 +1502,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Driver Temp", "type": "gauge" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -1284,6 +1547,8 @@ }, "id": 8, "options": { + "minVizHeight": 75, + "minVizWidth": 75, "orientation": "auto", "reduceOptions": { "calcs": [ @@ -1293,9 +1558,10 @@ "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "sizing": "auto" }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -1323,14 +1589,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Outside Temp", "type": "gauge" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -1361,6 +1634,8 @@ }, "id": 9, "options": { + "minVizHeight": 75, + "minVizWidth": 75, "orientation": "auto", "reduceOptions": { "calcs": [ @@ -1370,9 +1645,10 @@ "values": false }, "showThresholdLabels": false, - "showThresholdMarkers": true + "showThresholdMarkers": true, + "sizing": "auto" }, - "pluginVersion": "8.5.4", + "pluginVersion": "11.0.0", "targets": [ { "format": "table", @@ -1400,14 +1676,21 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "Inside Temp", "type": "gauge" }, { - "datasource": "TeslaMate", + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + }, "fieldConfig": { "defaults": { "color": { @@ -1415,6 +1698,12 @@ }, "custom": { "fillOpacity": 100, + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, "lineWidth": 0, "spanNulls": false }, @@ -1498,12 +1787,14 @@ "alignValue": "center", "legend": { "displayMode": "list", - "placement": "bottom" + "placement": "bottom", + "showLegend": true }, "mergeValues": true, "rowHeight": 0.9, "showValue": "auto", "tooltip": { + "maxHeight": 600, "mode": "single", "sort": "none" } @@ -1535,7 +1826,11 @@ "params": [], "type": "macro" } - ] + ], + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" + } } ], "title": "States", @@ -1543,20 +1838,18 @@ } ], "refresh": "30s", - "schemaVersion": 36, - "style": "dark", + "schemaVersion": 39, "tags": [ "tesla" ], "templating": { "list": [ { - "current": { - "selected": false, - "text": "All", - "value": "$__all" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;", "hide": 2, "includeAll": true, @@ -1575,12 +1868,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "km", - "value": "km" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select unit_of_length from settings limit 1;", "hide": 2, "includeAll": false, @@ -1598,12 +1890,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "C", - "value": "C" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select unit_of_temperature from settings limit 1;", "hide": 2, "includeAll": false, @@ -1621,12 +1912,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "ideal", - "value": "ideal" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select preferred_range from settings limit 1;", "hide": 2, "includeAll": false, @@ -1645,12 +1935,11 @@ "useTags": false }, { - "current": { - "selected": false, - "text": "http://localhost:4000", - "value": "http://localhost:4000" + "current": {}, + "datasource": { + "type": "grafana-postgresql-datasource", + "uid": "TeslaMate" }, - "datasource": "TeslaMate", "definition": "select base_url from settings limit 1;", "hide": 2, "includeAll": false, @@ -1674,6 +1963,7 @@ "from": "now-24h", "to": "now" }, + "timeRangeUpdatedDuringEditOrView": false, "timepicker": { "hidden": false, "refresh_intervals": [ @@ -1703,6 +1993,6 @@ "timezone": "", "title": "Overview", "uid": "kOuP_Fggz", - "version": 1, + "version": 4, "weekStart": "" -} +} \ No newline at end of file diff --git a/grafana/datasource.yml b/grafana/datasource.yml index 72e20923f7..7e9572d3b4 100644 --- a/grafana/datasource.yml +++ b/grafana/datasource.yml @@ -1,19 +1,19 @@ apiVersion: 1 datasources: -- name: TeslaMate - type: postgres - url: $DATABASE_HOST:$DATABASE_PORT - user: $DATABASE_USER - database: $DATABASE_NAME - access: proxy - basicAuth: false - withCredentials: false - isDefault: true - secureJsonData: - password: $DATABASE_PASS - jsonData: - postgresVersion: 1500 - sslmode: $DATABASE_SSL_MODE - version: 1 - editable: true + - name: TeslaMate + type: postgres + url: $DATABASE_HOST:$DATABASE_PORT + user: $DATABASE_USER + database: $DATABASE_NAME + access: proxy + basicAuth: false + withCredentials: false + isDefault: true + secureJsonData: + password: $DATABASE_PASS + jsonData: + postgresVersion: 1500 + sslmode: $DATABASE_SSL_MODE + version: 1 + editable: true