Synthetic Variables' editor

Ubidots Synthetic Variables' editor allows you to write and configure the synthetic expression that will be computed.

In the bottom right corner of the editor, you'll see a message that indicates whether the expression is valid and can be computed or if there is an issue with the syntax that has to be corrected.

Timezone

The editor allows selecting a timezone to reference the exact variable's timestamps based on a particular place. This comes in handy when a variable has to be calculated for a client, user, or process that has a different timezone than the one of your location.

Context

Synthetic Variables allow context data handling, meaning you can take the context of the raw variable and use it in the synthetic expression (only if the context value is a number). Accessing it from the editor is straightforward: you just need to use the dot . operator over the variable, add context and then the context key identifier:

{YOUR_VARIABLE}.context.context.key

Timestamp

Similarly to accessing context data, timestamps can be accessed in synthetic variables using the dot . operator.

{YOUR_VARIABLE}.timestamp

Device properties

It's possible to use device properties in a synthetic variable's expression as long as the property has a floating number format. To access it from the synthetic editor, it's necessary to use any of the following syntax to retrieve the device object:

Using a device's ID:

{{device:<device_id>}}

Using a device's label:

{{device:<device_label>}}

Then, in order to access this device's properties, you need to use the dot operator . , like this:

{{device:<device>}}.properties

Here, you need to replace <device> with the id or label of the device that you wish to calculate the synthetic variable for.

Now you can retrieve any of the device's properties using the property's key, like this:

{{device:<id>}}.properties.<key>

Where <key> is the property's key.

For example, suppose that you need to retrieve the property uptime from a device whose ID is 65fb47fad809281764f8a350 . The following syntax accomplishes that:

{{device:65fb47fad809281764f8a350}}.properties.uptime

Note that in order to use the properties of the device in a synthetic variable, it's necessary to have a mathematical expression with another variable, which will determine the calculation of new data within the synthetic variable.

Using device properties from device types synthetic variables editor

It is also possible to create a synthetic variable across device types from within the synthetic variables editor at device types module using any of the following syntax:

{{device:self}}.properties.<key>

Here, you should only replace the property's key for the intended value. The keyword self is a placeholder that gets replaced by the actual device ID for all the devices contained in this device type.

Last updated

Was this helpful?