{ "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- 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", "type": "dashboard" } ] }, "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 1, "links": [ { "icon": "dashboard", "tags": [], "title": "TeslaMate", "tooltip": "", "type": "link", "url": "${base_url:raw}" }, { "asDropdown": true, "icon": "external link", "tags": [ "tesla" ], "title": "Dashboards", "type": "dashboards" }, { "asDropdown": true, "icon": "external link", "includeVars": false, "keepTime": false, "tags": [ "TeslamateCustomDashboards" ], "targetBlank": false, "title": "Custom Dashboards", "tooltip": "", "type": "dashboards", "url": "" } ], "panels": [ { "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "fieldConfig": { "defaults": { "color": { "mode": "continuous-RdYlGr" }, "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", "fillOpacity": 13, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "insertNulls": false, "lineInterpolation": "smooth", "lineStyle": { "dash": [ 10, 10 ], "fill": "dash" }, "lineWidth": 2, "pointSize": 5, "scaleDistribution": { "type": "linear" }, "showPoints": "auto", "spanNulls": false, "stacking": { "group": "A", "mode": "none" }, "thresholdsStyle": { "mode": "line" } }, "fieldMinMax": false, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 367000 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "car_value_pls_el_savings" }, "properties": [ { "id": "custom.gradientMode", "value": "scheme" }, { "id": "displayName", "value": "Depreciated Car Value + Cumulative Savings" } ] } ] }, "gridPos": { "h": 10, "w": 16, "x": 0, "y": 0 }, "id": 76, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": true }, "tooltip": { "hideZeros": false, "maxHeight": 600, "mode": "single", "sort": "none" }, "xField": "period_number" }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "datasource", "uid": "-- Dashboard --" }, "panelId": 77, "refId": "A" } ], "title": "Break-Even Chart", "transformations": [ { "id": "filterFieldsByName", "options": { "include": { "names": [ "car_value_pls_el_savings", "period_number" ] } } } ], "type": "trend" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "description": "", "fieldConfig": { "defaults": { "color": { "mode": "continuous-YlRd" }, "custom": { "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", "axisLabel": "", "axisPlacement": "auto", "fillOpacity": 50, "hideFrom": { "legend": false, "tooltip": false, "viz": false }, "pointShape": "circle", "pointSize": { "fixed": 9 }, "pointStrokeWidth": 1, "scaleDistribution": { "type": "linear" }, "show": "points+lines" }, "fieldMinMax": false, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "period_number" }, "properties": [ { "id": "displayName", "value": "Period [$period]" } ] }, { "matcher": { "id": "byName", "options": "percent_depreciated" }, "properties": [ { "id": "displayName", "value": "Depreciated [%]" } ] } ] }, "gridPos": { "h": 10, "w": 8, "x": 16, "y": 0 }, "id": 75, "options": { "legend": { "calcs": [], "displayMode": "list", "placement": "bottom", "showLegend": false }, "mapping": "auto", "series": [ { "frame": { "matcher": { "id": "byIndex", "options": 0 } }, "x": { "matcher": { "id": "byType", "options": "number" } }, "y": { "exclude": { "id": "byNames", "options": [ "months", "depreciation_time", "depreciation_mileage" ] }, "matcher": { "id": "byType", "options": "number" } } } ], "tooltip": { "hideZeros": false, "maxHeight": 600, "mode": "single", "sort": "none" } }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "rawQuery": true, "rawSql": "WITH periodic_mileage AS (\r\n SELECT\r\n DATE_TRUNC('$period', TIMEZONE('UTC', start_date), '$__timezone') AS period_start,\r\n convert_km(SUM(end_km - start_km)::numeric, '$length_unit') AS total_mileage\r\n FROM\r\n drives\r\n WHERE\r\n car_id = $car_id \r\n GROUP BY\r\n period_start\r\n),\r\ncum_mileage AS (\r\n SELECT\r\n ROW_NUMBER() OVER () AS period_number,\r\n period_start,\r\n total_mileage,\r\n SUM(total_mileage) OVER (ORDER BY period_start) AS cum_mileage\r\n FROM\r\n periodic_mileage\r\n),\r\nBreakEven AS (\r\nSELECT\r\n cm.period_number,\r\n cm.cum_mileage * $loss_rate AS depreciation_mileage,\r\n ($depreciated_value - (cm.period_number - 1) * 5.0 / 12) AS depreciation_time\r\nFROM\r\n cum_mileage cm\r\nLEFT JOIN\r\n periodic_mileage mm ON cm.period_start = mm.period_start\r\nORDER BY\r\n cm.period_number\r\n)\r\nSELECT \r\n period_number,\r\n ($car_cost - depreciation_mileage - (($car_cost - depreciation_mileage) * depreciation_time / 100)) * 100 / $car_cost AS percent_depreciated\r\nFROM BreakEven", "refId": "A", "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 } } ], "title": "Depreciation over time", "type": "xychart" }, { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "fieldConfig": { "defaults": { "custom": { "align": "auto", "cellOptions": { "type": "auto" }, "inspect": false, "minWidth": 100 }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 80 } ] } }, "overrides": [ { "matcher": { "id": "byName", "options": "period_number" }, "properties": [ { "id": "displayName", "value": "Period [$period]" }, { "id": "custom.width", "value": 120 } ] }, { "matcher": { "id": "byName", "options": "periodic_mileage" }, "properties": [ { "id": "displayName", "value": "Mileage [$length_unit]" }, { "id": "custom.width", "value": 110 } ] }, { "matcher": { "id": "byName", "options": "period_el_cost" }, "properties": [ { "id": "displayName", "value": "Energy Cost" }, { "id": "custom.width", "value": 100 }, { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "period_cost_per_mileage" }, "properties": [ { "id": "displayName", "value": "Cost per $length_unit" }, { "id": "custom.width", "value": 105 }, { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "cum_mileage" }, "properties": [ { "id": "displayName", "value": "Cumulative Mileage" }, { "id": "custom.width", "value": 150 } ] }, { "matcher": { "id": "byName", "options": "cum_el_cost" }, "properties": [ { "id": "displayName", "value": "Cumulative Energy Cost" }, { "id": "custom.width", "value": 180 }, { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "cum_el_savings" }, "properties": [ { "id": "displayName", "value": "Cumulative Savings" }, { "id": "custom.width", "value": 150 }, { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "depreciated_car_value" }, "properties": [ { "id": "displayName", "value": "Depreciated Car Value" }, { "id": "custom.width", "value": 180 }, { "id": "decimals", "value": 2 } ] }, { "matcher": { "id": "byName", "options": "car_value_pls_el_savings" }, "properties": [ { "id": "displayName", "value": "Depreciated Car Value + Savings" }, { "id": "decimals", "value": 2 }, { "id": "custom.align", "value": "center" } ] }, { "matcher": { "id": "byName", "options": "depreciation_mileage" }, "properties": [ { "id": "displayName", "value": "Depreciation per $length_unit" }, { "id": "decimals", "value": 2 }, { "id": "custom.width", "value": 160 } ] }, { "matcher": { "id": "byName", "options": "depreciation_time" }, "properties": [ { "id": "displayName", "value": "Depreciation per age" }, { "id": "decimals", "value": 1 }, { "id": "custom.width", "value": 160 }, { "id": "unit", "value": "percent" } ] } ] }, "gridPos": { "h": 6, "w": 24, "x": 0, "y": 10 }, "id": 77, "options": { "cellHeight": "sm", "footer": { "countRows": false, "fields": "", "reducer": [ "sum" ], "show": false }, "showHeader": true }, "pluginVersion": "11.5.2", "targets": [ { "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "editorMode": "code", "format": "table", "rawQuery": true, "rawSql": "WITH periodic_mileage AS (\r\n SELECT\r\n DATE_TRUNC('$period', TIMEZONE('UTC', start_date), '$__timezone') AS period_start,\r\n convert_km(SUM(end_km - start_km)::numeric, '$length_unit') AS total_mileage\r\n FROM\r\n drives\r\n WHERE\r\n car_id = $car_id \r\n GROUP BY\r\n period_start\r\n),\r\nperiod_cost AS (\r\n SELECT\r\n DATE_TRUNC('$period', TIMEZONE('UTC', start_date), '$__timezone') AS period_start,\r\n SUM(cost) AS total_cost\r\n FROM\r\n charging_processes \r\n WHERE\r\n car_id = $car_id \r\n GROUP BY\r\n period_start\r\n),\r\ncum_mileage AS (\r\n SELECT\r\n ROW_NUMBER() OVER () AS period_number,\r\n period_start,\r\n total_mileage,\r\n SUM(total_mileage) OVER (ORDER BY period_start) AS cum_mileage\r\n FROM\r\n periodic_mileage\r\n),\r\ncum_cost AS (\r\n SELECT\r\n ROW_NUMBER() OVER () AS period_number,\r\n period_start,\r\n total_cost,\r\n SUM(total_cost) OVER (ORDER BY period_start) AS cum_el_cost\r\n FROM\r\n period_cost\r\n),\r\ncar_current_value AS (\r\n SELECT\r\n $car_cost AS car_current_value\r\n),\r\nBreakEven AS (\r\nSELECT\r\n cm.period_number,\r\n mm.total_mileage AS periodic_mileage,\r\n mc.total_cost AS period_el_cost,\r\n mc.total_cost/mm.total_mileage AS period_cost_per_mileage,\r\n cm.cum_mileage,\r\n cc.cum_el_cost,\r\n cm.cum_mileage * $loss_rate AS depreciation_mileage,\r\n ($depreciated_value - (cm.period_number - 1) * 5.0 / CASE WHEN '$period' = 'year' THEN 1 ELSE 12 END) AS depreciation_time,\r\n cm.cum_mileage * $fuel_price - cc.cum_el_cost AS cum_el_savings, car_current_value\r\nFROM\r\n cum_mileage cm\r\nLEFT JOIN\r\n cum_cost cc ON cm.period_number = cc.period_number\r\nLEFT JOIN\r\n periodic_mileage mm ON cm.period_start = mm.period_start\r\nLEFT JOIN\r\n period_cost mc ON cm.period_start = mc.period_start\r\nCROSS JOIN\r\n car_current_value\r\nORDER BY\r\n cm.period_number\r\n)\r\nSELECT \r\n period_number, periodic_mileage, period_el_cost, period_cost_per_mileage, cum_mileage, cum_el_cost, depreciation_mileage, depreciation_time, cum_el_savings,\r\n car_current_value - depreciation_mileage - ((car_current_value - depreciation_mileage) * depreciation_time / 100) AS depreciated_car_value,\r\n (car_current_value - depreciation_mileage - ((car_current_value - depreciation_mileage) * depreciation_time / 100)) + (cum_mileage * $fuel_price - cum_el_cost) AS car_value_pls_el_savings\r\nFROM BreakEven", "refId": "A", "sql": { "columns": [ { "parameters": [], "type": "function" } ], "groupBy": [ { "property": { "type": "string" }, "type": "groupBy" } ], "limit": 50 } } ], "title": "Break-Even Table", "type": "table" }, { "collapsed": true, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 16 }, "id": 79, "panels": [], "title": "Help", "type": "row" }, { "fieldConfig": { "defaults": {}, "overrides": [] }, "gridPos": { "h": 29, "w": 24, "x": 0, "y": 17 }, "id": 78, "options": { "code": { "language": "plaintext", "showLineNumbers": false, "showMiniMap": false }, "content": "# Amortization Tracker\n\nThis dashboard aims to show the depreciation value of the car over time and its journey.\n\nDepreciating a car by its mileage can be done using various methods. A common approach is to use a depreciation rate per mile or to create a depreciation curve based on data. On the other hand, the depreciation of a car due to age can vary depending on several factors such as the make, model, overall condition of the vehicle, and demand in the market.\n\nGenerally, it is estimated that a new car loses approximately 15% to 20% of its value in the first year. From there, the rate of depreciation tends to gradually decrease. Below is a rough estimate of the annual depreciation in the first few years:\n\n- First year: Around 15% to 20%.\n- Second year: Around 10% to 15%.\n- Third year and beyond: Around 5% to 10% annually.\n\nIt is important to remember that these values are approximate and may vary depending on individual circumstances. Also, some car models may hold their value better than others.\n\nAdditionally, some studies and experts suggest that a car loses a certain amount of value per mile driven. For instance, here we are using a standard rate 0.20 (use your currency) per mile or kilometer (depending on your preferred length unit)\n\n## Considerations for values in text boxes\n\nIn this panel we have both estimations: **Depreciation per Mileage** and **Depreciation per Age**\n\nSo fist of all you have to select:\n\n- Period to estimate (yearly or monthly)\n- Cost of your car\n- Depreciation percent % (of the first year). 20% by default as explained before\n- Loss rate per mile of kilometer. 0.2 (your currency) by default as explained before\n- Fuel price per mile of kilometer of your previous car (or a generic on equivalent to your actual Tesla)\n \n To calculate the cost per miles/kilometer of your car, you first need to determine how much it consumes in liters per 100 miles/kilometers. Then you can divide Consumption by mileage.\n\n For example: let's say a car consumes 6 liters per 100km and the fuel costs 1.8€ per liter, we can calculate the actual consumption: 6/100 = 0.06 L/km\n \n Now, to determine the cost per kilometer, we multiply the actual consumption by the price of a liter of fuel (use your currency). For example 0.06L/km × 1.8€/L =0.108€/km (use miles or kms).\n \n Therefore, the cost per kilometer for your car would be approximately 0.108€. That's the value expected on the Fuel price textbox.\n\n## Data shown in the table\n\n- **Period**: Could be 'month' or 'year' depending what you've selected in the drop down list. So if selected as 'month', its going to be the data accumulated from 1st month at which TeslaMate started logging data, So 1,2,3 will be the month numbers. If \"period\" is selected as 'year', then its the year numbers.\n- **Mileage**: is the number of kms/miles (depending on your preferred length unit) the car has driven in that period.\n- **Energy Cost**: is the cost spent for electricity in that particular period.\n- **Cost per km or mi** is *energy cost* / *Mileage*\n- **Cumulative Mileage** is the cumulative mileage for that particular period.\n- **Cumulative Cost** is the cumulative cost for electricity for that particular period.\n- **Depreciation per km or mi** is the depreciation by mileage explained at the beginning.\n- **Depreciation per age** is the depreciation by time explained at the beginning.\n- **Cumulative Savings** is running cost savings for driving an electric car when compared to a fossil fuel car, based on the value enter in the *Fuel price* textbox.\n- **Depreciated Car Value** is the estimated actual price based on the depreciation per age and mileage. \n- **Depreciated Car Value + Savings** is simply adding *Depreciated Car Value* + *Cumulative Savings*. So the expectation is like when one can get the Break-Even for the money we put into buying the car by driving at a cheaper electricity cost when compared to driving a fossil fuel car.\n", "mode": "markdown" }, "pluginVersion": "11.5.2", "title": "", "type": "text" } ], "preload": false, "refresh": "", "schemaVersion": 40, "tags": [ "TeslamateCustomDashboards" ], "templating": { "list": [ { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "SELECT\n id as __value,\n CASE WHEN COUNT(id) OVER (PARTITION BY name) > 1 AND name IS NOT NULL THEN CONCAT(name, ' - ', RIGHT(vin, 6)) ELSE COALESCE(name, CONCAT('VIN ', vin)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;", "includeAll": false, "label": "Car", "name": "car_id", "options": [], "query": "SELECT\n id as __value,\n CASE WHEN COUNT(id) OVER (PARTITION BY name) > 1 AND name IS NOT NULL THEN CONCAT(name, ' - ', RIGHT(vin, 6)) ELSE COALESCE(name, CONCAT('VIN ', vin)) end as __text \nFROM cars\nORDER BY display_priority ASC, name ASC, vin ASC;", "refresh": 1, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "select base_url from settings limit 1;", "hide": 2, "includeAll": false, "name": "base_url", "options": [], "query": "select base_url from settings limit 1;", "refresh": 1, "regex": "", "type": "query" }, { "current": {}, "datasource": { "type": "grafana-postgresql-datasource", "uid": "TeslaMate" }, "definition": "select unit_of_length from settings limit 1;", "hide": 2, "includeAll": false, "name": "length_unit", "options": [], "query": "select unit_of_length from settings limit 1;", "refresh": 1, "regex": "", "type": "query" }, { "auto": false, "auto_count": 30, "auto_min": "10s", "current": { "text": "year", "value": "year" }, "name": "period", "options": [ { "selected": false, "text": "month", "value": "month" }, { "selected": true, "text": "year", "value": "year" } ], "query": "month,year", "refresh": 2, "type": "interval" }, { "current": { "text": "40000", "value": "40000" }, "description": "Cost of the car to be recovered over time", "label": "Cost of the car", "name": "car_cost", "options": [ { "selected": true, "text": "40000", "value": "40000" } ], "query": "40000", "type": "textbox" }, { "current": { "text": "20", "value": "20" }, "description": "Depreciation percentage for age (first year %)", "label": "Depreciation percentage", "name": "depreciated_value", "options": [ { "selected": true, "text": "20", "value": "20" } ], "query": "20", "type": "textbox" }, { "current": { "text": "0.20", "value": "0.20" }, "description": "Loss per mile or km driven", "label": "Loss rate per mileage", "name": "loss_rate", "options": [ { "selected": true, "text": "0.20", "value": "0.20" } ], "query": "0.20", "type": "textbox" }, { "current": { "text": "0.108", "value": "0.108" }, "description": "Fuel price per mile or km driven on a combustion car", "label": "Fuel price", "name": "fuel_price", "options": [ { "selected": true, "text": "0.108", "value": "0.108" } ], "query": "0.108", "type": "textbox" } ] }, "time": { "from": "now-5y", "to": "now" }, "timepicker": { "hidden": true, "refresh_intervals": [] }, "timezone": "browser", "title": "Amortization Tracker", "uid": "jchmAdd4SiQgWa", "version": 1, "weekStart": "" }