Skip to content

Compare

Threshold-based change detection.

1 modules

ModuleDescription
Detect ChangeDetect if a value has changed beyond threshold (by amount or percentage)

Modules

Detect Change

compare.change

Detect if a value has changed beyond threshold (by amount or percentage)

Parameters:

NameTypeRequiredDefaultDescription
current_valuenumberYes-The current/new value to compare
previous_valuenumberYes-The previous/old value to compare against
modeselect (percent, absolute, any)NopercentThe previous/old value to compare against
thresholdnumberNo5Minimum change to trigger (5 = 5% or 5 units)
directionselect (both, up, down)NobothWhich direction of change to detect

Output:

FieldTypeDescription
okbooleanWhether the operation succeeded
changedbooleanWhether the operation succeeded
directionstringWhether the operation succeeded
change_percentnumberDirection of change:
change_absolutenumberPercentage change (positive = up, negative = down)
current_valuenumberThe current value
previous_valuenumberThe previous value
summarystringThe current value

Example: Crypto price alert (5% change)

yaml
current_value: 44500
previous_value: 42000
mode: percent
threshold: 5
direction: both

Example: Stock drop alert

yaml
current_value: 145.5
previous_value: 152.3
mode: percent
threshold: 3
direction: down

Example: Temperature change (absolute)

yaml
current_value: 32
previous_value: 25
mode: absolute
threshold: 5
direction: up

Released under the Apache 2.0 License.