{
    "__elements": {},
    "__requires": [
        {
            "type": "panel",
            "id": "barchart",
            "name": "Bar chart",
            "version": ""
        },
        {
            "type": "panel",
            "id": "geomap",
            "name": "Geomap",
            "version": ""
        },
        {
            "type": "grafana",
            "id": "grafana",
            "name": "Grafana",
            "version": "10.4.0"
        },
        {
            "type": "datasource",
            "id": "grafana-postgresql-datasource",
            "name": "PostgreSQL",
            "version": "1.0.0"
        },
        {
            "type": "panel",
            "id": "stat",
            "name": "Stat",
            "version": ""
        },
        {
            "type": "panel",
            "id": "timeseries",
            "name": "Time series",
            "version": ""
        }
    ],
    "annotations": {
        "list": [
            {
                "$$hashKey": "object:31",
                "builtIn": 1,
                "datasource": "-- Grafana --",
                "definition": "TeslaMate|U2FsdGVkX1/cEWK+8cz7pjEKXtzJnDN7b21ZDXt1MGneFGPWTLqOPtxKmu02mJPLzi/f29I+NBHd3vi0FB8R4Xn0+GtobWDgk6VAVSBTdSNniOKO8i2WPlhRaOsl2+hG7gnZ7wrf1Th2nxR7f1uYCrbwOek0IzkfLzrkjh7gkr6inT6bbDuJqrmogZajLxmAMrQ6V+/vHxBRGiwjJhgiEeq3hM1q2h04JKkNiZ8RHbsF5Cd/xd8Q9u0JVrZzIrtnhM/SFlaApU7RtRMu8CSj1llTX7WEOj6VDZAMSf+XUAanWdk725kEPN9MNu89o2zEq5P3E3cju8IbbBdPzXLV3oVuzD6/tMnxFToIIV1E/BrpF7s2RtNa8+KJJ1PF8xgs6m+/KTD2hy+WsP0636AgObRAmYg7+qotGrgNvpNPdE0EgrB7WHYlV7R/1q66bcq6tCe51X1Un70k+zo+K6AK0o4B1H6IyMlEVuRH/Fz8QVl9aYu2ztd08RbuKJlYVKpkH+pxVETAO9MclYQ90tzE6TfwDZrQZzsAlMenr4s1ZB1OlFXjLjVjnddnUilzO76cqv4yI2THQEuyQ47nuVQ4gUbx02K59vMQhns3C01JOAYokOaSXe66Y7QYdMlk09Lf|aes-256-cbc",
                "enable": true,
                "hide": true,
                "iconColor": "rgba(0, 211, 255, 1)",
                "name": "Annotations & Alerts",
                "target": {
                    "limit": 100,
                    "matchAny": false,
                    "tags": [],
                    "type": "dashboard"
                },
                "type": "dashboard"
            }
        ]
    },
    "editable": true,
    "fiscalYearStartMonth": 0,
    "graphTooltip": 1,
    "id": null,
    "links": [
        {
            "icon": "dashboard",
            "tags": [],
            "title": "TeslaMate",
            "tooltip": "",
            "type": "link",
            "url": "[[base_url:raw]]"
        },
        {
            "icon": "",
            "tags": [],
            "title": "GpxExport",
            "tooltip": "",
            "type": "link",
            "url": "[[base_url:raw]]/drive/$drive_id/gpx"
        },
        {
            "asDropdown": true,
            "icon": "external link",
            "tags": ["tesla"],
            "title": "Dashboards",
            "type": "dashboards"
        }
    ],
    "liveNow": false,
    "panels": [
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 0
            },
            "id": 40,
            "panels": [],
            "title": "Car: $car_id",
            "type": "row"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "custom": {
                        "axisBorderShow": false,
                        "axisCenteredZero": true,
                        "axisColorMode": "text",
                        "axisLabel": "",
                        "axisPlacement": "auto",
                        "barAlignment": 0,
                        "drawStyle": "line",
                        "fillOpacity": 5,
                        "gradientMode": "opacity",
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        },
                        "insertNulls": false,
                        "lineInterpolation": "smooth",
                        "lineWidth": 1,
                        "pointSize": 5,
                        "scaleDistribution": {
                            "type": "linear"
                        },
                        "showPoints": "never",
                        "spanNulls": true,
                        "stacking": {
                            "group": "A",
                            "mode": "none"
                        },
                        "thresholdsStyle": {
                            "mode": "off"
                        }
                    },
                    "links": [],
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 80
                            }
                        ]
                    },
                    "unit": "locale"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": ".*_kmh$"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "velocitykmh"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": ".*_mih$"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "velocitymph"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": ".*_km$"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "lengthkm"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": ".*_mi$"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "lengthmi"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "speed_.*"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Speed"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "power"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "kwatt"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "right"
                            },
                            {
                                "id": "displayName",
                                "value": "Power"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "battery_heater"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Battery Heater"
                            },
                            {
                                "id": "unit",
                                "value": "bool_on_off"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "range_ideal_.*"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Range (ideal)"
                            },
                            {
                                "id": "min",
                                "value": 0
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "range_rated_.*"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Range (rated)"
                            },
                            {
                                "id": "min",
                                "value": 0
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "battery_level"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "percent"
                            },
                            {
                                "id": "displayName",
                                "value": "SOC"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "usable_battery_level"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Usable SOC"
                            },
                            {
                                "id": "unit",
                                "value": "percent"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "range_estimated_.*"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Range (est.)"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Power"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "semi-dark-orange",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Usable SOC"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "semi-dark-green",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "SOC"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "light-green",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Range (est.)"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "light-purple",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Range (ideal)"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "semi-dark-purple",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Battery Heater"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "dark-red",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Speed"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "light-blue",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Range (rated)"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "semi-dark-purple",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 12,
                "w": 12,
                "x": 0,
                "y": 1
            },
            "id": 39,
            "options": {
                "legend": {
                    "calcs": ["mean", "max", "min"],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "none"
                }
            },
            "targets": [
                {
                    "alias": "",
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "editorMode": "code",
                    "format": "time_series",
                    "group": [],
                    "hide": false,
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\t$__time(date),\n\tconvert_km(speed::numeric, '$length_unit') AS speed_[[length_unit]]h,\n\tpower,\n\tconvert_km([[preferred_range]]_battery_range_km, '$length_unit') AS range_[[preferred_range]]_[[length_unit]],\n\tconvert_km(est_battery_range_km, '$length_unit') AS range_estimated_[[length_unit]],\n\tbattery_level,\n\tusable_battery_level,\n\tbattery_heater::integer\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["id"],
                                "type": "column"
                            }
                        ]
                    ],
                    "sql": {
                        "columns": [
                            {
                                "parameters": [],
                                "type": "function"
                            }
                        ],
                        "groupBy": [
                            {
                                "property": {
                                    "type": "string"
                                },
                                "type": "groupBy"
                            }
                        ],
                        "limit": 50
                    },
                    "table": "charging",
                    "timeColumn": "Datum",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Drive",
            "type": "timeseries"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "fixedColor": "red",
                        "mode": "thresholds"
                    },
                    "custom": {
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        }
                    },
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            }
                        ]
                    }
                },
                "overrides": []
            },
            "gridPos": {
                "h": 12,
                "w": 12,
                "x": 12,
                "y": 1
            },
            "id": 4,
            "maxDataPoints": 50000,
            "options": {
                "basemap": {
                    "config": {},
                    "name": "Layer 0",
                    "type": "osm-standard"
                },
                "controls": {
                    "mouseWheelZoom": true,
                    "showAttribution": true,
                    "showDebug": false,
                    "showMeasure": false,
                    "showScale": false,
                    "showZoom": true
                },
                "layers": [
                    {
                        "config": {
                            "arrow": 0,
                            "style": {
                                "color": {
                                    "fixed": "dark-blue"
                                },
                                "lineWidth": 2,
                                "opacity": 1,
                                "rotation": {
                                    "fixed": 0,
                                    "max": 360,
                                    "min": -360,
                                    "mode": "mod"
                                },
                                "size": {
                                    "fixed": 3,
                                    "max": 15,
                                    "min": 2
                                },
                                "symbol": {
                                    "field": "",
                                    "fixed": "",
                                    "mode": "fixed"
                                },
                                "symbolAlign": {
                                    "horizontal": "center",
                                    "vertical": "center"
                                },
                                "textConfig": {
                                    "fontSize": 12,
                                    "offsetX": 0,
                                    "offsetY": 0,
                                    "textAlign": "center",
                                    "textBaseline": "middle"
                                }
                            }
                        },
                        "location": {
                            "mode": "auto"
                        },
                        "name": "route",
                        "opacity": 1,
                        "tooltip": true,
                        "type": "route"
                    }
                ],
                "tooltip": {
                    "mode": "details"
                },
                "view": {
                    "allLayers": true,
                    "id": "fit",
                    "lat": 0,
                    "lon": 0,
                    "zoom": 15
                }
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "alias": "",
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "editorMode": "code",
                    "format": "time_series",
                    "group": [
                        {
                            "params": ["$__interval", "none"],
                            "type": "time"
                        }
                    ],
                    "hide": false,
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n  $__time(date),\n  latitude,\n  longitude\nFROM positions\nWHERE \n  car_id = $car_id AND \n  $__timeFilter(date)\nORDER BY \n  date ASC",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["lat"],
                                "type": "column"
                            },
                            {
                                "params": ["avg"],
                                "type": "aggregate"
                            },
                            {
                                "params": ["lat"],
                                "type": "alias"
                            }
                        ],
                        [
                            {
                                "params": ["lng"],
                                "type": "column"
                            },
                            {
                                "params": ["avg"],
                                "type": "aggregate"
                            },
                            {
                                "params": ["lat"],
                                "type": "alias"
                            }
                        ]
                    ],
                    "sql": {
                        "columns": [
                            {
                                "parameters": [],
                                "type": "function"
                            }
                        ],
                        "groupBy": [
                            {
                                "property": {
                                    "type": "string"
                                },
                                "type": "groupBy"
                            }
                        ]
                    },
                    "table": "pos",
                    "timeColumn": "Datum",
                    "timeColumnType": "datetime",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "type": "geomap"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "palette-classic"
                    },
                    "custom": {
                        "axisBorderShow": false,
                        "axisCenteredZero": false,
                        "axisColorMode": "text",
                        "axisLabel": "",
                        "axisPlacement": "auto",
                        "barAlignment": 0,
                        "drawStyle": "line",
                        "fillOpacity": 5,
                        "gradientMode": "opacity",
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        },
                        "insertNulls": false,
                        "lineInterpolation": "smooth",
                        "lineWidth": 1,
                        "pointSize": 5,
                        "scaleDistribution": {
                            "type": "linear"
                        },
                        "showPoints": "never",
                        "spanNulls": true,
                        "stacking": {
                            "group": "A",
                            "mode": "none"
                        },
                        "thresholdsStyle": {
                            "mode": "off"
                        }
                    },
                    "decimals": 0,
                    "links": [],
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 80
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": ".*_m$"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "lengthm"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": ".*_ft$"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "feet"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "elevation_.*"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Elevation"
                            },
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "super-light-blue",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 12,
                "w": 12,
                "x": 0,
                "y": 13
            },
            "id": 8,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": false
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "none"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "format": "time_series",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\t$__time(date),\n\tROUND(convert_m(elevation, '$alternative_length_unit')) AS elevation_[[alternative_length_unit]]\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["charge_energy_added"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "charges",
                    "timeColumn": "date",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Elevation",
            "type": "timeseries"
        },
        {
            "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,
                        "drawStyle": "line",
                        "fillOpacity": 5,
                        "gradientMode": "opacity",
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        },
                        "insertNulls": false,
                        "lineInterpolation": "smooth",
                        "lineWidth": 1,
                        "pointSize": 5,
                        "scaleDistribution": {
                            "type": "linear"
                        },
                        "showPoints": "never",
                        "spanNulls": true,
                        "stacking": {
                            "group": "A",
                            "mode": "none"
                        },
                        "thresholdsStyle": {
                            "mode": "off"
                        }
                    },
                    "links": [],
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 80
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "is_climate_on"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "rgb(210, 203, 203)",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "fan_status"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "#96D98D",
                                    "mode": "fixed"
                                }
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": ".*_c$"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "celsius"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": ".*_f$"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "fahrenheit"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "outside_temp_.*"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "#8AB8FF",
                                    "mode": "fixed"
                                }
                            },
                            {
                                "id": "displayName",
                                "value": "Outside Temperature"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "inside_temp_.*"
                        },
                        "properties": [
                            {
                                "id": "color",
                                "value": {
                                    "fixedColor": "#F2CC0C",
                                    "mode": "fixed"
                                }
                            },
                            {
                                "id": "displayName",
                                "value": "Inside Temperature"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "driver_temp_.*"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Driver Temperature"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "passenger_temp_.*"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Passenger Temperature"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "is_climate_on"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "bool_on_off"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            },
                            {
                                "id": "displayName",
                                "value": "Climate"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "fan_status"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Fan status"
                            },
                            {
                                "id": "custom.axisPlacement",
                                "value": "hidden"
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 6,
                "w": 12,
                "x": 12,
                "y": 13
            },
            "id": 6,
            "options": {
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "none"
                }
            },
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "format": "time_series",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\t$__time(date),\n\tconvert_celsius(outside_temp, '$temp_unit') AS outside_temp_$temp_unit,\n\tconvert_celsius(inside_temp, '$temp_unit') AS inside_temp_$temp_unit,\n\tconvert_celsius(driver_temp_setting, '$temp_unit') as driver_temp_$temp_unit,\n\tconvert_celsius(passenger_temp_setting, '$temp_unit') as passenger_temp_$temp_unit,\n  is_climate_on::integer,\n\tfan_status\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["charge_energy_added"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "charges",
                    "timeColumn": "date",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Temperatures",
            "type": "timeseries"
        },
        {
            "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,
                        "drawStyle": "line",
                        "fillOpacity": 5,
                        "gradientMode": "opacity",
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        },
                        "insertNulls": false,
                        "lineInterpolation": "linear",
                        "lineStyle": {
                            "fill": "solid"
                        },
                        "lineWidth": 1,
                        "pointSize": 5,
                        "scaleDistribution": {
                            "type": "linear"
                        },
                        "showPoints": "never",
                        "spanNulls": false,
                        "stacking": {
                            "group": "A",
                            "mode": "none"
                        },
                        "thresholdsStyle": {
                            "mode": "off"
                        }
                    },
                    "links": [],
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 80
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "tpms_pressure_front_left_bar"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "pressurebar"
                            },
                            {
                                "id": "displayName",
                                "value": "Front Left"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "tpms_pressure_front_right_bar"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "pressurebar"
                            },
                            {
                                "id": "displayName",
                                "value": "Front Right"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "tpms_pressure_rear_left_bar"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "pressurebar"
                            },
                            {
                                "id": "displayName",
                                "value": "Rear Left"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "tpms_pressure_rear_right_bar"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "pressurebar"
                            },
                            {
                                "id": "displayName",
                                "value": "Rear Right"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "tpms_pressure_front_left_psi"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "pressurepsi"
                            },
                            {
                                "id": "displayName",
                                "value": "Front Left"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "tpms_pressure_front_right_psi"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "pressurepsi"
                            },
                            {
                                "id": "displayName",
                                "value": "Front Right"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "tpms_pressure_rear_left_psi"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "pressurepsi"
                            },
                            {
                                "id": "displayName",
                                "value": "Rear Left"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "tpms_pressure_rear_right_psi"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "pressurepsi"
                            },
                            {
                                "id": "displayName",
                                "value": "Rear Right"
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 6,
                "w": 12,
                "x": 12,
                "y": 19
            },
            "id": 32,
            "options": {
                "legend": {
                    "calcs": ["logmin", "max"],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": true
                },
                "tooltip": {
                    "mode": "multi",
                    "sort": "none"
                }
            },
            "targets": [
                {
                    "alias": "",
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "format": "time_series",
                    "group": [],
                    "hide": false,
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\r\n    $__time(date),\r\n    convert_tire_pressure(tpms_pressure_fl,'$pressure_unit') AS tpms_pressure_front_left_$pressure_unit,\r\n    convert_tire_pressure(tpms_pressure_fr,'$pressure_unit') AS tpms_pressure_front_right_$pressure_unit,\r\n    convert_tire_pressure(tpms_pressure_rl,'$pressure_unit') AS tpms_pressure_rear_left_$pressure_unit,\r\n    convert_tire_pressure(tpms_pressure_rr,'$pressure_unit') AS tpms_pressure_rear_right_$pressure_unit\r\nFROM\r\n    positions\r\nWHERE\r\n    car_id = $car_id AND\r\n    $__timeFilter(date) AND\r\n    tpms_pressure_fl is not null\r\nORDER BY\r\n    date ASC",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["id"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "pos",
                    "timeColumn": "date",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Tire Pressure",
            "type": "timeseries"
        },
        {
            "collapsed": false,
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 25
            },
            "id": 36,
            "panels": [],
            "title": "More Details",
            "type": "row"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "description": "",
            "fieldConfig": {
                "defaults": {
                    "decimals": 2,
                    "mappings": [
                        {
                            "options": {
                                "match": "null",
                                "result": {
                                    "text": "N/A"
                                }
                            },
                            "type": "special"
                        }
                    ],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "super-light-blue"
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 3,
                "w": 6,
                "x": 0,
                "y": 26
            },
            "id": 38,
            "maxDataPoints": 100,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "center",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "/.*/",
                    "values": false
                },
                "showPercentChange": false,
                "textMode": "auto",
                "wideLayout": true
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "editorMode": "code",
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT CONCAT_WS(' - ', round(convert_km(start_km::numeric, '$length_unit')), round(convert_km(end_km::numeric, '$length_unit'))) ||' $length_unit' as \"Odometer\"\r\nFROM drives d\r\nWHERE d.id = $drive_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": "Odometer (From - To)",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "description": "",
            "fieldConfig": {
                "defaults": {
                    "decimals": 1,
                    "mappings": [
                        {
                            "options": {
                                "match": "null",
                                "result": {
                                    "text": "N/A"
                                }
                            },
                            "type": "special"
                        }
                    ],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "text"
                            }
                        ]
                    },
                    "unit": "dtdurations"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 3,
                "w": 3,
                "x": 6,
                "y": 26
            },
            "id": 14,
            "maxDataPoints": 100,
            "options": {
                "colorMode": "value",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "horizontal",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "showPercentChange": false,
                "textMode": "auto",
                "wideLayout": true
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT ((DATE_PART('day', end_date - start_date) * 24 + \n                DATE_PART('hour', end_date - start_date)) * 60 +\n                DATE_PART('minute', end_date - start_date)) * 60 +\n                DATE_PART('second', end_date - start_date) as sec_diff\nFROM drives\nWHERE drives.id = $drive_id;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Drive Duration",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "description": "",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "decimals": 1,
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "text"
                            }
                        ]
                    },
                    "unit": "dtdurations"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 3,
                "w": 3,
                "x": 9,
                "y": 26
            },
            "id": 34,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "showPercentChange": false,
                "textMode": "auto",
                "wideLayout": true
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "editorMode": "code",
                    "format": "table",
                    "rawQuery": true,
                    "rawSql": "SELECT ${__to:date:seconds} - ${__from:date:seconds}",
                    "refId": "A",
                    "sql": {
                        "columns": [
                            {
                                "parameters": [],
                                "type": "function"
                            }
                        ],
                        "groupBy": [
                            {
                                "property": {
                                    "type": "string"
                                },
                                "type": "groupBy"
                            }
                        ],
                        "limit": 50
                    }
                }
            ],
            "title": "Selected Duration",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "description": "",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "continuous-GrYlRd"
                    },
                    "custom": {
                        "axisBorderShow": false,
                        "axisCenteredZero": false,
                        "axisColorMode": "text",
                        "axisGridShow": false,
                        "axisLabel": "",
                        "axisPlacement": "auto",
                        "axisWidth": -10,
                        "fillOpacity": 90,
                        "gradientMode": "hue",
                        "hideFrom": {
                            "legend": false,
                            "tooltip": false,
                            "viz": false
                        },
                        "lineWidth": 1,
                        "scaleDistribution": {
                            "type": "linear"
                        },
                        "thresholdsStyle": {
                            "mode": "off"
                        }
                    },
                    "fieldMinMax": true,
                    "mappings": [],
                    "noValue": "0",
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "super-light-green"
                            }
                        ]
                    }
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Elapsed"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "percent"
                            },
                            {
                                "id": "decimals",
                                "value": 0
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 9,
                "w": 12,
                "x": 12,
                "y": 26
            },
            "id": 35,
            "options": {
                "barRadius": 0.05,
                "barWidth": 0.97,
                "colorByField": "Elapsed",
                "fullHighlight": false,
                "groupWidth": 0.7,
                "legend": {
                    "calcs": [],
                    "displayMode": "list",
                    "placement": "bottom",
                    "showLegend": false
                },
                "orientation": "auto",
                "showValue": "auto",
                "stacking": "none",
                "text": {},
                "tooltip": {
                    "mode": "multi",
                    "sort": "none"
                },
                "xField": "Speed",
                "xTickLabelRotation": 0,
                "xTickLabelSpacing": 0
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "editorMode": "code",
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT \r\n    speed_section_$length_unit AS \"Speed\",\r\n    SUM(seconds_elapsed) * 100 / MAX(duration) as \"Elapsed\",\r\n    TO_CHAR((SUM(seconds_elapsed) || ' second')::interval, 'HH24:MI:SS') AS \"Time\"\r\nFROM (\r\n    SELECT\r\n        ROUND(convert_km(p.speed::numeric, '$length_unit') / 10,0) * 10 AS speed_section_$length_unit,\r\n        EXTRACT(EPOCH FROM (LEAD(p.\"date\") OVER (ORDER BY p.\"date\") - p.\"date\")) AS seconds_elapsed,\r\n        EXTRACT(EPOCH FROM (end_date - start_date)) AS duration\r\n    FROM drives d\r\n    INNER JOIN positions p ON p.drive_id = d.id\r\n    WHERE d.id = $drive_id\r\n) AS drivedata\r\nGROUP BY 1\r\nORDER BY 1",
                    "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"
                        }
                    ]
                }
            ],
            "title": "Speed Histogram ($speed_unit)",
            "transformations": [
                {
                    "id": "filterFieldsByName",
                    "options": {
                        "include": {
                            "names": ["Elapsed", "Time", "Speed", "SpeedUnit"]
                        }
                    }
                }
            ],
            "type": "barchart"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "description": "",
            "fieldConfig": {
                "defaults": {
                    "decimals": 2,
                    "displayName": "Distance",
                    "mappings": [
                        {
                            "options": {
                                "match": "null",
                                "result": {
                                    "text": "N/A"
                                }
                            },
                            "type": "special"
                        }
                    ],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "semi-dark-green"
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "km"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "lengthkm"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "mi"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "lengthmi"
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 3,
                "w": 6,
                "x": 0,
                "y": 29
            },
            "id": 10,
            "maxDataPoints": 100,
            "options": {
                "colorMode": "value",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "showPercentChange": false,
                "textMode": "value",
                "wideLayout": true
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "select convert_km(distance::numeric, '$length_unit') as \"$length_unit\" from drives where id = $drive_id;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Distance",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    }
                },
                "overrides": []
            },
            "gridPos": {
                "h": 3,
                "w": 6,
                "x": 6,
                "y": 29
            },
            "id": 20,
            "options": {
                "colorMode": "value",
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "vertical",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "/.*/",
                    "values": false
                },
                "showPercentChange": false,
                "text": {},
                "textMode": "value_and_name",
                "wideLayout": true
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "editorMode": "code",
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "WITH height as (SELECT\n\televation-LAG(elevation,1) over ( order BY\n\tdate ASC ) as diff\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC\n\t)\nSELECT  ROUND(convert_m(sum(diff), '$alternative_length_unit')::numeric,0) || ' $alternative_length_unit'  as \"UP\" from height where diff > 0",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["start_km"],
                                "type": "column"
                            }
                        ]
                    ],
                    "sql": {
                        "columns": [
                            {
                                "parameters": [],
                                "type": "function"
                            }
                        ],
                        "groupBy": [
                            {
                                "property": {
                                    "type": "string"
                                },
                                "type": "groupBy"
                            }
                        ],
                        "limit": 50
                    },
                    "table": "drives",
                    "timeColumn": "start_date",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                },
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "editorMode": "code",
                    "format": "table",
                    "group": [],
                    "hide": false,
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "WITH height as (SELECT\n\televation-LAG(elevation,1) over ( order BY\n\tdate ASC ) as diff\nFROM\n\tpositions\nWHERE\n car_id = $car_id AND\n $__timeFilter(date)\nORDER BY\n\tdate ASC\n\t)\nSELECT ROUND(convert_m(sum(diff), '$alternative_length_unit')::numeric,0) || ' $alternative_length_unit' as \"DOWN\" from height where diff < 0",
                    "refId": "B",
                    "select": [
                        [
                            {
                                "params": ["start_km"],
                                "type": "column"
                            }
                        ]
                    ],
                    "sql": {
                        "columns": [
                            {
                                "parameters": [],
                                "type": "function"
                            }
                        ],
                        "groupBy": [
                            {
                                "property": {
                                    "type": "string"
                                },
                                "type": "groupBy"
                            }
                        ],
                        "limit": 50
                    },
                    "table": "drives",
                    "timeColumn": "start_date",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Elevation Summary",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "fieldConfig": {
                "defaults": {
                    "decimals": 2,
                    "mappings": [
                        {
                            "options": {
                                "match": "null",
                                "result": {
                                    "text": "N/A"
                                }
                            },
                            "type": "special"
                        }
                    ],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "light-yellow"
                            }
                        ]
                    },
                    "unit": "kwatth"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 3,
                "w": 6,
                "x": 0,
                "y": 32
            },
            "id": 12,
            "maxDataPoints": 100,
            "options": {
                "colorMode": "value",
                "graphMode": "none",
                "justifyMode": "center",
                "orientation": "horizontal",
                "reduceOptions": {
                    "calcs": ["lastNotNull"],
                    "fields": "",
                    "values": false
                },
                "showPercentChange": false,
                "textMode": "value",
                "wideLayout": true
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\t(NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) * car.efficiency)\nFROM\n\tdrives d\nJOIN cars car ON car.id = car_id\nWHERE\n\td.id = $drive_id;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Energy Used",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "fixedColor": "orange",
                        "mode": "fixed"
                    },
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            },
                            {
                                "color": "yellow",
                                "value": 200
                            },
                            {
                                "color": "red",
                                "value": 250
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "km"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "Wh/km"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "mi"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "Wh/mi"
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 3,
                "w": 3,
                "x": 6,
                "y": 32
            },
            "id": 18,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "auto",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["mean"],
                    "fields": "",
                    "values": false
                },
                "showPercentChange": false,
                "textMode": "value",
                "wideLayout": true
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "editorMode": "code",
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "select\n\t(NULLIF(GREATEST(start_[[preferred_range]]_range_km - end_[[preferred_range]]_range_km, 0), 0) * car.efficiency) *1000 /\n\t  convert_km(distance::numeric, '$length_unit') as \"$length_unit\"\nfrom drives d\nJOIN cars car ON car.id = car_id\nwhere d.id = $drive_id;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["start_km"],
                                "type": "column"
                            }
                        ]
                    ],
                    "sql": {
                        "columns": [
                            {
                                "parameters": [],
                                "type": "function"
                            }
                        ],
                        "groupBy": [
                            {
                                "property": {
                                    "type": "string"
                                },
                                "type": "groupBy"
                            }
                        ],
                        "limit": 50
                    },
                    "table": "drives",
                    "timeColumn": "start_date",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Consumption",
            "type": "stat"
        },
        {
            "datasource": {
                "type": "grafana-postgresql-datasource",
                "uid": "TeslaMate"
            },
            "description": "",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "fixedColor": "super-light-blue",
                        "mode": "fixed"
                    },
                    "decimals": 0,
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green"
                            }
                        ]
                    }
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/.*_mih/"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "velocitymph"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/.*_kmh/"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "velocitykmh"
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 3,
                "w": 3,
                "x": 9,
                "y": 32
            },
            "id": 37,
            "options": {
                "colorMode": "value",
                "graphMode": "area",
                "justifyMode": "center",
                "orientation": "auto",
                "reduceOptions": {
                    "calcs": ["mean"],
                    "fields": "",
                    "values": true
                },
                "showPercentChange": false,
                "textMode": "value",
                "wideLayout": false
            },
            "pluginVersion": "10.4.0",
            "targets": [
                {
                    "datasource": {
                        "type": "grafana-postgresql-datasource",
                        "uid": "TeslaMate"
                    },
                    "editorMode": "code",
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\tconvert_km(avg(speed)::numeric, '$length_unit') AS speed_[[length_unit]]h\nFROM positions\nWHERE car_id = $car_id AND $__timeFilter(date)",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["start_km"],
                                "type": "column"
                            }
                        ]
                    ],
                    "sql": {
                        "columns": [
                            {
                                "parameters": [],
                                "type": "function"
                            }
                        ],
                        "groupBy": [
                            {
                                "property": {
                                    "type": "string"
                                },
                                "type": "groupBy"
                            }
                        ],
                        "limit": 50
                    },
                    "table": "drives",
                    "timeColumn": "start_date",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Avg. Speed",
            "type": "stat"
        }
    ],
    "schemaVersion": 39,
    "tags": [],
    "templating": {
        "list": [
            {
                "current": {},
                "hide": 2,
                "name": "drive_id",
                "options": [
                    {
                        "selected": false,
                        "text": "NULL",
                        "value": "NULL"
                    }
                ],
                "query": "",
                "skipUrlSync": false,
                "type": "textbox"
            },
            {
                "current": {},
                "datasource": {
                    "type": "grafana-postgresql-datasource",
                    "uid": "TeslaMate"
                },
                "definition": "select unit_of_temperature from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "label": "",
                "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": {},
                "datasource": {
                    "type": "grafana-postgresql-datasource",
                    "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": "grafana-postgresql-datasource",
                    "uid": "TeslaMate"
                },
                "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
                "hide": 0,
                "includeAll": false,
                "label": "Car",
                "multi": false,
                "name": "car_id",
                "options": [],
                "query": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "tagValuesQuery": "",
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },
            {
                "current": {},
                "datasource": {
                    "type": "grafana-postgresql-datasource",
                    "uid": "TeslaMate"
                },
                "definition": "select case when unit_of_length = 'km' then 'm' when unit_of_length = 'mi' then 'ft' end  from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "label": "",
                "multi": false,
                "name": "alternative_length_unit",
                "options": [],
                "query": "select case when unit_of_length = 'km' then 'm' when unit_of_length = 'mi' then 'ft' end  from settings limit 1;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "tagValuesQuery": "",
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },
            {
                "current": {},
                "datasource": {
                    "type": "grafana-postgresql-datasource",
                    "uid": "TeslaMate"
                },
                "definition": "select preferred_range from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "multi": false,
                "name": "preferred_range",
                "options": [],
                "query": "select preferred_range from settings limit 1;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "tagValuesQuery": "",
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },
            {
                "current": {},
                "datasource": {
                    "type": "grafana-postgresql-datasource",
                    "uid": "TeslaMate"
                },
                "definition": "select base_url from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "label": "",
                "multi": false,
                "name": "base_url",
                "options": [],
                "query": "select base_url from settings limit 1;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "tagValuesQuery": "",
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },
            {
                "current": {},
                "datasource": {
                    "type": "grafana-postgresql-datasource",
                    "uid": "TeslaMate"
                },
                "definition": "select unit_of_pressure from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "multi": false,
                "name": "pressure_unit",
                "options": [],
                "query": "select unit_of_pressure from settings limit 1;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "type": "query"
            },
            {
                "current": {},
                "datasource": {
                    "type": "grafana-postgresql-datasource",
                    "uid": "TeslaMate"
                },
                "definition": "SELECT  CASE WHEN '$length_unit' = 'km' THEN 'km/h' WHEN '$length_unit' = 'mi' THEN 'mph' END",
                "hide": 2,
                "includeAll": false,
                "multi": false,
                "name": "speed_unit",
                "options": [],
                "query": "SELECT  CASE WHEN '$length_unit' = 'km' THEN 'km/h' WHEN '$length_unit' = 'mi' THEN 'mph' END",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "type": "query"
            }
        ]
    },
    "timepicker": {
        "hidden": true,
        "refresh_intervals": [],
        "time_options": []
    },
    "timezone": "",
    "title": "Drive Details",
    "uid": "zm7wN6Zgz",
    "version": 4,
    "weekStart": ""
}
