Following up on the previous post about pulling sensor data from sensors in a Verisure alarm system, here is a slightly more hardware focused post.
One use case that the new Verisure alarm system does not handle nicely is machine-to-machine notification when the alarm is disarmed (turned off). Such notifications are sent to the mobile app – so the data exists somewhere. The problem is that it’s all undocumented and thus hard to build something on top of.
Let’s hack a solution instead – be aware, some soldering required….
Existing setup – Telldus and MQTT
I already have a well functioning Telldus based system (they are great by the way – been running rock solid for years) and did not want to invest in additional remote controlled power outlets from Verisure. That would mean throwing all the existing devices away – not an option.
I also have most of the Telldus devices hooked into a MQTT broker, which means that lights can be turned on/off by simply sending MQTT messages. Same things for sensors – all sensor readings are sent as MQTT messages that can be picked up by any system or software that need that data.
Easy, elegant and stable.
The idea is thus to somehow send a MQTT message when the alarm system is turned off.
A remote control sandwich
Other hackers/makers/smart people have solved this particular challenge in an interesting way. They have cracked open a Verisure smart plug and then soldered wires into the appropriate places on the PCBs inside. This works, but means dealing with the inside of 220V devices, and makes the smart plug useless for anything else.
As I am only interested in a single MQTT message being sent (rather than dealing with Z-Wave signals) when the alarm is turned off, and another message when the alarm is turned on, I found an easier solution.
Program a small ESP8266 based micro controller(these cost just a few Euros each) to
- Connect to a wifi network when power is applied, and then
- send a single MQTT message, saying something like “alarm system turned off” (assuming that the smart plug is turned ON when the alarm system is turned OFF. More on that later.
Good. But what about the other scenario, when the alarm is turned ON? That would result in the smart plug being turned off, and the ESP8266 loosing power. No MQTT messages sent then, obviously.
The MQTT broker (there are different ones, Mosquitto is really good though) has something called “Last Will and Testament”, a.k.a. LWT.
When the broker lose contact with a client, the broker can be configured to send a LWT message after a certain timeout (usually 15 seconds). We can use this to send a MQTT message along the lines of “alarm system turned on”.
The device stack (smart plug – USB power adapter – ESP8266 box) looks like this:
Based on the above, at most there will be a 15 second delay before the “alarm is on” MQTT message (it’s really the LWT message) is sent, but that’s fine.
On the other hand, the ESP8266 only needs 2-3 seconds to connect to the wifi network and send the “alarm system off” MQTT message, and that is very acceptable when it comes to turning on lights when arriving home etc.
Links & references
Source code and additional information is available on GitHub.
The project was built using PlatformIO, which is an extremely nice Visual Studio Code based IDE for embedded development.
As so often is the case, once you find that easy elegant solution its implementation is pretty quick and painless. In this case a few cables had to be soldered, some hot gluing was needed but that’s about it. Pretty neat, and the setup works really well.