Heating and Ventilation Control
/HvcLightControl
Keine Erläuterungen gefunden.
import datetime from suntime import Sun class HvcLightControl: def __init__(self, debug=False): self.debug = debug self.latitude = 53 + 10.0/60.0 + 7.0/3600.0 self.longitude = 8 + 37.0/60.0 + 30.0/3600.0 def getSunSet(self): timeZone = datetime.datetime.now() sun = Sun(self.latitude, self.longitude) sunRise = sun.get_local_sunrise_time(timeZone) sunSet = sun.get_local_sunset_time(timeZone) srH = sunRise.strftime('%H') srM = sunRise.strftime('%M') self.sunRise = sunRise.strftime('%H:%M') ssH = sunSet.strftime('%H') ssM = sunSet.strftime('%M') self.sunSet = sunSet.strftime('%H:%M') self.sunRiseTime = float(srH) + float(srM)/60.0 self.sunSetTime = float(ssH) + float(ssM)/60.0 if self.debug: print("timeZone", timeZone) print("sunRise", sunRise) print("sunSet", sunSet) print("sunRiseTime", self.sunRiseTime) print("sunSetTime", self.sunSetTime) return def exteriorLight(self, OM, switches, myTime=-1): opMod = OM.operationMode parameter = OM.parameters switchOld = switches['LC1'] anyChange = False if opMod["extLight"]=="on": switches['LC1'] = 1 elif opMod["extLight"]=="off": switches['LC1'] = 0 else: now = datetime.datetime.now() #year = now.strftime("%Y") #mon = now.strftime("%m") #day = now.strftime("%d") hour = now.strftime("%H") minute = now.strftime("%M") if myTime < 0: myTime = float(hour) + float(minute)/60.0 offTime = parameter['extLightOffTime'] anyChange = False if self.debug: print("times", myTime, self.sunSetTime) print(ot,offTime,parameter['sunSetOffset']) print("switch old", switchOld ) if myTime > self.sunSetTime + parameter['sunSetOffset']: switches['LC1'] = 1 if (myTime < self.sunSetTime and myTime > offTime) or myTime == offTime: switches['LC1'] = 0 if abs(switches['LC1']-switchOld)>0: anyChange = True if self.debug: print("switch new", switches['LC1'] ) return switches, anyChange if __name__ == "__main__": from HvcOperationMode import HvcOperationMode #parameter = {} #OM.parameter['sunSetOffset'] = 0.5 #h #OM.parameter['extLightOffTime'] = "01:00" OM = HvcOperationMode() newOm,parameter,changed = OM.read() OM.operationMode['extLight'] = 'auto' myWRactual = {} myWRactual['LC1'] = 0 myEL = HvcLightControl(True) myEL.getSunSet() print("-------------- now") myWRactual, anyChange = myEL.exteriorLight(OM,myWRactual) print(myWRactual) if anyChange: print("some change") print("-------------- switch on?") myWRactual, anyChange = myEL.exteriorLight(OM,myWRactual,23.5) print(myWRactual) if anyChange: print("some change") print("-------------- nach Mitternacht") myWRactual, anyChange = myEL.exteriorLight(OM,myWRactual,0.5) print(myWRactual) if anyChange: print("some change") print("-------------- mittags") myWRactual, anyChange = myEL.exteriorLight(OM,myWRactual,12.5) print(myWRactual) if anyChange: print("some change") print("-------------- OM = on") OM.operationMode['extLight'] = 'on' myWRactual, anyChange = myEL.exteriorLight(OM,myWRactual,12.5) print('manual on',myWRactual) if anyChange: print("some change") print("-------------- OM off") OM.operationMode['extLight'] = 'off' myWRactual, anyChange = myEL.exteriorLight(OM,myWRactual,12.5) print('manual off',myWRactual) if anyChange: print("some change")
python
php
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.