Using On{X} and InControl to activate your lights when you get home

6. June 2012 11:38 by Ryan in Clipsal, InControl Tips, z-wave  //  Tags: , ,   //   Comments (0)

Microsoft has a new product out called On{X}, which lets you add even more brains to your Android device. On{X} is basically an engine that let's you check your phone's many sensors (like GPS) and then perform special tasks when something important happens.

For me, I wanted to setup On{X} to watch my GPS and when I got near my home, it would tell InControl to activate my z-wave enabled garage lights (New to Z-Wave?) Here's how I set it up.

Step 1: Setup a scene inside InControl that activates the lights that should turn on when On{X} detects the phone arriving near the house.

a) Create a new scene. I named mine "Garage On."


b) Click Add Device, choose the Garage Lights, then adjust the slider to the "On" position.


c) Click Activate Scene to verify that the garage lights turn on properly

d) For this to work, you'll need to make sure you've taken a few steps to access InControl over your 3g phone network.

Step 2: Setup an account on On{X}. It's free and relatively painless since it uses Facebook.

Step 3: Click the Create button to start a new script. You'll end up with a screen that looks like this:



Step 4: Delete all the code you see in your script, then copy & paste the following into the window:

    // Initializing variables 
    // This requires InControl Home Automation (
    var location = { name : "Home",latitude : "28.482657",longitude : "141.935347" } ;
    var inControlServer = "";  // Enter your external IP
    var inControlPort = "1178"; 
    var inControlPassword = "";
    var sceneName = "Garage On";  // Enter the name of your scene
    // End of variables initializing 

    console.log('Started script: Turn on Garage Lights when arriving home');
    // create a geo region for the trigger to take place at
    var region = device.regions.createRegion({
        latitude: parseFloat(location.latitude, 10),
        longitude: parseFloat(location.longitude, 10),
        radius: 500

    // Assign the callback when entering the region
    region.on('enter', function () {
        console.log('Entered target location!');
        // Create a notification that the timer has been started
        var notification = device.notifications.createNotification('Welcome to ' + + '.');
        notification.content = "Your lights have been turned on.";;
          url: inControlServer + ":" + inControlPort + '/zwave/activateScenePost',
          type: 'POST',
          data: JSON.stringify({
          headers: {
            'Content-Type': 'application/json;charset=utf-8'
        function onSuccess(body, textStatus, response){  
            console.log("Sucess:" + textStatus + ":" + body);
        function onError(textStatus, response){   
            console.log("onError:" + textStatus + ":");
    // start monitoring the region

    console.log('Completed script: Turn on/off garage lights.');

Step 5: Customize the script to work with your home

a) Change your lat and long to match where your house is. To find mine, I used Google Maps. Just right click on your house and choose "What's here?" to have it show you the Latitude and Longitude (you'll need to hover your mouse over the green arrow that shows up).


b) Change your IP address to match what your own external IP is. Just go to and copy the IP address shown.


c) Change the scene name to match the one you created earlier in InControl.


Now just save your rule and send it to your phone. Next time you come back to your home, your garage lights should activate automatically for you.

Pingbacks and trackbacks (1)+