sensor: Fix set sensor reading for analog sensors

Tested: Set temperature sensor to sensor object

Change-Id: I77b8dcd6f298ca7b09aac475c2e8da4af5825940
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index a3253b9..e36b71a 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -271,25 +271,19 @@
 ipmi_ret_t readingData(const SetSensorReadingReq& cmdData,
                        const Info& sensorInfo)
 {
-    auto msg = makeDbusMsg(
-                   "org.freedesktop.DBus.Properties",
-                   sensorInfo.sensorPath,
-                   "Set",
-                   sensorInfo.sensorInterface);
+    T raw_value = (sensorInfo.coefficientM * cmdData.reading) +
+                  sensorInfo.scaledOffset;
+
+    raw_value *= pow(10, sensorInfo.exponentR - sensorInfo.scale);
+
+    auto msg = makeDbusMsg("org.freedesktop.DBus.Properties",
+                           sensorInfo.sensorPath,
+                           "Set",
+                           sensorInfo.sensorInterface);
 
     const auto& interface = sensorInfo.propertyInterfaces.begin();
     msg.append(interface->first);
 
-    ipmi::sensor::Multiplier m = sensorInfo.coefficientM;
-    if (0 == m)
-    {
-        m = 1;  // Avoid * 0
-    }
-
-    // TODO: Refactor this into a generated function depending on the type
-    // of conversion for the value between IPMI and dbus.
-    T raw_value = (m * cmdData.reading) + sensorInfo.scaledOffset;
-
     for (const auto& property : interface->second)
     {
         msg.append(property.first);