1
0
Fork 0
Browse Source

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.
unstable
gallery2 3 years ago
parent
commit
723f053a86
  1. 22
      relay.py

22
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: