Sharing enlightening moments of home automation

Smarter Swimming Pool 7: Pool Gate

It’s time for an update on the endeavour to make my swimming pool smarter. After we partially refurbished our pool fence last year I thought it would be great to add a door sensor to the gate to notify myself when someone left the gate open for too long.

You can find similar functionality on some gate latches, and all the ones I have seen are battery powered and sound an audible alarm, i.e. someone needs to be nearby to hear the alarm sound.

Generally the pool fence and gate have of course been installed according to our local requirements, and so the physical barriers to prevent small children from entering the pool area without supervision are all there. My main remaining concern now is human error or some unexpected mechanical problem, for example if someone accidentally left the pool gate open or the gate did not self-close for some reason.

Please note: Where I live, having a pool gate alarm is not mandatory, and so I am considering this DIY add-on as a nice-to-have feature. Adding a sensor to my pool gate will give me lots of options to alert myself.

The approach I have decided to go with is an ESP with a weatherproof reed switch (AliExpress affiliate link), running ESPHome and integrated into my existing Home Assistant system.

Mounting the sensor

The actual sensor that I installed on the door is a simple reed switch that comes with a strong magnet, and each part has 2 screw holes. I mounted the magnet with two metal screws on the aluminium gate, and the reed switch with timber screws onto the hardwood post.

Pool Gate Sensor

The reed switch itself is in a weatherproof metal enclosure with two thin wires sticking out, and of normally closed type. I soldered a twin core cable onto those wires as an extension and used wire braid and heat shrink tubing to protect the cable from the reed switch into the conduit that leads to the ESP.

Pool Gate Cabling

Connecting the sensor

The ESP is located in a weatherproof electrical box near the pool gate. In the picture below the cable from the reed switch is coming in from the left, and 12V DC power is coming in from the right.

ESP in Weatherproof Box

ESP schematics

The schematics for the ESP are fairly simple: One end of the reed switch is connected to 3.3V on the ESP and the other end to pin 25. And then I added a 10kΩ pull-down resistor between pin 25 and ground.

Pool Gate Schematics

I know that most pins have a built-in pull-down resistor, but I have had mixed experiences with those, and so I usually add an external pull-down resistor to these kinds of circuits.

I left out the power supply bit in the diagram: For this ESP device I have 12V DC available nearby which I run into the weatherproof box and then use a simple DC-DC converter that outputs 5V DC which I directly connect to the corresponding pin on the ESP.

ESPHome configuration

The ESPHome code is very simple and the reed switch is configured as a binary sensor with a special device class. The relevant sensor configurations looks like this:

  # Pool Gate
  - platform: gpio
      number: GPIO25
      inverted: True
    name: "Pool Gate"
    device_class: door

Home Assistant entity

Unsurprisingly the above ESPHome configuration does exactly what you would expect and after successfully adding the new device to Home Assistant and new entity is ready that represents the open/closed state of the pool gate.

Pool Gate Entity

A simple automation that I added as a starting point is sending me a notification when the pool gate is open for more than 30 seconds.


Adding the pool gate as a simple door entity to Home Assistant is a first step to then add more automations or additional functionality. Some ideas I am considering are:

  • Some commercial pool gate alarm systems immediately sound an alarm whenever the door has been opened for a few seconds, but come with a bypass that an adult would press to prevent the alarm. I guess the idea here is that a small child may have somehow managed to open the pool gate. In our case the latch is mounted very high (150cm above ground), so I am not sure if this alarm approach would be beneficial.
  • Commcercial pool gate alarms always come with some sort of siren. This could be a simple add-on to the ESP device where even the automation could run inside ESPHome itself. The advantage of an audible alarm is of course that anyone around the pool would hear the alarm.
At the time of writing this post, I used:
* Home Assistant 2023.12.2 with Python 3.11.6
* ESPHome v2023.10.6

Smarter Swimming Pool Series

  1. Pool Pump
  2. Water Temperature
  3. Water Level
  4. Liquid Chlorine Level
  5. Improvements Under the Surface
  6. Chlorinator Refurbishment
  7. Pool Gate


Leave a Reply

Your email address will not be published. Required fields are marked *