ARTIK Cloud Rules: Ready, Set, Go

Today we released a new ARTIK Cloud Rules feature that adds the ability to define Rules with a sliding time window. The existing Rules documentation has been updated to cover the new duration condition.

The duration condition is added to the Rule body. A duration condition tests whether a device matches a state (i.e., the values of the specified field and operand match the operator condition) for a certain period of time.

{ 
  "if": { 
    "and": [ { 
      "sdid": ... the device...,
      "field": ... the field...,
      "operator": ... the operator...,
      "operand": { "value": ... the value... },
      "duration": {
        "value": ... duration in seconds ...,
        "acceptUpdate": ... true/false ...
      }
    } ]
  } 
}

value defines the length of the duration in seconds, while acceptUpdate is a Boolean that defines how the duration condition is tested.

Say you want to monitor the temperature of the room and trigger an Action if it stays below 60 degrees Fahrenheit for five minutes:

  • If acceptUpdate is true, the Action will trigger if the smart thermostat returns a value below 60 degrees and does not send any value equal than or higher to 60 during a five-minute window.
  • If acceptUpdate is false, the Action will trigger only if the smart thermostat returns a value below 60 degrees and does not subsequently send any value during a five-minute window.

The former condition would look like this:

{
  "if": {
    "and": [ {
      "sdid": "d1111bbbb",
      "field": "temperature",
      "operator": "<",
      "operand": { "value": 60 },
      "duration": {
        "value": 300,
        "acceptUpdate": false
    } ]
  },
  ...
}

Read the Rules documentation to get the full details on duration conditions and the Rule body, and read this blog for a refresher on how the Rules feature works.