def crux(*args): if not isDoorWindowOrMotion(args[2]): return 1 if args[1] != 'control': return 1 ChimeOnActivity() return 0
def crux(*args): if not isDoorWindowOrMotion(args[2]): return 1 if args[1] != 'control': return 1 current = getNotificationFromNodeById(args[2], args[3], args[1]) previous = getNotificationFromNodeById(args[2], args[4], args[1]) EmailAlertAlways(args[2], current, previous) return 0
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) sendEmail(mailto, subject, getNodeReport(node))
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: subject = name + " has been open for " + convert_timedelta_str(delta)