LIFX wall mounted control and home automation

LED smart lights are great but normally you control them with an app on your phone. This can be a problem when you have guests staying or if you just don’t want to have to search for your phone in order to switch on a light. The solution, of course, is to have some form of physical light switch, possibly connected to a home automation system, or possibly a wirelessly enabled mechanical switch or a touchscreen.

There are a few home automation control panels with dashboard-like interfaces that exist but I wanted to build a custom one that could control my LIFX light bulbs, would be flexible enough to easily add other home automation functionality in the future, would run on low cost hardware, and that could be wall mounted. It would also be a chance to learn some new programming skills in the form of building a web application.

With that in mind I got a Raspberry Pi 3 with the new 7 inch touchscreen. For the app, I had already constructed a simple Python library that used the LIFX HTTP API to control the lights. I decided to learn Javascript and Node to build a server, and borrowed heavily from the Dashing.js project to get a quick dashboard front end. Modifying and updating the latter turned out to be more time consuming than expected and next time I would probably build a front end from scratch using something like Angular.

The complete code can be found here. The Node server follows the Dashing structure and adds clickable widgets for the switches. I also updated it for Express 4. The pylifx.py library contains the LIFX HTTP class and the lifxpyfunctions.py is the script that is called by the Node server whenever the lights are queried, toggled, or changed state. There are job files for the weather widgets and also one to set a vacation mode where the lights are automatically toggled on a timer.




Comments

  1. oh this is exactly the type of thing I want to do. I just don't know about the software side of something like this.

    ReplyDelete

Post a Comment

Popular posts from this blog

LEVMpy: a python wrapper for Fortran LEVM code