Get an email after leaving the house if there are one or more windows open

+++ I use OH2 and have no idea if this is working in OH1 as well!

Hi guys,

I just setup a new simple rule to receive an email after leaving the house if there are one or more windows still open and which ones they are.


  • a working presence detection (there are multiple tutorials already available)
  • multiple window/door sensors of course
  • working and configured persistence (I use rrd4j)
  • configured “Mail Action” add-on

Item configuration:

Group:Contact:OR(OPEN,CLOSED) WindowSensors "Window Sensors [%s]"

Contact Window1 "Window1 [%s]" (WindowSensors) { channel="zwave:device:12345678:node1:sensor_door" }
Contact Window2 "Window2 [%s]" (WindowSensors) { channel="zwave:device:12345678:node2:sensor_door" }
Contact Window3 "Window3 [%s]" (WindowSensors) { channel="zwave:device:12345678:node3:sensor_door" }
Contact Window4 "Window4 [%s]" (WindowSensors) { channel="zwave:device:12345678:node4:sensor_door" }

Rule configuration: (how you check your presence is up to you)

rule "Window rule"
    Item Presence changed from ON to OFF
        if (WindowSensors.state == OPEN) {
            var String open_windows = "| "
            WindowSensors.members.forEach [ window |
                if (window.state == OPEN) {
                    open_windows = open_windows + + " | "
            sendMail("", "Window(s) still open! (" + open_windows + ")", "Window(s) still open: " + open_windows )

The email would look like this:

Subject: Window(s) still open! (| Window2 | Window4 | )

Window(s) still open: | Window2 | Window4 | 

I hope this comes in handy :slight_smile:



Nice! Here is a similar example that sets the Nest thermostat to “away” mode when doors or windows are opened.