Attribute Value Formats

Attribute values are formatted automatically by the pimatic frontend. Generally, the idea is to presemt attribute values in a better, human-readable way. The formatting depends on variours aspects such as the attribute value type, the unit type associated with a values (if defined), and the size of the value. In some cases the resulting display of the value is not what the user would like to see. For example, for currency values the user may want to have the value displayed with a fixed number of digits (for cents) rather than having the display of decimals depending on the actual value. For this reason, it is possible to override the the default format with a format selected by the user.

displayFormat.png

User-defined display formats are set by defining a xAttributeOption for the respective attribute as part of the device configuration. The easiest way of doing this is to use the device editor of the pimatic frontend. As shown in the screenshot a xAttributeOption is linked to an attribute exposed by the device. If you need to find out which attributes are exposed use the Variables editor of the pimatic front to get a list of all variables including device attributes. The "displayFormat" xAttributeOption use a simple syntax as follows:

uptime

The uptime formatter is meant to be used for numeric attributes providing time duration values given in seconds. The formatter will produce a string presenting human-readable breakdown of the duration into applicable time unit, similar to what the Linux command "uptime -p" produces. The following options are provided:

fixed

The fixed formatter is meant to be used for numeric attributes to formats number using fixed-point notation. By default the number will be formatted with no decimals in place. The following options are provided:

localeString

The localeString formatter is meant to be used for numeric attributes to provide the value using locale conventions. Basically, it uses the capabilities of the Javascript [toLocaleString function for Number objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString). The following, optionas are applicable: