I’m a fearful person. Much of my life is spent building and maintaining stable systems that need to satisfy a high standard of reliability, and fear helps me make good decisions for that. Sure, it can hold you back a lot in life if you let the fear dictate behavior, but if you interpret it as a signal, it can be incredibly useful.
It took me an embarrassingly long time to harness fear as a power, a signal for things not being right. This only helps with rational fear, though.
Naturally, I’m affected by low-signal, irrational fear as well. This post is about dealing with it using technology.
The fear of leaving the apartment door open when I leave🔗
This is a classic irrational fear, because I’ve never in my life left the threshold between (semi-)public spaces and my private space in an unintentional state. 99.9% of the time reliably shut, temporarily left open in the 0.1% of other cases.
Still, I found myself more often than not turning around one flight of stairs away from home, just to check if the door is shut, which I closed with full intent and self awareness half a minute ago. Just annoying, yet also a minor stressor. When I force myself not to turn around to check the door, I’ll have to deal with doubts for a bit.
Automation is all about accelerating the consolidation of wealth in the ruling class getting the annoying stuff out of the way to focus on the once-in-a-lifetime experience of being alive - no time for that when you’re dead. Let’s harness it to defeat fear.
The answer is a simple door sensor. They typically consist of two parts: A magnet, and a main unit. The main unit contains a hall sensor, which detects changes in magnetic fields. If the magnet moves relative to the sensor, the magnetic field changes, and the sensor sends an impulse to the controller, waking it up. The controller then lets something else know that the door state changed.
Choice of hardware🔗
I went with a Shelly BLU door/window sensor, which promises a battery life of up to 5 years and broadcasts the door/window state using BLE and BTHome. Not sponsored, but I personally like the brand, because I only ever made positive experiences with their products that are designed to be local-first, are fully functional without cloud, and are developed in Europe.
It can do Zigbee too, which would probably be more power-friendly, but I don’t have a Zigbee coordinator yet, and already had Bluetooth proxies connected to Home Assistant all over the apartment for full coverage.
To be honest, I didn’t really research alternatives, because it was an impulse purchase before identifying a use case, so I don’t know if there are better/cheaper options out there. It checked all the boxes, though, and I have no regrets.
Software integration🔗
If you haven’t added any Bluetooth stuff to Home Assistant yet, you might need to do some preparation. Assuming your Home Assistant hardware has Bluetooth and is in range of the sensor, no extra work is required. In case of missing Bluetooth or lack of range, Bluetooth proxies can be used.
With ESPHome, it’s trivial to extend existing devices with Bluetooth capabilities to additionally serve as proxies with a single line of configuration:
bluetooth_proxy:Sadly, the ESP8266 (which runs most of my environmental sensors) has not Bluetooth, but I still had plenty of ESP32 gadgets around the apartment to achieve full coverage.
When the door sensor starts operating in range, it will show up in Home Assistant’s Devices & Services section as new BTHome devices that can be added with one click. In the case of the Shelly version I got, this will expose entities for open/closed state, rotation (for tilting windows/doors) and light level.
Addressing the fear part🔗
Cool, now Home Assistant knows when my apartment door opens and closes. To help me avoid turn around to check the door, I now have a widget on my phone’s home screen (plus a badge on a Home Assistant dashboard) that shows me the door state.
It took me a while to actually trust it, and my confidence is increasing every day.
To go with it, I also added an automation that sends door events to my watch for some tactile feedback.
The fear of accidentally leaving the balcony door open over night or when I’m traveling🔗
This fear goes into the category of “irrational, except it actually happened once”. One night, I forgot to close the living room balcony door in chilly weather, causing the death of one house plant. Couldn’t decide whether I’m more upset due to the death or my failure to perform a basic task, but in my defense: I was tired af.
This happened only once, and never again thus far, but the fear of a recurrence hasn’t left me alone.
You guessed it by now - the answer is door sensors, on all the things I’m liable to accidentally leave open over night. I went with a different user experience to fight this fear, though.
Consolidating sensor state🔗
Helpers in the Devices & Services section of Home Assistant are a less-known, but incredibly useful feature that allows you to create “virtual” entities based on others.
The most flexible one is probably the template helper, which allows defining the resulting entity’s state as a Jinja2 template. What I need is:
- A door entity, which is a binary sensor.
- It should be closed when all constituent doors are closed.
- It should be open when any of the constituent doors is open.
This is where a funny regional quirk comes into play: In Austria and nearby countries (German-speaking ones in particular), windows and window-style balcony doors primarily swing open, but typically also come with tilt functionality, allowing partial opening so there is an open gap on top, but the window/door is closed at the bottom. During hot summer periods, this feature is really useful to cool down the apartment over night.
When tilting the window, the sensor’s magnet is moved away from the main unit, so it would be considered open, but a tilted window/door should be considered closed for purposes of alerting. Luckily, the Shelly hardware that also measures the tilt angle, so I can take that into account in my template helper entity.
Right now, I’m monitoring 3 doors, so the template for the entity looks like this:
{{
(
(states.binary_sensor.apartment_door_window.state == "on" and states.sensor.apartment_door_rotation.state|float < 2.0) or
(states.binary_sensor.office_balcony_door_window.state == "on" and states.sensor.office_balcony_door_rotation.state|float < 2.0) or
(states.binary_sensor.living_room_balcony_door_window.state == "on" and states.sensor.living_room_balcony_door_rotation.state|float < 2.0)
)
}}The rotation angle sometimes misreports non-zero values on completely closed doors, so I set an experimentally determined threshold of 2.0 to define “closed-ness”.
Alerting myself to doors accidentally left open🔗
I less commonly question my sanity when going outside, so I simply added a badge for the consolidated entity to my primary Home Assistant dashboard.
More commonly, I doubt myself when I’m tired and going to sleep. Luckily, I already had an ESP32 with a couple of environmental sensors on my bedside table to control a humidifier and monitor CO2.
In all the years it has been sitting there, I never bothered making it a proper circuit board or at least an enclosure, which is now an advantage, because I can easily add new stuff, like a bright red LED.
The controller runs ESPHome, so making the LED a switchable entity in Home Assistant only took a few lines of configuration:
switch:
- platform: gpio
pin: GPIO25
id: alert_led_output
name: "Alert LED"With all these pieces in play, the only missing link was an automation that changes the state of the LED to the state of the consolidated entity whenever the consolidated entity’s state changes. Now, when I go to bed while any of the windows/doors is still open in a non-tilted state, I won’t miss the fact, kinda like this:
Any fears left?🔗
Plenty.
It’s still relieving to have two out of the way. Three actually: I also installed a smoke detector, but there isn’t really anything interesting to say about that.