# sendWhatsApps(dictSensors[iControlSensor].GetMobiles(), getInfoText("Started")) sH_Log.Add('Radiator activated') elif (counterLow == TriggerCountB or vBoolInterval == False or modules_radiators == False or boolTriggerOutdoor == False) and RadiatorStarted: dictActors[dictSensors[iControlSensor].GetFritzActor()].SetActor(False) #LedR.off() #LedY.off() RadiatorStarted = False # sendWhatsApps(dictSensors[iControlSensor].GetMobiles(), getInfoText("Stopped")) sH_Log.Add('Radiator deactivated') if vVerbose.startswith('test'): #print getInfoText("Status") print '##### - #####' #threadCreateFile('/var/sensorTool/www/sensor.php', getHTML()) threadCreateFile('/var/sensorTool/www/sensor.csv', getCSVSensor(), 'csv') threadCreateFile('/var/sensorTool/www/module.csv', getCSVModules(), 'csv') threadCreateFile('/var/sensorTool/www/fa.csv', getCSVfa(), 'csv') strAlarm = 'False' if boolInfoLight: strAlarm = 'True' threadCreateFile('/var/sensorTool/www/alarm.csv', strAlarm, 'csv') # thread.start_new_thread(threadCreatePHPFile, ('/var/sensorTool/www/sensor.php', getHTML(),)) plotting_DeviceValues(dictActiveModules, '1_Modules', vVerbose) plotting_DeviceValues(dictTemperature, '3_Temperature', vVerbose, -20, 50) plotting_DeviceValues(dictRelativeHumidity, '4_Relative_Humidity', vVerbose) plotting_DeviceValues(dictAbsoluteHumidity, '2_Absolute_Humidity', vVerbose, 0, 30) plotting_DeviceValues(dictPressure, '9_Pressure', vVerbose, 700, 1100) # thread.start_new_thread(plotting, (dictPlotSens, dictPlotAussen, vVerbose,))
def sensorSwitches(PathToConfig='/home/pi/sensorTool/switches.conf', vVerbose='start'): config = ConfigParser.ConfigParser() config.read(PathToConfig) #print(config.sections() ) dictGroups = {} GroupCount = 0 for vSec in config.sections(): if vSec[:6] == 'Switch': vGroup = config.get(vSec, 'group') boolDings = False for vGi in dictGroups: if dictGroups[vGi]['name'] == vGroup: boolDings = True if not boolDings: GroupCount = GroupCount + 1 dictGroup = {} dictGroup['name'] = vGroup dictGroup['switches'] = None dictGroups[GroupCount] = dictGroup #print dictGroups for vKGroup in dictGroups: #print str(vKGroup) + " " + str(dictGroups[vKGroup]['name']) dictSwitches = {} CountSwitch = 0 for vSec in config.sections(): if vSec[:6] == 'Switch': vGroup = config.get(vSec, 'group') if dictGroups[vKGroup]['name'] == vGroup: CountSwitch = CountSwitch + 1 dictSwitch = {} dictSwitch['protocol'] = config.get(vSec, 'protocol') dictSwitch['id'] = config.get(vSec, 'id') try: dictSwitch['unit'] = config.get(vSec, 'unit') except: dictSwitch['unit'] = None dictSwitch['name'] = config.get(vSec, 'name') dictSwitches[CountSwitch] = dictSwitch dictGroups[vKGroup]['switches'] = dictSwitches #for vGroup in dictGroups: #print str(vGroup) + ": " + str(dictGroups[vGroup]['name']) #for vDictSwitch in dictGroups[vGroup]['switches']: #print " " + str(dictGroups[vGroup]['switches'][vDictSwitch]['name']) vhttpResult = '' for vGroup in dictGroups: #print str(vGroup) + ": " + str(dictGroups[vGroup]['name']) vhttpResult += 'echo " <table class=\\"switch\\">\\n";\n' vhttpResult += 'echo " <th>' + str( dictGroups[vGroup]['name']) + '</th>\\n";\n' for vDictSwitch in dictGroups[vGroup]['switches']: #print " " + str(dictGroups[vGroup]['switches'][vDictSwitch]) vhttpResult += 'echo " <tr>\\n";\n' vhttpResult += 'echo " <td class=\\"switchlabel\\">' + str( dictGroups[vGroup]['switches'][vDictSwitch] ['name']) + '</td>\\n";\n' vhttpResult += 'echo " <td class=\\"switch\\">\\n";\n' vhttpResult += 'echo " <form class=\\"switch\\" method=\\"post\\">\\n";\n' vhttpResult += 'echo " <input type=\\"hidden\\" name=\\"SwitchID\\" value=\\"' + str( dictGroups[vGroup]['switches'][vDictSwitch] ['id']) + '\\">\\n";\n' #if 'unit' in dictGroups[vGroup]['switches'][vDictSwitch] and not dictGroups[vGroup]['switches'][vDictSwitch]['unit'] is None: if not (dictGroups[vGroup]['switches'][vDictSwitch]['unit'] is None): vhttpResult += 'echo " <input type=\\"hidden\\" name=\\"SwitchUnit\\" value=\\"' + str( dictGroups[vGroup]['switches'][vDictSwitch] ['unit']) + '\\">\\n";\n' vhttpResult += 'echo " <input type=\\"hidden\\" name=\\"SwitchProtocol\\" value=\\"' + str( dictGroups[vGroup]['switches'][vDictSwitch] ['protocol']) + '\\">\\n";\n' vhttpResult += 'echo " <button class=\\"switch\\" type=\\"submit\\" name=\\"SwitchAction\\" value=\\"1\\">An</button>\\n";\n' vhttpResult += 'echo " <button class=\\"switch\\" type=\\"submit\\" name=\\"SwitchAction\\" value=\\"0\\">Aus</button>\\n";\n' vhttpResult += 'echo " </form>\\n";\n' vhttpResult += 'echo " </td>\\n";\n' vhttpResult += 'echo " </tr>\\n";\n' vhttpResult += 'echo " </table>\n";\n' vhttpResult += 'echo " <br />\n";\n' #print vhttpResult threadCreateFile('/var/sensorTool/www/preswitch.php', vhttpResult)
def sensorSwitches(PathToConfig='/home/pi/sensorTool/switches.conf', vVerbose='start'): config = ConfigParser.ConfigParser() config.read(PathToConfig) #print(config.sections() ) dictGroups = {} GroupCount = 0 for vSec in config.sections(): vGroup = config.get(vSec, 'group') boolDings = False for vGi in dictGroups: if dictGroups[vGi]['name'] == vGroup: boolDings = True if not boolDings: GroupCount = GroupCount + 1 dictGroup = {} dictGroup['name'] = vGroup dictGroup['switches'] = None dictGroups[GroupCount] = dictGroup #print dictGroups for vKGroup in dictGroups: #print str(vKGroup) + " " + str(dictGroups[vKGroup]['name']) dictSwitches = {} CountSwitch = 0 for vSec in config.sections(): vGroup = config.get(vSec, 'group') if dictGroups[vKGroup]['name'] == vGroup: CountSwitch = CountSwitch + 1 dictSwitch = {} dictSwitch['protocol'] = config.get(vSec, 'protocol') dictSwitch['id'] = config.get(vSec, 'id') try: dictSwitch['unit'] = config.get(vSec, 'unit') except: dictSwitch['unit'] = None dictSwitch['name'] = config.get(vSec, 'name') dictSwitches[CountSwitch] = dictSwitch dictGroups[vKGroup]['switches'] = dictSwitches #for vGroup in dictGroups: #print str(vGroup) + ": " + str(dictGroups[vGroup]['name']) #for vDictSwitch in dictGroups[vGroup]['switches']: #print " " + str(dictGroups[vGroup]['switches'][vDictSwitch]['name']) vhttpResult = '' for vGroup in dictGroups: #print str(vGroup) + ": " + str(dictGroups[vGroup]['name']) vhttpResult += 'echo " <table class=\\"switch\\">\\n";\n' vhttpResult += 'echo " <th>' + str(dictGroups[vGroup]['name']) + '</th>\\n";\n' for vDictSwitch in dictGroups[vGroup]['switches']: #print " " + str(dictGroups[vGroup]['switches'][vDictSwitch]) vhttpResult += 'echo " <tr>\\n";\n' vhttpResult += 'echo " <td class=\\"switchlabel\\">'+str(dictGroups[vGroup]['switches'][vDictSwitch]['name'])+'</td>\\n";\n' vhttpResult += 'echo " <td class=\\"switch\\">\\n";\n' vhttpResult += 'echo " <form class=\\"switch\\" method=\\"post\\">\\n";\n' vhttpResult += 'echo " <input type=\\"hidden\\" name=\\"SwitchID\\" value=\\"'+str(dictGroups[vGroup]['switches'][vDictSwitch]['id'])+'\\">\\n";\n' #if 'unit' in dictGroups[vGroup]['switches'][vDictSwitch] and not dictGroups[vGroup]['switches'][vDictSwitch]['unit'] is None: if not (dictGroups[vGroup]['switches'][vDictSwitch]['unit'] is None): vhttpResult += 'echo " <input type=\\"hidden\\" name=\\"SwitchUnit\\" value=\\"'+str(dictGroups[vGroup]['switches'][vDictSwitch]['unit'])+'\\">\\n";\n' vhttpResult += 'echo " <input type=\\"hidden\\" name=\\"SwitchProtocol\\" value=\\"'+str(dictGroups[vGroup]['switches'][vDictSwitch]['protocol'])+'\\">\\n";\n' vhttpResult += 'echo " <button class=\\"switch\\" type=\\"submit\\" name=\\"SwitchAction\\" value=\\"1\\">An</button>\\n";\n' vhttpResult += 'echo " <button class=\\"switch\\" type=\\"submit\\" name=\\"SwitchAction\\" value=\\"0\\">Aus</button>\\n";\n' vhttpResult += 'echo " </form>\\n";\n' vhttpResult += 'echo " </td>\\n";\n' vhttpResult += 'echo " </tr>\\n";\n' vhttpResult += 'echo " </table>\n";\n' vhttpResult += 'echo " <br />\n";\n' #print vhttpResult threadCreateFile('/var/sensorTool/www/preswitch.php', vhttpResult)
def sensorPHPConf(vVerbose='start'): PathToSwitchesConfig = '/home/pi/sensorTool/switches.conf' PathToWebradioConfig = '/home/pi/sensorTool/webradio.conf' config = ConfigParser.ConfigParser() config.read(PathToSwitchesConfig) dictSwitches = {} dictGroups = {} dictGroups2 = {} countGroups2 = 0 countSwitches = 0 countSwitchGroups = 0 for vSec in config.sections(): if vSec[:5] == 'Group': dictGroup = {} dictGroup['group'] = vSec dictGroup['switchgroup'] = config.get(vSec, 'switchgroup') try: dictGroup['slideshow'] = config.getboolean(vSec, 'slideshow') except: dictGroup['slideshow'] = False try: dictGroup['OnAndOff'] = config.getboolean(vSec, 'OnAndOff') except: dictGroup['OnAndOff'] = True dictGroups[countSwitchGroups] = dictGroup countSwitchGroups = countSwitchGroups + 1 elif vSec[:6] == 'Switch': dictSwitch = {} dictSwitch['switch'] = vSec dictSwitch['protocol'] = config.get(vSec, 'protocol') dictSwitch['name'] = config.get(vSec, 'name') dictSwitch['id'] = config.getint(vSec, 'id') try: dictSwitch['unit'] = config.getint(vSec, 'unit') except: dictSwitch['unit'] = None dictSwitch['group'] = config.get(vSec, 'group') if not config.get(vSec, 'group') in dictGroups2: dictGroups2[config.get(vSec, 'group')] = countGroups2 countGroups2 = countGroups2 + 1 try: dictSwitch['switchgroup'] = config.get(vSec, 'switchgroup') except: dictSwitch['switchgroup'] = None try: dictSwitch['alarm'] = config.getboolean(vSec, 'alarm') except: dictSwitch['alarm'] = False try: dictSwitch['slideshow'] = config.getboolean(vSec, 'slideshow') except: dictSwitch['slideshow'] = False try: dictSwitch['OnAndOff'] = config.getboolean(vSec, 'OnAndOff') except: dictSwitch['OnAndOff'] = True dictSwitches[countSwitches] = dictSwitch countSwitches = countSwitches + 1 config = None config = ConfigParser.ConfigParser() config.read(PathToWebradioConfig) dictWebradios = {} countWR = 0 for vSec in config.sections(): dictWebradio = {} dictWebradio['sender'] = vSec dictWebradio['name'] = config.get(vSec, 'name') dictWebradio['preset'] = config.get(vSec, 'preset') dictWebradio['volumeM'] = config.getint(vSec, 'volumeM') dictWebradio['volumeS'] = config.getint(vSec, 'volumeS') try: dictWebradio['slideshow'] = config.getboolean(vSec, 'slideshow') except: dictWebradio['slideshow'] = False try: dictWebradio['index'] = config.getboolean(vSec, 'index') except: dictWebradio['index'] = False dictWebradios[countWR] = dictWebradio countWR = countWR + 1 vhttpResult = '' # vhttpResult += '<?php\n' vhttpResult += 'define(\'SENSORTOOLSERVER\', \'raspberrypi3\');\n' vhttpResult += '$vtop_menue = \'rpidisplay\';\n' vhttpResult += '\n' for vW in dictWebradios: vhttpResult += '$arrWebradio[] = array ( \"' vhttpResult += str(vW) vhttpResult += '\", \"' vhttpResult += str(dictWebradios[vW]['sender']) vhttpResult += '\", \"' vhttpResult += str(dictWebradios[vW]['name']) vhttpResult += '\", \"' vhttpResult += str(dictWebradios[vW]['preset']) vhttpResult += '\", ' vhttpResult += str(dictWebradios[vW]['volumeM']) vhttpResult += ', ' vhttpResult += str(dictWebradios[vW]['volumeS']) vhttpResult += ', ' vhttpResult += str(dictWebradios[vW]['index']) vhttpResult += ', ' vhttpResult += str(dictWebradios[vW]['slideshow']) vhttpResult += ');\n' vhttpResult += '\n' for vS in dictGroups: vhttpResult += '$arrSwitchGroups[] = array ( \"' vhttpResult += str(vS) vhttpResult += '\", \"' vhttpResult += str(dictSwitches[vS]['group']) vhttpResult += '\", \"' vhttpResult += str(dictGroups[vS]['switchgroup']) vhttpResult += '\", ' vhttpResult += str(dictGroups[vS]['slideshow']) vhttpResult += ', ' vhttpResult += str(dictGroups[vS]['OnAndOff']) vhttpResult += ');\n' vhttpResult += '\n' iii = 0 for iii in range(countGroups2): vhttpResult += '$arrSwitchTopicGroups[] = array ( \"' for vS2 in dictGroups2: if iii == dictGroups2[vS2]: vhttpResult += str(iii) vhttpResult += '\", \"' vhttpResult += str(vS2) vhttpResult += '\");\n' vhttpResult += '\n' vCSVResult = '' for vS in dictSwitches: vhttpResult += '$arrSwitches[] = array ( \"' vhttpResult += str(vS) vhttpResult += '\", \"' vhttpResult += str(dictSwitches[vS]['switch']) vhttpResult += '\", \"' vhttpResult += str(dictSwitches[vS]['name']) vhttpResult += '\", \"' vhttpResult += str(dictSwitches[vS]['protocol']) vhttpResult += '\", ' vhttpResult += str(dictSwitches[vS]['id']) vhttpResult += ', ' if dictSwitches[vS]['unit'] is not None: vhttpResult += str(dictSwitches[vS]['unit']) else: vhttpResult += '\"' vhttpResult += str(dictSwitches[vS]['unit']) vhttpResult += '\"' vhttpResult += ', \"' vhttpResult += str(dictSwitches[vS]['group']) vhttpResult += '\", \"' vhttpResult += str(dictSwitches[vS]['switchgroup']) vhttpResult += '\", ' vhttpResult += str(dictSwitches[vS]['alarm']) vhttpResult += ', ' vhttpResult += str(dictSwitches[vS]['slideshow']) vhttpResult += ', ' vhttpResult += str(dictSwitches[vS]['OnAndOff']) vhttpResult += ');\n' vCSVResult += str(vS) vCSVResult += ';' vCSVResult += str(dictSwitches[vS]['switch']) vCSVResult += ';0;\n' vhttpResult += '\n' # vhttpResult += '?>\n' #print vhttpResult threadCreateFile('/var/sensorTool/www/conf.php', vhttpResult) threadCreateFile('/var/sensorTool/www/switchstate.csv', vCSVResult, 'csv')
or modules_radiators == False or boolTriggerOutdoor == False) and RadiatorStarted: dictActors[dictSensors[iControlSensor].GetFritzActor()].SetActor( False) #LedR.off() #LedY.off() RadiatorStarted = False # sendWhatsApps(dictSensors[iControlSensor].GetMobiles(), getInfoText("Stopped")) sH_Log.Add('Radiator deactivated') if vVerbose.startswith('test'): #print getInfoText("Status") print '##### - #####' #threadCreateFile('/var/sensorTool/www/sensor.php', getHTML()) threadCreateFile('/var/sensorTool/www/sensor.csv', getCSVSensor(), 'csv') threadCreateFile('/var/sensorTool/www/module.csv', getCSVModules(), 'csv') threadCreateFile('/var/sensorTool/www/fa.csv', getCSVfa(), 'csv') strAlarm = 'False' if boolLeuchte: strAlarm = 'True' #thread.start_new_thread(threadRequestAlarm, ()) if vVerbose.startswith('test'): print 'Alarm triggered' threadCreateFile('/var/sensorTool/www/alarm.csv', strAlarm, 'csv') # thread.start_new_thread(threadCreatePHPFile, ('/var/sensorTool/www/sensor.php', getHTML(),)) if time.time() > refreshTime_Diag: plotting_DeviceValues(dictActiveModules, '1_Modules', vVerbose)