Creating alerts on the device from sensor data

Although all the sensor data from the CC1 can be received on a backend application, which can then generate actions based on the values seen, it is also potentially interesting to detect alert conditions on the device itself and immediatly generate a local action.

For example, if the battery gauge falls below 20%, change the current screen to the system page showing the battery level.

An alert therefore includes the following config : the sensor to monitor (power.gauge), the check to be performed (value is under a limit) and a set of 1-n actions to take when the check is true ie the alert is active (eg change page). It is also possible to define a set of actions for when the check then becomes false (the alert is cleared)

As the device also includes sensing of its environment around it, the checks can also include :

  • seeing a specific BLE iBeacon or wifi AP (or NOT seeing it!)
  • being in range of a specific geographical point (as determined by the GPS, or a geopos ibeacon UUID)

To configure these alerts, we need to set global config for the ‘alert’ sensor. This config consists of a list of defined alert for each check type (ids, positions, limit checks, etc). Each alert has an id, the specific config for that alert check type, and the action for the ‘active’ and ‘clear’ transitions.

Consult the reference documentation for all the possibilities, here we will conclude with an example:

{
  "dev": {
    "alerts": {
      "onEquals": [
        {
          "active": [{
            "action": "vibrate",
            "aparam": "V30"
          }],
          "dname": "power.ext",
          "id": "extpowerOn",
          "value": false
        }
      ],
      "onIdMissing": [
        {
          "active": [{
            "action": "buzzer",
            "aparam": "Z710S 01Z810S 01Z910"
          }],
          "id": "visitor1",
          "onMissing": "000107d0",
          "type": "majmin"
        }
      ],
      "onIdSeen": [
        {
          "active": [{
            "action": "buzzer",
            "aparam": "bb01c-01ab01Ab05Eb10"
          }],
          "id": "dangerzone1",
          "onSeeing": "00020003",
          "type": "majmin"
        }
      ],
      "onUnderLimit": [
        {
          "active": [{
            "action": "gotopage",
            "aparam": "system.1"
          }],
          "dname": "power.voltage",
          "id": "lowBattery",
          "limit": 4
        }
      ]
    }
}

This example has:

  • an alert that plays a sound when the ble scan sees a specific iBeacon major/minor value ‘00020003’
  • an alert that plays a sound if the ble scan does NOT see a specific beacon (‘000107d0’)
  • an alert that vibrates the device whenever it is removed from the charger
  • an alert that changes the current page to the system sensor display when the battery voltage is less than 4V

Note that all alerts generate an UL message when they transition (clear->active or active->clear) as well.

Hopefully this gives you some ideas for your own applications!