Deassert thresholds when sensor is unavailable
Some dbus-sensors applications allows you to specify "PowerState"
parameter for its sensors in the configarition. With this parameter
sensor is sampled/checked against its thresholds only if certain
system conditions are met.
Therefore if sensor becomes unavailable because of the "PowerState"
parameter, all its threshold states must be deasserted.
Tested: tested on the AMD DaytonaX CRB. It is a 2-socket board. For
the test only 1 CPU was installed. In this case voltage sensors that
measure voltages for CPU2 and configured with '"PowerState": "On"'
assert their thresholds when the system is powered on.
Before the patch even if the system is powered off after that, these
voltage sensors stay with the asserted thresholds. Because of that
webui will continue to displays these sensors with a 'Critical' status.
After the patch if system is powered off, the voltage sensors deasset
all their thresholds and the sensors correctly change their status to
'OK' in webui.
Change-Id: Id6a33f15c18ca7aa30e8c449ab9c9e239673dd1f
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
diff --git a/src/sensor.hpp b/src/sensor.hpp
index d2ba8af..434d81d 100644
--- a/src/sensor.hpp
+++ b/src/sensor.hpp
@@ -490,6 +490,11 @@
if (!readingStateGood())
{
markAvailable(false);
+ for (auto& threshold : thresholds)
+ {
+ assertThresholds(this, value, threshold.level,
+ threshold.direction, false);
+ }
updateValueProperty(std::numeric_limits<double>::quiet_NaN());
return;
}