From 723f053a86f13b0269ae01f218137f8543b327d0 Mon Sep 17 00:00:00 2001 From: gallery2 Date: Mon, 1 Feb 2021 14:21:46 +0000 Subject: [PATCH] seperate light reading conditions for each relay. With both Light-Meters installed in Ritheron, it is now apparent, each booth has different levels on light in them. This means each Relay (linked to its factory counterpart) needs to adjust to match. The branching logic is implemented in a sloppy way here so it will need to be refactored at some point but this is just a quick change to test the code. --- relay.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) 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: