check-health: always calculate on the lower voltage value

This makes sure an alert is triggered in both directions. Before we could have:

24.0V to 21.8V -> OK
21.8V to 24.0V -> Alert!
This commit is contained in:
Christian Hesse 2020-01-24 08:08:52 +01:00
parent 958bfa7ce8
commit 6e5e0e72bd

View file

@ -22,7 +22,7 @@
:if ([ :typeof ($CheckHealthLast->$Voltage) ] = "num" && \
[ :typeof ($CheckHealthCurrent->$Voltage) ] = "num") do={
:if ($CheckHealthLast->$Voltage * (100 + $CheckHealthVoltagePercent) / 100 < $CheckHealthCurrent->$Voltage || \
$CheckHealthLast->$Voltage * 100 / (100 + $CheckHealthVoltagePercent) > $CheckHealthCurrent->$Voltage) do={
$CheckHealthLast->$Voltage > $CheckHealthCurrent->$Voltage * (100 + $CheckHealthVoltagePercent) / 100) do={
$SendNotification ("Health warning: " . $Voltage) \
("The " . $Voltage . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
"old value: " . [ $FormatVoltage ($CheckHealthLast->$Voltage) ] . "\n" . \