Turn WIFI on when arriving at location. Turn it off when leaving

Used to turn on/off wifi when arrving/leaving at home.

Save Recipe

You will need:
  • Install SetOnx on your Android phone http://setonx.com
  • Change the lat/long for your location
  • Change the radius: 40 to whatever you want the region to be (in meters)
Et voila!

To use this on{X} Recipe, simply copy the code below and modify if needed.

    // Initializing variables 
    var location = { name : "home",latitude : "45.497345",longitude : "-73.576581" } ;

    // 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: 40
    });

    // assign the callback when entering the region
    region.on('enter', function () {
        // turn on wifi
        var params = {message:"network", wifiState:"enable"};
        device.applications.launch("setonx",params,null);
        console.info('wifi on');
    });
    
    region.on('exit', function () {
        // turn off wifi
        var params = {message:"network", wifiState:"disable"};
        device.applications.launch("setonx",params,null);
        console.info('wifi off');
    });

    // start monitoring the region
    device.regions.startMonitoring(region);

Recipe Wall

2,905

Views