Although I like Control4’s touchscreens, the Android app, and Control4’s SR-250 remote, sometimes when I want to adjust my office lights or turn on / off the office ceiling fan, I’d rather do that with a simple command-line application.
Since I typically have a terminal window or two open, I can quickly type ‘lights 20’ or ‘fan off’, much faster than I can start up the Control4 Android App, or find my SR-250.
To that end, a while back I created a small Lua script that does just that.
A Zipped version is here: C4Light.lua (Zipped).
NOTE: I’ve only used this on Linux, but it should also work on Unix / OSX, and maybe even Windows, with Lua For Windows.
The script requires that you have Lua and LuaSocket installed. Google is a good resource for this for various situations.
To use the script, first you need to unzip the script, and put the C4Light.lua somewhere on the executable path. I’ve installed mine in /usr/local/bin/.
For convenience, in Linux / Unix you can execute the following lines to make symbolic links to the script, so you can just say ‘lights 20’, or ‘light 33’ or ‘fan on’, instead of C4Light.lua 20. The script uses the name it’s called with to determine whether to send commands to the fan or the light.
ln -s /usr/local/bin/C4Light.lua light
ln -s /usr/local/bin/C4Light.lua lights
ln -s /usr/local/bin/C4Light.lua fan
Once the script is setup and you have symbolic links for fan, light, and lights, you need to edit the C4Light.lua file to customize it for your Control4 setup:
- Change DirectorIP (‘192.168.29.226’) to the IP Address of your main Control4 controller.
- Change defaultLight (78) to the Device ID of the light you wish to control (See Below)
- Change defaultFan (80) to the Device ID of the fan you wish to control
To determine the light and fan Device ID’s, you can use the following trick:
In Composer (Homeowner’s Edition should work fine for this), create a single line of programming with the light or fan whose Device ID you wish to know. Right-click on the programming, and copy the programming to the clipboard. Paste the programming into a text editor (or XML editor), and you will see a Device Command inside the ‘cutitems’ section, like this:
<Description>Turn on the NAME</Description>
<devicecommand owneridtype="" owneriditem="-1">
Once you have the script setup, you can also create shortcuts in your OS to call the scripts.
With any luck and a small amount of brains and effort, you can be just as lazy as me!