Standard Library Reference
Author
Danilo Vidovic <dv@allthingstalk.com>
Date
November 16th, 2017
Description
Earl Standard Library Components Reference
Reviewers

Earl Standard Library implements components that are thought of as being useful for implementing rules in IoT scenarios. This document describes all components in detail. The code that implements components is in stdlib.py.  For components that are already implemented externally, info can be found at the bottom.

Conventions

  • Components are divided into sections according to their namespace
  • Description of each component starts with listing its inputs and outputs
  • Input names are prefixed with req if they are required and opt” if they are optional
  • Both input and output names are followed by type in parentheses, e.g. “(urn)”
  • Types might be specified informally, e.g. “(comparable)”
  • Input/Output (port) description follows the type
  • If no inputs or outputs are available, this will be indicated as None
  • Components in general let Earl save the values on inputs for later even when “called”. However, some of them instruct Earl to erase certain inputs. These inputs’ types are prefixed with “◐”.
  • Variable number of inputs will be indicated with “…”

Messaging

Notify - allthingstalk.messaging.notify

Inputs
  • req recipient (urn): The message recipient, either a user or a ground
  • req message (string): The message that will be sent
  • opt sendPush (◐ truthy): Send push notification
  • opt sendWeb (◐ truthy): Send web notification
  • opt sendEmail (◐ truthy): Send email
Outputs
  • None

Notify is used for sending messages to a single user or all users in a ground. It can be used to send push notifications, web notifications and emails.

Example

# Send email when data is received on an asset

device = allthingstalk.device.ExampleId1
notify = allthingstalk.messaging.notify
urn:allthingstalk:user:ExampleId2 -> notify.recipient
"Your device just sent something!" -> notify.message
device.asset -> notify.sendEmail

Math

Compare - allthingstalk.math.compare

Inputs
  • req a (comparable): One of the values that’s being compared
  • req b (comparable): The other value that’s being compared
Outputs
  • a>b (bool): True if a is greater than b
  • a=b (bool): True if a equals b
  • a<b (bool): True if a is less than b
  • a<>b (bool): true if a doesn’t equal b

Compare compares values either numerically or lexicographically. End results of comparing values of different types is not defined.