X10 Home Security DIY - Control
So we want a system that we can control from all devices - computers, tablets, and smartphones (iOS and Android). Generally, this would imply developing apps for each platform, but there is one application that works on all these devices - an internet browser.
This means that if we develop the functionality to work on a server, and develop a set of mobile-friendly pages, then we can develop the control mechanism once, but access it from all devices using the browser - this is definitely the way to go for a DIY project.
From previous development efforts, I've found that the Abyss web server from Aprelium is a very flexible and easy-to-install server. With a bit of HTML, Javascript, and CSS development knowledge it is remarkable how easy it is to develop websites.
The other key piece is the same mochad daemon that we use to catch X10 RF commands. This function came with a set of scripts that have the ability to send out X10 powerline commands, so we can use it to control X10 devices by calling the commands directly from HTML buttons.
Control Flowchart

any LAN client --> LAN
--> Abyss web server on localhost:8080 -->
--> index.html Control Panel --> X10 powerline commands -->
--> mochad daemon running on port 1099 --> netcat TCP
--> X10 CM15A controller --> household wiring -->
--> X10 devices
At the same time, we can use the lifxlan-master scripts to send commands to LIFX bulbs on the LAN, and even send commands to IFTTT Maker channel to control other devices (like the Thermostat fan). We'll integrate an ARM/DISARM function into the control panel (and add a numeric keypad for an access code) in a later post.
Here is the control panel.
Here's the html file that implements the control panel
A few comments on the code:
The file uses a simple table with buttons to perform the control functions. A little bit of fancy styling is used to make the table and the buttons rounded, and perform some simple effects (like changing the cursor when it is over the buttons, and some simple animations to give the feedback that a button is clicked). Each of the buttons then calls a perl script (x10cmd.pl) with parameters indicating the command to be performed. The perl script then calls the system function for the button - e.g. lifxlan-master for the LIFX bulb, or the x10cmd shell script for the x10 commands, and so on.
The styling also makes the control panel usable from mobile devices (I tried to use very common-denominator styling so that it will work even from very old Android and iPhone phones). This has the added advantage of raising the WAF (Wife Approval Factor), as it will work from her fancy new mobile phone as well.
The perl scipt x10cmd.pl gives simple feedback that the command was executed in a basic html page. I plan to migrate all of this code, and the Abyss web server, to a standalone Linux PC so that it does not load down my desktop (although from what I have seen so far, it is hardly noticeable).
No comments:
Post a Comment