{
    "annotations": {
        "list": [
            {
                "builtIn": 1,
                "datasource": "-- Grafana --",
                "enable": true,
                "hide": true,
                "iconColor": "rgba(0, 211, 255, 1)",
                "name": "Annotations & Alerts",
                "target": {
                    "limit": 100,
                    "matchAny": false,
                    "tags": [],
                    "type": "dashboard"
                },
                "type": "dashboard"
            }
        ]
    },
    "editable": true,
    "fiscalYearStartMonth": 0,
    "graphTooltip": 0,
    "iteration": 1642771806943,
    "links": [
        {
            "icon": "dashboard",
            "tags": [],
            "title": "TeslaMate",
            "tooltip": "",
            "type": "link",
            "url": "[[base_url:raw]]"
        },
        {
            "asDropdown": true,
            "icon": "external link",
            "tags": ["tesla"],
            "title": "Dashboards",
            "type": "dashboards"
        }
    ],
    "liveNow": false,
    "panels": [
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "#c7d0d9",
                                "value": null
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 3,
                "w": 7,
                "x": 0,
                "y": 0
            },
            "id": 12,
            "links": [],
            "maxDataPoints": 100,
            "options": {
                "colorMode": "value",
                "fieldOptions": {
                    "calcs": ["mean"]
                },
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "horizontal",
                "reduceOptions": {
                    "calcs": ["mean"],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "select count(*) from addresses;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Total addresses",
            "type": "stat"
        },
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "#c7d0d9",
                                "value": null
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 3,
                "w": 7,
                "x": 7,
                "y": 0
            },
            "id": 20,
            "links": [],
            "maxDataPoints": 100,
            "options": {
                "colorMode": "value",
                "fieldOptions": {
                    "calcs": ["mean"]
                },
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "horizontal",
                "reduceOptions": {
                    "calcs": ["mean"],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\tCOUNT(DISTINCT city)\nFROM\n\taddresses;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Cities",
            "type": "stat"
        },
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "#c7d0d9",
                                "value": null
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 3,
                "w": 5,
                "x": 14,
                "y": 0
            },
            "id": 18,
            "links": [],
            "maxDataPoints": 100,
            "options": {
                "colorMode": "value",
                "fieldOptions": {
                    "calcs": ["mean"]
                },
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "horizontal",
                "reduceOptions": {
                    "calcs": ["mean"],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\tCOUNT(DISTINCT state)\nFROM\n\taddresses;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "States",
            "type": "stat"
        },
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "#c7d0d9",
                                "value": null
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": []
            },
            "gridPos": {
                "h": 3,
                "w": 5,
                "x": 19,
                "y": 0
            },
            "id": 16,
            "links": [],
            "maxDataPoints": 100,
            "options": {
                "colorMode": "value",
                "fieldOptions": {
                    "calcs": ["mean"]
                },
                "graphMode": "none",
                "justifyMode": "auto",
                "orientation": "horizontal",
                "reduceOptions": {
                    "calcs": ["mean"],
                    "fields": "",
                    "values": false
                },
                "textMode": "value"
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\tCOUNT(DISTINCT country)\nFROM\n\taddresses;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Countries",
            "type": "stat"
        },
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "displayName": "$__cell_0",
                    "mappings": [],
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "semi-dark-green",
                                "value": null
                            },
                            {
                                "color": "super-light-green",
                                "value": 50
                            }
                        ]
                    }
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 0,
                "y": 3
            },
            "id": 10,
            "options": {
                "displayMode": "gradient",
                "orientation": "horizontal",
                "reduceOptions": {
                    "calcs": ["mean"],
                    "fields": "",
                    "values": true
                },
                "showUnfilled": true
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\tcity,\n\tcount(*) as \"# addresses\"\nFROM\n\taddresses\nWHERE\n\tcity IS NOT NULL\nGROUP BY\n\t1\nORDER BY\n\t2 DESC\nLIMIT 10;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["value"],
                                "type": "column"
                            }
                        ]
                    ],
                    "timeColumn": "time",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Cities",
            "type": "bargauge"
        },
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "displayName": "$__cell_0",
                    "mappings": [],
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "semi-dark-orange",
                                "value": null
                            },
                            {
                                "color": "super-light-orange",
                                "value": 50
                            }
                        ]
                    }
                },
                "overrides": []
            },
            "gridPos": {
                "h": 8,
                "w": 12,
                "x": 12,
                "y": 3
            },
            "id": 14,
            "options": {
                "displayMode": "gradient",
                "orientation": "horizontal",
                "reduceOptions": {
                    "calcs": ["mean"],
                    "fields": "",
                    "values": true
                },
                "showUnfilled": true
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n\tstate,\n\tcount(*) as \"# addresses\"\nFROM\n\taddresses\nWHERE\n\tstate IS NOT NULL\nGROUP BY\n\t1\nORDER BY\n\t2 DESC\nLIMIT 10;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "States",
            "type": "bargauge"
        },
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "custom": {
                        "displayMode": "auto",
                        "filterable": false
                    },
                    "mappings": [],
                    "max": 100,
                    "min": 0,
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "semi-dark-blue",
                                "value": null
                            },
                            {
                                "color": "light-red",
                                "value": 50
                            }
                        ]
                    },
                    "unit": "none"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Date"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "dateTimeAsLocal"
                            },
                            {
                                "id": "custom.width",
                                "value": 180
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "City"
                        },
                        "properties": [
                            {
                                "id": "custom.width"
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 11,
                "w": 24,
                "x": 0,
                "y": 11
            },
            "id": 22,
            "options": {
                "footer": {
                    "fields": "",
                    "reducer": ["sum"],
                    "show": false
                },
                "showHeader": true,
                "sortBy": [
                    {
                        "desc": true,
                        "displayName": "Date"
                    }
                ]
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n  max(end_date) as \"Date\",\n  count(*) as visited,\n  COALESCE(g.name, array_to_string(((string_to_array(a.display_name, ', ', ''))[0:2]), ', ')) AS \"Address\",\n\tCOALESCE(city, neighbourhood) as \"City\"\nFROM drives t\nINNER JOIN addresses a ON end_address_id = a.id\nLEFT JOIN geofences g ON end_geofence_id = g.id\nWHERE a.display_name ilike '%$address_filter%' or g.name ilike '%$address_filter%'\nGROUP BY 3,4\nORDER BY visited DESC\nLIMIT 100",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Last visited",
            "transformations": [
                {
                    "id": "organize",
                    "options": {
                        "excludeByName": {
                            "visited": true
                        },
                        "indexByName": {},
                        "renameByName": {}
                    }
                }
            ],
            "type": "table"
        },
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "custom": {
                        "displayMode": "auto"
                    },
                    "decimals": 2,
                    "displayName": "",
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 80
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "updated_at"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Updated at"
                            },
                            {
                                "id": "unit",
                                "value": "time: YYYY-MM-DD HH:mm:ss"
                            },
                            {
                                "id": "custom.align"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "name"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Name"
                            },
                            {
                                "id": "unit",
                                "value": "short"
                            },
                            {
                                "id": "decimals",
                                "value": 2
                            },
                            {
                                "id": "links",
                                "value": [
                                    {
                                        "targetBlank": true,
                                        "title": "",
                                        "url": "[[base_url:raw]]/geo-fences/${__data.fields.path}"
                                    }
                                ]
                            },
                            {
                                "id": "custom.align"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "neighbourhood"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Neighbourhood"
                            },
                            {
                                "id": "unit",
                                "value": "short"
                            },
                            {
                                "id": "decimals",
                                "value": 2
                            },
                            {
                                "id": "custom.align"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "city"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "City"
                            },
                            {
                                "id": "unit",
                                "value": "short"
                            },
                            {
                                "id": "decimals",
                                "value": 2
                            },
                            {
                                "id": "custom.align"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "state"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "State"
                            },
                            {
                                "id": "unit",
                                "value": "short"
                            },
                            {
                                "id": "decimals",
                                "value": 2
                            },
                            {
                                "id": "custom.align"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "country"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Country"
                            },
                            {
                                "id": "unit",
                                "value": "short"
                            },
                            {
                                "id": "decimals",
                                "value": 2
                            },
                            {
                                "id": "custom.align"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "path"
                        },
                        "properties": [
                            {
                                "id": "custom.align"
                            },
                            {
                                "id": "custom.hidden",
                                "value": true
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 11,
                "w": 18,
                "x": 0,
                "y": 22
            },
            "id": 2,
            "links": [],
            "options": {
                "footer": {
                    "fields": "",
                    "reducer": ["sum"],
                    "show": false
                },
                "showHeader": true
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\n  CONCAT('new?lat=', latitude, '&lng=', longitude) as path,\n\tCOALESCE(name, CONCAT(road, ' ', house_number)) AS name,\n\tneighbourhood,\n\tcity,\n\tstate,\n\tcountry\nFROM addresses\nWHERE display_name ilike '%$address_filter%'\nORDER BY inserted_at DESC\nLIMIT 100;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["latitude"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "addresses",
                    "timeColumn": "inserted_at",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Addresses",
            "transformations": [
                {
                    "id": "merge",
                    "options": {
                        "reducers": []
                    }
                }
            ],
            "type": "table"
        },
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "color": {
                        "mode": "thresholds"
                    },
                    "custom": {
                        "displayMode": "auto"
                    },
                    "decimals": 2,
                    "displayName": "",
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 80
                            }
                        ]
                    },
                    "unit": "short"
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Time"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Time"
                            },
                            {
                                "id": "unit",
                                "value": "time: YYYY-MM-DD HH:mm:ss"
                            },
                            {
                                "id": "custom.align"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "name"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Name"
                            },
                            {
                                "id": "unit",
                                "value": "short"
                            },
                            {
                                "id": "decimals",
                                "value": 2
                            },
                            {
                                "id": "links",
                                "value": [
                                    {
                                        "targetBlank": true,
                                        "title": "",
                                        "url": "[[base_url:raw]]/geo-fences/${__data.fields.id.numeric:raw}/edit"
                                    }
                                ]
                            },
                            {
                                "id": "custom.align"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "id"
                        },
                        "properties": [
                            {
                                "id": "custom.align"
                            },
                            {
                                "id": "custom.hidden",
                                "value": true
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 11,
                "w": 6,
                "x": 18,
                "y": 22
            },
            "id": 6,
            "options": {
                "footer": {
                    "fields": "",
                    "reducer": ["sum"],
                    "show": false
                },
                "showHeader": true
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT id, name \nFROM geofences \nORDER BY inserted_at DESC\nLIMIT 512;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["value"],
                                "type": "column"
                            }
                        ]
                    ],
                    "timeColumn": "time",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Geo-fences",
            "transformations": [
                {
                    "id": "merge",
                    "options": {
                        "reducers": []
                    }
                }
            ],
            "type": "table"
        }
    ],
    "schemaVersion": 36,
    "style": "dark",
    "tags": ["tesla"],
    "templating": {
        "list": [
            {
                "current": {
                    "selected": true,
                    "text": ["All"],
                    "value": ["$__all"]
                },
                "datasource": "TeslaMate",
                "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
                "hide": 1,
                "includeAll": true,
                "label": "Car",
                "multi": true,
                "name": "car_id",
                "options": [],
                "query": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "tagValuesQuery": "",
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },
            {
                "current": {
                    "selected": false,
                    "text": "http://localhost:4000",
                    "value": "http://localhost:4000"
                },
                "datasource": "TeslaMate",
                "definition": "select base_url from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "label": "",
                "multi": false,
                "name": "base_url",
                "options": [],
                "query": "select base_url from settings limit 1;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "tagValuesQuery": "",
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },
            {
                "current": {
                    "selected": false,
                    "text": "",
                    "value": ""
                },
                "hide": 0,
                "label": "Address",
                "name": "address_filter",
                "options": [
                    {
                        "selected": true,
                        "text": "",
                        "value": ""
                    }
                ],
                "query": "",
                "skipUrlSync": false,
                "type": "textbox"
            }
        ]
    },
    "time": {
        "from": "now-30d",
        "to": "now"
    },
    "timepicker": {
        "hidden": true,
        "refresh_intervals": [
            "5s",
            "10s",
            "30s",
            "1m",
            "5m",
            "15m",
            "30m",
            "1h",
            "2h",
            "1d"
        ],
        "time_options": [
            "5m",
            "15m",
            "1h",
            "6h",
            "12h",
            "24h",
            "2d",
            "7d",
            "30d"
        ]
    },
    "timezone": "",
    "title": "Locations",
    "uid": "ZzhF-aRWz",
    "version": 1,
    "weekStart": ""
}
