Factor out getPowerState() helper function

This same pattern had been open-coded in many of the sensor daemons;
let's reduce the duplication a bit.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I8556af30fdcd53cdf06e5a4911f9152d3265c7af
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 1683e39..0e4deea 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -484,14 +484,7 @@
         checkGroupEvent(directory.string(), groupEventMatch,
                         groupEventPathList);
 
-        PowerState readState = PowerState::always;
-        auto findPowerOn = baseConfig->second.find("PowerState");
-        if (findPowerOn != baseConfig->second.end())
-        {
-            std::string powerState =
-                std::visit(VariantToStringVisitor(), findPowerOn->second);
-            setReadState(powerState, readState);
-        }
+        PowerState readState = getPowerState(baseConfig->second);
 
         /* Check if there are more sensors in the same interface */
         int i = 1;