Exemplo n.º 1
0
def pump_cv():

   answer = ""

   GPIO.setup(RELAY_CV,GPIO.OUT)   # heater pump
   aStand = ("on","off")

   pump_status = GPIO.input(RELAY_CV)
   status_old = pump_status

   while True:

      print "\nHeater pump is : ", aStand[pump_status]

      answer = raw_input("\nHeater pump (a)an (q)uit of (u)it : ")

      if answer == "a":
         GPIO.output(RELAY_CV,GPIO.LOW)
      elif answer == "u":
         GPIO.output(RELAY_CV,GPIO.HIGH)

      sleep(0.3)
      pump_status = GPIO.input(RELAY_CV)
      print cHeader
      print pump_status

      if answer == "q":
        break

   pump_status = GPIO.input(RELAY_CV)

   cMsg = TimeStamp("cv") + " cv_utils - Heater pump t=" + aStand[pump_status]
   semafoor("cv_pump.dat",cMsg,"w")
   cMsg = TimeStamp("l") + " | cv_utils - Heater pump switched: " + aStand[pump_status]
   semafoor("sf.log",cMsg,"a")
Exemplo n.º 2
0
def out_of_office():

   with open("ooo.sem", "r") as fo:
      line = fo.readlines()

   if "NO" in line[0]:
      cStr = "NO"
   else:
      cStr = "YES"
      
   cOld = cStr

   print "\nOut of Office set to: ", cOld, "\n"

   answer = raw_input("\n Out of office? (Y)es N(o) (q)uit : ")

   if answer.upper() == "Y":
      cStr = "YES"
   elif answer.upper() == "N":
      cStr = "NO"
   elif answer.upper() == "Q":
      return

   print "\nOut of Office is now: ", cStr, "\n"
   cMsg = TimeStamp("ooo") + "Out of Office t="+cStr
   semafoor("ooo.sem",cMsg,"w")

   return    
