ExternalSensor: Set available to true when a valid value is set

Ensure that the sensor's available status is marked as true when the
external set method is triggered and the new value is not infinite or
NaN.

This change allows dependent services (e.g., phosphor-pid-controller) to
correctly recognize the sensor as available once it receives a valid
reading.

Change-Id: I8d48c4c207aa88dca50c91af605111582593aa30
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
diff --git a/src/external/ExternalSensor.cpp b/src/external/ExternalSensor.cpp
index 3a6a407..51a439a 100644
--- a/src/external/ExternalSensor.cpp
+++ b/src/external/ExternalSensor.cpp
@@ -10,6 +10,7 @@
 #include <sdbusplus/asio/object_server.hpp>
 
 #include <chrono>
+#include <cmath>
 #include <cstddef>
 #include <functional>
 #include <limits>
@@ -195,6 +196,11 @@
                    "VALUE", value);
     }
 
+    if (std::isfinite(value))
+    {
+        markAvailable(true);
+    }
+
     auto now = std::chrono::steady_clock::now();
 
     writeBegin(now);