{
    "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": 1642862616523,
    "links": [
        {
            "asDropdown": false,
            "icon": "dashboard",
            "includeVars": false,
            "keepTime": false,
            "tags": [],
            "targetBlank": false,
            "title": "TeslaMate",
            "tooltip": "",
            "type": "link",
            "url": "[[base_url:raw]]"
        },
        {
            "asDropdown": true,
            "icon": "external link",
            "includeVars": false,
            "keepTime": false,
            "tags": ["tesla"],
            "targetBlank": false,
            "title": "Dashboards",
            "tooltip": "",
            "type": "dashboards",
            "url": ""
        }
    ],
    "liveNow": false,
    "panels": [
        {
            "collapsed": false,
            "datasource": "TeslaMate",
            "gridPos": {
                "h": 1,
                "w": 24,
                "x": 0,
                "y": 0
            },
            "id": 4,
            "panels": [],
            "repeat": "car_id",
            "title": "$car_id",
            "type": "row"
        },
        {
            "datasource": "TeslaMate",
            "fieldConfig": {
                "defaults": {
                    "custom": {
                        "align": "auto",
                        "displayMode": "auto",
                        "filterable": false
                    },
                    "mappings": [],
                    "thresholds": {
                        "mode": "absolute",
                        "steps": [
                            {
                                "color": "green",
                                "value": null
                            },
                            {
                                "color": "red",
                                "value": 80
                            }
                        ]
                    }
                },
                "overrides": [
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Start"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "dateTimeAsLocal"
                            },
                            {
                                "id": "custom.width",
                                "value": 180
                            },
                            {
                                "id": "links",
                                "value": [
                                    {
                                        "targetBlank": true,
                                        "title": "",
                                        "url": "d/FkUpJpQZk/trip?from=${__data.fields.start_date_ts}&to=${__data.fields.end_date_ts}&var-car_id=$car_id"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "SoC"
                        },
                        "properties": [
                            {
                                "id": "custom.width",
                                "value": 70
                            },
                            {
                                "id": "unit",
                                "value": "percent"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "SoC Diff"
                        },
                        "properties": [
                            {
                                "id": "custom.width",
                                "value": 70
                            },
                            {
                                "id": "unit",
                                "value": "percent"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "start_path"
                        },
                        "properties": [
                            {
                                "id": "custom.hidden",
                                "value": true
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "end_path"
                        },
                        "properties": [
                            {
                                "id": "custom.hidden",
                                "value": true
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Action"
                        },
                        "properties": [
                            {
                                "id": "custom.width",
                                "value": 150
                            },
                            {
                                "id": "custom.filterable",
                                "value": true
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "kWh"
                        },
                        "properties": [
                            {
                                "id": "custom.width",
                                "value": 100
                            },
                            {
                                "id": "unit",
                                "value": "kwatth"
                            },
                            {
                                "id": "decimals",
                                "value": 1
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "End"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "dateTimeAsLocal"
                            },
                            {
                                "id": "custom.width",
                                "value": 152
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Duration"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "m"
                            },
                            {
                                "id": "custom.width",
                                "value": 100
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Start Address"
                        },
                        "properties": [
                            {
                                "id": "links",
                                "value": [
                                    {
                                        "targetBlank": true,
                                        "title": "Create or edit geo-fence",
                                        "url": "[[base_url:raw]]/geo-fences/${__data.fields.start_path:raw}"
                                    }
                                ]
                            },
                            {
                                "id": "custom.filterable",
                                "value": true
                            },
                            {
                                "id": "custom.minWidth",
                                "value": 200
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "End Address"
                        },
                        "properties": [
                            {
                                "id": "links",
                                "value": [
                                    {
                                        "targetBlank": true,
                                        "title": "Create or edit geo-fence",
                                        "url": "[[base_url:raw]]/geo-fences/${__data.fields.end_path:raw}"
                                    }
                                ]
                            },
                            {
                                "id": "custom.filterable",
                                "value": true
                            },
                            {
                                "id": "custom.minWidth",
                                "value": 200
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "start_date_ts"
                        },
                        "properties": [
                            {
                                "id": "custom.hidden",
                                "value": true
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "end_date_ts"
                        },
                        "properties": [
                            {
                                "id": "custom.hidden",
                                "value": true
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "odometer_km"
                        },
                        "properties": [
                            {
                                "id": "custom.width",
                                "value": 100
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/.*_km/"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "km"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/.*_mi/"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "mi"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/.*_c/"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "celsius"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/.*_f/"
                        },
                        "properties": [
                            {
                                "id": "unit",
                                "value": "fahrenheit"
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/odometer_.*/"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Odometer"
                            },
                            {
                                "id": "custom.width",
                                "value": 100
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/distance_.*/"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Distance"
                            },
                            {
                                "id": "custom.width",
                                "value": 100
                            },
                            {
                                "id": "decimals",
                                "value": 1
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/range_diff_.*/"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Range Diff"
                            },
                            {
                                "id": "custom.width",
                                "value": 100
                            },
                            {
                                "id": "decimals",
                                "value": 1
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/outside_temp_avg_.*/"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Temperature"
                            },
                            {
                                "id": "custom.width",
                                "value": 100
                            },
                            {
                                "id": "decimals",
                                "value": 1
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byRegexp",
                            "options": "/end_range_.*/"
                        },
                        "properties": [
                            {
                                "id": "displayName",
                                "value": "Range"
                            },
                            {
                                "id": "custom.width",
                                "value": 100
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Range"
                        },
                        "properties": [
                            {
                                "id": "custom.width",
                                "value": 118
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "Action"
                        },
                        "properties": [
                            {
                                "id": "links",
                                "value": [
                                    {
                                        "targetBlank": true,
                                        "title": "Slot details",
                                        "url": "${__data.fields.slotlink:raw}"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "matcher": {
                            "id": "byName",
                            "options": "slotlink"
                        },
                        "properties": [
                            {
                                "id": "custom.hidden",
                                "value": true
                            }
                        ]
                    }
                ]
            },
            "gridPos": {
                "h": 22,
                "w": 24,
                "x": 0,
                "y": 1
            },
            "id": 2,
            "options": {
                "footer": {
                    "fields": "",
                    "reducer": ["sum"],
                    "show": false
                },
                "showHeader": true,
                "sortBy": [
                    {
                        "desc": true,
                        "displayName": "Start"
                    }
                ]
            },
            "pluginVersion": "8.3.4",
            "targets": [
                {
                    "format": "table",
                    "group": [],
                    "metricColumn": "none",
                    "rawQuery": true,
                    "rawSql": "SELECT\r\n  start_date AS \"Start\",\r\n  end_date AS \"End\",\r\n  ROUND(EXTRACT(EPOCH FROM start_date))*1000 AS start_date_ts,\r\n  ROUND(EXTRACT(EPOCH FROM end_date))*1000 AS end_date_ts,\r\n  '🚗 Driving' AS \"Action\",\r\n  drives.duration_min AS \"Duration\",\r\n  CASE WHEN start_geofence_id IS NULL THEN CONCAT('new?lat=', TP1.latitude, '&lng=', TP1.longitude)\r\n       WHEN start_geofence_id IS NOT NULL THEN CONCAT(start_geofence_id, '/edit')\r\n  END AS start_path,\r\n  CASE WHEN end_geofence_id IS NULL THEN CONCAT('new?lat=', TP2.latitude, '&lng=', TP2.longitude)\r\n       WHEN start_geofence_id IS NOT NULL THEN CONCAT(end_geofence_id, '/edit')\r\n  END AS end_path,\r\n  COALESCE(start_geofence.name, CONCAT_WS(', ', COALESCE(start_address.name, nullif(CONCAT_WS(' ', start_address.road, start_address.house_number), '')), start_address.city)) AS \"Start Address\",\r\n  COALESCE(end_geofence.name, CONCAT_WS(', ', COALESCE(end_address.name, nullif(CONCAT_WS(' ', end_address.road, end_address.house_number), '')), end_address.city)) AS \"End Address\",\r\n  convert_km(end_km::NUMERIC, '$length_unit') AS odometer_$length_unit,\r\n  convert_km(distance::NUMERIC, '$length_unit') AS distance_$length_unit,\r\n  convert_km(end_[[preferred_range]]_range_km::NUMERIC, '$length_unit') AS end_range_$length_unit,\r\n  convert_km((end_[[preferred_range]]_range_km - start_[[preferred_range]]_range_km)::NUMERIC, '$length_unit') * efficiency AS \"kWh\",\r\n  convert_km((end_[[preferred_range]]_range_km - start_[[preferred_range]]_range_km)::NUMERIC, '$length_unit') AS range_diff_$length_unit,\r\n  TP2.battery_level AS \"SoC\",\r\n  TP2.battery_level-TP1.battery_level AS \"SoC Diff\",\r\n  convert_celsius(outside_temp_avg, '$temp_unit') AS outside_temp_avg_$temp_unit,\r\n  CONCAT('d/zm7wN6Zgz/drive-details?from=', ROUND(EXTRACT(EPOCH FROM start_date))*1000, '&to=', ROUND(EXTRACT(EPOCH FROM end_date))*1000, '&var-car_id=', drives.car_id, '&var-drive_id=', drives.id) AS slotlink\r\nFROM drives\r\n  LEFT OUTER JOIN positions AS TP1 on drives.start_position_id = TP1.id\r\n  LEFT OUTER JOIN positions AS TP2 on drives.end_position_id = TP2.id\r\n  LEFT JOIN addresses start_address ON start_address_id = start_address.id\r\n  LEFT JOIN addresses end_address ON  end_address_id = end_address.id\r\n  LEFT JOIN geofences start_geofence ON start_geofence_id = start_geofence.id\r\n  LEFT JOIN geofences end_geofence ON end_geofence_id = end_geofence.id\r\n  JOIN cars ON cars.id = drives.car_id\r\nWHERE \r\n  $__timeFilter(drives.start_date)\r\n  AND drives.car_id = $car_id\r\n  AND '🚗 Driving' in ($action_filter)\r\n  AND\r\n    (COALESCE(start_geofence.name, CONCAT_WS(', ', COALESCE(start_address.name, nullif(CONCAT_WS(' ', start_address.road, start_address.house_number), '')), start_address.city))::TEXT like '%$text_filter%' or\r\n    COALESCE(end_geofence.name, CONCAT_WS(', ', COALESCE(end_address.name, nullif(CONCAT_WS(' ', end_address.road, end_address.house_number), '')), end_address.city))::TEXT like '%$text_filter%')\r\n\r\nUNION\r\nSELECT\r\n  start_date AS \"Start\",\r\n  end_date AS \"End\",\r\n  ROUND(EXTRACT(EPOCH FROM start_date))*1000 AS start_date_ts,\r\n  ROUND(EXTRACT(EPOCH FROM end_date))*1000 AS end_date_ts,\r\n  '🔋 Charging' AS \"Action\",\r\n  charging_processes.duration_min AS \"Duration\",\r\n  CASE WHEN geofence_id IS NULL THEN CONCAT('new?lat=', address.latitude, '&lng=', address.longitude)\r\n       WHEN geofence_id IS NOT NULL THEN CONCAT(geofence_id, '/edit')\r\n  END AS start_path,\r\n  NULL AS end_path,\r\n  COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS \"Start Address\",\r\n  '' AS \"End Address\",\r\n  convert_km(position.odometer::NUMERIC, '$length_unit') AS odometer_$length_unit,\r\n  NULL AS distance_$length_unit,\r\n  convert_km(end_[[preferred_range]]_range_km::NUMERIC, '$length_unit') AS end_range_$length_unit,\r\n  charging_processes.charge_energy_added AS \"kWh\",\r\n  convert_km((end_[[preferred_range]]_range_km - start_[[preferred_range]]_range_km)::NUMERIC, '$length_unit') AS range_diff_$length_unit, \r\n  end_battery_level AS \"SoC\",\r\n  end_battery_level - start_battery_level AS \"SoC Diff\",\r\n  convert_celsius(outside_temp_avg, '$temp_unit') AS outside_temp_avg_$temp_unit,\r\n  CONCAT('d/BHhxFeZRz/charge-details?from=', ROUND(EXTRACT(EPOCH FROM start_date)-10)*1000, '&to=', ROUND(EXTRACT(EPOCH FROM end_date)+10)*1000, '&var-car_id=', charging_processes.car_id, '&var-charging_process_id=', charging_processes.id) AS slotlink\r\nFROM charging_processes\r\n  INNER JOIN positions AS position ON position_id = position.id\r\n  LEFT JOIN addresses address ON address_id = address.id\r\n  LEFT JOIN geofences geofence ON geofence_id = geofence.id\r\nWHERE\r\n  $__timeFilter(charging_processes.start_date)\r\n  AND charging_processes.charge_energy_added > 0\r\n  AND charging_processes.car_id = $car_id\r\n  AND '🔋 Charging' in ($action_filter)\r\n  AND COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city))::TEXT like '%$text_filter%'\r\nUNION\r\nSELECT\r\n  d.end_date AS \"Start\",\r\n  LEAD(d.start_date) over w AS \"End\",\r\n  ROUND(EXTRACT(EPOCH FROM d.end_date)) * 1000 AS start_date_ts,\r\n  ROUND(EXTRACT(EPOCH FROM LEAD(d.start_date) over w))*1000 AS end_date_ts,\r\n  '🅿️ Parking' AS \"Action\",\r\n  EXTRACT(EPOCH FROM LEAD(d.start_date) over w - d.end_date)/60 AS \"Duration\",\r\n  CASE WHEN d.end_geofence_id IS NULL THEN CONCAT('new?lat=', end_position.latitude, '&lng=', end_position.longitude)\r\n       WHEN d.end_geofence_id IS NOT NULL THEN CONCAT(d.end_geofence_id, '/edit')\r\n  END AS start_path,\r\n  NULL AS end_path,\r\n  COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city)) AS \"Start Address\",\r\n  '' AS \"End Address\",\r\n  convert_km(end_position.odometer::NUMERIC, '$length_unit') AS odometer_$length_unit,\r\n  NULL AS distance_$length_unit,\r\n  convert_km(LEAD(d.start_[[preferred_range]]_range_km) over w::NUMERIC, '$length_unit') AS end_range_$length_unit,\r\n  convert_km(((LEAD(d.start_[[preferred_range]]_range_km) over w + (LEAD(d.start_km) over w - d.end_km)) - d.end_[[preferred_range]]_range_km)::NUMERIC, '$length_unit') * efficiency AS \"kWh\",\r\n  convert_km(((LEAD(d.start_[[preferred_range]]_range_km) over w + (LEAD(d.start_km) over w - d.end_km)) - d.end_[[preferred_range]]_range_km)::NUMERIC, '$length_unit') AS range_diff_$length_unit,\r\n  LEAD(start_position.battery_level) over w AS \"SoC\",\r\n  LEAD(start_position.battery_level) over w - end_position.battery_level AS \"SoC Diff\",\r\n  convert_celsius(outside_temp_avg, '$temp_unit') AS outside_temp_avg_$temp_unit,\r\n  CONCAT('d/FkUpJpQZk/trip?from=', ROUND(EXTRACT(EPOCH FROM d.end_date))*1000, '&to=', ROUND(EXTRACT(EPOCH FROM LEAD(d.start_date) over w))*1000, '&var-car_id=', d.car_id) AS slotlink\r\nFROM\r\n  drives AS d\r\n  LEFT OUTER JOIN positions start_position on d.start_position_id = start_position.id\r\n  LEFT OUTER JOIN positions end_position on d.end_position_id = end_position.id\r\n  LEFT JOIN addresses address ON d.end_address_id = address.id\r\n  LEFT JOIN geofences geofence ON d.end_geofence_id = geofence.id\r\n  JOIN cars ON cars.id = d.car_id\r\nWHERE\r\n  $__timeFilter(d.end_date)\r\n  AND d.car_id=$car_id\r\n  AND '🅿️ Parking' in ($action_filter)\r\n  AND COALESCE(geofence.name, CONCAT_WS(', ', COALESCE(address.name, nullif(CONCAT_WS(' ', address.road, address.house_number), '')), address.city))::TEXT like '%$text_filter%'\r\nWINDOW w as (ORDER BY d.id ASC)\r\n\r\nUNION\r\nSELECT\r\n\tT1.end_date +(1 * interval '1 second') AS \"Start\", -- added 1 sec to get it after the corresponding Parking row\r\n\tT2.start_date AS \"End\",\r\n\tROUND(EXTRACT(EPOCH FROM T2.start_date)) * 1000 - 1 AS start_date_ts,\r\n\tROUND(EXTRACT(EPOCH FROM T2.start_date)) * 1000 - 1 AS end_date_ts,\r\n\t'❓ Missing' AS \"Action\",\r\n\t-- EXTRACT(EPOCH FROM T2.start_date - T1.end_date)/60 AS \"Duration\",\r\n\tNULL AS \"Duration\",\r\n\tCASE WHEN T1.end_geofence_id IS NULL THEN CONCAT('new?lat=', TP1.latitude, '&lng=', TP1.longitude)\r\n\t\tWHEN T1.end_geofence_id IS NOT NULL THEN CONCAT(T1.end_geofence_id, '/edit')\r\n\tEND AS start_path,\r\n\tCASE WHEN T2.start_geofence_id IS NULL THEN CONCAT('new?lat=', TP2.latitude, '&lng=', TP2.longitude)\r\n\t\tWHEN T2.start_geofence_id IS NOT NULL THEN CONCAT(T2.start_geofence_id, '/edit')\r\n\tEND AS end_path,\r\n\tCOALESCE(start_geofence.name, CONCAT_WS(', ', COALESCE(start_address.name, nullif(CONCAT_WS(' ', start_address.road, start_address.house_number), '')), start_address.city)) AS \"Start Address\",\r\n\tCOALESCE(end_geofence.name, CONCAT_WS(', ', COALESCE(end_address.name, nullif(CONCAT_WS(' ', end_address.road, end_address.house_number), '')), end_address.city)) AS \"End Address\",\r\n\tconvert_km(TP2.odometer::INTEGER, '$length_unit') AS odometer_$length_unit,\r\n\tconvert_km((TP2.odometer - TP1.odometer)::INTEGER, '$length_unit') AS distance_$length_unit,\r\n  convert_km(T2.end_[[preferred_range]]_range_km::NUMERIC, '$length_unit') AS end_range_$length_unit,\r\n\tconvert_km(((TP2.[[preferred_range]]_battery_range_km + (TP2.odometer - TP1.odometer)) - TP1.[[preferred_range]]_battery_range_km)::INTEGER, '$length_unit')::INTEGER * efficiency AS \"kWh\",\r\n\tconvert_km(((TP2.[[preferred_range]]_battery_range_km + (TP2.odometer - TP1.odometer)) - TP1.[[preferred_range]]_battery_range_km)::INTEGER, '$length_unit') AS range_diff_$length_unit,\r\n\tNULL AS \"SoC\",\r\n\tNULL AS \"SoC Diff\",\r\n\tNULL AS outside_temp_avg_$temp_unit,\r\n\tNULL AS slotlink\r\n\t-- TP2.battery_level AS \"SoC\",\r\n\t-- TP2.battery_level-TP1.battery_level AS \"SoC Diff\",\r\n\t-- (T1.outside_temp_avg+T2.outside_temp_avg)/2 AS outside_temp_avg_$temp_unit\r\nFROM\r\n\t(SELECT row_number() over(ORDER BY start_date) AS time_id, * FROM drives) AS T1\r\n\tLEFT OUTER JOIN (SELECT row_number() over(ORDER BY start_date) AS time_id, * FROM drives ) AS T2 on T1.time_id + 1 = T2.time_id\r\n\tLEFT OUTER JOIN positions AS TP1 on T1.end_position_id = TP1.id\r\n\tLEFT OUTER JOIN positions AS TP2 on T2.start_position_id = TP2.id\r\n\tLEFT JOIN addresses start_address ON T1.end_address_id = start_address.id\r\n\tLEFT JOIN addresses end_address ON T2.start_address_id = end_address.id\r\n\tLEFT JOIN geofences start_geofence ON T1.end_geofence_id = start_geofence.id\r\n\tLEFT JOIN geofences end_geofence ON T2.start_geofence_id = end_geofence.id\r\n\tJOIN cars ON cars.id = T2.car_id\r\nWHERE\r\n\t$__timeFilter(T1.end_date)\r\n\tAND T1.car_id=$car_id \r\n\tAND T2.car_id=$car_id \r\n\tAND TP2.car_id=$car_id \r\n\tAND TP1.car_id=$car_id \r\n\tAND TP2.odometer - TP1.odometer > 0.5\r\n\tAND T1.end_address_id <> T2.start_address_id AND ((T1.end_geofence_id IS NOT NULL OR T2.end_geofence_id IS NOT NULL) OR T1.end_geofence_id <> T2.start_geofence_id)\r\n\tAND '❓ Missing' in ($action_filter)\r\n\tAND (\r\n\t  (COALESCE(start_geofence.name, CONCAT_WS(', ', COALESCE(start_address.name, nullif(CONCAT_WS(' ', start_address.road, start_address.house_number), '')), start_address.city))::TEXT like '%$text_filter%') or\r\n\t  (COALESCE(end_geofence.name, CONCAT_WS(', ', COALESCE(end_address.name, nullif(CONCAT_WS(' ', end_address.road, end_address.house_number), '')), end_address.city)))::TEXT like '%$text_filter%')\r\nUNION\r\nSELECT\r\n  start_date AS \"Start\",\r\n  end_date AS \"End\",\r\n  ROUND(EXTRACT(EPOCH FROM start_date))*1000 AS start_date_ts, \r\n  ROUND(EXTRACT(EPOCH FROM end_date))*1000 AS end_date_ts, \r\n  '💾 Updating' AS \"Action\",\r\n\tEXTRACT(EPOCH FROM end_date - start_date)/60  AS \"Duration\",\r\n  NULL AS start_path,\r\n  NULL AS end_path,\r\n  version AS \"Start Address\",\r\n  '' AS \"End Address\",\r\n  NULL AS odometer_$length_unit,\r\n  NULL AS distance_$length_unit,\r\n  NULL AS end_range_$length_unit,\r\n  NULL AS \"kWh\",\r\n  NULL AS range_diff_$length_unit,\r\n  NULL AS \"SoC\",\r\n  NULL AS \"SoC Diff\",\r\n  NULL AS outside_temp_avg_$temp_unit,\r\n  CONCAT('https://www.notateslaapp.com/software-updates/version/', split_part(version, ' ', 1), '/release-notes') AS slotlink\r\nFROM updates\r\nWHERE \r\n  $__timeFilter(start_date)\r\n  AND car_id = $car_id \r\n  AND '💾 Updating' in ($action_filter)\r\n  AND version::TEXT like '%$text_filter%'\r\n\r\nORDER BY \"Start\" DESC;",
                    "refId": "A",
                    "select": [
                        [
                            {
                                "params": ["id"],
                                "type": "column"
                            }
                        ]
                    ],
                    "table": "candata",
                    "timeColumn": "datum",
                    "timeColumnType": "timestamp",
                    "where": [
                        {
                            "name": "$__timeFilter",
                            "params": [],
                            "type": "macro"
                        }
                    ]
                }
            ],
            "title": "Timeline",
            "transformations": [
                {
                    "id": "organize",
                    "options": {
                        "excludeByName": {
                            "End": true,
                            "start_date_ts": false
                        },
                        "indexByName": {
                            "Action": 2,
                            "Duration": 7,
                            "End": 1,
                            "End Address": 4,
                            "SoC": 15,
                            "SoC Diff": 16,
                            "Start": 0,
                            "Start Address": 3,
                            "distance_km": 8,
                            "distance_mi": 9,
                            "end_date_ts": 22,
                            "end_path": 20,
                            "end_range_km": 10,
                            "end_range_mi": 11,
                            "kWh": 13,
                            "odometer_km": 5,
                            "odometer_mi": 6,
                            "outside_temp_avg_c": 17,
                            "outside_temp_avg_f": 18,
                            "range_diff_km": 12,
                            "range_diff_mi": 13,
                            "start_date_ts": 21,
                            "start_path": 19
                        },
                        "renameByName": {
                            "action": "",
                            "end_address": "End",
                            "km_diff": "Km",
                            "kwh": "",
                            "minutediff": "Time",
                            "odometer": "",
                            "outside_temp_avg": "Temperature",
                            "rangediff": "Range Difference",
                            "soc": "",
                            "soc_diff": "SoC Difference",
                            "start_address": "Start",
                            "start_date": "Date",
                            "start_date_ts": ""
                        }
                    }
                }
            ],
            "type": "table"
        }
    ],
    "refresh": "1h",
    "schemaVersion": 36,
    "style": "dark",
    "tags": ["tesla"],
    "templating": {
        "list": [
            {
                "current": {
                    "selected": false,
                    "text": "All",
                    "value": "$__all"
                },
                "datasource": "TeslaMate",
                "definition": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
                "hide": 2,
                "includeAll": true,
                "label": "Car",
                "multi": false,
                "name": "car_id",
                "options": [],
                "query": "SELECT name AS __text, id AS __value FROM cars ORDER BY display_priority ASC, name ASC;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "tagValuesQuery": "",
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },
            {
                "current": {
                    "selected": false,
                    "text": "http://localhost:4000",
                    "value": "http://localhost:4000"
                },
                "datasource": "TeslaMate",
                "definition": "select base_url from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "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": ["All"],
                    "value": ["$__all"]
                },
                "hide": 0,
                "includeAll": true,
                "label": "Action",
                "multi": true,
                "name": "action_filter",
                "options": [
                    {
                        "selected": true,
                        "text": "All",
                        "value": "$__all"
                    },
                    {
                        "selected": false,
                        "text": "🚗 Driving",
                        "value": "🚗 Driving"
                    },
                    {
                        "selected": false,
                        "text": "🔋 Charging",
                        "value": "🔋 Charging"
                    },
                    {
                        "selected": false,
                        "text": "🅿️ Parking",
                        "value": "🅿️ Parking"
                    },
                    {
                        "selected": false,
                        "text": "❓ Missing",
                        "value": "❓ Missing"
                    },
                    {
                        "selected": false,
                        "text": "💾 Updating",
                        "value": "💾 Updating"
                    }
                ],
                "query": "🚗 Driving,🔋 Charging,🅿️ Parking,❓ Missing,💾 Updating",
                "queryValue": "",
                "skipUrlSync": false,
                "type": "custom"
            },
            {
                "current": {
                    "selected": false,
                    "text": "",
                    "value": ""
                },
                "hide": 0,
                "label": "Text Filter",
                "name": "text_filter",
                "options": [
                    {
                        "selected": true,
                        "text": "",
                        "value": ""
                    }
                ],
                "query": "",
                "skipUrlSync": false,
                "type": "textbox"
            },
            {
                "current": {
                    "selected": false,
                    "text": "km",
                    "value": "km"
                },
                "datasource": "TeslaMate",
                "definition": "select unit_of_length from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "label": "length unit",
                "multi": false,
                "name": "length_unit",
                "options": [],
                "query": "select unit_of_length from settings limit 1;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "tagValuesQuery": "",
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },
            {
                "current": {
                    "selected": false,
                    "text": "C",
                    "value": "C"
                },
                "datasource": "TeslaMate",
                "definition": "select unit_of_temperature from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "label": "temperature unit",
                "multi": false,
                "name": "temp_unit",
                "options": [],
                "query": "select unit_of_temperature from settings limit 1;",
                "refresh": 1,
                "regex": "",
                "skipUrlSync": false,
                "sort": 0,
                "tagValuesQuery": "",
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },
            {
                "current": {
                    "selected": false,
                    "text": "ideal",
                    "value": "ideal"
                },
                "datasource": "TeslaMate",
                "definition": "select preferred_range from settings limit 1;",
                "hide": 2,
                "includeAll": false,
                "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
            }
        ]
    },
    "time": {
        "from": "now-14d",
        "to": "now"
    },
    "timepicker": {},
    "timezone": "",
    "title": "Timeline",
    "uid": "SUBgwtigz",
    "version": 1,
    "weekStart": ""
}
