diff --git a/relay.py b/relay.py index e2069fd..7a37f86 100644 --- a/relay.py +++ b/relay.py @@ -35,14 +35,20 @@ def main(): # print(data) # For testing. the_reading = data.get("reading") # print(the_reading) # For testing. - if the_reading > 48: - # Print for testing. - # print(f"[INFO] Light is on -- {the_reading}.") - GPIO.output(relay_pin, GPIO.HIGH) - else: - # Print for testing. - # print(f"[INFO] Light is off -- {the_reading}.") - GPIO.output(relay_pin, GPIO.LOW) + if (device_id == "gallery1"): + if (the_reading > 38): + # print(f"[INFO: FACTORY1] Light is on -- {the_reading}.") + GPIO.output(relay_pin, GPIO.HIGH) + else: + # print(f"[INFO: FACTORY1] Light is off -- {the_reading}.") + GPIO.output(relay_pin, GPIO.LOW) + elif (device_id == "gallery2"): + if (the_reading > 48): + # print(f"[INFO: FACTORY2] Light is on -- {the_reading}.") + GPIO.output(relay_pin, GPIO.HIGH) + else: + # print(f"[INFO: FACTORY2] Light is off -- {the_reading}.") + GPIO.output(relay_pin, GPIO.LOW) except KeyboardInterrupt: print("[INFO] KEYBOARD INTERRUPT: quitting program.") except requests.exceptions.ConnectionError: