Events
Events are notifications triggered by a Thing to inform about specific occurrences or changes. These are used for asynchronous communication, allowing Things to push updates to clients without requiring constant polling. For example, a motion sensor might emit an event when movement is detected. Events are typically consumed through subscription mechanisms, such as WebSockets or MQTT.
- Events are immutable once triggered; they only represent a past occurrence.
- Each event contains a timestamp to indicate when it was emitted.
Add Events to a Thing
-
In the Overview panel of a Thing, click the plus icon next
to Events.
The New Event dialog opens.
- Enter the Event Key value. This should be a descriptor of the Event.
-
If desired, enter a Title, any optional descriptors and the data type for this
Event.
-
Click Create.
The information is added to the schema.
"events": { "overheating": { "data": { "type": "string" }, "description": "Lamp reaches a critical temperature", "title": "" } },
-
Once the Event has been created, you can click on the
Edit icon to make further changes to this
Event.
Events Detailed Information
Events are defined similarly to Properties and Actions. They allow for several metadata keys to describe what the event is, and those metadata keys follow a standard format.
The following keys can be used to describe an event:
Metadata Definition | Description | Required? | Type |
---|---|---|---|
title |
Title of the Event | No | string |
description |
Additional content to tell the user what the event is for. | No | string |
data |
Defines the expected format of the event body. | No | object |
data
key. The data key is
what stores the information that describes what each event should look like. The
information expected in an event (as defined in the data key of the Thing
description) can be any one of the following primitive types:array
- Expects a list of results
boolean
- Expects a true/false
number
- Expects any real number
integer
- Expects any whole number
object
- Expects a JSON object with additional properties defined.
string
- Expects a series of letters and/or numbers
null
- Expects no value
Each of these primitive types can be further defined by any or all of the following metadata keys.
Metadata Definition | Description | Required? | Type |
---|---|---|---|
title |
Title of the event data displayed in the UI. | No | string |
description |
Additional content to tell the user what the event data is for. | No | string |
type |
Primitive data type for validation of the event data. | No | string |
unit |
Provides a reference unit, especially for numbers and integers. | No | string |
readOnly |
Validates that a value should not be written to. | Yes (default is false ) |
boolean |
Metadata Definition | Description | Required? | Type |
---|---|---|---|
minimum |
Minimum value. Used for validation. | No | number |
maximum |
Maximum value. Used for validation. | No | number |
Metadata Definition | Description | Required? | Type |
---|---|---|---|
minimum |
Minimum value. Used for validation. | No | integer |
maximum |
Maximum value. Used for validation. | No | integer |