Used to turn on/off wifi when arrving/leaving at home.
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);
Views