From bc6a634370a08976bd449c8dcd1956e46c6a41d8 Mon Sep 17 00:00:00 2001 From: ThePnuts <126296751+ThePnuts@users.noreply.github.com> Date: Sat, 1 Apr 2023 12:07:40 -0700 Subject: [PATCH 1/5] Update README.md transitioned instructions away from editing grafana.ini file to using variables instead --- tools/influxdb2/README.md | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tools/influxdb2/README.md b/tools/influxdb2/README.md index 50f60ec6..69ede094 100644 --- a/tools/influxdb2/README.md +++ b/tools/influxdb2/README.md @@ -40,8 +40,8 @@ This includes optionals files and instructions to help setup InfluxDB 2.x (inste * Host Path: /var/lib/grafana TO wherever you want to store your Grafana config and plugins (So its not stored in the container) * Variable: GF_SERVER_ROOT_URL | http://xxx.xxx.xxx.xxx (Your localhost IP) * Variable: GF_SECURITY_ADMIN_PASSWORD | Sup3rSecr3t (admin account password) - * Variable: GF_PATHS_CONFIG | /etc/grafana/grafana.ini (location of config file within container) - * Host Path: /etc/grafana/grafana.ini TO wherever you want to store your Grafana config (So its not stored in the container) + * Variable: GF_PANELS_DISABLE_SANITIZE_HTML | true (allow html code for tesla graphic) + * Variable: GF_INSTALL_PLUGINS | yesoreyeram-boomtable-panel, fetzerch-sunandmoon-datasource (auto install required plugins) ## Configure containers * InfluxDB 2.x @@ -54,7 +54,7 @@ This includes optionals files and instructions to help setup InfluxDB 2.x (inste * At this time not all data is aggregated, everything used for current reporting is aggregated to tesla_energy, set a retention policy respective of how much data you want to keep (its stored at 5s intervals from pyPowerwall) * tesla_energy (For aggregate date from raw_tesla_energy, also primary source for tesla data on the dashboard) * Aggregate data (@1m intervals) from raw_tesla_energy, do not set a retention policy if you want to keep historical data. - * Generate the following API tokens. Each a sperate tokens unless specified together. API tokens are only displayed at creatiion and need to be recreated if lost. + * Generate the following API tokensin the Web UI. Each a sperate tokens unless specified together. API tokens are only displayed at creatiion and need to be recreated if lost. * Write * raw_weather (for weather 411) * raw_tesla_energy (for Telegraf capturing pyPowerwall) @@ -71,20 +71,11 @@ This includes optionals files and instructions to help setup InfluxDB 2.x (inste * Telegraf * Edit telegraf.conf file with your server information and Write API token for raw_tesla_energy from above. Ensure it is saved where you specfied above. * Grafana (http://IP:3000/) - * grafana.ini - * Get the sample file from: https://github.com/grafana/grafana/blob/main/conf/sample.ini - * Save this file as grafana.ini in the location you specified - * Allow html - * In the grafana.ini file, find and edit: - * ;disable_sanitize_html = false TO disable_sanitize_html = true - * Add data sources in configuration + * Add data sources in configuration (Grafana web UI) * Enter the URL of your influxdb: http://IP:8086 * Enter the Organization you created * Default Bucket: tesla_energy - * Add plugins in configuration - * Search for and install: Sun and Moon (By fetzerch) - * Search for and install: Boom Table (By yesoreyeram) - * Dashboard + * Dashboard (Grafana web UI) * Import grafana dashboard json file ## Discussion Link From 0746d7da52c5e954d5f6a6da72adcf104cb2c109 Mon Sep 17 00:00:00 2001 From: ThePnuts <126296751+ThePnuts@users.noreply.github.com> Date: Sat, 1 Apr 2023 14:24:43 -0700 Subject: [PATCH 2/5] Add files via upload --- .../influxdb2/flux/tesla_energy.strings.flux | 26 ++++++++++++++ tools/influxdb2/flux/tesla_energy.vitals.flux | 34 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tools/influxdb2/flux/tesla_energy.strings.flux create mode 100644 tools/influxdb2/flux/tesla_energy.vitals.flux diff --git a/tools/influxdb2/flux/tesla_energy.strings.flux b/tools/influxdb2/flux/tesla_energy.strings.flux new file mode 100644 index 00000000..87582e03 --- /dev/null +++ b/tools/influxdb2/flux/tesla_energy.strings.flux @@ -0,0 +1,26 @@ +import "date" +import "regexp" + +option task = {name: "tesla_energy.strings", every: 1m} + +data = + from(bucket: "raw_tesla_energy") + //for historical generation change start here, otherwise use -2m for previous minute final total + |> range(start: date.truncate(t: -2m, unit: 1m), stop: date.truncate(t: now(), unit: 1m)) + |> filter(fn: (r) => r["_measurement"] == "http") + +withoutnum = + data + |> filter(fn: (r) => r["_field"] =~ /\A[A-D]_.*/) + |> map(fn: (r) => ({r with _field: regexp.replaceAllString(v: r._field, r: /_/, t: "0_")})) + +withnum = + data + |> filter(fn: (r) => r["_field"] =~ /\A[A-D][1-99]_.*/) + +union(tables: [withoutnum, withnum]) + |> aggregateWindow(every: 1m, fn: mean, createEmpty: false) + |> drop(columns: ["host", "month", "url", "year"]) + |> map(fn: (r) => ({r with _measurement: "strings"})) + |> drop(columns: ["_start", "_stop"]) + |> to(bucket: "tesla_energy") diff --git a/tools/influxdb2/flux/tesla_energy.vitals.flux b/tools/influxdb2/flux/tesla_energy.vitals.flux new file mode 100644 index 00000000..b64a7e14 --- /dev/null +++ b/tools/influxdb2/flux/tesla_energy.vitals.flux @@ -0,0 +1,34 @@ +import "date" +import "regexp" +option task = { + name: "tesla_energy.vitals", + every: 1m, +} + +data = from(bucket: "raw_tesla_energy") +//for historical generation change start here, otherwise use -2m for previous minute final total + |> range(start: date.truncate(t: -2m, unit: 1m), stop: date.truncate(t: now(), unit: 1m)) + |> filter(fn: (r) => r["_measurement"] == "http") + |> drop(columns: ["host", "month", "url", "year"]) + +pinv = data + |> filter(fn: (r) => r["_field"] =~ /PW[0-99]_PINV/) + |> aggregateWindow(every: 1m, fn: mean, createEmpty: false) + +island = data + |> filter(fn: (r) => r["_field"] =~ /ISLAND_/) + |> aggregateWindow(every: 1m, fn: mean, createEmpty: false) + +meter = data + |> filter(fn: (r) => r["_field"] =~ /METER_/) + |> filter(fn: (r) => r["_field"] !~ /.*Life/) + |> aggregateWindow(every: 1m, fn: mean, createEmpty: false) + +life = data + |> filter(fn: (r) => r["_field"] =~ /_Life/) + |> aggregateWindow(every: 1m, fn: last, createEmpty: false) + +union(tables: [pinv, island, meter, life]) + |> drop(columns: ["_start", "_stop"]) + |> map(fn: (r) => ({r with _measurement: "vitals"})) + |> to(bucket: "tesla_energy") \ No newline at end of file From 4a86be99e6e6a2dc66551d6db02ac1c9e2f5c510 Mon Sep 17 00:00:00 2001 From: ThePnuts <126296751+ThePnuts@users.noreply.github.com> Date: Sat, 1 Apr 2023 14:26:34 -0700 Subject: [PATCH 3/5] Update README.md --- tools/influxdb2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/influxdb2/README.md b/tools/influxdb2/README.md index 69ede094..6f9dfd78 100644 --- a/tools/influxdb2/README.md +++ b/tools/influxdb2/README.md @@ -54,7 +54,7 @@ This includes optionals files and instructions to help setup InfluxDB 2.x (inste * At this time not all data is aggregated, everything used for current reporting is aggregated to tesla_energy, set a retention policy respective of how much data you want to keep (its stored at 5s intervals from pyPowerwall) * tesla_energy (For aggregate date from raw_tesla_energy, also primary source for tesla data on the dashboard) * Aggregate data (@1m intervals) from raw_tesla_energy, do not set a retention policy if you want to keep historical data. - * Generate the following API tokensin the Web UI. Each a sperate tokens unless specified together. API tokens are only displayed at creatiion and need to be recreated if lost. + * Generate the following API tokens in the Web UI. Each a sperate tokens unless specified together. API tokens are only displayed at creatiion and need to be recreated if lost. * Write * raw_weather (for weather 411) * raw_tesla_energy (for Telegraf capturing pyPowerwall) From 8d331dc352079fdaa6943b5664c7d33c40e58719 Mon Sep 17 00:00:00 2001 From: ThePnuts <126296751+ThePnuts@users.noreply.github.com> Date: Sat, 1 Apr 2023 14:32:10 -0700 Subject: [PATCH 4/5] Update and rename Tesla Energy-Dashboard v0.10.json to Tesla Energy-Dashboard v0.11.json Fixed naming bug with Current State panel --- ...json => Tesla Energy-Dashboard v0.11.json} | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) rename tools/influxdb2/grafana/{Tesla Energy-Dashboard v0.10.json => Tesla Energy-Dashboard v0.11.json} (98%) diff --git a/tools/influxdb2/grafana/Tesla Energy-Dashboard v0.10.json b/tools/influxdb2/grafana/Tesla Energy-Dashboard v0.11.json similarity index 98% rename from tools/influxdb2/grafana/Tesla Energy-Dashboard v0.10.json rename to tools/influxdb2/grafana/Tesla Energy-Dashboard v0.11.json index 89d7165c..430dc8c1 100644 --- a/tools/influxdb2/grafana/Tesla Energy-Dashboard v0.10.json +++ b/tools/influxdb2/grafana/Tesla Energy-Dashboard v0.11.json @@ -541,7 +541,7 @@ }, "gridPos": { "h": 13, - "w": 17, + "w": 16, "x": 0, "y": 1 }, @@ -610,18 +610,18 @@ }, "gridPos": { "h": 10, - "w": 7, - "x": 17, + "w": 8, + "x": 16, "y": 1 }, - "id": 4, + "id": 62, "options": { "code": { "language": "plaintext", "showLineNumbers": false, "showMiniMap": false }, - "content": "\n
\n \n \n
\n
\n

Firmware

\n
\n", + "content": "\n
\n \n \n
\n
\n

Firmware

\n
\n", "mode": "html" }, "pluginVersion": "9.4.7", @@ -1690,7 +1690,7 @@ "type": "piechart" }, { - "activePatternIndex": 2, + "activePatternIndex": 0, "datasource": { "type": "influxdb", "uid": "${DS_INFLUXDB}" @@ -1769,11 +1769,11 @@ "value_below": "" }, "format": "kwatt", - "name": "Home", + "name": "Grid", "null_color": "darkred", "null_textcolor": "black", "null_value": "No data", - "pattern": "Home", + "pattern": "Grid", "row_col_wrapper": "_", "row_name": "_1_", "textColors": "white | white | white", @@ -1973,7 +1973,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -2065,7 +2066,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -2157,7 +2159,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -2249,7 +2252,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -4621,6 +4625,6 @@ "timezone": "", "title": "Tesla Energy", "uid": "yDBrTi-4k", - "version": 61, + "version": 64, "weekStart": "monday" } From 43aa8ed66fb2d4ffc0ef138c839b5a0619ff63c8 Mon Sep 17 00:00:00 2001 From: ThePnuts <126296751+ThePnuts@users.noreply.github.com> Date: Sat, 1 Apr 2023 14:36:22 -0700 Subject: [PATCH 5/5] Update and rename Tesla Energy-Dashboard v0.11.json to Tesla Energy-Dashboard v0.12.json Adjusted sizing of some panels to better match official dashboard --- ...shboard v0.11.json => Tesla Energy-Dashboard v0.12.json} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename tools/influxdb2/grafana/{Tesla Energy-Dashboard v0.11.json => Tesla Energy-Dashboard v0.12.json} (99%) diff --git a/tools/influxdb2/grafana/Tesla Energy-Dashboard v0.11.json b/tools/influxdb2/grafana/Tesla Energy-Dashboard v0.12.json similarity index 99% rename from tools/influxdb2/grafana/Tesla Energy-Dashboard v0.11.json rename to tools/influxdb2/grafana/Tesla Energy-Dashboard v0.12.json index 430dc8c1..1f6184a6 100644 --- a/tools/influxdb2/grafana/Tesla Energy-Dashboard v0.11.json +++ b/tools/influxdb2/grafana/Tesla Energy-Dashboard v0.12.json @@ -717,8 +717,8 @@ }, "gridPos": { "h": 3, - "w": 5, - "x": 18, + "w": 6, + "x": 17, "y": 11 }, "id": 6, @@ -4625,6 +4625,6 @@ "timezone": "", "title": "Tesla Energy", "uid": "yDBrTi-4k", - "version": 64, + "version": 65, "weekStart": "monday" }