Skip to content
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.0.0 - Add Cloud Mode support via pyPowerwall v0.7.0 #414

Merged
merged 28 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a0ed67c
Stage updates for pypowerwall v0.7.0
jasonacox Dec 27, 2023
1ab975e
v4.0.0
jasonacox Dec 27, 2023
39462a1
Add auth and site file creation
jasonacox Dec 29, 2023
ad1958c
Add .auth folder
jasonacox Dec 30, 2023
252f335
Update powerwall.yml for .auth
jasonacox Dec 30, 2023
d5bc73e
Add PW_AUTH_PATH to Docker Compose config
mcbirse Dec 31, 2023
7c54343
Add CQ for nominal_full_pack_energy
jasonacox Jan 2, 2024
a2fff22
Merge branch 'v4.0.0' of https://github.com/jasonacox/Powerwall-Dashb…
jasonacox Jan 2, 2024
5aa5fcd
Capture SIGTERM when weather411 halts due to missing config
mcbirse Jan 10, 2024
e8817c5
Add auth files
mcbirse Jan 10, 2024
32b946f
Remove profiles
mcbirse Jan 10, 2024
666947a
Update setup scripts and remove profiles
mcbirse Jan 10, 2024
b9bd555
Update container versions and remove profiles
mcbirse Jan 10, 2024
7e1bd00
Update pypowerwall
jasonacox Jan 14, 2024
90c2d7e
Add v3.0.8
jasonacox Jan 14, 2024
f41de0d
v4.0.0 upgrade script
mcbirse Jan 14, 2024
fde66b2
Fix network scan ip addr in Windows Git Bash
mcbirse Jan 15, 2024
7e7d692
Merge branch 'main' into v4.0.0
jasonacox Jan 15, 2024
1d96c9a
Merge branch 'v4.0.0' of https://github.com/jasonacox/Powerwall-Dashb…
jasonacox Jan 15, 2024
fa1bd89
Get ip addr based on OS
mcbirse Jan 16, 2024
1b2aae4
Fix for missing cmd
mcbirse Jan 16, 2024
94c75f7
Update verify script
mcbirse Jan 16, 2024
253dffe
Add sample docker compose for tesla-history
mcbirse Jan 19, 2024
2e1c504
Update setup options, README and RELEASE notes
mcbirse Jan 19, 2024
2f58551
Update to latest pypowerwall and proxy
mcbirse Jan 21, 2024
a493e91
Update README
jasonacox Jan 21, 2024
910e627
Add animation to solar-only dashboard
jasonacox Jan 21, 2024
7807a8c
Add script descriptions
jasonacox Jan 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
v4.0.0 upgrade script
  • Loading branch information
mcbirse committed Jan 14, 2024
commit f41de0d4802447630ed6b4f70e78bdda33ab81b5
4 changes: 2 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,9 @@ if [ -f weather/weather411.conf ]; then
fi

# Display Final Instructions
if [ "${config}" == "Tesla Cloud" ]
if ! grep -qE "^PW_HOST=.+" "${PW_ENV_FILE}"
then
DASHBOARD="'dashboard-solar-only.json' or 'dashboard-no-animation.json'"
DASHBOARD="'dashboard.json' or 'dashboard-solar-only.json'"
else
DASHBOARD="'dashboard.json'"
fi
Expand Down
129 changes: 43 additions & 86 deletions upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ INFLUXDB_ENV_FILE="influxdb.env"
TELEGRAF_LOCAL="telegraf.local"
PW_ENV_FILE="pypowerwall.env"
GF_ENV_FILE="grafana.env"
PROFILE="none"
if [ -f VERSION ]; then
CURRENT=`cat VERSION`
fi
Expand Down Expand Up @@ -41,44 +40,6 @@ running() {
[[ $status == ${code} ]]
}

# Compose Profiles Helper Functions
get_profile() {
if [ ! -f ${COMPOSE_ENV_FILE} ]; then
return 1
else
unset COMPOSE_PROFILES
. "${COMPOSE_ENV_FILE}"
fi
# Check COMPOSE_PROFILES for profile
IFS=',' read -ra PROFILES <<< "${COMPOSE_PROFILES}"
for p in "${PROFILES[@]}"; do
if [ "${p}" == "${1}" ]; then
return 0
fi
done
return 1
}

add_profile() {
# Create default docker compose env file if needed.
if [ ! -f ${COMPOSE_ENV_FILE} ]; then
cp "${COMPOSE_ENV_FILE}.sample" "${COMPOSE_ENV_FILE}"
fi
if ! get_profile "${1}"; then
# Add profile to COMPOSE_PROFILES and save to env file
PROFILES+=("${1}")
if [ -z "${COMPOSE_PROFILES}" ]; then
if grep -q "^#COMPOSE_PROFILES=" "${COMPOSE_ENV_FILE}"; then
sed -i.bak "s@^#COMPOSE_PROFILES=.*@COMPOSE_PROFILES=$(IFS=,; echo "${PROFILES[*]}")@g" "${COMPOSE_ENV_FILE}"
else
echo -e "\nCOMPOSE_PROFILES=$(IFS=,; echo "${PROFILES[*]}")" >> "${COMPOSE_ENV_FILE}"
fi
else
sed -i.bak "s@^COMPOSE_PROFILES=.*@COMPOSE_PROFILES=$(IFS=,; echo "${PROFILES[*]}")@g" "${COMPOSE_ENV_FILE}"
fi
fi
}

