For those who have read the Immersion Heater control page, there were times in that project where I just had to wait – I could not test the economy 7 heading except by observing the results in the morning;  so with time on my hands, and looking for things to do in home automation, I looked at my old alarm system.

Opening the alarm panel revealed an alarm controller from 1986; there was some lightening damage (torched/exploded capacitors on the 12V output circuit), but on power up, there was still power.

I investigated the cabling, and got a basic understanding of how the wiring was arranged, but had no LEDs on and of the PIRs.  Turns out, I severed the cables when re-laying the bathroom floor years ago!.

The cables ran across the floor of the upstairs landing, under the carpet, so having located the point they were cut, I found I could re-lay them to almost reach the new wifi immersion heater controller.  The ESP8266 running the immersion heater controller had 4 I/O pins spare, and there were 3 PIR sensors in the house.

Issue 1. The PIRs need 12v; I only had 5 and 3.3 at the controller, so I re-wired the controller to include a 12v to 5v dc-dc convertor, and used a 12v power brick as the psu.  Issue 1 overcome.

Issue 2.  The controller was running relatively vanilla Arendst firmware.  I love this firmware for it’s OTA upgrade implementation, MQTT support, wemo emulation (for Alexa control), and it seems very stable.  I’m all for standing on the shoulders of giants these days – nothing under the sun has not been done, so just use it….  Except; the firmware had no ability to define generic inputs to send over MQTT.  So after a lot of playing, trying to use the ‘buttons’ feature, and finding that in order to do so, my modifications were becoming quite invasive on the original source code, I implemented a ‘new’ feature called ‘INPUT_PINS’.  This new feature allows for a number of input pins to be defined, and sends changes over MQTT on the topic stat/<topic>/INPUTn, and tele/<topic>/INPUTn.  Perfect.

Issue 3. I found that one of the PIRs had also suffered from the lightening damage; two diode short circuit, and probably a 78L08 down… so off to the shed to find a spare PIR (yes, I have quite a lot of old s**t lying around! -I found a wired PIR and also a wireless PIR.  The wireless one may be a subject for a future project to detect visitors at the door; since no-one seems to understand how to ring our doorbell!). Wired PIR tested and fitted….

Alarm PIR detectors generally need 12v for power, and have a dry contact relay for output (sometimes with a resistor in series – in my case ~4k), and a tamper connection pair (usually just a microswitch on the cover).  I wired 12v gnd plus one side of the dry contact output relay together, the 12v power to my new 12v supply, and the 3 wires from the other side of the dry contact relays to input pins on the ESP8266.

The with a very simple Node-Red flow, detected the MQTT messages, and set lights on the Node-Red GUI to indicate movement, with a configurable persistence time in Node-Red.  The final test was to wire the input to my light called ‘trevor’ to the output of the persisted state, and trevor now turns on when you walk into the room, staying on for at least 5 minutes!.

How useful this is in reality in MY house is a moot point, as the 2 large dogs trigger the PIRs rather well; but for the landing light it could work well.  Because of the way UK houses are wired for lighting circuits, I’ve not got a sparklingly good way of controlling light fittings yet, but because the landing light wiring is at least accessible via the loft (unlike the downstairs lights), I may put a sonoff in the loft above the landing light and add a couple of ESP8266 based switches – I’d been planning to make a couple of those anyway :).

One question for the audience: should the sonoff be in series with the current light switches, or in parallel.  If in series, then the light switch must be on for the sonoff to operate, and with two switches, understanding IF the sonoff is powered is difficult from a user perspective.  In parallel, both the switches and the sonoff would be able to turn the light on, but this then implies that an accessible and obvious isolation switch should be installed…. don’t fancy changing the bulb thinking the power is off, but actually it is on, and don’t want to leave people in the dark if the system is down… answers through the contact form?