Overview
When devices report values in units that differ from what your dashboards or reports require, meta data source points provide the solution. A meta point runs a script that reads source point values, applies a formula, and produces a new virtual data point with the converted value.
How Meta Points Work
- Create a meta data source (or use an existing one)
- Add a meta point to the data source
- Add the source points under External context points and give each one a Key — the key is the name your script uses to read that point
- Write a script that reads context point values, performs the calculation, and returns the result
- The returned value becomes the meta point's current value, logged and available like any other data point
Common Unit Conversions
Temperature: Celsius to Fahrenheit
// Context key: p1 = temperature in Celsius
return p1.value * 9/5 + 32;
Temperature: Fahrenheit to Celsius
// Context key: p1 = temperature in Fahrenheit
return (p1.value - 32) * 5/9;
Pressure: PSI to Bar
// Context key: p1 = pressure in PSI
return p1.value * 0.0689476;
Power: Watts to Kilowatts
// Context key: p1 = power in watts
return p1.value / 1000;
Flow: Gallons per Minute to Liters per Minute
// Context key: p1 = flow in GPM
return p1.value * 3.78541;
Step-by-Step: Creating a Unit Conversion Point
- Go to Data integration > Data sources and open (or create) a Meta Data Source
- On the Data points tab, click Add
- Name the point descriptively (e.g., "RTU-01 Temperature (F)")
- Set the Export ID (XID) (e.g.,
DP_BLDG_A_RTU_01_TEMP_F) - On the Meta data point tab, set Data type to Numeric. This is the type your script's return value gets converted to
- Under External context points, add the source point and give it a Key (e.g.,
a). Keys must be valid ECMAScript identifiers: start with a letter or underscore, and no spaces - Tick Updates context on that row, so the script runs when the source updates. It starts unticked on every new row, and with Timer update event at its default of None, a point with nothing ticked never runs
- Write the conversion formula in the script editor, referring to the source by its key
- Leave Context event type at Update (the default)
- Save the point and enable it, then click Validate to test the script. Validation reports the computed result, and it needs the point saved and enabled first
- On Point properties, set Unit to the target unit. Mango by Radix IoT validates this string and rejects an unrecognised one, so stick to known symbols. Then, on Text renderer properties, tick Use unit symbol as suffix so the unit is shown with the value
- On Logging properties, set Logging type — usually All data for converted points
Warning
Key and Variable name are different fields and it is easy to confuse them. The Key column, on each row of External context points, is how your script refers to a source point. Variable name, higher up the same tab, is the name by which this meta point refers to itself in its own script context — useful for reading the point’s previous value, and not what you set to name a source.
Beyond Simple Conversions
Calculated Totals
// Sum power across three generators
// Context keys: gen1, gen2, gen3 = power points
return gen1.value + gen2.value + gen3.value;
Efficiency Calculation
// Context keys: output = output power, input = input power
// A context point with no value reads as null, and null is cast to 0 when used,
// so guard for both. Returning UNCHANGED leaves the point alone; returning 0
// would log a real reading of zero.
if (input.value === null || Number(input.value) === 0) return UNCHANGED;
return (output.value / input.value) * 100;
Running Average
// Context key: p1 = source point, which must be NUMERIC
// past() returns a statistics object — use .average (do not loop it like an array)
return p1.past(MINUTE, 10).average;
On a numeric point past() returns an AnalogStatistics object, which carries
average, minimumValue, maximumValue, sum,
integral, delta and count. On a binary or multistate
point it returns a StartsAndRuntimeList instead, which has no average — so the
same line silently yields undefined. Period constants are SECOND,
MINUTE, HOUR, DAY, WEEK, MONTH and
YEAR.
Conditional Status
// Context keys: temp = temperature, pressure = pressure
// Return alarm level: 0=OK, 1=Warning, 2=Critical
if (temp.value > 200 || pressure.value > 150) return 2;
if (temp.value > 180 || pressure.value > 130) return 1;
return 0;
Backfilling a New Conversion Point
A new meta point starts empty and only gains values as its context updates. To fill in the past, use the meta data source's Generate history tab: choose the From and To dates and times (they default to the last month), and Mango replays the context points' stored values in that range through your script and saves the results. A context-triggered point gets no values where its source points have no stored history. On an SQL point value store a second run over the same range can store duplicates, so tick Delete existing data in range when the range already holds values.
Performance Tips
- Leave Context event type at "Update" for most conversions — it recalculates on every new value from a context row that has Updates context ticked. Change runs only when that value differs from the last one, and Logged only when it is logged
- Use Timer update event only when you need a fixed calculation interval regardless of source updates. Its options are None, start of minute, hour, day, week, month or year, and Cron pattern, which reveals a required Cron pattern field
- Avoid heavy operations in meta point scripts — HTTP calls, large historical queries, or complex iterations slow down the system
- Move slow work off the context trigger. With Execution delay(seconds) at 0 the script runs on the thread that delivered the source value, so a slow script delays that data source. Give it a delay, or run it on a Timer update event. A global script is a shared function, not a schedule: it runs only when another script calls it
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| Meta point shows no value | Script error, or no context point set to update context | Click Validate on the script — a failing script also raises a "Script error in point" event. Confirm at least one context row has Updates context ticked, and that the source points are enabled |
| Value is NaN or undefined | Context point has no value, division by zero, treating past() like an array, or calling .average on a non-numeric point | Check for null as well as zero — a null value is cast to 0 when used, so a zero-only guard misses it. Use past(...).average (stats object), not a loop |
| Conversion seems wrong | Formula error or wrong context point assigned | Verify formula independently; check context point mapping |
| Meta point updates too slowly | No context row has Updates context ticked, so only the Timer update event runs it | Tick Updates context on the source's row and leave Context event type at Update; set Timer update event to None unless you need a fixed interval |
| Nothing appears in the script log | Log Level on the meta data point defaults to None | Raise Log Level. Script output goes to that point's own script log file, which the editor links; ma.log carries general Mango logging |
Summary
Meta points are the simplest way to create unit conversions and calculated values in Mango. Add context points, write a formula, and the meta point produces a new data point with converted values. Beyond simple conversions, meta points handle totals, averages, efficiency calculations, and conditional logic — all without external scripting tools.