# Because this file can be upgraded, don't use it to run the upgrade
if [ "$0" != "tmp.sh" ]; then
# Grab latest upgrade script from GitHub and run it
Expand All @@ -98,18 +59,13 @@ echo "This script will attempt to upgrade you to the latest version without"
echo "removing existing data. A backup is still recommended."
echo ""

# Check for existing solar-only installation
# Check for existing beta solar-only installation or solar-only profile
if [ -f tools/solar-only/compose.env ] && [ ! -f ${COMPOSE_ENV_FILE} ]; then
echo "NOTE: Your existing 'solar-only' installation will be migrated to:"
echo " ${PWD}"
echo ""
PROFILE="solar-only"
fi

# Check COMPOSE_PROFILES for existing configuration profile
if get_profile "default"; then
PROFILE="default"
elif get_profile "solar-only"; then
elif [ -f ${COMPOSE_ENV_FILE} ] && grep -q "^COMPOSE_PROFILES=.*solar-only" "${COMPOSE_ENV_FILE}"; then
PROFILE="solar-only"
fi

Expand All @@ -136,7 +92,7 @@ else
exit
fi

# Migrate existing solar-only installation if found
# Migrate existing beta solar-only installation if found
if [ -f tools/solar-only/compose.env ] && [ ! -f ${COMPOSE_ENV_FILE} ]; then
cd tools/solar-only

Expand Down Expand Up @@ -183,14 +139,32 @@ if [ -f tools/solar-only/compose.env ] && [ ! -f ${COMPOSE_ENV_FILE} ]; then
fi
rm -rf tz tesla-history weather dashboard.json.bak
cd ../..
echo ""
fi

# Add solar-only and weather411 (if configured) to COMPOSE_PROFILES
PROFILE="solar-only"
add_profile "solar-only"
if [ -f weather/weather411.conf ]; then
add_profile "weather411"
# Migrate solar-only profile to pypowerwall cloud mode
if [ "${PROFILE}" == "solar-only" ]; then
# Create Powerwall Settings
rm -f ${PW_ENV_FILE}
mkdir -p .auth
cp tools/tesla-history/tesla-history.auth .auth/.pypowerwall.auth
if grep -qE "^SITE = [0-9].+" tools/tesla-history/tesla-history.conf; then
grep -E "^SITE = [0-9].+" tools/tesla-history/tesla-history.conf | awk '{ print $NF }' > .auth/.pypowerwall.site
fi
echo ""
EMAIL=$(grep -E "^USER = .+@.+" tools/tesla-history/tesla-history.conf | awk '{ print $NF }')
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration logic is clever! ! I'll run it across my various OS systems but seems like it would be universal.

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}
fi

# Remove use of COMPOSE_PROFILES (deprecated as of 4.0.0)
if [ -f ${COMPOSE_ENV_FILE} ] && grep -qE "^COMPOSE_PROFILES=.*(default|solar-only)" "${COMPOSE_ENV_FILE}"; then
./compose-dash.sh down
sed -i.bak "s@^COMPOSE_PROFILES=.*@# *** Deprecated as of 4.0.0 ***\n#&@g" "${COMPOSE_ENV_FILE}"
fi

# Remember Timezone and Reset to Default
Expand Down Expand Up @@ -247,40 +221,23 @@ else
fi
fi

# Check for COMPOSE_PROFILES and add if missing (required in 3.0.0)
if get_profile "default"; then
PROFILE="default"
elif get_profile "solar-only"; then
PROFILE="solar-only"
else
# Missing - Add default and weather411 (if configured) to COMPOSE_PROFILES
PROFILE="default"
add_profile "default"
if [ -f weather/weather411.conf ]; then
add_profile "weather411"
fi
# Create default telegraf local file if needed.
if [ ! -f ${TELEGRAF_LOCAL} ]; then
cp "${TELEGRAF_LOCAL}.sample" "${TELEGRAF_LOCAL}"
fi

if [ "${PROFILE}" == "default" ]
then
# Create default telegraf local file if needed.
if [ ! -f ${TELEGRAF_LOCAL} ]; then
cp "${TELEGRAF_LOCAL}.sample" "${TELEGRAF_LOCAL}"
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}
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}
fi

# Check to see that TZ is set in pypowerwall
if ! grep -q "TZ=" ${PW_ENV_FILE}; then
echo "Your pypowerwall environmental settings are missing TZ."
echo "Adding..."
echo "TZ=America/Los_Angeles" >> ${PW_ENV_FILE}
fi
# Check to see that TZ is set in pypowerwall
if ! grep -q "TZ=" ${PW_ENV_FILE}; then
echo "Your pypowerwall environmental settings are missing TZ."
echo "Adding..."
echo "TZ=America/Los_Angeles" >> ${PW_ENV_FILE}
fi

# Check to see if Weather Data is Available
Expand Down Expand Up @@ -366,9 +323,9 @@ echo "Restarting Powerwall-Dashboard stack..."
./compose-dash.sh up -d

# Display Final Instructions
if [ "${PROFILE}" == "solar-only" ]
if ! grep -qE "^PW_HOST=.+" "${PW_ENV_FILE}"
then
DASHBOARD="'dashboard-solar-only.json' or 'dashboard-no-animation.json'"
DASHBOARD="'dashboard.json' or 'dashboard-solar-only.json'"
else
DASHBOARD="'dashboard.json'"
fi
Expand Down