Exemplo n.º 3
0
def main():

    aData = []

    # contents climate file
    aLight = get_light()
    aData.append(aLight[0])

    aCloud = get_cloud(aLight[1])

    aHumid = get_humid()
    aData.append(aHumid[0])

    aBaro = get_baro()
    aData.append(aBaro[0])

    nWindSpeed = get_windspeed()
    cWindDir = get_winddir()

    cPluvio = str(get_pluvio())

    # create physical file from data[]:

    nCount = 0

    while nCount < 3:
        try:
            if DEBUG:
                print "writing 'climate.dat' file"

            with open("climate.dat", 'w') as fout:
                fcntl.flock(fout.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
                fout.writelines("%s\n" % item for item in aData)
        except:
            nCount += 1
            print 'file climate.dat could not be written to', nCount
            sleep(1)
        finally:
            break

    # format timestamp lumen, pressure, humidity, teperature, wind, direction, cloud type

    cStr = TimeStamp("w") + " " + str(aLight[1]) + " " + str(
        aBaro[1]) + " " + str(round(aHumid[1], 1)) + " "
    cStr += str(round(aHumid[2], 1)) + " " + str(round(
        nWindSpeed, 0)) + " " + cWindDir + " " + str(aCloud[0])
    cStr += " " + cPluvio
    if DEBUG:
        print cStr, aCloud[1]

    semafoor("weather.dat", cStr, 'a')
Exemplo n.º 4
0
def pump_studio():

   # write semafoor to SSD @kachel will react on that
   # replace with SQL

   # get temp kachel from semafoor file


   aStand = ("on","off")
   answer = ""

   GPIO.setup(RELAY_FLOOR,GPIO.OUT)   	# FLOOR PUMP

   pump_status = GPIO.input(RELAY_FLOOR)
   status_old = pump_status

   while True:

      print "\nFloor pump is : ", aStand[pump_status]

      answer = raw_input("\n Pomp Studio (a)an of (u)it (q)uit : ")

      if answer == "a":
         GPIO.output(RELAY_FLOOR,GPIO.LOW)
      elif answer == "u":
         GPIO.output(RELAY_FLOOR,GPIO.HIGH)

      sleep(0.3)

      pump_status = GPIO.input(RELAY_FLOOR)

      if answer == "q":
         break

   pump_status = GPIO.input(RELAY_FLOOR)
   cMsg = TimeStamp("cv") + " cv_utils - Floor pump t=" + aStand[pump_status]
   semafoor("floorpump.dat",cMsg,"w")
   cMsg = TimeStamp("l") + " | cv_utils - Floor pump switched: " + aStand[pump_status]
   semafoor("sf.log",cMsg,"a")
   
   return
Exemplo n.º 5
0
def logfile():

   while True:
   
      answer = raw_input("\nToon staart log file, type aantal regels of (q)uit : ")

      if answer <> "q" or answer <> "":
         cStr = "tail -" + answer + " sf.log" 

         if answer == "": 
            cStr = "tail sf.log" 

         print "\n============= staart logfile SF ============\n"  
         os.system(cStr)
         print "\n============== end logfile SF ==============\n"  

         cMsg = TimeStamp("l") + " | logfile CV shown"
         semafoor("sf.log",cMsg,"a")

      if answer == "q":
         break
Exemplo n.º 6
0
def boiler5():

# boiler works the other way around as pumps

   aStand = ("off","on")
   answer = ""

   GPIO.setup(RELAY_STUDIO,GPIO.OUT)     # FLOOR PUMP

   bl_status = GPIO.input(RELAY_STUDIO)
   status_old = bl_status

   while True:

      print "\nBoiler STUDIO is : ", aStand[bl_status]

      answer = raw_input("\n Boiler STUDIO (u)p or (d)own (q)uit : ")

      if answer == "u":
         GPIO.output(RELAY_STUDIO,GPIO.HIGH)
      elif answer == "d":
         GPIO.output(RELAY_STUDIO,GPIO.LOW)

      sleep(0.3)
      bl_status = GPIO.input(RELAY_STUDIO)

      if answer == "q":
         break

      if status_old <> bl_status:
         bl_status = GPIO.input(RELAY_STUDIO)
         cMsg = TimeStamp("cv") + " cv_utils - Boiler STUDIO t=" + aStand[bl_status]
         semafoor("boiler-studio.dat",cMsg,"w")
         cMsg = TimeStamp("l") + " | cv_utils - Boiler STUDIO switched: " + aStand[bl_status]
         semafoor("sf.log",cMsg,"a")

      status_old = bl_status

   return
Exemplo n.º 7
0
def minimax():

   global yMiniMax
   global yTempsYest

   yMiniMax    = ""
   cSolarOld   = cDummy
   cOutOld     = cDummy
   cHeatOld    = cDummy
   cPoolOld    = cDummy
   cTSmax      = cDummy
   cTSmin      = cDummy
   cOSmax      = cDummy
   cOSmin      = cDummy
   cGTS        = cDummy
   cGround     = cDummy

   nSpaces     = 7				# filling spaces in columns
   nMaxSol     = 0
   nMinSol     = 100
   nMaxOut     = 0
   nMinOut     = 100

   DATE_TIME   = 0
   SOLAR       = 2
   OUTSIDE     = 3

   bTimeSet    = False

   with open("cv_now.dat", 'r') as fo:
      read_data = fo.readlines()

   # this routine should be converted into (map, max min, array)
   for line in read_data:

       line = line.strip()
       columns = line.split()

       # to catch an empty record generate timestamp
       if columns[DATE_TIME] == None:
          columns[DATE_TIME] = TimeStamp("l")
          cMsg = TimeStamp("l") + " | Dashboard - timestamp from cv_now.dat missing, created timestamp."
          semafoor("sf.log", cMsg, "a")

       if not bTimeSet:
           cTimeDate = columns[DATE_TIME]
           bTimeSet  = True
                
       try:
           nSolar = float(columns[SOLAR])
           cSolarOld = columns[SOLAR]
       except:
           columns[SOLAR] = cSolarOld		# take last known value or dummy
           nSolar = float(cSolarOld)

       try: 
           nOut = float(columns[OUTSIDE])
           cOutOld = columns[OUTSIDE]
       except:
           columns[OUTSIDE] = cOutOld
           nOut = float(cOutOld)

       if nMaxSol < nSolar:
         nMaxSol  = nSolar
         cTSmax   = columns[DATE_TIME]

       if nMinSol > nSolar:
         nMinSol  = nSolar
         cTSmin   = columns[DATE_TIME]

       if nMaxOut < nOut:
         nMaxOut  = nOut
         cOSmax   = columns[DATE_TIME]

       if nMinOut > nOut:
         nMinOut  = nOut
         cOSmin   = columns[DATE_TIME]

   with open("ground.dat","r") as f:
     line = f.readline()
     cGround = line.split('t=')[-1][:-1]
     cGTS    = line.partition("|")[2][:5]

   cRegel  = "SolarFarm max temp" + str(nMaxSol).rjust(nSpaces) + " @ " + cTSmax.partition("|")[2][:5]
   cRegel += "  min temp " + str(nMinSol).rjust(nSpaces) + " @ "+ cTSmin.partition("|")[2][:5]
   cRegel += "<br>Outside   max temp" + str(nMaxOut).rjust(nSpaces) + " @ " + cOSmax.partition("|")[2][:5]
   cRegel += "  min temp " + str(nMinOut).rjust(nSpaces) + " @ "+  cOSmin.partition("|")[2][:5]
   cRegel += "<br>Ground temperature" + cGround.rjust(nSpaces) + " @ " + cGTS + "  100cm below groundlevel" 

   yMiniMax = cRegel

   nHour = get_hour()
   
   # preserve yesterdays minimax string
   if nHour == 8:				# this runs until 08:59 so it takes the last reading
      semafoor("minimax.sem", cRegel, "w")
      yTempsYest = cRegel
   else:
      with open("minimax.sem", "r") as f:
         yTempsYest = f.readline().strip()
         if DEBUG:
            print yTempsYest
   
   return