Archived
1
0

Working automatic mode.No DB stuff yet.

This commit is contained in:
Shaun Setlock
2021-11-12 15:23:57 -05:00
parent 266204d9ce
commit 3dc11546ac
4 changed files with 135 additions and 23 deletions

68
automatic/state_trans.py Normal file
View File

@@ -0,0 +1,68 @@
#! env/bin/python3
import RPi.GPIO as GPIO
import time
from datetime import datetime
def check_state(inputs):
# Define alias variables for input devices.
green_button = inputs['green_button']
yellow_button = inputs['yellow_button']
blue_button = inputs['blue_button']
# Define state variables for each of the output devices.
pump_state = inputs['pump']
lamp_state = inputs['lamp']
# Get mode and schedule information.
mode = inputs['mode']
hour = inputs['hour']
minute = inputs['minute']
# Determine state.
# Assume no change in state.
pump_out = pump_state
lamp_out = lamp_state
# Automatic mode.
if mode == "AUTO":
detect = False
if 6 < hour < 22:
lamp_out = True
pump_out = True
else:
lamp_out = False
pump_out = False
# Manual mode.
if mode == "MANUAL":
detect = False
# Pump Flip-Flop
if not detect and blue_button and pump_state:
pump_out = False
detect = True
if not detect and blue_button and not pump_state:
pump_out = True
detect = True
# Lamp Flip-Flop
if not detect and yellow_button and lamp_state:
lamp_out = False
detect = True
if not detect and yellow_button and not lamp_state:
lamp_out = True
detect = True
# Define alias variables for input devices.
outputs = {
'detect' : detect,
'pump' : pump_out,
'lamp' : lamp_out,
}
return outputs