From 7b33111894dfe50974bebc904680866e983359a7 Mon Sep 17 00:00:00 2001 From: Christopher Pitstick Date: Thu, 16 Jan 2025 23:50:01 -0500 Subject: [PATCH] Dual Inverter Prototype --- dashboards/dashboard-alt.json | 4 +-- dashboards/dashboard-min-mean-max.json | 2 +- dashboards/dashboard-no-animation.json | 2 +- dashboards/dashboard-simple.json | 2 +- dashboards/dashboard-solar-only.json | 2 +- dashboards/dashboard.json | 2 +- grafana/provisions/datasources/influxdb.yml | 2 +- grafana/provisions/datasources/sunandmoon.yml | 8 ++++++ influxdb/influxdb.sql | 4 +-- powerwall.yml | 18 ++++++------- telegraf.conf | 27 ++++++++++++------- tz | 2 +- 12 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 grafana/provisions/datasources/sunandmoon.yml diff --git a/dashboards/dashboard-alt.json b/dashboards/dashboard-alt.json index 1416092d..f8cdc080 100644 --- a/dashboards/dashboard-alt.json +++ b/dashboards/dashboard-alt.json @@ -34,7 +34,7 @@ "name": "VAR_TZ", "type": "constant", "label": "Timezone", - "value": "America/Los_Angeles", + "value": "America/New_York", "description": "" } ], @@ -1388,7 +1388,7 @@ ] ], "tags": [], - "tz": "America/Los_Angeles" + "tz": "America/New_York" }, { "alias": "off_grid", diff --git a/dashboards/dashboard-min-mean-max.json b/dashboards/dashboard-min-mean-max.json index ae75a759..01feb19b 100644 --- a/dashboards/dashboard-min-mean-max.json +++ b/dashboards/dashboard-min-mean-max.json @@ -27,7 +27,7 @@ "name": "VAR_TZ", "type": "constant", "label": "Timezone", - "value": "America/Los_Angeles", + "value": "America/New_York", "description": "" } ], diff --git a/dashboards/dashboard-no-animation.json b/dashboards/dashboard-no-animation.json index 99a47a9a..41e2ef6b 100644 --- a/dashboards/dashboard-no-animation.json +++ b/dashboards/dashboard-no-animation.json @@ -27,7 +27,7 @@ "name": "VAR_TZ", "type": "constant", "label": "Timezone", - "value": "America/Los_Angeles", + "value": "America/New_York", "description": "" } ], diff --git a/dashboards/dashboard-simple.json b/dashboards/dashboard-simple.json index 56468982..453a7722 100644 --- a/dashboards/dashboard-simple.json +++ b/dashboards/dashboard-simple.json @@ -27,7 +27,7 @@ "name": "VAR_TZ", "type": "constant", "label": "Timezone", - "value": "America/Los_Angeles", + "value": "America/New_York", "description": "" } ], diff --git a/dashboards/dashboard-solar-only.json b/dashboards/dashboard-solar-only.json index 7dee8535..46055513 100644 --- a/dashboards/dashboard-solar-only.json +++ b/dashboards/dashboard-solar-only.json @@ -34,7 +34,7 @@ "name": "VAR_TZ", "type": "constant", "label": "Timezone", - "value": "America/Los_Angeles", + "value": "America/New_York", "description": "" } ], diff --git a/dashboards/dashboard.json b/dashboards/dashboard.json index f5b27789..08c09fac 100644 --- a/dashboards/dashboard.json +++ b/dashboards/dashboard.json @@ -34,7 +34,7 @@ "name": "VAR_TZ", "type": "constant", "label": "Timezone", - "value": "America/Los_Angeles", + "value": "America/New_York", "description": "" } ], diff --git a/grafana/provisions/datasources/influxdb.yml b/grafana/provisions/datasources/influxdb.yml index c9e4e0e7..acee7620 100644 --- a/grafana/provisions/datasources/influxdb.yml +++ b/grafana/provisions/datasources/influxdb.yml @@ -4,7 +4,7 @@ datasources: - name: InfluxDB (auto provisioned) type: influxdb access: proxy - url: http://influxdb:8086 + url: http://localhost:8086 database: powerwall jsonData: dbName: powerwall diff --git a/grafana/provisions/datasources/sunandmoon.yml b/grafana/provisions/datasources/sunandmoon.yml new file mode 100644 index 00000000..9740f17c --- /dev/null +++ b/grafana/provisions/datasources/sunandmoon.yml @@ -0,0 +1,8 @@ +apiVersion: 1 + +datasources: + - name: Sun and Moon (auto provisioned) + type: fetzerch-sunandmoon-datasource + jsonData: + latitude: 40.44062 + longitude: -79.995888 diff --git a/influxdb/influxdb.sql b/influxdb/influxdb.sql index 4ba1184d..a900c055 100644 --- a/influxdb/influxdb.sql +++ b/influxdb/influxdb.sql @@ -15,8 +15,8 @@ CREATE RETENTION POLICY alerts ON powerwall duration INF replication 1 CREATE CONTINUOUS QUERY cq_autogen ON powerwall BEGIN SELECT mean(home) AS home, mean(solar) AS solar, mean(from_pw) AS from_pw, mean(to_pw) AS to_pw, mean(from_grid) AS from_grid, mean(to_grid) AS to_grid, last(percentage) AS percentage INTO powerwall.autogen.:MEASUREMENT FROM (SELECT load_instant_power AS home, solar_instant_power AS solar, abs((1+battery_instant_power/abs(battery_instant_power))*battery_instant_power/2) AS from_pw, abs((1-battery_instant_power/abs(battery_instant_power))*battery_instant_power/2) AS to_pw, abs((1+site_instant_power/abs(site_instant_power))*site_instant_power/2) AS from_grid, abs((1-site_instant_power/abs(site_instant_power))*site_instant_power/2) AS to_grid, percentage FROM raw.http) GROUP BY time(1m), month, year fill(linear) END CREATE CONTINUOUS QUERY cq_autogen_current ON powerwall BEGIN SELECT mean(home) AS home_current, mean(solar) AS solar_current, mean(pw) AS pw_current, mean(grid) AS grid_current INTO powerwall.autogen.:MEASUREMENT FROM (SELECT load_instant_total_current AS home, solar_instant_total_current AS solar, battery_instant_total_current AS pw, site_instant_total_current AS grid FROM raw.http) GROUP BY time(1m), month, year fill(linear) END CREATE CONTINUOUS QUERY cq_autogen_voltage ON powerwall BEGIN SELECT mean(home) AS home_voltage, mean(solar) AS solar_voltage, mean(pw) AS pw_voltage, mean(grid) AS grid_voltage INTO powerwall.autogen.:MEASUREMENT FROM (SELECT load_instant_average_voltage AS home, solar_instant_average_voltage AS solar, battery_instant_average_voltage AS pw, site_instant_average_voltage AS grid FROM raw.http) GROUP BY time(1m), month, year fill(linear) END -CREATE CONTINUOUS QUERY cq_kwh ON powerwall RESAMPLE EVERY 1m BEGIN SELECT integral(home)/1000/3600 AS home, integral(solar)/1000/3600 AS solar, integral(from_pw)/1000/3600 AS from_pw, integral(to_pw)/1000/3600 AS to_pw, integral(from_grid)/1000/3600 AS from_grid, integral(to_grid)/1000/3600 AS to_grid INTO powerwall.kwh.:MEASUREMENT FROM autogen.http GROUP BY time(1h), month, year tz('America/Los_Angeles') END -CREATE CONTINUOUS QUERY cq_daily ON powerwall RESAMPLE EVERY 1h BEGIN SELECT sum(home) AS home, sum(solar) AS solar, sum(from_pw) AS from_pw, sum(to_pw) AS to_pw, sum(from_grid) AS from_grid, sum(to_grid) AS to_grid INTO powerwall.daily.:MEASUREMENT FROM powerwall.kwh.http GROUP BY time(1d), month, year tz('America/Los_Angeles') END +CREATE CONTINUOUS QUERY cq_kwh ON powerwall RESAMPLE EVERY 1m BEGIN SELECT integral(home)/1000/3600 AS home, integral(solar)/1000/3600 AS solar, integral(from_pw)/1000/3600 AS from_pw, integral(to_pw)/1000/3600 AS to_pw, integral(from_grid)/1000/3600 AS from_grid, integral(to_grid)/1000/3600 AS to_grid INTO powerwall.kwh.:MEASUREMENT FROM autogen.http GROUP BY time(1h), month, year tz('America/New_York') END +CREATE CONTINUOUS QUERY cq_daily ON powerwall RESAMPLE EVERY 1h BEGIN SELECT sum(home) AS home, sum(solar) AS solar, sum(from_pw) AS from_pw, sum(to_pw) AS to_pw, sum(from_grid) AS from_grid, sum(to_grid) AS to_grid INTO powerwall.daily.:MEASUREMENT FROM powerwall.kwh.http GROUP BY time(1d), month, year tz('America/New_York') END CREATE CONTINUOUS QUERY cq_monthly ON powerwall RESAMPLE EVERY 1h BEGIN SELECT sum(home) AS home, sum(solar) AS solar, sum(from_pw) AS from_pw, sum(to_pw) AS to_pw, sum(from_grid) AS from_grid, sum(to_grid) AS to_grid INTO powerwall.monthly.:MEASUREMENT FROM powerwall.daily.http GROUP BY time(365d), month, year END CREATE CONTINUOUS QUERY cq_pw_temps ON powerwall BEGIN SELECT mean(PW1_temp) AS PW1_temp, mean(PW2_temp) AS PW2_temp, mean(PW3_temp) AS PW3_temp, mean(PW4_temp) AS PW4_temp, mean(PW5_temp) AS PW5_temp, mean(PW6_temp) AS PW6_temp INTO powerwall.pwtemps.:MEASUREMENT FROM (SELECT PW1_temp, PW2_temp, PW3_temp, PW4_temp, PW5_temp, PW6_temp FROM raw.http) GROUP BY time(1m), month, year fill(linear) END CREATE CONTINUOUS QUERY cq_pw_tempsb ON powerwall BEGIN SELECT mean(PW7_temp) AS PW7_temp, mean(PW8_temp) AS PW8_temp, mean(PW9_temp) AS PW9_temp, mean(PW10_temp) AS PW10_temp, mean(PW11_temp) AS PW11_temp, mean(PW12_temp) AS PW12_temp INTO powerwall.pwtemps.:MEASUREMENT FROM (SELECT PW7_temp, PW8_temp, PW9_temp, PW10_temp, PW11_temp, PW12_temp FROM raw.http) GROUP BY time(1m), month, year fill(linear) END diff --git a/powerwall.yml b/powerwall.yml index c87a85fd..366413e9 100644 --- a/powerwall.yml +++ b/powerwall.yml @@ -4,6 +4,7 @@ services: container_name: influxdb hostname: influxdb restart: unless-stopped + network_mode: host volumes: - type: bind source: ./influxdb.conf @@ -12,13 +13,11 @@ services: - type: bind source: ./influxdb target: /var/lib/influxdb - ports: - - "${INFLUXDB_PORTS:-8086:8086}" env_file: - influxdb.env pypowerwall: - image: jasonacox/pypowerwall:0.12.0t66 + image: jasonacox/pypowerwall:0.12.3.t68 container_name: pypowerwall hostname: pypowerwall restart: unless-stopped @@ -27,10 +26,10 @@ services: source: .auth target: /app/.auth user: "${PWD_USER:-1000:1000}" - ports: - - "${PYPOWERWALL_PORTS:-8675:8675}" + network_mode: host environment: - - PW_AUTH_PATH=.auth + - PW_AUTH_PATH_1=.auth + - PW_AUTH_PATH_2=.auth env_file: - pypowerwall.env @@ -40,6 +39,7 @@ services: hostname: telegraf restart: unless-stopped user: "${PWD_USER:-1000:1000}" + network_mode: host command: [ "telegraf", "--config", @@ -74,12 +74,11 @@ services: hostname: grafana restart: unless-stopped user: "${PWD_USER:-1000:1000}" + network_mode: host volumes: - type: bind source: ./grafana target: /var/lib/grafana - ports: - - "${GRAFANA_PORTS:-9000:9000}" env_file: - grafana.env depends_on: @@ -91,13 +90,12 @@ services: hostname: weather411 restart: unless-stopped user: "${PWD_USER:-1000:1000}" + network_mode: host volumes: - type: bind source: ./weather target: /var/lib/weather read_only: true - ports: - - "${WEATHER411_PORTS:-8676:8676}" environment: - WEATHERCONF=/var/lib/weather/weather411.conf depends_on: diff --git a/telegraf.conf b/telegraf.conf index 36bc0e79..f8ed5874 100644 --- a/telegraf.conf +++ b/telegraf.conf @@ -93,19 +93,25 @@ ############################################################################### [[outputs.influxdb]] - urls = ["http://influxdb:8086"] + urls = ["http://localhost:8086"] database = "powerwall" skip_database_creation = false retention_policy = "raw" [[inputs.http]] urls = [ - "http://pypowerwall:8675/aggregates", - "http://pypowerwall:8675/soe", - "http://pypowerwall:8675/strings", - "http://pypowerwall:8675/temps/pw", - "http://pypowerwall:8675/freq", - "http://pypowerwall:8675/pod" + "http://localhost:8675/aggregates", + "http://localhost:8675/soe", + "http://localhost:8675/strings", + "http://localhost:8675/temps/pw", + "http://localhost:8675/freq", + "http://localhost:8675/pod", + "http://localhost:8685/aggregates", + "http://localhost:8685/soe", + "http://localhost:8685/strings", + "http://localhost:8685/temps/pw", + "http://localhost:8685/freq", + "http://localhost:8685/pod" ] method = "GET" insecure_skip_verify = true @@ -115,17 +121,18 @@ [[processors.date]] tag_key = "month" date_format = "Jan" - timezone = "America/Los_Angeles" + timezone = "America/New_York" [[processors.date]] tag_key = "year" date_format = "2006" - timezone = "America/Los_Angeles" + timezone = "America/New_York" # Alert Data [[inputs.http]] urls = [ - "http://pypowerwall:8675/alerts/pw" + "http://localhost:8675/alerts/pw", + "http://localhost:8685/alerts/pw" ] name_override = "alerts" method = "GET" diff --git a/tz b/tz index 49244fce..46ed5d3e 100644 --- a/tz +++ b/tz @@ -1 +1 @@ -America/Los_Angeles +America/New_York