def waterTemp(): global _lastRunningWaterTemp global _lastRunningWaterTime t = temp.getTempC(WATER_GPIO) # Pump is running, update the cache if pump.state() > pump.STATE_OFF: _lastRunningWaterTemp = t _lastRunningWaterTime = time.time() # If pump isn't running, the temperature is unreliable, start the pump if time.time() - _lastRunningWaterTime > _maxLag: if not pump.Stopped() and pump.state() == pump.STATE_OFF: log.debug("Running pump to get updated temperature") pump.startSolar() return t
def runPumpsIfNeeded(): global _lastRunningWaterTemp, zipcode, _deltaT, targetTemp solar_on = flowThroughCollectors() # Updates temperature cache log.debug("Solar(%s) pump(%d) stopped(%s)" % (str(solar_on), pump.state(), str(pump.Stopped()))) if solar_on and pump.state() == pump.STATE_OFF and not pump.Stopped(): observation = weather.getCurrentTempC(zipcode) if observation < targetTemp - _deltaT: log.info("SolarOn, weather too cold, starting sweep") pump.startSolarMixing() elif targetTemp - _deltaT > _lastRunningWaterTemp: log.info("SolarOn, pool too cold starting sweep") pump.startSolarMixing() else: log.info("SolarOn, starting pump") pump.startSolar() return True if solar_on and not pump.Stopped(): return True return False
def isDay(rT): global targetTemp, _deltaT if pump.state() == pump.STATE_OFF: if rT > targetTemp + _deltaT: return True # Not enough sun yet return False # Pump is running, return true unless the temp really drops (prevents bouncing of pumps) if rT > targetTemp - _tolerance: return True return False
def pushButtonCallback(channel): time.sleep(0.1) if GPIO.input(channel) != GPIO.LOW: return # false positive, humans take 1/10th sec state = pump.state() if state == pump.STATE_OFF: log.info("ButtonAction: Starting Pump") pump.startPump() elif state == pump.STATE_PUMP: log.info("ButtonAction: Starting Sweep") pump.startSweep() else: log.info("ButtonAction: Stopping all pumps") pump.stopAll(manual=True)
sleep(3) print('[INFO]: Pump OFF') pump.off() sleep(3) print('[INFO]: Pump Toggle (ON)') pump.toggle() sleep(3) print('[INFO]: Pump Toggle (OFF)') pump.toggle() sleep(10) # test pump states print('[INFO]: Pump Toggle (ON)') pump.toggle() active = pump.is_active() state = pump.state() print(' Pump is active: {active}'.format(active=active)) print(' Pump is active: {state}'.format(state=state)) sleep(3) print('[INFO]: Pump Toggle (OFF)') pump.toggle() active = pump.is_active() state = pump.state() print(' Pump is active: {active}'.format(active=active)) print(' Pump is active: {state}'.format(state=state)) print('[INFO]: Pump OFF') pump.off() pump.cleanup()
def recordPumpActivity(): relay.logStatus() log.debug("Pumps: pump(%d) solar(%d)" % (pump.state(), solar.state())) RRD.update(RrdFilename(PUMP_RRD), "N:%d:%d" % (pump.state(), solar.state()))