Mains powered Zigbee sensor for door contact (reed relay)

When installing a new back door recently I took the step of integrating a reed relay switch into the frame to act as an hidden door open/closed switch for HA, the wiring running behind the frame and up into the loft space above.

At the time I knew I wanted the sensor to be mains powered (I go through enough batteries already on other sensors) and I wanted it to use Zigbee for communication . I didn’t really research what off the shelf sensor I might use, perhaps naively I just assumed there would be plenty of options to chose from. It turns out this is not the case and after finding an old post here from someone else asking the same question I opted for a Sonoff ZBMini, which was handy as I already had some on-hand.

A quick template to have the ZBMini report as door sensor instead of a light switch and everything seemed to work great.

Over time however I’ve discovered a fatal flaw with using the ZBMini for this use case - it can’t tell if it’s on or off without a load. By design the ZBMini merely detects a change in state of the connected switch, but doesn’t report the state itself. The reed relay switching is often not perfect, it can fluctuate as the door is opened and the ZBMini starts reporting that it’s ‘on’ (closed) when it’s actually ‘off’ (open). Essentially I can’t depend on the ZBMini to report the correct state of the door rendering it useless.

So are there any other options? Only hard rules are that it must be mains powered and it must be zigbee. I have considered waiting (weeks, months?) for the new zigbee versions of ESP32 to become available and supported by ZHA but then I have the complications of power conversion in a small space (gamble on a tiny buck converter from Ali Express) and finding a suitable project box and making the whole thing look reasonable enough so that the first electrician who finds it on the lighting circuit doesn’t immediately rip it out and bin it as ‘unsafe’.

This is a bit ‘way out there’ however depending on how deep you want to go and your experience with SDK’s and C programming. I think I am correct on this. I ran across the Telink series of 825X mcu chips a bit back. I’ve not done what you are proposing, how I am pretty sure the Telink chip is what powers a number of the Sonoff zigbee products, and Telink publishes the source code for these devices as examples for how to work with their MCU’s. I am still learning the 825x SDK so I am real noob. You can buy a number of their raw chips and their hardware flasher/debugger for well under USD 50 to mess around with and then if I am correct either custom flash your device or build your own based on the common design. That said, there is some really great work being done by some amazing github folks to totally repurpose some of these Telink based devices. Have a look at links and pics below.

Another possible path which I’ve a little more experience is the great work by PTVO on creating zigbee devices with the TI CCx family (and clones) zigbee chips, less control of firmware here but easier to ‘get into’. link below.
Good hunting and much home automation success in 2024!

http://wiki.telink-semi.cn/wiki/chip-series/TLSR825x-Series/

https://drive.google.com/drive/folders/1NvPi_iiQZMSVH_H6IZW9hgsdTwBX8w_m?usp=sharing

https://ptvo.info/

Thanks, I’ll look into that option. It’s probably within my skill set at least on the code side, though I’m more of an amateur on the electronics side. Main issue right now is time, only have so much to give over to projects like this which is why given the option between an off the shelf device and rolling my own, I’d lean towards the former.

Even if you down the rabbit hole of the Telink zigbee chips, it might be a good learning experience for using a firmware flasher device and getting the device on your zigbee network to invest a small amount of your coin and your time in the PTVO firmware, very easy to setup a simple to fairly complex zigbee device with this firmware.

You can have a TI CC 2531 based device setup in under an hour with zero coding using the PTVO firmware and something like this USD 11 kit, link below. I can not speak for this specific seller, however the CC2531 programmers and chips are available from hundreds of sellers on ali express and other shopping sites. I would buy a couple CC 2531 (or clone) raw chips with various pinouts to give yourself some wiring, placement, antenna and power options. The raw chips are on the order of USD 2 or less.

Good hunting!

https://www.aliexpress.us/item/2255800253177633.html?

https://www.aliexpress.us/item/3256805388030744.html

https://www.aliexpress.us/item/2251832144443114.html

@stuartm1 did you find a solution? I’m looking for the same currently. Thanks for your answer!

I posted in link below about my recent experiment with the new ESP32-C6 chips using only the Arduino IDE to create Zigbee devices that are compatible with Zigbee2MQTT (and with a little more work ZHA). The M5Stack folks have some very nice hardware components, such as the USD 3.5 simple input switch that will plug into the Grove connector of their NanoC6 MCU. With these two components and a little work with modifying one of the programs from Espressif Zigbee examples in the Arduino IDE, you should be able to have a sub ten dollar input sensor in a nice form factor that you can drive with 5 volts and customize to your specs. Good hunting!

I never did find an off the shelf solution,that met my requirements or even a simple config solution to resolve the issues I had with using a Sonoff ZBMini. To be honest I’ve just been a bit too busy lately and I shelved it as a problem to resolve later. That’s not to say there aren’t any solutions just that anything I could think of either involved more time than I had to give (e.g. custom development/firmware) or were just too hacky for my taste*.

  • e.g. scripting a ‘debounce’ for the zbmini and adding a power wasting electrical load so that it wouldn’t get confused about the state.