3 min read

The air conditioner in the rental apartment stops by itself when a window is open and starts when it’s closed

A window sensor and an automation in Home Assistant stop the AC when the window stays open, and bring it back when it closes, unless you or the guest stopped it.

Level
Intermediate
Active time
45–90 minutes
Home Assistant required
Yes

A guest turns on the AC and opens the balcony to air the room. The AC runs all day against an open window. The electricity bill is yours, and the room does not cool. A window sensor can stop the AC while it is open and bring it back after it closes.

What you will get

The AC switches off when the window has been open for more than a set time, and returns to its previous state when the window closes. If the guest or you have stopped it by hand during that time, the automation does not start it by itself. A notification tells you that the window was open.

What we need

  • 1 unit Sonoff SNZB-04PR1 for every window you want to track: Zigbee 3.0, CR2477 battery.
  • An AC that has already been added to Home Assistant as a climate entity. The AC is not part of the product.
  • A working Home Assistant and a phone with the Home Assistant app.

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

Time: 45–90 minutes. No electrical installation is touched and the AC is not changed.

How it works

The first trigger is “the window is open for N minutes” (at Simeon’s apartment it is 2 hours). The automation saves the AC’s state with scene.create, then switches it off. The second trigger is “the window is closed”. If the AC is off, it restores the saved state. If the guest has started it by hand, it does not interfere.

At Simeon’s apartment the air conditioners are Mitsubishi Electric units controlled through MELCloud Home (the cloud); Home Assistant shows the current temperature and the monthly consumption. A window or a terrace door that stays open for 2 hours stops the air conditioner of that room, and its old mode comes back when everything in the room has been closed for 1 minute.

Steps

  1. Fit the sensor on the sash and the frame of the window. Pair it. You expect binary_sensor, which is on when the window is open.
  2. Check that the AC is a climate entity and that the switch-off and switch-on commands work.
  3. The automation (the entity IDs are examples):
alias: AC - stop when a window is open
mode: restart
triggers:
  - trigger: state
    entity_id: binary_sensor.window_living
    to: "on"
    for: "02:00:00"
    id: open
  - trigger: state
    entity_id: binary_sensor.window_living
    to: "off"
    id: closed
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: open
          - condition: not
            conditions:
              - condition: state
                entity_id: climate.living_ac
                state: "off"
        sequence:
          - action: scene.create
            data:
              scene_id: ac_before_window
              snapshot_entities:
                - climate.living_ac
          - action: climate.turn_off
            target:
              entity_id: climate.living_ac
          - action: notify.mobile_app_your_phone
            data:
              message: The window is open. The AC has been stopped.
      - conditions:
          - condition: trigger
            id: closed
          - condition: state
            entity_id: climate.living_ac
            state: "off"
        sequence:
          - action: scene.turn_on
            target:
              entity_id: scene.ac_before_window
  1. Save and try it with a window, temporarily reducing for to 20 seconds.

Checking the result

  • Start the AC, open the window and wait: the AC stops and a notification arrives.
  • Close the window: the AC returns to the saved mode.
  • Stop the AC by hand while the window is closed, then open and close it: the AC must not start.

If it does not work

  • Nothing triggers → a different entity name → check the entity ID.
  • The AC returns in a different mode → scene.create has not saved everything → check the AC’s attributes.
  • It comes back when the guest switched it off → the state condition did not trigger → review the second block.

Limitations

  • If Home Assistant goes down while the AC is stopped, it stays stopped until you start it.
  • If you restart Home Assistant, the saved scene is lost (scene.create is temporary).
  • The automation does not know whether the AC was stopped by the automation or by the guest, except by its state after closing. Review the logic for your case.
  • Warn the guests in the check-in instructions that the AC stops when a window is open.

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.