sensorhandler: Fixes for dbus->type conversion.

This enables Get Type IPMI command.

Change-Id: I2e7ec6320d5e6a8eeb6566c6a4389b77c49bc92a
Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 9355fe3..1d0f4c9 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -154,6 +154,9 @@
     strncpy(interface->interface, str3, MAX_DBUS_PATH);
 
     interface->sensornumber = num;
+    // Make sure we know that the type hasn't been set, as newer codebase will
+    // set it automatically from the YAML at this step.
+    interface->sensortype = 0;
 
 final:
 
@@ -340,7 +343,13 @@
     // is not a supported sensor
     if (dbus_if.interface[0] == 0) { return 0;}
 
-    if (strstr(dbus_if.interface, "InventoryItem")) {
+    // Fetch type from interface itself.
+    if (dbus_if.sensortype != 0)
+    {
+        type = dbus_if.sensortype;
+    }
+    // Legacy codebase does not populate type during initial handling:
+    else if (strstr(dbus_if.interface, "InventoryItem")) {
         // InventoryItems are real frus.  So need to get the
         // fru_type property
         type = dbus_to_sensor_type_from_dbus(&dbus_if);