Window Open / Closed Contact Sensors

One thing I sometimes wish I’d hard-wired for before plastering the House is contact sensors to report the open / closed state of the (openable) windows – mostly so that the automations which close the roller blinds can be ‘blocked’ if a window is open. The sensors could also provide a useful confirmation that the building is secure when nobody is home. (There are already sensors as part of the intruder alarm system, but those respond to ‘shock’ impact from any attempt to force open windows or doors and do not report open / closed status.)

The workaround is to fall back to battery-powered radio-connected sensors. While I’m not generally a fan of battery-powered devices, they’re OK for non-critical uses like this – especially when they provide accurate reporting of battery status so battery failure can be predicted (or at least reported).

From a brief trial of one IKEA MYGGBETT door / windows sensor I’m happy those will work well enough to invest in a few more of them:

  • They are powered by a single AAA battery and specifically recommend rechargeable batteries (such as the IKEA LADDA)
  • They use Matter over Thread for communications and management and so integrate very nicely with Home Assistant – especially since I’ve got a working Matter over Thread ecosystem in both the Outbuildings and the House
  • They’re fairly compact – given they have to accommodate a AAA battery
  • They’re competitively priced; £7 each in 2026 (although that seems slightly expensive compared to £5 for a TIMMERFLOTTE temperature & humidity sensor) – whereas similar devices from other brands tend to be £20 or more
    • That price does not include the battery, which is another £1 (actually £4 for a pack of 4)
  • They report battery status both as a voltage and as “percent charged” figure (to the nearest 1%)

On the tilt-and-turn windows it’s best to mount the sensors at the top, so they report ‘open’ no matter whether the window is tilted back or hinged open (like a door).

IKEA MYGGBETT door and window sensor mounted at the top of a tilt-and-turn window

These MYGGBETT sensors have a unique Matter ID printed along one side and I elected to mount them so that remains visible. There’s also a printed QR code used for commissioning but that’s only visible when the sensor is unclipped from its backplate.

If I was doing this again, I would at least install the wiring for hard-wired sensors – which would mean checking which windows have opening sections (about half of them) and whereabouts on the opening windows the sensor would be located. I would wire them with 4-core ‘alarm’ cable back to a central point, with the plan to connect them to a KNX binary input module – something like the MDT BE-16000.02 Binary Input Module for Potential-Free Contacts. Note that costs £200 for 16 channels, i.e. £12.50 per input. In addition, there would be the cost of the cable (roughly £1 for a 5m run) and the magnetic / reed-switch sensor itself (about £2 each for a basic ‘Grade 1’ sensor) which works out at about £16 per window (assuming a 7.5m cable run) so actually the battery-powered sensors are roughly half the price – but need ongoing attention to their batteries. (Arguably a proportion of the cost of the Thread Border Router required to receive the Matter over Thread signals should be included in the cost of the battery-powered sensors, but that was only £35 and covers all other Matter over Thread devices too.)

Home Assistant Hosting; Raspberry Pi 4; SD Card Failure

When I first started to properly explore Home Assistant with a view to moving to that, from openHAB, as the Home Automation ‘hub’, I wasn’t certain things would work out so I decided to host it on a Raspberry Pi 4 that I could re-purpose if required. I was aware the lifetime of the Pi’s Micro SD card storage would be limited, having had issues with SD cards wearing out when hosting databases previously, but I left that as a problem for my future self.

About 15 months later it looks like the SD card has worn out. While Home Assistant’s control functionality is still working, Backups are failing and History data and graphs are missing. There are errors in Settings > System > Log like: Unrecoverable sqlite3 database corruption detected: (sqlite3.DatabaseError) database disk image is malformed

Now I’m settled on using Home Assistant, one option would be to host it on a more robust platform. (For example, I used to run openHAB in a Docker Container on an HP MicroServer.) For now though, I’m going to keep it on the Raspberry Pi 4 – albeit with a couple of improvements to the storage set-up:

  • I’m going to use a SanDisk “High Endurance” Micro SD card in the hope that will last longer
  • I’m going to use an External Data Disk – a separate USB 3.0 Flash Drive – to move the write-heavy transactions onto that other drive, which should cope a bit better (and possibly perform better too)
    • A proper USB-connected SSD would be ideal but would need more power which could be an issue for the PoE-powered Pi 4 – and I’d prefer to keep using PoE so the power comes via the UPS

I downloaded the last successful automated backup. I did try Restoring to that but it didn’t work, tending to confirm the theory of the SD card being the issue.

Installing HAOS on the new SD card then booting with that and importing the good backup when first prompted with the option to do that worked fine.

We’ll see how long the new SD-card-and-USB-storage combination lasts this time. I do like the principle of running Home Assistant on a standalone machine – and I like the built-in “App” feature that comes with that – so as long as it lasts for a few years I’ll probably stick with the standalone configuration.