Skip to content

Commit

Permalink
Merge pull request #598 from jasonacox/v4.6.5
Browse files Browse the repository at this point in the history
Update setup.sh to check for existing LAT and LONG coordinates #589
  • Loading branch information
jasonacox authored Mar 7, 2025
2 parents f3ab228 + da66e78 commit 66436a5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
5 changes: 5 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# RELEASE NOTES

## v4.6.5 - Coordinates

* Update `setup.sh` to check for existing LAT and LONG coordinate setting in SunAndMoon auto-provision datasource as reported in https://github.com/jasonacox/Powerwall-Dashboard/issues/589#issuecomment-2704639794.
* Provide disclaimer that 'already exist' errors are harmless as reported in https://github.com/jasonacox/Powerwall-Dashboard/issues/597

## v4.6.4 - InfluxDB Auto

* Fix URI too long issue by adding `POST` method for InfluxDB Auto-provision datasource in Grafana reported in https://github.com/jasonacox/Powerwall-Dashboard/issues/591 by @devachnid.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.6.4
4.6.5
27 changes: 20 additions & 7 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,27 @@ echo ""
# Get latitude and longitude
LAT="0.0"
LONG="0.0"
PYTHON=$(command -v python3 || command -v python)
if [ -n "${PYTHON}" ]; then
IP_RESPONSE=$(curl -s https://freeipapi.com/api/json)
LAT=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['latitude'])")
LONG=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['longitude'])")
# Check for existing LAT and LONG in grafana/provisions/datasources/sunandmoon.yml
if [ -f grafana/provisions/datasources/sunandmoon.yml ]; then
LAT=$(grep latitude grafana/provisions/datasources/sunandmoon.yml | cut -d: -f2 | tr -d '[:space:]')
LONG=$(grep longitude grafana/provisions/datasources/sunandmoon.yml | cut -d: -f2 | tr -d '[:space:]')
fi
# If LAT and LONG are zzLAT and zzLONG, then use the IP address to determine location
if [ "${LAT}" == "zzLAT" ] || [ "${LONG}" == "zzLONG" ] || [ "${LAT}" == "0.0" ] || [ "${LONG}" == "0.0" ]; then
echo "Attempting to determine your location..."
LAT="0.0"
LONG="0.0"
# Use IP address to determine location
PYTHON=$(command -v python3 || command -v python)
if [ -n "${PYTHON}" ]; then
IP_RESPONSE=$(curl -s https://freeipapi.com/api/json)
LAT=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['latitude'])")
LONG=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['longitude'])")
fi
else
echo "Found existing location coordinates for sun cycle."
fi
# check to see if LAT and LONG are not 0.0
echo "Using your location coordinates to determine sun cycle."
if [ "${LAT}" == "0.0" ] || [ "${LONG}" == "0.0" ]; then
echo " Your current location could not be automatically determined."
echo " For help go to https://jasonacox.github.io/Powerwall-Dashboard/location.html"
Expand Down Expand Up @@ -525,7 +538,7 @@ until running http://localhost:8086/ping 204 2>/dev/null; do
done
echo " up!"
sleep 2
echo "Setup InfluxDB Data..."
echo "Setup InfluxDB Data... ('already exist' errors harmless)"
docker exec --tty influxdb sh -c "influx -import -path=/var/lib/influxdb/influxdb.sql"
sleep 2
# Execute Run-Once queries for initial setup.
Expand Down
2 changes: 1 addition & 1 deletion upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -e

# Set Globals
VERSION="4.6.4"
VERSION="4.6.5"
CURRENT="Unknown"
COMPOSE_ENV_FILE="compose.env"
INFLUXDB_ENV_FILE="influxdb.env"
Expand Down

0 comments on commit 66436a5

Please sign in to comment.