How to set up a local API for Home IoT Devices in your office using WiFi

Oliver Thamm

Small offices can profit from Home IoT devices made programmable with OSS

This article is part of a blog series where we explain how to save money, improve security and convenience in small offices using consumer-market Home IoT devices.

If you are working in an office with up to eight rooms, you may find yourself overlooked by commercial IoT solutions promising the typical benefits, e.g. energy savings, security improvements, disaster detection and other facility management improvements.

Luckily there are plenty of Home IoT product series on the market that you can use. Unfortunately, they are usually closed proprietary systems and don’t target specific office needs. At Xapix, we decided to open source our Industrial Internet of Things (IIoT) Server software that enables you to access common consumer-market Home IoT devices and develop custom office automation software against an HTTP API in your local office WiFi.
If you’d like an even simpler solution, you can enable the IIoT Server’s bridge to the free Xapix Community Edition and use the ready-made Xapix data pipelines. 

Get started with a Home IoT test environment

This post sets up the technical work for the rest of the series with just a little bit of hacker spirit. 

Most Home IoT device series are closed proprietary systems that often involve a gateway hub device and a vendor mobile app. We need a way to programmatically access the Home IoT devices, e.g. via an HTTP API, from within the local office WiFi as you do not want to expose it to the internet for security reasons.

Within this post, we explain how to set up a local API to a Home IoT light bulb on your development computer using our freshly released Open Source project IIoT Server and test your setup with a sample HTTP request via cURL or Postman.

If you have a Xapix Community Edition account, we can even take the test setup one step further and create a Xapix pipeline. You’ll be able to turn your light bulb on and off with your web browser or cURL.

We will describe the setup process for a Mac computer and a light bulb, hub device, and dimmer of a globally operating swedish furniture chain. Feel free to use other hardware - the setup process is likely to be similar and we’d be happy to help if you want to reach out to us directly, e.g on our Discord community channel.

Send HTTP API requests to your Home IoT devices within your local WiFi

Setting up the Home IoT devices as documented by the vendor is the first step. You can follow the instructions that the maker includes in the product. For our devices, we connect the hub device to the office router and power plug and then use the vendor mobile app to register the hub device with the app.

Put batteries into the dimmer and register it with the vendor mobile app by putting the dimmer close to the hub and pressing the hub’s link button. Your hub device now manages your dimmer.

To register your light bulb with the app, plug in your light bulb, hold the dimmer close to the bulb and press the dimmer’s link button. Your hub now manages the dimmer, the dimmer manages your light bulb and the vendor mobile app controls everything. With the app or dimmer you should be able to dim, turn on and turn off the light bulb. The app additionally will allow you to change light color.

To do the same with cURL, Postman or your favourite programming language’s HTTP library, go ahead and download and install the Xapix IIoT Server and it’s dependency software libraries. Follow the setup instructions and install the necessary libraries. 

One of the trickier steps is finding the IP address of your hub device within your local WiFi. You can best find it in your router’s administration UI. On a Mac you can also run `arp -a` in a terminal window and look for the IP address associated with your hub device’s MAC address to be found on the back of the device.

Once everything is configured, run the IIoT Server in a terminal window and next, to programmatically turn on your light bulb for the first time, run the cURL command:

Congratulations! You are now good to go ahead and develop your own custom applications for your local office’s IoT setup.

Getting ready to integrate cloud APIs and services with your Home IoT setup

If you are interested in some easy paths to advanced tasks, especially when using web APIs and services, then we recommend trying our free Xapix Community Edition that seamlessly integrates with the IIoT Server when enabled. With Xapix, you can start by creating a basic data pipeline to test your setup and from that point onward, integrations with different APIs for solving your use-cases, e.g. weather forecast APIs or text notification APIs, will only be a few clicks away.

To get started, Create a Xapix account if you haven’t already. Xapix works a little bit like the popular cloud service IFTTT, but is built for much more complex and custom data pipelines and can access many more types of data sources and APIs.

To test the connection between Xapix and your local instance of the Xapix IIoT Server, we will create a Xapix pipeline accessible from your local terminal via cURL, turning on or off your light bulb. To achieve that, enable the External Executor on your Xapix IIoT Server in line with the documentation provided.

In the Xapix Community Edition, set up an External Data Source as documented to resemble your local WiFi cURL command from above to look something like this:

Now you are ready to setup your first Xapix pipeline as shown in this video and described below:

First, let’s create a Xapix pipeline triggered by an HTTP endpoint `GET /bulb/{bulb_status}`. Next, on the pipeline dashboard, click on the Request unit and for “bulb_status” click “Set Data Sample”. Set it to “bulb_on” or “bulb_off” and click “Save”.

Now, on the pipeline dashboard, add your External Executor Data Source. Using drag and drop, connect the units Request -> External Executor -> Endpoint. Click on the External Executor unit and from the left input side drag “bulb_status” and drop it on the right side into the “cmd” parameter. The “device” parameter can be hardcoded to “test_bulb” for now. When adding more light bulbs and controllers you can always make changes later.

Back on the pipeline dashboard, click on the Endpoint unit. Unfold the response “body” section on the right side, drag the “status” on the left and drop it into a “new property” on the right side. Hardcode the HTTP response status on the bottom right to 200 for now and save.

To deploy your pipeline to the cloud press the “Publish” button. 

Finally, let’s test if the data flow between your cURL -> Xapix pipeline -> local IIoT Server -> your light bulb is working. To test this, copy and paste the cURL command below the “Publish” button and execute it in your terminal.

Join our Home IoT Community

We are working on numerous follow-ups to this blog-series and will be posting updates regularly within our Discord community to help inspire you on how best to make use of the Xapix IIoT Server once you have set it up. We would love to hear your ideas too and collaborate on this fun project. 

Please contact us on our Discord community channel if you would like to discuss this tutorial or if you have questions or feedback about the Xapix Community Edition. Or really anything else as well. We look forward to hearing from you!

About the author

Oliver is a senior software developer and an API and data transformation enthusiast. He’s a co-founder of Xapix, writer and conference speaker on all things API. Most recently, he’s bringing his perspective and experience to the world of Industrial IoT.

You can get in touch with Oliver via or find him on our Xapix Community Discord.