Fix threshold updating

The object type was never stored so it was never
updated. Also change threshold size to count of
thresholds for if anything has multiple thresholds.

Tested-by: set thresholds for front panel temp

Change-Id: I0949261b87336eb4a85cf596805c02683fb30d9b
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/Thresholds.hpp b/include/Thresholds.hpp
index cd1e3b5..22943c9 100644
--- a/include/Thresholds.hpp
+++ b/include/Thresholds.hpp
@@ -52,7 +52,8 @@
 
 void persistThreshold(const std::string& baseInterface, const std::string& path,
                       const thresholds::Threshold& threshold,
-                      std::shared_ptr<sdbusplus::asio::connection>& conn);
+                      std::shared_ptr<sdbusplus::asio::connection>& conn,
+                      size_t thresholdCount);
 
 void updateThresholds(Sensor* sensor);
 // returns false if a critical threshold has been crossed, true otherwise
diff --git a/include/sensor.hpp b/include/sensor.hpp
index de790c8..bba2c4d 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -11,8 +11,9 @@
            const std::string& configurationPath, const std::string& objectType,
            const double max, const double min) :
         name(name),
-        path(path), thresholds(std::move(thresholdData)),
-        configurationPath(configurationPath), maxValue(max), minValue(min)
+        path(path), configurationPath(configurationPath),
+        objectType(objectType), thresholds(std::move(thresholdData)),
+        maxValue(max), minValue(min)
     {
     }
     virtual ~Sensor() = default;
@@ -105,7 +106,8 @@
                     oldValue = request; // todo, just let the config do this?
                     threshold.value = request;
                     thresholds::persistThreshold(configurationPath, objectType,
-                                                 threshold, conn);
+                                                 threshold, conn,
+                                                 thresholds.size());
                     return 1;
                 });
             iface->register_property(alarm, false);
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index 49dca1f..4932bce 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -8,8 +8,6 @@
 #include <sensor.hpp>
 
 static constexpr bool DEBUG = false;
-static constexpr size_t maxThresholds = 4;
-
 namespace thresholds
 {
 unsigned int toBusValue(const Level& level)
@@ -109,9 +107,10 @@
 
 void persistThreshold(const std::string& path, const std::string& baseInterface,
                       const thresholds::Threshold& threshold,
-                      std::shared_ptr<sdbusplus::asio::connection>& conn)
+                      std::shared_ptr<sdbusplus::asio::connection>& conn,
+                      size_t thresholdCount)
 {
-    for (int ii = 0; ii < maxThresholds; ii++)
+    for (int ii = 0; ii < thresholdCount; ii++)
     {
         std::string thresholdInterface =
             baseInterface + ".Thresholds" + std::to_string(ii);