Heating and Ventilation Control
HvcOperationMode
Keine Erläuterungen gefunden.
import os from stat import * import json class HvcOperationMode: def __init__(self): """ Initialization, specify the configuration file. """ self.opModFile = "./ConfDir/operationMode.yml" self.paramFile = "./ConfDir/parameters.yml" def read(self): """ Check for changes of the configuration fles, and load it on change. """ try: st = os.stat(self.opModFile) except IOError: print("failed to get information about", self.opModFile) else: lastModo = st[ST_MTIME] changed = 0 if HvcOperationMode.lastModo != lastModo: changed = 1 HvcOperationMode.lastModo = lastModo with open(self.opModFile) as json_file: HvcOperationMode.operationMode = json.load(json_file) try: st = os.stat(self.paramFile) except IOError: print("failed to get information about", self.paramFile) else: lastModp = st[ST_MTIME] changed = 0 if HvcOperationMode.lastModp != lastModp: changed = 1 HvcOperationMode.lastModp = lastModp with open(self.paramFile) as json_file: parTmp = json.load(json_file) for p in parTmp: HvcOperationMode.parameters[p] = float(parTmp[p]) return HvcOperationMode.operationMode,HvcOperationMode.parameters,changed def write(self,operationMode): """ Typically, the configuration file is edited via the web-frontend, use this to initially create an yaml file. """ with open(self.opModFile, 'w') as outfile: json.dump(operationMode, outfile) #persistant values: HvcOperationMode.lastModo = 0 HvcOperationMode.lastModp = 0 HvcOperationMode.operationMode = {} HvcOperationMode.parameters = {} """ for testing """ if __name__ == "__main__": import time, threading om = HvcOperationMode() operationMode = {} operationMode['solar']= "auto" # {on / off / auto} operationMode['oven'] = "off" # {on / off / auto} operationMode['pump'] = "off" # {on / off / auto} operationMode['vent'] = "minimal" # {minimal/normal/maximal/auto} operationMode['byPs'] = "shut" # {open/shut} operationMode['opMod'] = "summer" # {winter/summer/vacation} om.write(operationMode) next_call = time.time() while True: newOm,params,changed = om.read() if changed: print(newOm) next_call = next_call+1; time.sleep(next_call - time.time())
Index of Library
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.