1
0
Fork 0
Browse Source

update URL for RestAPI calls.

The API calls now go to rither.abbether.net instead of the designated IP
address assigned the server (AWS). This change makes it easier to access the
RestAPI (see midpoint repo.) server. The URL will remain constant and if the
server needs to be powered-down/restarted for anything, the new IP address
Amazon (web services) assigns to it will no longer matter. And, the code used
to make the RestAPI call will no longer need changing manually.
unstable
Craig Oates 3 years ago
parent
commit
f95ac677d6
  1. 4
      relay.py
  2. 2
      shutdown.sh
  3. 2
      startup.sh

4
relay.py

@ -14,13 +14,13 @@ def main():
try:
while True:
# Make sure the U.R.L. is valid.
r = requests.get('http://3.9.19.84/api/readings/latest/1')
r = requests.get('http://ritherdon.abbether.net/api/readings/latest/1')
# print(r.status_code) # For testing.
data = r.json()
# print(data) # For testing.
the_reading = data.get("reading")
# print(the_reading) # For testing.
if the_reading > 30:
if the_reading > 33:
# Print for testing.
# print(f"[INFO] Light is on -- {the_reading}.")
GPIO.output(relay_pin, GPIO.HIGH)

2
shutdown.sh

@ -13,7 +13,7 @@
logDate=$(date '+%Y-%m-%dT%TZ')
logFile="/home/rtrp/logs/shutdown-logs.txt"
mainURL="http://3.9.19.84/api/status/update" # Make sure this is valid.
mainURL="http://ritherdon.abbether.net/api/status/update" # Make sure this is valid.
getApiUrl () {
case $HOSTNAME in

2
startup.sh

@ -23,7 +23,7 @@ sleep 60
logDate=$(date '+%Y-%m-%dT%TZ')
logFile="/home/rtrp/logs/startup-logs.txt"
mainURL="http://3.9.19.84/api/status/update" # Make sure this is valid.
mainURL="http://ritherdon.abbether.net/api/status/update" # Make sure this is valid.
getApiUrl () {
case $HOSTNAME in