def doorbell_notification(event): global lastRing # yellow if (lastRing.isBefore(DT.now().minusSeconds(30))): # blue lastRing = DT.now() # yellow # send the doorbell notification logDebug("Demo1", "Doorbeell Alert") else: logDebug("Demo1", "Waiting ...")
def window_x_open(event): timerX = ir.getItem(event.itemName + "_Timer") # yellow if event.itemState == OPEN: # green events.sendCommand(timerX, ON) # blue logDebug("Demo6", "Set/Reset timer for " + event.itemName) else: if timerX.state == ON: # green events.postUpdate(timerX, OFF) # blue logDebug("Demo6", "Timer canceled for " + event.itemName)
def mainsEnergyMonitor(event): lastThreeWeeksUsage = float( str( PersistenceExtensions.sumSince( ir.getItem("HEM1_Total_Energy_Delta"), DateTime.now().minusDays(21)))) # blue yellow if lastThreeWeeksUsage > 200: # green logDebug( "Demo8", "Send alert - {} => {}".format(event.itemName, str(event.itemState)))
def front_door_motion(event): global lastEHallMotion, lastFDoorMotion # yellow lastFDoorMotion = ZDateTime.now() # yellow logDebug("Automation5", "Motion detected in the Front Door") if lastEHallMotion.isBefore(lastFDoorMotion.minusSeconds(10)): # blue logDebug("Automation5", "Discarding old Motion Detected in the Entrance Hall") return # blue if lastFDoorMotion.isAfter(lastDoorOpen) and lastDoorOpen.isAfter( lastEHallMotion): # purple logDebug("Automation5", "Leaving Home!")
def boiler_alert(event): global events, lastNotification # yellow logDebug("Demo4", "States: {}".format(events)) eventStr = str(items.BoilerAlarm) # yellow currCount = events[eventStr] # yellow events[eventStr] = currCount + 1 # yellow # //now.plusHours(1) - We don't ever need to cancel the Timer so we don't need to keep a handle on it # ScriptExecution.createTimer(DateTime.now().plusSeconds(5), lambda e=eventStr: update_counter(e)) Timer(5, lambda e=eventStr: update_counter(e)).start() # blue if events["FHS_FAILURE"] >= 3 and events["IS_FAILURE"] >= 1: # green if lastNotification.isBefore(ZDateTime.now().minusSeconds(5)): # blue lastNotification = ZDateTime.now() # yellow logDebug("Demo4", "Sending Boiler Alert Notification") else: logDebug("Demo4", "Waiting ...")
def start_timer(): # blue global timer # yellow timer = Timer( 5, lambda: logDebug("Automation2", "turning off the light ...")) # yellow timer.start() # blue
def update_counter(event): # yellow global events # yellow currCount = events[event] # yellow events[event] = currCount - 1 # yellow logDebug("Demo4", "Timeout - New State {}".format(events))
def front_door_opened(event): global lastDoorOpen # yellow lastDoorOpen = ZDateTime.now() # yellow logDebug("Automation5", "The Front Door was opened")
def timer_expired(event): # blue logDebug("Demo6", "Timer expired for " + event.itemName)
def bathroom_motion(event): if items.Bathroom_AmbientLight.intValue( ) <= 40 and items.Bathroom_Lamp == OFF: # green logDebug("Demo2", "Turning ON Bathroom Lamp") events.sendCommand("Bathroom_Lamp", "ON")