Combining multiple properties into one

Calculated Properties can combine, select and gate other properties

You can use CPs to combine multiple properties into one.

Unifying device schemas

If you have two types of device, and one type reports "temp" and the other type reports "temperature", then you could define a universal property (to use in KPIs etc.) which will be correct for both types of device:


temp ? temp : temperature

Calculations on multiple properties

You can also combine multiple properties using a formula: if your device reports air temperature and device temperature, you can create a property which is the difference between these values.


air_temp - device_temp

Some qualities are inherently multi-dimensional, which makes them hard to analyse as a single number. For example, comfort is determined by both temperature and humidity, so if your sensor reports both values then you can combine them into a single "comfort" index which returns 1 at the perfect combination, and smaller numbers the further away you get (with a slight tendency for warmer temperature to be comfortable when humidity is low)  e.g.:


1 / (1 + abs(temperature - 26 + humidity / 50) * 0.2)

Selecting from multiple properties

You can use CPs to make one property which follows the value of two or more other properties, dependent on some criterion, and for this we use the ternary "?" if/then/else operator. For example, if our device has a knob to select whether it measures inside or outside temperature, we could say:


selector == "inside" ? inside_temp  : outside_temp

Or perhaps you have some US devices reporting temperature in Farenheit on one property, and some European devices reporting temperature in Centigrade on another property? A CP can unify these into a single universal temperature property:


made_in_usa ? (tempF - 32) * 5.0 / 9.0 : tempC

You can also use the "?" operator to ‘gate’ or mute a property, based on its own state or that of another property. For example, buildings which have solar panels experience electricity-flow both in (+ve) and out of them (-ve), and summing such a value in a KPI will correctly give you the overall net figure. But if you wanted to gather stats on just the exported amount, you could gate the value thus:


energy < 0 ? -energy : 0

Sometimes you may have multiple properties describing the state of your machine, for example multiple error properties each of which can be true or false at any moment in time. With CPs you can combine these into a single property (based on e.g. their priority). Then they just occupy one column in a list, and you can GROUP BY the current worst error:


polonium_leak ? "Polonium leak" : loose_nut ? "Loose nut" : null


Learn more about Calculated Properties