Skip to content

Commit fd079bb

Browse files
committed
Release v4.6.3: Enhance SunAndMoon datasource with user-editable location and confirm coordinates during setup #589
1 parent c301e6c commit fd079bb

File tree

6 files changed

+50
-19
lines changed

6 files changed

+50
-19
lines changed

RELEASE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# RELEASE NOTES
22

3+
## v4.6.3 - SunAndMoon Edit
4+
5+
* Update SunAndMoon datasource auto-provisioning to allow user to edit location.
6+
* Add location LAT and LONG confirmation as part of setup.sh script.
7+
38
## v4.6.2 - Normalize Alerts
49

510
Updates to pyPowerwall v0.12.7 which includes:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.6.2
1+
4.6.3

grafana/sunandmoon-template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ datasources:
66
jsonData:
77
latitude: zzLAT
88
longitude: zzLONG
9+
editable: true

setup.sh

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,6 @@ running() {
8080
[[ $status == ${code} ]]
8181
}
8282

83-
# Get latitude and longitude
84-
LAT="0.0"
85-
LONG="0.0"
86-
PYTHON=$(command -v python3 || command -v python)
87-
if [ -n "${PYTHON}" ]; then
88-
IP_RESPONSE=$(curl -s https://freeipapi.com/api/json)
89-
LAT=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['latitude'])")
90-
LONG=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['longitude'])")
91-
fi
92-
9383
# Docker Dependency Check
9484
if ! docker info > /dev/null 2>&1; then
9585
echo "ERROR: docker is not available or not running."
@@ -442,9 +432,37 @@ fi
442432
echo "-----------------------------------------"
443433
echo ""
444434

435+
# Get latitude and longitude
436+
LAT="0.0"
437+
LONG="0.0"
438+
PYTHON=$(command -v python3 || command -v python)
439+
if [ -n "${PYTHON}" ]; then
440+
IP_RESPONSE=$(curl -s https://freeipapi.com/api/json)
441+
LAT=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['latitude'])")
442+
LONG=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['longitude'])")
443+
fi
444+
# check to see if LAT and LONG are not 0.0
445+
echo "Using your location coordinates to determine sun cycle."
446+
if [ "${LAT}" == "0.0" ] || [ "${LONG}" == "0.0" ]; then
447+
echo " Your current location could not be automatically determined."
448+
echo " For help go to https://jasonacox.github.io/Powerwall-Dashboard/location.html"
449+
else
450+
echo " Your current location appears to be Latitude: ${LAT}, Longitude: ${LONG}"
451+
fi
452+
echo ""
453+
read -p 'Enter Latitude (default: '${LAT}'): ' USER_LAT
454+
if [ -n "${USER_LAT}" ]; then
455+
LAT="${USER_LAT}"
456+
fi
457+
read -p 'Enter Longitude (default '${LONG}'): ' USER_LONG
458+
if [ -n "${USER_LONG}" ]; then
459+
LONG="${USER_LONG}"
460+
fi
461+
echo ""
462+
445463
# Optional - Setup Weather Data
446464
if [ -f weather.sh ]; then
447-
./weather.sh setup
465+
./weather.sh setup "${LAT}" "${LONG}"
448466
fi
449467

450468
if [ -f grafana/sunandmoon-template.yml ]; then

upgrade.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
set -e
77

88
# Set Globals
9-
VERSION="4.6.2"
9+
VERSION="4.6.3"
1010
CURRENT="Unknown"
1111
COMPOSE_ENV_FILE="compose.env"
1212
INFLUXDB_ENV_FILE="influxdb.env"

weather.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ fi
2121

2222
# Docker Dependency Check - moved to compose-dash.sh, 14/10/22
2323

24-
# Get latitude and longitude
24+
# Set latitude and longitude
2525
LAT="0.0"
2626
LONG="0.0"
27-
PYTHON=$(command -v python3 || command -v python)
28-
if [ -n "${PYTHON}" ]; then
29-
IP_RESPONSE=$(curl -s https://freeipapi.com/api/json)
30-
LAT=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['latitude'])")
31-
LONG=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['longitude'])")
27+
# Check for LAT and LONG on command line
28+
if [ "${1}" == "setup" ] && [ -n "${2}" ] && [ -n "${3}" ]; then
29+
LAT="${2}"
30+
LONG="${3}"
31+
else
32+
# Try to detect location
33+
PYTHON=$(command -v python3 || command -v python)
34+
if [ -n "${PYTHON}" ]; then
35+
IP_RESPONSE=$(curl -s https://freeipapi.com/api/json)
36+
LAT=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['latitude'])")
37+
LONG=$(echo "$IP_RESPONSE" | "${PYTHON}" -c "import sys, json; print(json.load(sys.stdin)['longitude'])")
38+
fi
3239
fi
3340

3441
# Setup Weather?

0 commit comments

Comments
 (0)