Growth of the IoT market: the good and the less good

Technology regularly introduces new paradigms, advances or improvements that create a huge hype around them, boosting the market, creativity and competition. The Internet of Things is one of these, according to the numerous studies and forecasts that have been conducted, and proven to be quite true so far. As it is usually the case when this happens, the number of topic-related products and gravitating services starts increasing, and in the specific case of the IoT, every day brings a new player in the different market segments: prototyping, platforms, smart home, fitness and health, connected vehicles, etc.

The good

The profusion of (IoT) actors and products creates positive competition among them, which brings many advantages: it raises productivity and efficiency, increases quality and innovation, while reducing prices, which is good for consumers. Competition also promotes dynamic markets, eventually leading to economic growth.

The less good

While this variety of players and products is rather positive, the pace at which they are introduced has a few drawbacks, among which the lack of standardization and interoperability. For example, although Nest, Honeywell or Ecobee thermostats provide quite similar features, they do not expose them through identical APIs. Hence, when purchasing smart home devices (cameras, alarms, thermostats, etc.) from different manufacturers, chances are to end up with one different mobile app per manufacturer, to control the different devices.

Thus, there is a wide variety of products in the market, which cannot really communicate with each other although they – nearly – expose the same behavior through different APIs. Although this can easily be accommodated for if – as a consumer or as a developer – you decide to stick to one “brand”, this is rather hindering in the more probable case where you are trying to build a solution that combines the best of breed products.

Orchestration and integration to the rescue

The above is actually a recurrent scenario in the technology field. Some actually see this as an opportunity to offer middleman – or hub – services, as it is the case for scriptr.io, to a greater extent. Indeed, implementing large scale and real-life IoT solutions involves the orchestration of multiple heterogeneous devices and APIs, while guaranteeing quality of service (scalability, reliability, throughput, etc.). This is something that scriptr.io provides, drawing from years of hands on experience.

Since most devices currently have limited processing capabilities and thus cannot handle complex treatments, nor fulfill important storage needs, these latter have to be delegated to back-end services and be exposed to devices as APIs. Even when – thanks to the progress of technology and to cost reduction – many devices will see their capabilities enhanced, a majority of IoT solutions will still have to factor out part of their business processes, rules, and data storage into the back-end (on the Cloud or even on the Edge), because these need to be shared across the multiple actors of a solution.

scriptr.io is a Cloud platform for implementing scalable, secure and robust IoT applications. It notably provides orchestration and integration capabilities, allowing to integrate with any third party APIs and services – including bespoke components, and orchestrate them to execute business processes. Moreover, orchestration scripts can be exposed as REST APIs in a snap, opening them up to other apps or devices.

Orchestration example

Let us demonstrate the above through a real life smart home scenario that we will implement in a few lines of code. The process to execute is the following: when a user falls asleep at home, the house shutters should automatically close, the home security system should be armed and the bedroom’s temperature should be set to an optimal value. In this example, we assume the following:

  • The user owns a Withings pulse tracker that regularly checks his heart rate. A heart rate below a given threshold indicates that the user has fallen to sleep
  • The user also owns a Myfox shutter controller and a Myfox home alarm system that are used to close/open the house shutters, respectively arm the security mode.
  • The temperature is regulated using a Nest smart thermostat.

Executing our process requires thus the orchestration of multiple devices from different vendors, which is actually very simple to do using scriptr.io’s scripts and connectors, as you can observe in the below:

/***********************************
 * samples/orchestration/smartHome *
 ***********************************/
// require the Withings, Myfox and Nest connectors
var withings = require("modules/withings/user.js");
var foxModule = require("modules/myfox/fox.js");
var nestModule = require("modules/nest/nestClient.js");

var HEART_SLEEP_RATE = 60;
var OPTIMAL_TEMP = 23;

// this function is automatically executed when a Withing heart pulse notification is received by scriptr.io
function handle(notification) {
  
  // check if the user's heart pulse matches that of a sleeping person
  if (isSleeping(notification.userid)) {
    // create an instance of the myfox connector for the given user
    var myfox = new foxModule.Fox({userId:notification.userid});
    // get the "Home" site (we need its id)
    var home = myfox.getSiteByLabel("Home");
    // close all shutters at this site
    closeShutters(myfox, home.siteId);
    // arm security 
    armSecurity(myfox, home.siteId);
    // set temperature to optmimal value
    setTemperature();
  }
}

function isSleeping(userId) {
  
  var user = new withings.User({userid: userId});
  var heartPulseMeasures = user.listHeartPulseMeasures();
  var lastMeasure = heartPulseMeasures[0].measures.realValue;
  return lastMeasure <= HEART_SLEEP_RATE;    
}

function closeShutters(myfox, siteId) {      
  var shutters = myfox.listShutters(home.siteId);
  for (var i = 0; i < shutters.length; i++) {
    var shutter = myfox.getShutter({siteId: siteId, id: shutters[i].deviceId});
    shutter.close();
  }
}

function armSecurity(myfox, home) {  
  var mappings = require("modules/myfox/mappings");
  myfox.setSecurity({siteId: home.siteId, securityLevel: mappings.securityLevels.ARMED});
}

function setTemperature() {
  var nest = new nestModule.NestClient(true);
  var smartThermostat = nest.getThermostatByName("master_bedroom");
  nest.setTargetTemperature(smartThermostat.device_id, OPTIMAL_TEMP);
}

Note: the “handle()” function is specific to “notification handlers” – as defined in our Withings connector. Handlers are automatically invoked (as callbacks) by Withings. Thus, with the proper configuration, our script will automatically execute after receiving a Withing notification. For that to happen, we only need to modify the “handlers” variable defined in the withings/common file by mapping the heart beat event to the above script:

handlers[notificationTypes.HEART_AND_BP] = "samples/orchestration/smartHome";

We now have a working smart home orchestration.