diff --git a/relay.py b/relay.py index 42af4b2..30434a7 100644 --- a/relay.py +++ b/relay.py @@ -5,16 +5,26 @@ import time import requests relay_pin = 11 -#GPIO.setmode(GPIO.BCM) # GPIO umbers instead of board numbers. +#GPIO.setmode(GPIO.BCM) # GPIO numbers instead of board numbers. GPIO.setmode(GPIO.BOARD) GPIO.setup(relay_pin, GPIO.OUT) +def get_api_url(): + # Yes, I know I could do this better. Stop moaning. + if (device_id == "factory1"): + return "http://ritherdon.abbether.net/api/readings/add/1" + elif (device_id == "factory2"): + return "http://ritherdon.abbether.net/api/readings/add/2" + +# Make sure this is valid. +# api_url = "http://ritherdon.abbether.net/api/readings/add/1" +api_url = get_api_url() # Saves having to do the if-check every call. def main(): try: while True: # Make sure the U.R.L. is valid. - r = requests.get('http://ritherdon.abbether.net/api/readings/latest/1') + r = requests.get(api_url) # print(r.status_code) # For testing. data = r.json() # print(data) # For testing.