From f5632c34f9c661f556737a8c870360f732301e50 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Wed, 15 May 2024 21:16:41 -0700 Subject: [PATCH 1/5] Fix docker group verification in setup.sh #476 --- setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index b61bcd73..ae9385d9 100755 --- a/setup.sh +++ b/setup.sh @@ -36,7 +36,7 @@ fi # Verify user in docker group (not required for Windows Git Bash) if ! type winpty > /dev/null 2>&1; then - if ! $(id -Gn 2>/dev/null | grep -qE " docker( |$)"); then + if ! $(id -Gn 2>/dev/null | grep -qw "docker"); then echo "WARNING: You do not appear to be in the docker group." echo "" echo "Please ensure your local user is in the docker group and run without sudo." From 6dc94a3832e4b05d63b4e598119381bd8c78aee8 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Wed, 15 May 2024 21:20:36 -0700 Subject: [PATCH 2/5] Prep for v4.4.0 --- RELEASE.md | 6 ++++++ VERSION | 2 +- upgrade.sh | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 7309ae0f..403572d4 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,11 @@ # RELEASE NOTES +## v4.4.0 - FleetAPI + +* Upgrade to pyPowerwall v0.9.0 proxy t57 +* Added support for using Tesla FleetAPI for cloud access. +* Fix setup.sh for docker group permission bug identified by @hulkster in #476 + ## v4.3.2 - Solar Only Fix * Upgrade to pyPowerwall v0.8.5 proxy t56 diff --git a/VERSION b/VERSION index cc2fbe89..fdc66988 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.3.2 +4.4.0 diff --git a/upgrade.sh b/upgrade.sh index b4cd0842..7c2d0194 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -6,7 +6,7 @@ set -e # Set Globals -VERSION="4.3.2" +VERSION="4.4.0" CURRENT="Unknown" COMPOSE_ENV_FILE="compose.env" INFLUXDB_ENV_FILE="influxdb.env" From 704e01a6f48cc12992d2aa7975a6ec6767af02c5 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sat, 18 May 2024 15:42:02 -0500 Subject: [PATCH 3/5] Add NetZero app --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ac081488..dd186d20 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,10 @@ Since [weather411](https://hub.docker.com/r/jasonacox/weather411) is part of thi **Data Retention and Backups** InfluxDB is configured to use a infinite retention policy (see [influxdb.sql](../influxdb/influxdb.sql)). It uses continuous queries to downsample Powerwall data and preserve disk space. However, this does not safeguard the data from accidental deletion or corruption. It is recommend that you set up a backup plan to snapshot the data for disaster recovery. See [backups](backups/) for some suggestions. +### Other Tools and Related Projects + +* NetZero app - iOS and Android App for monitoring your System - https://www.netzeroapp.io/ + ### Credits * This project is based on the great work by mihailescu2m at [https://github.com/mihailescu2m/powerwall_monitor](https://github.com/mihailescu2m/powerwall_monitor) and has been modified to use pypowerwall as a proxy to the Powerwall and includes solar String, Inverter and Powerwall Temperature graphs for Powerwall+ systems. From f39dbbfd7b53e0a0243ecc545799f1125076d1ae Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Mon, 3 Jun 2024 00:14:48 -0700 Subject: [PATCH 4/5] Upgrade pypowerwall to v0.10.0 to add FleetAPI and TEDAPI support --- RELEASE.md | 14 +++++++--- powerwall.yml | 2 +- setup.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++++++--- upgrade.sh | 19 +++++++++++--- 4 files changed, 97 insertions(+), 11 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 403572d4..753a7299 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,11 +1,19 @@ # RELEASE NOTES -## v4.4.0 - FleetAPI +## v4.4.0 - FleetAPI and TEDAPI -* Upgrade to pyPowerwall v0.9.0 proxy t57 -* Added support for using Tesla FleetAPI for cloud access. +* Add TEDAPI Support for Extended Device Metrics (the return of most of `/vitals`) - This requires connecting to Powerwall WiFi directly or setting up a network route on the Dashboard host to allow it to reach the GW address (192.168.91.1). +* Add support for Tesla's official API, [FleetAPI](https://developer.tesla.com/docs/fleet-api). This requires additional registration and configuration. Instructions are part of setup process or on the project page. +* Run `upgrade.sh` and then run `setup.sh` to choose these new options. +* Upgrade to [pyPowerwall v0.10.0](https://github.com/jasonacox/pypowerwall/releases/tag/v0.10.0) proxy t58 - Release addresses some issues, including fixing Solar Only grid_status issues as reported by @lsgc123 in https://github.com/jasonacox/Powerwall-Dashboard/issues/478 * Fix setup.sh for docker group permission bug identified by @hulkster in #476 +* Addresses several open issues and discussions: + * https://github.com/jasonacox/Powerwall-Dashboard/discussions/392 + * https://github.com/jasonacox/Powerwall-Dashboard/discussions/402 + * https://github.com/jasonacox/Powerwall-Dashboard/issues/436 + * https://github.com/jasonacox/Powerwall-Dashboard/issues/472 + ## v4.3.2 - Solar Only Fix * Upgrade to pyPowerwall v0.8.5 proxy t56 diff --git a/powerwall.yml b/powerwall.yml index bb949ec9..ce7b3419 100644 --- a/powerwall.yml +++ b/powerwall.yml @@ -18,7 +18,7 @@ services: - influxdb.env pypowerwall: - image: jasonacox/pypowerwall:0.8.5t56 + image: jasonacox/pypowerwall:0.10.0t58 container_name: pypowerwall hostname: pypowerwall restart: unless-stopped diff --git a/setup.sh b/setup.sh index ae9385d9..a57a75ac 100755 --- a/setup.sh +++ b/setup.sh @@ -12,6 +12,7 @@ INFLUXDB_ENV_FILE="influxdb.env" TELEGRAF_LOCAL="telegraf.local" PW_ENV_FILE="pypowerwall.env" GF_ENV_FILE="grafana.env" +PW_STYLE="grafana-dark" if [ ! -f VERSION ]; then echo "ERROR: Missing VERSION file. Setup must run from installation directory." @@ -111,8 +112,9 @@ echo "Select configuration mode:" echo "" echo "Current: ${config}" echo "" -echo " 1 - Local Access (Powerwall 1, 2, or + using the Tesla Gateway on LAN) - Default" -echo " 2 - Tesla Cloud (Solar-only systems or Powerwalls without LAN access)" +echo " 1 - Local Access (Powerwall 1, 2, or + using the Tesla Gateway on LAN) - Default" +echo " 2 - Tesla Cloud (Solar-only systems or Powerwalls without LAN access)" +echo " 3 - FleetAPI Cloud (Powerwall systems using Official Telsa API)" echo "" while :; do read -r -p "Select mode: ${choice}" response @@ -120,6 +122,8 @@ while :; do selected="Local Access" elif [ "${response}" == "2" ]; then selected="Tesla Cloud" + elif [ "${response}" == "3" ]; then + selected="FleetAPI Cloud" elif [ -z "${response}" ] && [ ! -z "${choice}" ]; then selected="${config}" else @@ -237,6 +241,19 @@ if [ -f ${PW_ENV_FILE} ]; then fi fi +# Function to test an IP to see if it returns a ping +function test_ip() { + local IP=$1 + if [ -z "${IP}" ]; then + return 1 + fi + if ping -c 1 -W 1 ${IP} > /dev/null 2>&1; then + return 0 + else + return 1 + fi +} + # Create Powerwall Settings if [ ! -f ${PW_ENV_FILE} ]; then if [ "${config}" == "Local Access" ]; then @@ -247,12 +264,51 @@ if [ ! -f ${PW_ENV_FILE} ]; then while [ -z "${EMAIL}" ]; do read -p 'Email: ' EMAIL done - read -p 'IP Address (leave blank to scan network): ' IP + IP="" + # Can we reach 192.168.91.1 + if test_ip "192.168.91.1"; then + IP="192.168.91.1" + echo "Found Powerwall Gateway at ${IP}" + read -p 'Use this IP? [Y/n] ' response + if [[ "$response" =~ ^([nN][oO]|[nN])$ ]]; then + IP="" + else + echo "Congratulations!" + echo "Extended Device Metrics (vitals) are available on this endpoint via TEDAPI." + echo "However, you will need the Gateway password to access them." + echo "This password is often on the QR code on the Powerwall Gateway unit." + echo "" + read -p 'Enter Gateway Password or leave blank to disable: ' PW + if [ -z "${PW}" ]; then + PW_GW_PWD="" + else + PW_GW_PWD="PW_GW_PWD=${PW}" + fi + + fi + else + echo "The Powerwall Gateway (192.168.91.1) is not found on your LAN." + echo "Standard dashboard metrics will work but Extended data (vitals) via TEDAPI" + echo "will not be available. Consult the project for information on how to enable." + echo "Proceeding with standard metrics..." + echo "" + fi + if [ -z "${IP}" ]; then + read -p 'Powerwall IP Address (leave blank to scan network): ' IP + fi else echo "Enter email address for Tesla Account..." while [ -z "${EMAIL}" ]; do read -p 'Email: ' EMAIL done + echo "If you have a Solar-only system, you can customize the dashboard for Solar and" + echo "hide the Powerwall metrics." + echo "" + # ask if user has a solar only system + read -p 'Set dashboard to Solar-only system? [y/N] ' response + if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then + PW_STYLE="solar" + fi fi echo "PW_EMAIL=${EMAIL}" > ${PW_ENV_FILE} echo "PW_PASSWORD=${PASSWORD}" >> ${PW_ENV_FILE} @@ -260,7 +316,8 @@ if [ ! -f ${PW_ENV_FILE} ]; then echo "PW_TIMEZONE=America/Los_Angeles" >> ${PW_ENV_FILE} echo "TZ=America/Los_Angeles" >> ${PW_ENV_FILE} echo "PW_DEBUG=no" >> ${PW_ENV_FILE} - echo "PW_STYLE=grafana-dark" >> ${PW_ENV_FILE} + echo "PW_STYLE=${PW_STYLE}" >> ${PW_ENV_FILE} + echo "PW_GW_PWD=${PW_GW_PWD}" >> ${PW_ENV_FILE} fi # Create default telegraf local file if needed. @@ -330,6 +387,14 @@ if [ "${config}" == "Tesla Cloud" ]; then echo "-----------------------------------------" fi +# Run FleetAPI mode setup +if [ "${config}" == "FleetAPI Cloud" ]; then + docker exec -it pypowerwall python3 -m pypowerwall fleetapi + echo "Restarting..." + docker restart pypowerwall + echo "-----------------------------------------" +fi + # Set up Influx echo "Waiting for InfluxDB to start..." until running http://localhost:8086/ping 204 2>/dev/null; do diff --git a/upgrade.sh b/upgrade.sh index 7c2d0194..f50ff79e 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -186,7 +186,7 @@ if [ "${PROFILE}" == "solar-only" ]; then echo "PW_TIMEZONE=America/Los_Angeles" >> ${PW_ENV_FILE} echo "TZ=America/Los_Angeles" >> ${PW_ENV_FILE} echo "PW_DEBUG=no" >> ${PW_ENV_FILE} - echo "PW_STYLE=grafana-dark" >> ${PW_ENV_FILE} + echo "PW_STYLE=solar" >> ${PW_ENV_FILE} fi # Remove use of COMPOSE_PROFILES (deprecated as of 4.0.0) @@ -260,8 +260,21 @@ fi # Check for PW_STYLE setting and add if missing if ! grep -q "PW_STYLE" ${PW_ENV_FILE}; then echo "Your pypowerwall environmental settings are missing PW_STYLE." - echo "Adding..." - echo "PW_STYLE=grafana-dark" >> ${PW_ENV_FILE} + # Check to see if they are solar only + if grep -q "PW_HOST=" ${PW_ENV_FILE}; then + echo "Do you want to use the solar-only style?" + read -r -p "Use solar-only style? [y/N] " response + if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] + then + echo "Adding..." + echo "PW_STYLE=solar" >> ${PW_ENV_FILE} + else + echo "Adding..." + echo "PW_STYLE=grafana-dark" >> ${PW_ENV_FILE} + fi + else + echo "Adding..." + echo "PW_STYLE=grafana-dark" >> ${PW_ENV_FILE} fi # Check to see that TZ is set in pypowerwall From 1deb9fa1c4163c34e87bb7990b20557391ee3da2 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Mon, 3 Jun 2024 00:33:53 -0700 Subject: [PATCH 5/5] Fix setup.sh to correctly handle empty PW_GW_PWD variable --- setup.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index a57a75ac..ea340ebc 100755 --- a/setup.sh +++ b/setup.sh @@ -282,9 +282,8 @@ if [ ! -f ${PW_ENV_FILE} ]; then if [ -z "${PW}" ]; then PW_GW_PWD="" else - PW_GW_PWD="PW_GW_PWD=${PW}" + PW_GW_PWD="${PW}" fi - fi else echo "The Powerwall Gateway (192.168.91.1) is not found on your LAN." @@ -317,7 +316,9 @@ if [ ! -f ${PW_ENV_FILE} ]; then echo "TZ=America/Los_Angeles" >> ${PW_ENV_FILE} echo "PW_DEBUG=no" >> ${PW_ENV_FILE} echo "PW_STYLE=${PW_STYLE}" >> ${PW_ENV_FILE} - echo "PW_GW_PWD=${PW_GW_PWD}" >> ${PW_ENV_FILE} + if [ ! -z "${PW_GW_PWD}" ]; then + echo "PW_GW_PWD=${PW_GW_PWD}" >> ${PW_ENV_FILE} + fi fi # Create default telegraf local file if needed.