thresholds: support hysteresis field if supplied
At the moment dbus-sensors that use thresholds use a default hysteresis
of (max - min) * 0.01. If a hysteresis field is specified for a
threshold that is not NaN, use that instead.
Tested by giving a sensor multiple thresholds, with and without
hysteresis, changing the value of the sensor and observing that the
threshold alarms are asserted and deasserted as expected.
Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com>
Change-Id: I9c6c2ef3bb034157b0a6b3bd5c359dae7592d85b
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 3ac7774..3df7118 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -230,6 +230,10 @@
});
for (auto& threshold : thresholds)
{
+ if (std::isnan(threshold.hysteresis))
+ {
+ threshold.hysteresis = hysteresisTrigger;
+ }
std::shared_ptr<sdbusplus::asio::dbus_interface> iface;
std::string level;
std::string alarm;