#!/usr/bin/env python import datetime from NotificationHandler import getEarliestNotificationOfCurrentState, getNodeReport from ConfUtils import getNodeName, getNodes, getMailto, isDoorWindowOrMotion from Utils import convert_timedelta_str from RobotUtils import sendEmail from LoggerUtils import setupCronbotLogger logger = setupCronbotLogger() mailto = getMailto() maxCloseTimeInSeconds = 28440 now = datetime.datetime.now() for node in getNodes(): if not isDoorWindowOrMotion(node): continue name = getNodeName(node) logger.info("Testing node: " + node + ":" + name) notification = getEarliestNotificationOfCurrentState(node, logger=logger) if not notification: logger.info("No notifications for node: " + name) elif (notification.value == 'False'): delta = now - notification.time logger.info(name + " has been closed for " + convert_timedelta_str(delta)) if delta.total_seconds() > maxCloseTimeInSeconds: subject = name + " has been closed for " + convert_timedelta_str( delta)
from LoggerUtils import setupSecurityLogger from NotificationHandler import getNCB,NodeControlBlock,getEarliestNotificationOfCurrentState from ConfUtils import getNodes,getNodeName from Utils import getTimeElapsed_HHMMSS import cgi, cgitb from controlpanel import getBaseUrl cgitb.enable() logger = setupSecurityLogger() print 'Content-Type: text/html' print # HTTP says you have to have a blank line between headers and content print '<html>' print ' <head>' print ' <title> Node Report </title>' print ' </head>' print ' <body>' print ' <h1> Node Report </h1>' for nodeId in getNodes(): ncb = getNCB(nodeId) notification = getEarliestNotificationOfCurrentState(nodeId) nodeName = getNodeName(nodeId) print '<h2>' + nodeName + '</h2>' if ncb: print '<h3>' + nodeName + ' has been ' + ncb.state + ' for ' + getTimeElapsed_HHMMSS(notification.time) + '</h3>' print '<p> Current State: ' + ncb.state + ' since ' + str(notification.time) + '</p>' print '<p> Battery Level: ' + str(ncb.batteryValue) + '</p>' print ' <button onClick="window.location=\'' + getBaseUrl() + '/raspwave/controlpanel.py\'" style="font: bold 60px Arial">Back to Control Panel</button><br><br>' print ' </body>' print '</html>'
#!/usr/bin/env python import datetime from NotificationHandler import getEarliestNotificationOfCurrentState, getNodeReport from ConfUtils import getNodeName, getNodes, getMailto, isDoorWindowOrMotion from Utils import convert_timedelta_str from RobotUtils import sendEmail from LoggerUtils import setupCronbotLogger logger = setupCronbotLogger() mailto = getMailto() maxOpenTimeInSeconds = 240 now = datetime.datetime.now() for node in getNodes(): if not isDoorWindowOrMotion(node): continue name = getNodeName(node) logger.info("Testing node: " + node + ":" + name) notification = getEarliestNotificationOfCurrentState(node, logger=logger) if not notification: logger.info("No notifications for node: " + name) elif notification.value == "False": delta = now - notification.time logger.info(name + " has been closed for " + convert_timedelta_str(delta)) elif notification.value == "True": delta = now - notification.time logger.info(name + " has been open for " + convert_timedelta_str(delta)) if delta.total_seconds() > maxOpenTimeInSeconds:
from Utils import getTimeElapsed_HHMMSS import cgi, cgitb from controlpanel import getBaseUrl cgitb.enable() logger = setupSecurityLogger() print 'Content-Type: text/html' print # HTTP says you have to have a blank line between headers and content print '<html>' print ' <head>' print ' <title> Node Report </title>' print ' </head>' print ' <body>' print ' <h1> Node Report </h1>' for nodeId in getNodes(): ncb = getNCB(nodeId) notification = getEarliestNotificationOfCurrentState(nodeId) nodeName = getNodeName(nodeId) print '<h2>' + nodeName + '</h2>' if ncb: print '<h3>' + nodeName + ' has been ' + ncb.state + ' for ' + getTimeElapsed_HHMMSS( notification.time) + '</h3>' print '<p> Current State: ' + ncb.state + ' since ' + str( notification.time) + '</p>' print '<p> Battery Level: ' + str(ncb.batteryValue) + '</p>' print ' <button onClick="window.location=\'' + getBaseUrl( ) + '/raspwave/controlpanel.py\'" style="font: bold 60px Arial">Back to Control Panel</button><br><br>' print ' </body>' print '</html>'