-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V4.4.0 - Vitals and FleetAPI #479
Changes from all commits
f5632c3
6dc94a3
704e01a
f39dbbf
1deb9fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.3.2 | ||
4.4.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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." | ||
|
@@ -36,7 +37,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." | ||
|
@@ -111,15 +112,18 @@ 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 | ||
if [ "${response}" == "1" ]; then | ||
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,20 +264,61 @@ 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!" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SETUP: If local mode is selected, the setup script will attempt to find the Powerwall gateway at the default IP (192.168.91.1) and ask the user if they wish to set up the TEDAPI extended device vitals metrics. Otherwise, it will prompt the user for the IP address (or to scan). This means that the user needs to set up the network routes to the PW Gateway prior to running |
||
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}" | ||
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} | ||
echo "PW_HOST=${IP}" >> ${PW_ENV_FILE} | ||
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} | ||
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. | ||
|
@@ -330,6 +388,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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SETUP SCRIPT: This release adds the ability to use FleetAPI. If selected, it will kick off the FleetAPI setup process. If FleetpAPI is set up, the pypowerwall will always prefer that over cloud (Tesla Owners unofficial API) as FleetAPI is a Tesla provided official API.