DEV Community

Cover image for How to build an office alarm system with Home IoT devices
Oliver Thamm
Oliver Thamm

Posted on

How to build an office alarm system with Home IoT devices

Building a security system with alarm and notifications using Home IoT hardware

Office security is a 100 billion dollar business. Trustworthy products and service providers come with a steep price tag. Specialised cloud-based solution providers come with the potential threat of misusing or selling your office’s IoT sensor data. Data privacy raises major concerns, since every supplier with access to data gets a full view of an office schedule—how employees behave and when the office is empty.

Hiring a security service company offers a good alternative to this. The security company could install a closed IIoT system within your company WiFi. But such services are very expensive.

A less pricey option is to use consumer market Home IoT devices and install it yourself. In this blog post, we show you how to make your own security system with just a bit of time and hacker spirit. Save a lot of money and no trust into an external security service company is required. We will show how to set up a text notification, play an alarm sound and change the color of a light to red when a motion sensor detects movement after 8pm.

iiot office alarm system

Setting up the Home IoT motion sensor with lights

In Home IoT applications, motions sensors are often used to switch lights on only when they register movement within their range. In the right room this saves energy and money. The motion sensors keep associated lights switched off and switch them on only for a configurable timespan when they detect movement. If there is further movement around the sensor, the devices will remain switched on.

Home applications for this type of setup are often found in garages or driveways. Rooms in which people sit and stay usually don’t benefit. Also, pets can create unwanted side effects when they trigger motion sensors. In a small office, usage patterns are different to a private home. In an office before and after a workday, movement should trigger an alarm. Plus, it’s the kind of thing an office manager would like to know about.

For this post, we use the motion sensors of a global swedish furniture chain. Follow the basic setup as described by the vendor and our initial post. Screw open the back of the motion sensor device so you can see three buttons and put in batteries. Pair the motion sensor first with your hub device and then with the lights.

Go into the manufacturer's mobile app and test your setup. Use the app to name your light, e.g “room-a”.

Creating a service to report events and trigger an alarm

To access and react to events sent by the motion sensor, find out the device’s communication protocol. If the device communicates using keep-alive connections, e.g. CoaP or MQTT, then observe it’s messages. Otherwise frequently request, or poll, the device’s state.

The hardware we use works best when it does not directly observe the motion sensor but observes the associated light instead. That too is handled by drivers in IIoT Server. In Xapix IIoT Server drivers for this are included and you only need to configure the devices in the file ./config/devices.yml. Additionally configure your speaker and put your desired alarm audio file, e.g. “alarm.wav”, into a new folder ./tmp/iiot_office/media/.

      model_class: TradfriHub
      mac: XX:XX:XX:XX:XX:XX
          model_class: TradfriLedColorBulb
          name: room-a
      model_class: Audio
      installation_name: iiot_office
Enter fullscreen mode Exit fullscreen mode

One option to trigger alarms and send text notifications is to create your own local web server application. The web application needs to have an HTTP POST endpoint accepting JSON formatted data. In the code for the endpoint,put the decision logic for the alarm and notifications. Enter the endpoint’s URL as an environment variable named EVENT_WEBHOOK_URL for IIoT server.

A second option is to use our free Xapix Community Edition and it’s web UI to trigger data pipelines which change the light color, play an alarm sound and send text notifications.

If interested, then > CONTINUE READING < the full version of this article on our Xapix blog.

Join our Home IoT community

We are working on follow-ups to this blog series to inspire you with new ideas about how to use the Xapix IIoT Server once you have set it up. We would love to hear your ideas and collaborate!

Contact me on Twitter if you would like to discuss this tutorial or if you have questions or feedback about the Xapix Community Edition. We look forward to hearing from you!

Top comments (1)

siffon404 profile image

Well, DIY stuff is a great way to spend time on. But I don't think they are as reliable as professional systems. I used to have an old-fashioned DIY home security system. But I did not work properly. Sometimes the alarm started to ring at night without any reason. After I installed an Ajax system, I forgot about all those issues. I hope you won't think badly of me. I am just sharing my thoughts and experience. I believe that is more reasonable to spend a little more money and acquire a qualitative security system.