Exit Air: Allow destruction

In the current mode a configuration reload would not
cause thresholds to update. Allow destruction so we
reload the interfaces each time.

Change-Id: I1fec9c6fc9ae1a20a95477157ad399c73e3f9c75
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/ExitAirTempSensor.hpp b/include/ExitAirTempSensor.hpp
index e06c20d..24f87db 100644
--- a/include/ExitAirTempSensor.hpp
+++ b/include/ExitAirTempSensor.hpp
@@ -71,6 +71,7 @@
     double inletTemp = std::numeric_limits<double>::quiet_NaN();
 
     std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
+    sdbusplus::asio::object_server& objServer;
     std::chrono::time_point<std::chrono::system_clock> lastTime;
     double getTotalCFM(void);
     bool calculate(double& val);
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 06eddc0..d3fb6c1 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -203,7 +203,7 @@
 
         if (findRange == tachRanges.end())
         {
-            std::cerr << "Can't find " << tachName << "in ranges\n";
+            std::cerr << "Can't find " << tachName << " in ranges\n";
             return false; // haven't gotten a max / min
         }
 
@@ -269,7 +269,7 @@
            "" /* todo: remove arg from base*/, std::move(thresholds),
            sensorConfiguration, "xyz.openbmc_project.Configuration.ExitAirTemp",
            exitAirMaxReading, exitAirMinReading),
-    dbusConnection(conn)
+    dbusConnection(conn), objServer(objectServer)
 {
     sensorInterface = objectServer.add_interface(
         "/xyz/openbmc_project/sensors/temperature/" + name,
@@ -294,7 +294,9 @@
 
 ExitAirTempSensor::~ExitAirTempSensor()
 {
-    // this sensor currently isn't destroyed so we don't care
+    objServer.remove_interface(thresholdInterfaceWarning);
+    objServer.remove_interface(thresholdInterfaceCritical);
+    objServer.remove_interface(sensorInterface);
 }
 
 void ExitAirTempSensor::setupMatches(void)
@@ -551,19 +553,12 @@
                         std::vector<thresholds::Threshold> sensorThresholds;
                         parseThresholdsFromConfig(pathPair.second,
                                                   sensorThresholds);
-                        if (!exitAirSensor)
-                        {
-                            std::string name =
-                                loadVariant<std::string>(entry.second, "Name");
-                            exitAirSensor = std::make_shared<ExitAirTempSensor>(
-                                dbusConnection, name, pathPair.first.str,
-                                objectServer, std::move(sensorThresholds));
-                        }
-                        else
-                        {
-                            exitAirSensor->thresholds = sensorThresholds;
-                        }
 
+                        std::string name =
+                            loadVariant<std::string>(entry.second, "Name");
+                        exitAirSensor = std::make_shared<ExitAirTempSensor>(
+                            dbusConnection, name, pathPair.first.str,
+                            objectServer, std::move(sensorThresholds));
                         exitAirSensor->powerFactorMin =
                             loadVariant<double>(entry.second, "PowerFactorMin");
                         exitAirSensor->powerFactorMax =