Datapoint Localization

Datapoint Presets is available with SmartServer 2.8 and higher.

Datapoint localization are discussed in Connections and Datapoint Objects property table.

Datapoint localization transforms a datapoint value to a specific localized value and datatype, based on the localization rules.  A global setting selects SI or US units.  For example, when SI is selected, temperatures are reported and accepted in Celsius, and when US is selected, temperatures are reported and accepted in Fahrenheit.

This page contains the following sections:

Using Localization and Presets Together

You can use both localization and presets properties at the same time or by themselves.  When presets and localization are set for a datapoint, the presets map is configured based on the local value.  So when you get an update, the value needs to be localized first before mapping to a preset string.  Same with the other direction, when users input a preset string, the map value needs to be transformed using the reverse transformation rule to get the IAP value. 

The Localization Object

The localization object describes the localization transformation. 

  • Localization is optional. If the source/destinations do not have localization, the localization object is set to an empty object or null.
  • The localization object contains the transformation rules.
  • The presets object is submitted with the connection object’s create or update actions and stored in the connection configuration objects.
  • The localization object is not stored in the connection object’s status.

The following table describes the location object properties:

Field Name       Type              Description
sourceObject. 
The localization rules object for the source segment.

The source localization rule is global for all the datapoints sources.  The source object is empty if there is no localization rule.

{                                                          
   "value": {
   "transform": "$.value * 0.5"
},
"state": {
 "transform": "$.state"
}
}
destinationsList.
Items are the localization transformation rules used in the destination segment.

The datapoints localization is based on optional transformation rules that connect elements of source properties to destination properties. 

The source object is empty if there are no destination presets.

[                                                           
null,
{
   "value": {
     "transform": "$.value * 0.5"
   },
   "state": {
     "transform": "$.state"
   }
},
null,
null,
null
]

In the following example, the data will not be sent to the destination segment.

repeatLOCBoolean

The repeatLoc property is set to true if the localization rule specified (in the first index) is used for all the destinations. If repeatLoc is set to false, the localization rule only applies to the specific destinations.

Default is False if undefined.

The following example shows a case where only the second destination uses localization.

{                                                           
   destinations: [
 null,
 {
    "value": {
     "transform": "$.value * 0.5"
  },
    "state": {
     "transform": "$.state"
    }
 },
  null,
 null,
 null
],
repeatLoc: false
}


The following example uses the same localization rule for all destinations.

destinations: [                                             
{
 transform: "$ * 0.15"  
}
],
repeatLoc: true // the localization rule is repeated
// in all destinations

Transformations

The transformations support a scaling factor to specify a multiplier (transformA),  an exponent (transformB), and an adder (transformC).  You can transform any simple data type, and you can also transform any field in a structure or union.            

{transformA:<multiplier>, transformB:<exponent>, transformC:<adder>, unit:"<optional unit string>"}

The transformation value is determined using the following:  
                ( rawValue *  transformA *  10^transformB ) + transformC

The maximum number of digits to the right of the decimal point is calculated based on the exponent value.  If the exponent value is greater than -1,  the  decimal place is 0.   Otherwise, the decimal place is the abs(exponent).  For example, if the exponent is -1, the decimal place is 1.

Field NameTypeDescription
transformAlongTransformation multiplier.
transformBlongTransformation exponent.
transformClongTransformation adder.
unitstringThe unit of the transformation value. The value can be empty ("").

Examples

An example of how to specify the localization datapoints with structure: 

    localization: {
        value: {
            occupied_cool: {transformA: 18, transformB: -1, transformC: 32, unit:"deg F"},
            standby_cool: {transformA: 18, transformB: -1, transformC: 32, unit:"deg F"},
            unoccupied_cool: {transformA: 18, transformB: -1, transformC: 32, unit:"deg F"},
            occupied_heat: {transformA: 1, transformB: 0, transformC: 0, unit:"deg C"},
            standby_heat: {transformA: 1, transformB: 0, transformC: 0, unit:"deg C"},
            unoccupied_heat: {transformA: 1, transformB: 0, transformC: 0, unit:"deg C"}
        }
    }

    occupied_cool transformation value = (rawValue * 18 * 0.1) + 32    → decimalPlace = 1

    occupied_heat transformation value = (rawValue * 1 * 1) + 0    →  decimalPlace = 0   // no transformation


Another example with more complex structure:

    localization: {
        value: {
            property_1: {
                property_1_1: {transformA: 11023, transformB: -4, transformC: 0, unit:"tons"},
                property_1_2: {transformA: 14504, transformB: -8, transformC: 0, unit:"p.s.i."},
            },
            property_2: {transformA: 40217, transformB: -7, transformC: 0, unit:"in. of H2O"},
       }
    }

    property_1_1 transformation value = (rawValue * 11023 * 0.0001) + 0    → decimalPlace = 4

    property_1_2 transformation value = (rawValue * 14504 * 0.00000001) + 0    → decimalPlace = 8

    property_2 transformation value = (rawValue * 40217 * 0.0000001) + 0    → decimalPlace = 7


In the following example, the value of the standard type SNVT_temp_p is transformed from Celsius to Fahrenheit. In the destination segment, the value is transformed back from Fahrenheit to Celsius:

{
  // the localization transformation for all the sources
  source: {
    transform: "$ * 1.8 + 32"
  },

  // the localization transformation for all the destinations
  destinations: [
    {
      transform: "($ - 32) / 1.8"        // reverse transformation 
    }
  ],
  repeatLoc: true                  // the localization rule is repeated in all destinations
}