Add reporting of Relative Humidity for Hwmon
By checking for IIO devies of in_humidityrelative_input or
in_humidityrelative_raw we add to the reading of those devices too.
Also the units for "Percent" now have become overloaded, as humidity
is "Percent" Relative Humidity and not a a Utilization. I believe
Utilization should NOT be a "Percent" but a fraction from 0 to 1.
Tested: on Rainier's Blyth and Everest's Storm King Op Panels
busctl introspect --no-pager xyz.openbmc_project.HwmonTempSensor \
/xyz/openbmc_project/sensors/humidity/Relative_Humidity
Results consistent with location of the systems.
Signed-off-by: Bruce Mitchell <bruce.mitchell@linux.vnet.ibm.com>
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I62c2464177542e7a2234f277be30d4fa4a849381
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index dbccd27..b6bf910 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -41,6 +41,9 @@
static constexpr double maxValuePressure = 120000; // Pascals
static constexpr double minValuePressure = 30000; // Pascals
+static constexpr double maxValueRelativeHumidity = 100; // PercentRH
+static constexpr double minValueRelativeHumidity = 0; // PercentRH
+
static constexpr double maxValueTemperature = 127; // DegreesC
static constexpr double minValueTemperature = -128; // DegreesC
@@ -130,6 +133,16 @@
tmpSensorParameters.typeName = "pressure";
tmpSensorParameters.units = sensor_paths::unitPascals;
}
+ else if (path.filename() == "in_humidityrelative_input" ||
+ path.filename() == "in_humidityrelative_raw")
+ {
+ tmpSensorParameters.minValue = minValueRelativeHumidity;
+ tmpSensorParameters.maxValue = maxValueRelativeHumidity;
+ // Relative Humidity are read in milli-percent, we need percent.
+ tmpSensorParameters.scaleValue *= 0.001;
+ tmpSensorParameters.typeName = "humidity";
+ tmpSensorParameters.units = "PercentRH";
+ }
else
{
// Temperatures are read in milli degrees Celsius,
@@ -166,6 +179,7 @@
fs::path root("/sys/bus/iio/devices");
findFiles(root, R"(in_temp\d*_(input|raw))", paths);
findFiles(root, R"(in_pressure\d*_(input|raw))", paths);
+ findFiles(root, R"(in_humidityrelative\d*_(input|raw))", paths);
findFiles(fs::path("/sys/class/hwmon"), R"(temp\d+_input)", paths);
if (paths.empty())
@@ -270,7 +284,8 @@
// Temperature has "Name", pressure has "Name1"
auto findSensorName = baseConfigMap->find("Name");
- if (thisSensorParameters.typeName == "pressure")
+ if (thisSensorParameters.typeName == "pressure" ||
+ thisSensorParameters.typeName == "humidity")
{
findSensorName = baseConfigMap->find("Name1");
}