Temperature Difference Calculation
Calculation Formula: 1-2
{
"name": "T Measurements changes > Calculate T Difference",
"actions": [
{
"if": {
"changes": {
"operand": {
"device": {
"devices": [
"-- ID Temperature Measurement Device 1 --"
],
"component": "main",
"capability": "temperatureMeasurement",
"attribute": "temperature",
"trigger": "Always"
}
}
},
"then": [
{
"command": {
"devices": [
"-- ID Number Field Device --"
],
"commands": [
{
"component": "main",
"capability": "legendabsolute60149.numberFieldOne",
"command": "setNumberFieldOne",
"arguments": [
{
"device": {
"devices": [
"-- ID Temperature Measurement Device 1 --"
],
"component": "main",
"capability": "temperatureMeasurement",
"attribute": "temperature"
}
}
]
}
]
}
}
]
}
},
{
"if": {
"changes": {
"operand": {
"device": {
"devices": [
"-- ID Temperature Measurement Device 2 --"
],
"component": "main",
"capability": "temperatureMeasurement",
"attribute": "temperature",
"trigger": "Always"
}
}
},
"then": [
{
"command": {
"devices": [
"-- ID Number Field Device --"
],
"commands": [
{
"component": "main",
"capability": "legendabsolute60149.numberFieldTwo",
"command": "setNumberFieldTwo",
"arguments": [
{
"device": {
"devices": [
"-- ID Temperature Measurement Device 2 --"
],
"component": "main",
"capability": "temperatureMeasurement",
"attribute": "temperature"
}
}
]
}
]
}
}
]
}
}
],
"sequence": {
"actions": "Parallel"
}
}
The Calculation Result is correct only after the values of both measurements have changed.
The Calculation Result can also be used in ST App Routines as Condition.
===============================================
It’s also possible to add Rules API rules using AWA.
Rules API rule template for AWA
{
"if": {
"changes": {
"operand": {
"device": {
"devices": [
"-- ID Temperature Measurement Device 1 --"
],
"component": "main",
"capability": "temperatureMeasurement",
"attribute": "temperature",
"trigger": "Always"
}
}
},
"then": [
{
"command": {
"devices": [
"-- ID Number Field Device --"
],
"commands": [
{
"component": "main",
"capability": "legendabsolute60149.numberFieldOne",
"command": "setNumberFieldOne",
"arguments": [
{
"device": {
"devices": [
"-- ID Temperature Measurement Device 1 --"
],
"component": "main",
"capability": "temperatureMeasurement",
"attribute": "temperature"
}
}
]
}
]
}
}
]
}
},
{
"if": {
"changes": {
"operand": {
"device": {
"devices": [
"-- ID Temperature Measurement Device 2 --"
],
"component": "main",
"capability": "temperatureMeasurement",
"attribute": "temperature",
"trigger": "Always"
}
}
},
"then": [
{
"command": {
"devices": [
"-- ID Number Field Device --"
],
"commands": [
{
"component": "main",
"capability": "legendabsolute60149.numberFieldTwo",
"command": "setNumberFieldTwo",
"arguments": [
{
"device": {
"devices": [
"-- ID Temperature Measurement Device 2 --"
],
"component": "main",
"capability": "temperatureMeasurement",
"attribute": "temperature"
}
}
]
}
]
}
}
]
}
}
Change to template your device IDs
– ID Temperature Measurement Device 1 – to your device ID; example 12345678-1234-1234-1234-123456789777
– ID Temperature Measurement Device 2 – to your device ID; example 12345678-1234-1234-1234-123456789888
– ID Number Field Device – to your device ID; example 12345678-1234-1234-1234-123456789999