3 min read

Cross ventilation: a reminder to close the windows once the air has changed

Two sensors on opposite windows and one automation in Home Assistant remind you to close the windows after they have stood open together for a set time. The time is an example and you choose it.

Level
Beginner
Active time
30–60 minutes
Home Assistant required
Yes

You open a window on one side of the apartment and another on the opposite side. The draught changes the air much faster than a single window. Then you forget to close them and the rooms get cold. Here we make a notification that reminds you when the two windows have been open together long enough.

What you will get

A notification on the phone when both windows stay open together for a set time. The time is an example (8 minutes in the code) and you choose it according to your rooms.

The window sensors don’t measure air. The automation does not knowthat the air has really changed. It counts the time during which both windows are open. If you want a real measurement, you need a CO₂ sensor, which is not part of this project.

What you need

  • 2 pcs Sonoff SNZB-04PR1: a Zigbee 3.0 door and window sensor with a CR2477 battery. You put one on each of the two opposite windows.
  • A working Home Assistant and a phone with the Home Assistant app.

You need a Zigbee hub or Home Assistant with a Zigbee adapter.

The hub or adapter is not included in the product. Setup time: 30–60 minutes. Installation is sticking the two parts of the sensor on the sash and on the frame. No electrical installation is touched.

How it works

Each sensor has two parts: a body with the electronics and a small magnet. When the magnet moves away, the sensor reports “open”. In Home Assistant this is binary_sensor with the state on when the window is open.

The automation uses a template trigger. It fires when the expression “both windows are open” becomes true and stays true for the set time. If one of the windows closes earlier, the counting is interrupted.

Simeon adds a second rule by humidity: when it is 65% or more and the outdoor dew point is at least 1 °C lower, the automation suggests 8 minutes of cross ventilation, and after those 8 minutes it reminds him to close the windows. A phone notification lists the open windows.

Steps

  1. Pair the two sensors in Home Assistant. You expect two binary_sensor entities that change state when opened and closed.
  2. Give them recognisable names, for example “North window” and “South window”. Write down the entity IDs of both.
  3. In Settings → Automations & scenes → Create automation create an empty automation and from the three-dots menu choose Edit in YAML.
  4. Replace the entire content with the following example code. Change the two entity IDs, the time and the name of the notification (notify.mobile_app_your_phone is an example; the exact name is in Developer tools → Actions).
alias: Cross ventilation - reminder
description: A notification when both windows have been open together for 8 minutes
mode: single
triggers:
  - trigger: template
    value_template: >
      {{ is_state('binary_sensor.window_north', 'on')
         and is_state('binary_sensor.window_south', 'on') }}
    for: "00:08:00"
actions:
  - action: notify.mobile_app_your_phone
    data:
      title: Enough ventilation
      message: Both windows have been open for 8 minutes. Time to close them.

You expect the automation to save without an error. Close the windows to return it to its initial state.

Checking the result

  • Open only one window and wait more than 8 minutes: no notification comes.
  • Open both: the notification comes about 8 minutes after the second one is opened.
  • For a quick test temporarily change for to 20 seconds, check the notification and restore the value.
  • Restart Home Assistant with the windows open: after the restart the counting starts over. If a sensor is unavailable, the expression is not true and no notification comes.

If it doesn’t work

  • No notification comes, and the sensors are open → the name of the notify action is wrong → send a test message from Developer tools.
  • The notification comes immediately → in for remained 00:00:00 or the trigger is another type → check the YAML.
  • A sensor shows the opposite state → the magnet is stuck on the wrong side → move it relative to the body.
  • A sensor often becomes unavailable → weak Zigbee signal or weak battery → check the connection and replace the battery.

Limitations and switching off

  • The notification doesn’t close the windows and doesn’t know how much time is needed to change the air in your room. Choose the time by experience.
  • In winter cold or summer heat you may want a shorter time. This is a manual setting, not an automatic one.
  • The automation works only with a working Home Assistant and Zigbee network. The windows are closed by hand as usual.
  • To switch it off, disable the automation from its page.

Sources and verification status

Checked against the documentation on 22.11.2026.

Need a hand?

We can set up and install everything in this project. In some regions we install it ourselves — ask us.

Contact us

Related projects

Smart Door and Window Sensor Sonoff SNZB-04PR1 – Zigbee 3.0 Protocol, CR2477 Battery Powered, Real-Time Opening Alerts, eWeLink & Home Assistant

15,70 €
View parts

What you need

Added to cart

Real Home Automations

Sign in to your account

With a code sent to your email

Continue with Google
or

By continuing, you accept the Terms and Conditions and the Privacy Policy.