This object is passed as the parameter to event handlers in apps, providing some information about the event and the device that produced it.
Boolean
Not used
String
Driver-provided description of event, often including device name, attribute name, new value, and (if applicable) unit as human-friendly string (e.g., "Living Room dimmer level is 50%"). Not mandatory.
boolean
Not used
String
The type of source that generated the event (may be null).
Boolean
If true, platform will generate an event even if the new value is the same as the old value. The default behavior filters out events that do not represent a change in value.
String
The name of the device attribute represented by this event (e.g., "switch" or "temperature")
String
The new value of the specified attribute
String
The units for the new value, (e.g., "%" or "°F"; optional)
String
Boolean
Not used
String
May be "physical" (if event was generated by user action on the device itself, e.g., pressing a button/switch) or "digital" (if generated as a result of a command sent from the hub), or null (default and very common)
Long
The id of the location the event belongs to (may be null).
Long
The id of the hub the event belongs to (may be null).
Long
The id of the installed app the event is for (may be null).
Long
The id of the event.
String
Subscription-specific data attached to the event when it is delivered to a subscription handler (see the subscriptionData option of subscribe()).
Retrieve the event's data as a String. (Map data supplied to sendEvent() is stored as JSON; see getJsonData().)
String getData()None
The event data as a String, or null if no data was set
Parse the serialized event data as a JSON object.
Map getJsonData()None
A Map parsed from the event's JSON data, or null if there is no data or it is not valid JSON
Determine whether the event was generated by a physical action on the device (i.e., its type is "physical").
Boolean isPhysical()None
true if the event type is physical, false otherwise.
Determine whether the event was generated by a command sent from the hub (i.e., its type is "digital").
Boolean isDigital()None
true if the event type is digital, false otherwise.
Retrieve the date and time of the event.
Date getDate()None
Date - The date and time of the event
Retrieve the time of the event as milliseconds since the Unix epoch.
long getUnixTime()None
long - The event time in milliseconds since the Unix epoch
Retrieve the display name of the event's source (for a device event, the device's display name).
String getDisplayName()None
String - The display name
Retrieve the ID of the device that produced the event.
Long getDeviceId()None
Long - The device ID
Retrieve the device that produced the event.
DeviceWrapper getDevice()None
The device (DeviceWrapper), or null if the event has no device
Retrieve the hub's location.
Location getLocation()None
The Location object
Convert the event's value to a Double.
Double getDoubleValue()None
The value as a Double, or 0.0 if it is not numeric
Convert the event's value to a Float.
Float getFloatValue()None
The value as a Float, or 0.0 if it is not numeric
Parse the event's value as a date.
Date getDateValue()None
The value as a Date, or null if it cannot be parsed using the supported event date formats
Convert the event's value to an Integer.
Integer getIntegerValue()None
The value as an Integer, or 0 if it is not an integer
Convert the event's value to a Long.
Long getLongValue()None
The value as a Long, or 0 if it is not an integer
Parse the event's value as a number, using the number format of the current locale.
Number getNumberValue()None
The value as a Number, or null if parsing fails
Parse the event's value as a number. Same as getNumberValue().
Number getNumericValue()None
The value as a Number, or null if parsing fails
Deprecated; use getDisplayName() instead.
String getLinkText()None
The display name
Set the event's data.
void setData(String data)data - The serialized event data to store.none
Set the display name of the event's source.
void setLinkText(String linkText)linkText - The display name to assign to this event.none
Serialize the event to JSON.
String toJson(boolean includeData = false)includeData - Optional; defaults to false. True to include the serialized data fieldA JSON String containing the event's source, name, displayName, value, type, unit, deviceId, hubId, installedAppId, and descriptionText (and data, if requested)
Convert the event to a Map in the form used by the hub UI.
Map toUIMap()None
Map with these keys:
id: Long event id; non-null.source: String source type; nullable.name: String event name; nullable.displayName: String source label; nullable.value: String event value; nullable.unit: String unit; nullable.deviceId: Long device id; nullable.deviceID: Long compatibility alias for deviceId; nullable.hubId: Long hub id; nullable.locationId: Long location id; nullable.installedAppId: Long installed app id; nullable.descriptionText: String display description; nullable.isStateChange: Boolean state-change flag; nullable.physical: Boolean indicating type equals physical; non-null.digital: Boolean indicating type equals digital; non-null.type: String event type; nullable.date: String JSON-formatted event date; non-null.Apply event fields supplied to createEvent or sendEvent. Accepted options and their effects:
name: optional String event name; a falsey value leaves the current name unchanged.value: optional value; its toString() result is tested, then the original value is assigned when that result is truthy. Empty text is ignored; false and zero are retained.descriptionText: optional String description; a falsey value leaves the current value unchanged.displayed: optional truthy Boolean-like value; falsey values leave the field unchanged.linkText: optional String source label; a falsey value leaves the current value unchanged.isStateChange: optional truthy Boolean-like value; falsey values leave the field unchanged.unit: optional String unit; a falsey value leaves the current value unchanged.type: optional String event type, normally physical or digital; a falsey value is ignored.data: optional value; a truthy LinkedHashMap is serialized as JSON, while another truthy value is converted with toString().forceAttributeUpdate: optional Boolean-like value; any non-null value is assigned.The method does not validate option value types.
Event populateValues(Map options)options - Map of event fields to apply; it must not be nullThis event after applying the supplied fields