No problem… let me go back a little bit and explain how I’ve integrated them with ST before. I had two devices that I wanted to integrate into ST – a water sensor in my water closet (I have a pressure tank, water heater, etc in a closet) and my existing hard-wired alarm system. Not so much the alarm, just the contact sensors.
To preface, I do realize there are sensors for the water closet but I was cheap at the time and it worked for the time I needed it. I later switched it out to a Z-wave sensor. Initially I was going to modify contact sensors for the alarm system but realized quickly to get 14 zones was going to be very expensive. At the present, I only have one Z-wave contact sensor in place.
So to make all of this work I had to setup an MQTT broker on a linux box that served as the communication bridge between my devices and ST. This broker would accept messages from the ESP devices and then relay it to ST and vice-versa. ST would have the broker registered as a device and communicate with it locally on the network.
I started out with the water closet sensor. This was intended to be a simple, single I/O headless device. To accomplish this I used an ESP-01 with 512Kbit of flash. I removed the NodeMCU firmware and flashed the Arduino firmware to it. It was fairly simple code that ran a simple web server (for debugging and stats) and an MQTT client that pointed to the broker over WiFi. When the sensor contact was closed, it would send a ‘1’ to the MQTT broker at a specific address, ‘0’ if it was open (default state). The sensor was connected to one of the I/O input pins across a modified soil moisture sensor. I ground down the bottom ‘points’ of the sensor so it met the concrete flat and would detect a small puddle about 3/4" in width. This was all put into a small project case and mounted on the wall with a power LED and a wall wart for power. Because of the small amount of flash on the ESP-01, OTA programming was not available so I had a few jumpers to put it into programming mode for reflashing.
The alarm system was originally a DSC 8-zone system that I completely tore out. I rewired the zones to create 14 zones for additional detail (splitting windows vs doors, for instance) in each room. Three ESP-12E boards with 4Mbit each were used with each having its own set of code based on the inputs/outputs of that particular board. The software was similar to the water sensor in that each was reflashed with Arduino and ran a web server, MQTT client and WiFi client. Because of the additional flash, these boards allowed OTA programming directly from the Arduino software which was great when updating code. One of the boards had an output programmed and would listen for MQTT messages for an external powered siren I have in the attic. When triggered, it would turn on the output which would trip a relay board and 12v would be applied to the siren. This was a bit finicky because of how the 12E handled its outputs during reboots and needed some massaging to work smoothly. The whole unit was powered by a 12V supply and then a 3.3v/5v regulator board was used to power the ESPs and relay board. Each alarm contact was tied to one of the I/O pins on one of the three boards and mapped to ST accordingly through MQTT.
All in all the system worked alright for the most part. Some logic was put in place to reboot the ESPs when WiFi was lost or the MQTT broker disconnected. Additional logic was put in place for debouncing, ST errors and stale sensors but ultimately it was never really a clean solution. One of the biggest problems is that the ESP is a single-threaded finicky beast. For instance, if you’re running a lightweight HTTP server on it and make a request, it will pause the entire CPU while it produces the output for the connection. Fine for monitoring a plant or watering your hermit crab tank but not good when you need near real-time sensor monitoring.
Now that I’ve mentioned where I’ve been… with your info, here is where I’d like to go…
Through the first setup I learned that combining all of the contact sensors on two or three boards was a bad idea. These little boards just work better when given a single task. The water closet sensor was this way and quite frankly, I never had to touch it. While it will take additional IPs on the network, I’m going to use ESP-01s because a) they’re cheap at $1-2 each and b) they work great for single sensor usage and put one on each contact sensor. This will result in 14 ESP-01s in the closet and that should cover all of the zone inputs. While this seems like a lot of sensors, it should get around ST’s lack of one-to-many sensor support as well. The siren output is being covered by existing Z-wave sirens that are now installed.
Some of this is still tumbling around in my head until I get things out and play around again… but hopefully it clears up some of my madness