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 (http://www.incontrolzwave.com)
    var location = { name : "Home",latitude : "28.482657",longitude : "141.935347" } ;
    var inControlServer = "http://208.15.221.12";  // 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),
        name: location.name,
        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 ' + location.name + '.');
        notification.content = "Your lights have been turned on.";
        notification.show();
        
        device.ajax({
          url: inControlServer + ":" + inControlPort + '/zwave/activateScenePost',
          type: 'POST',
          data: JSON.stringify({
            password:inControlPassword,
            sceneName:sceneName,
            activate:"1"
          }),
          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
    device.regions.startMonitoring(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 www.whatsmyip.com 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.

Thermostat Scheduling Using InControl

31. May 2012 02:01 by Ryan in Clipsal, InControl Tips, z-wave  //  Tags: , ,   //   Comments (0)

This requires InControl version 2.0 or higher.

This page will describe the steps required to setup a thermostat to turn up the heat at 7 AM and turn it down again at 10 PM, Monday through Friday. 

Step 1: Create Scene to turn thermostat heat to 72 degrees.

a) Click the New Scene button and enter a name describing the scene.

 

 b) With your new scene selected, click Add Device...  and check the box next to your thermostat. After the your thermostat has been added to the scene, you can click on it and enter a Cool and Heat point. I set my cool point to something high and my heat point to 72.
 
 
 
 

Step 2: Create Scene to turn thermostat heat to 60 degrees.

Repeat step 1 again, this time creating a scene named "Thermostat Heat Off" which tells your thermostat to go to a low heat point, such as 60.

Step 3: Create rule to activate heat on scene at 7 AM

a) Click New Rule and name it "Heat on: Morning"

 

 b) Select the rule Heat On: Morning in your list and verify that Trigger and Script to Execute are set to "On a Specific Date (repeatable)" and "ActivateScene.cs", respectively and that the rule is marked as Enabled.
 

 
c) Click the Rule Data... button. Enter today for the Target Date, and 7:00 AM for when you want the heat to turn on. NOTE: This date may be in the past. This is OK since we are going to tell this rule to repeat everyday at the same time.
 

 d) Choose the scene you'd like to activate for this rule. In this case, we pick "Thermostat Heat On."

 e) For the Interval, enter "Days" to specify that this rule should repeat every day.

 f) For the interval number, we will specify "1" to tell it to repeat every 1 day.

 g) Finally, choose which Days of the Week you'd like this rule to be valid on.

 

Step 4: Repeat step 3, creating a rule to activate the "Heat Off" scene at 10 PM.

Your thermostat should now turn on and off every day based on the schedule you set.