Dec-17-2020, 06:40 PM
Yes forgot the return had nothing if not going through IF statements. Change to below code which at present seems to be working ok. Probable not best way to get this done but seems to be working :).
Thanks for the link, this is really useful
Thanks for the link, this is really useful
import datetime nersFlag = False nuserySWdatabase = 0 nersOffTime = 0 def nuseryControlFunction(nuserySWdatabase, nersFlag, nersOffTime): if nuserySWdatabase == 0 and not nersFlag: print ("pump on") # GPIO.output(pump, GPIO.LOW) nersOffTime = datetime.datetime.now() + datetime.timedelta(seconds=30) print (nersOffTime) print (now) nersFlag = True if nuserySWdatabase == 1: print ("pump off") # GPIO.output(pump, GPIO.HIGH) nersOffTime = 0 nersFlag = False if nersOffTime < now: print "shutdown" return nersFlag, nersOffTime while True: now = datetime.datetime.now() nersFlag, nersOffTime = nuseryControlFunction(nuserySWdatabase, nersFlag, nersOffTime)