diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
 IndentWrappedFunctionNames: true
 InsertNewlineAtEOF: true
 KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
 LineEnding: LF
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
@@ -98,13 +98,14 @@
 ObjCSpaceBeforeProtocolList: true
 PackConstructorInitializers: BinPack
 PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
 PenaltyBreakComment: 300
 PenaltyBreakFirstLessLess: 120
 PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
 PenaltyExcessCharacter: 1000000
 PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
 PointerAlignment: Left
 QualifierAlignment: Left
 ReferenceAlignment: Left
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index a025419..0b3fd28 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -48,15 +48,14 @@
 static constexpr double maxVoltageReading = 1.8; // pre sensor scaling
 static constexpr double minVoltageReading = 0;
 
-ADCSensor::ADCSensor(const std::string& path,
-                     sdbusplus::asio::object_server& objectServer,
-                     std::shared_ptr<sdbusplus::asio::connection>& conn,
-                     boost::asio::io_context& io, const std::string& sensorName,
-                     std::vector<thresholds::Threshold>&& thresholdsIn,
-                     const double scaleFactor, const float pollRate,
-                     PowerState readState,
-                     const std::string& sensorConfiguration,
-                     std::optional<BridgeGpio>&& bridgeGpio) :
+ADCSensor::ADCSensor(
+    const std::string& path, sdbusplus::asio::object_server& objectServer,
+    std::shared_ptr<sdbusplus::asio::connection>& conn,
+    boost::asio::io_context& io, const std::string& sensorName,
+    std::vector<thresholds::Threshold>&& thresholdsIn, const double scaleFactor,
+    const float pollRate, PowerState readState,
+    const std::string& sensorConfiguration,
+    std::optional<BridgeGpio>&& bridgeGpio) :
     Sensor(escapeName(sensorName), std::move(thresholdsIn), sensorConfiguration,
            "ADC", false, false, maxVoltageReading / scaleFactor,
            minVoltageReading / scaleFactor, conn, readState),
@@ -121,27 +120,27 @@
             std::chrono::milliseconds(bridgeGpio->setupTimeMs));
         waitTimer.async_wait(
             [weakRef, buffer](const boost::system::error_code& ec) {
-            std::shared_ptr<ADCSensor> self = weakRef.lock();
-            if (ec == boost::asio::error::operation_aborted)
-            {
-                return; // we're being canceled
-            }
+                std::shared_ptr<ADCSensor> self = weakRef.lock();
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    return; // we're being canceled
+                }
 
-            if (self)
-            {
-                boost::asio::async_read_until(
-                    self->inputDev, *buffer, '\n',
-                    [weakRef, buffer](const boost::system::error_code& ec,
-                                      std::size_t /*bytes_transfered*/) {
-                    std::shared_ptr<ADCSensor> self = weakRef.lock();
-                    if (self)
-                    {
-                        self->readBuf = buffer;
-                        self->handleResponse(ec);
-                    }
-                });
-            }
-        });
+                if (self)
+                {
+                    boost::asio::async_read_until(
+                        self->inputDev, *buffer, '\n',
+                        [weakRef, buffer](const boost::system::error_code& ec,
+                                          std::size_t /*bytes_transfered*/) {
+                            std::shared_ptr<ADCSensor> self = weakRef.lock();
+                            if (self)
+                            {
+                                self->readBuf = buffer;
+                                self->handleResponse(ec);
+                            }
+                        });
+                }
+            });
     }
     else
     {
@@ -149,13 +148,13 @@
             inputDev, *buffer, '\n',
             [weakRef, buffer](const boost::system::error_code& ec,
                               std::size_t /*bytes_transfered*/) {
-            std::shared_ptr<ADCSensor> self = weakRef.lock();
-            if (self)
-            {
-                self->readBuf = buffer;
-                self->handleResponse(ec);
-            }
-        });
+                std::shared_ptr<ADCSensor> self = weakRef.lock();
+                if (self)
+                {
+                    self->readBuf = buffer;
+                    self->handleResponse(ec);
+                }
+            });
     }
 }
 
diff --git a/src/ADCSensor.hpp b/src/ADCSensor.hpp
index 81f630d..f562405 100644
--- a/src/ADCSensor.hpp
+++ b/src/ADCSensor.hpp
@@ -29,11 +29,11 @@
         {
             try
             {
-                line.request({"adcsensor",
-                              gpiod::line_request::DIRECTION_OUTPUT,
-                              polarity == gpiod::line::ACTIVE_HIGH
-                                  ? 0
-                                  : gpiod::line_request::FLAG_ACTIVE_LOW});
+                line.request(
+                    {"adcsensor", gpiod::line_request::DIRECTION_OUTPUT,
+                     polarity == gpiod::line::ACTIVE_HIGH
+                         ? 0
+                         : gpiod::line_request::FLAG_ACTIVE_LOW});
             }
             catch (const std::system_error&)
             {
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index 723ff01..ec38908 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -98,217 +98,220 @@
         dbusConnection,
         [&io, &objectServer, &sensors, &dbusConnection, sensorsChanged,
          updateType](const ManagedObjectType& sensorConfigurations) {
-        bool firstScan = sensorsChanged == nullptr;
-        std::vector<fs::path> paths;
-        if (!findFiles(fs::path("/sys/class/hwmon"), R"(in\d+_input)", paths))
-        {
-            std::cerr << "No adc sensors in system\n";
-            return;
-        }
-
-        // iterate through all found adc sensors, and try to match them with
-        // configuration
-        for (auto& path : paths)
-        {
-            if (!isAdc(path.parent_path()))
+            bool firstScan = sensorsChanged == nullptr;
+            std::vector<fs::path> paths;
+            if (!findFiles(fs::path("/sys/class/hwmon"), R"(in\d+_input)",
+                           paths))
             {
-                continue;
+                std::cerr << "No adc sensors in system\n";
+                return;
             }
-            std::smatch match;
-            std::string pathStr = path.string();
 
-            std::regex_search(pathStr, match, inputRegex);
-            std::string indexStr = *(match.begin() + 1);
-
-            // convert to 0 based
-            size_t index = std::stoul(indexStr) - 1;
-
-            const SensorData* sensorData = nullptr;
-            const std::string* interfacePath = nullptr;
-            const std::pair<std::string, SensorBaseConfigMap>*
-                baseConfiguration = nullptr;
-            for (const auto& [path, cfgData] : sensorConfigurations)
+            // iterate through all found adc sensors, and try to match them with
+            // configuration
+            for (auto& path : paths)
             {
-                // clear it out each loop
-                baseConfiguration = nullptr;
-
-                // find base configuration
-                for (const char* type : sensorTypes)
+                if (!isAdc(path.parent_path()))
                 {
-                    auto sensorBase = cfgData.find(configInterfaceName(type));
-                    if (sensorBase != cfgData.end())
+                    continue;
+                }
+                std::smatch match;
+                std::string pathStr = path.string();
+
+                std::regex_search(pathStr, match, inputRegex);
+                std::string indexStr = *(match.begin() + 1);
+
+                // convert to 0 based
+                size_t index = std::stoul(indexStr) - 1;
+
+                const SensorData* sensorData = nullptr;
+                const std::string* interfacePath = nullptr;
+                const std::pair<std::string, SensorBaseConfigMap>*
+                    baseConfiguration = nullptr;
+                for (const auto& [path, cfgData] : sensorConfigurations)
+                {
+                    // clear it out each loop
+                    baseConfiguration = nullptr;
+
+                    // find base configuration
+                    for (const char* type : sensorTypes)
                     {
-                        baseConfiguration = &(*sensorBase);
-                        break;
-                    }
-                }
-                if (baseConfiguration == nullptr)
-                {
-                    continue;
-                }
-                auto findIndex = baseConfiguration->second.find("Index");
-                if (findIndex == baseConfiguration->second.end())
-                {
-                    std::cerr << "Base configuration missing Index"
-                              << baseConfiguration->first << "\n";
-                    continue;
-                }
-
-                unsigned int number = std::visit(VariantToUnsignedIntVisitor(),
-                                                 findIndex->second);
-
-                if (number != index)
-                {
-                    continue;
-                }
-
-                sensorData = &cfgData;
-                interfacePath = &path.str;
-                break;
-            }
-            if (sensorData == nullptr)
-            {
-                if constexpr (debug)
-                {
-                    std::cerr << "failed to find match for " << path.string()
-                              << "\n";
-                }
-                continue;
-            }
-
-            if (baseConfiguration == nullptr)
-            {
-                std::cerr << "error finding base configuration for"
-                          << path.string() << "\n";
-                continue;
-            }
-
-            auto findSensorName = baseConfiguration->second.find("Name");
-            if (findSensorName == baseConfiguration->second.end())
-            {
-                std::cerr << "could not determine configuration name for "
-                          << path.string() << "\n";
-                continue;
-            }
-            std::string sensorName =
-                std::get<std::string>(findSensorName->second);
-
-            // on rescans, only update sensors we were signaled by
-            auto findSensor = sensors.find(sensorName);
-            if (!firstScan && findSensor != sensors.end())
-            {
-                bool found = false;
-                for (auto it = sensorsChanged->begin();
-                     it != sensorsChanged->end(); it++)
-                {
-                    if (findSensor->second &&
-                        it->ends_with(findSensor->second->name))
-                    {
-                        sensorsChanged->erase(it);
-                        findSensor->second = nullptr;
-                        found = true;
-                        break;
-                    }
-                }
-                if (!found)
-                {
-                    continue;
-                }
-            }
-
-            auto findCPU = baseConfiguration->second.find("CPURequired");
-            if (findCPU != baseConfiguration->second.end())
-            {
-                size_t index = std::visit(VariantToIntVisitor(),
-                                          findCPU->second);
-                auto presenceFind = cpuPresence.find(index);
-                if (presenceFind == cpuPresence.end())
-                {
-                    continue; // no such cpu
-                }
-                if (!presenceFind->second)
-                {
-                    continue; // cpu not installed
-                }
-            }
-            else if (updateType == UpdateType::cpuPresenceChange)
-            {
-                continue;
-            }
-
-            std::vector<thresholds::Threshold> sensorThresholds;
-            if (!parseThresholdsFromConfig(*sensorData, sensorThresholds))
-            {
-                std::cerr << "error populating thresholds for " << sensorName
-                          << "\n";
-            }
-
-            auto findScaleFactor =
-                baseConfiguration->second.find("ScaleFactor");
-            float scaleFactor = 1.0;
-            if (findScaleFactor != baseConfiguration->second.end())
-            {
-                scaleFactor = std::visit(VariantToFloatVisitor(),
-                                         findScaleFactor->second);
-                // scaleFactor is used in division
-                if (scaleFactor == 0.0F)
-                {
-                    scaleFactor = 1.0;
-                }
-            }
-
-            float pollRate = getPollRate(baseConfiguration->second,
-                                         pollRateDefault);
-            PowerState readState = getPowerState(baseConfiguration->second);
-
-            auto& sensor = sensors[sensorName];
-            sensor = nullptr;
-
-            std::optional<BridgeGpio> bridgeGpio;
-            for (const auto& [key, cfgMap] : *sensorData)
-            {
-                if (key.find("BridgeGpio") != std::string::npos)
-                {
-                    auto findName = cfgMap.find("Name");
-                    if (findName != cfgMap.end())
-                    {
-                        std::string gpioName = std::visit(
-                            VariantToStringVisitor(), findName->second);
-
-                        int polarity = gpiod::line::ACTIVE_HIGH;
-                        auto findPolarity = cfgMap.find("Polarity");
-                        if (findPolarity != cfgMap.end())
+                        auto sensorBase =
+                            cfgData.find(configInterfaceName(type));
+                        if (sensorBase != cfgData.end())
                         {
-                            if (std::string("Low") ==
-                                std::visit(VariantToStringVisitor(),
-                                           findPolarity->second))
-                            {
-                                polarity = gpiod::line::ACTIVE_LOW;
-                            }
+                            baseConfiguration = &(*sensorBase);
+                            break;
                         }
-
-                        float setupTime = gpioBridgeSetupTimeDefault;
-                        auto findSetupTime = cfgMap.find("SetupTime");
-                        if (findSetupTime != cfgMap.end())
-                        {
-                            setupTime = std::visit(VariantToFloatVisitor(),
-                                                   findSetupTime->second);
-                        }
-
-                        bridgeGpio = BridgeGpio(gpioName, polarity, setupTime);
+                    }
+                    if (baseConfiguration == nullptr)
+                    {
+                        continue;
+                    }
+                    auto findIndex = baseConfiguration->second.find("Index");
+                    if (findIndex == baseConfiguration->second.end())
+                    {
+                        std::cerr << "Base configuration missing Index"
+                                  << baseConfiguration->first << "\n";
+                        continue;
                     }
 
+                    unsigned int number = std::visit(
+                        VariantToUnsignedIntVisitor(), findIndex->second);
+
+                    if (number != index)
+                    {
+                        continue;
+                    }
+
+                    sensorData = &cfgData;
+                    interfacePath = &path.str;
                     break;
                 }
-            }
+                if (sensorData == nullptr)
+                {
+                    if constexpr (debug)
+                    {
+                        std::cerr << "failed to find match for "
+                                  << path.string() << "\n";
+                    }
+                    continue;
+                }
 
-            sensor = std::make_shared<ADCSensor>(
-                path.string(), objectServer, dbusConnection, io, sensorName,
-                std::move(sensorThresholds), scaleFactor, pollRate, readState,
-                *interfacePath, std::move(bridgeGpio));
-            sensor->setupRead();
-        }
-    });
+                if (baseConfiguration == nullptr)
+                {
+                    std::cerr << "error finding base configuration for"
+                              << path.string() << "\n";
+                    continue;
+                }
+
+                auto findSensorName = baseConfiguration->second.find("Name");
+                if (findSensorName == baseConfiguration->second.end())
+                {
+                    std::cerr << "could not determine configuration name for "
+                              << path.string() << "\n";
+                    continue;
+                }
+                std::string sensorName =
+                    std::get<std::string>(findSensorName->second);
+
+                // on rescans, only update sensors we were signaled by
+                auto findSensor = sensors.find(sensorName);
+                if (!firstScan && findSensor != sensors.end())
+                {
+                    bool found = false;
+                    for (auto it = sensorsChanged->begin();
+                         it != sensorsChanged->end(); it++)
+                    {
+                        if (findSensor->second &&
+                            it->ends_with(findSensor->second->name))
+                        {
+                            sensorsChanged->erase(it);
+                            findSensor->second = nullptr;
+                            found = true;
+                            break;
+                        }
+                    }
+                    if (!found)
+                    {
+                        continue;
+                    }
+                }
+
+                auto findCPU = baseConfiguration->second.find("CPURequired");
+                if (findCPU != baseConfiguration->second.end())
+                {
+                    size_t index =
+                        std::visit(VariantToIntVisitor(), findCPU->second);
+                    auto presenceFind = cpuPresence.find(index);
+                    if (presenceFind == cpuPresence.end())
+                    {
+                        continue; // no such cpu
+                    }
+                    if (!presenceFind->second)
+                    {
+                        continue; // cpu not installed
+                    }
+                }
+                else if (updateType == UpdateType::cpuPresenceChange)
+                {
+                    continue;
+                }
+
+                std::vector<thresholds::Threshold> sensorThresholds;
+                if (!parseThresholdsFromConfig(*sensorData, sensorThresholds))
+                {
+                    std::cerr << "error populating thresholds for "
+                              << sensorName << "\n";
+                }
+
+                auto findScaleFactor =
+                    baseConfiguration->second.find("ScaleFactor");
+                float scaleFactor = 1.0;
+                if (findScaleFactor != baseConfiguration->second.end())
+                {
+                    scaleFactor = std::visit(VariantToFloatVisitor(),
+                                             findScaleFactor->second);
+                    // scaleFactor is used in division
+                    if (scaleFactor == 0.0F)
+                    {
+                        scaleFactor = 1.0;
+                    }
+                }
+
+                float pollRate =
+                    getPollRate(baseConfiguration->second, pollRateDefault);
+                PowerState readState = getPowerState(baseConfiguration->second);
+
+                auto& sensor = sensors[sensorName];
+                sensor = nullptr;
+
+                std::optional<BridgeGpio> bridgeGpio;
+                for (const auto& [key, cfgMap] : *sensorData)
+                {
+                    if (key.find("BridgeGpio") != std::string::npos)
+                    {
+                        auto findName = cfgMap.find("Name");
+                        if (findName != cfgMap.end())
+                        {
+                            std::string gpioName = std::visit(
+                                VariantToStringVisitor(), findName->second);
+
+                            int polarity = gpiod::line::ACTIVE_HIGH;
+                            auto findPolarity = cfgMap.find("Polarity");
+                            if (findPolarity != cfgMap.end())
+                            {
+                                if (std::string("Low") ==
+                                    std::visit(VariantToStringVisitor(),
+                                               findPolarity->second))
+                                {
+                                    polarity = gpiod::line::ACTIVE_LOW;
+                                }
+                            }
+
+                            float setupTime = gpioBridgeSetupTimeDefault;
+                            auto findSetupTime = cfgMap.find("SetupTime");
+                            if (findSetupTime != cfgMap.end())
+                            {
+                                setupTime = std::visit(VariantToFloatVisitor(),
+                                                       findSetupTime->second);
+                            }
+
+                            bridgeGpio =
+                                BridgeGpio(gpioName, polarity, setupTime);
+                        }
+
+                        break;
+                    }
+                }
+
+                sensor = std::make_shared<ADCSensor>(
+                    path.string(), objectServer, dbusConnection, io, sensorName,
+                    std::move(sensorThresholds), scaleFactor, pollRate,
+                    readState, *interfacePath, std::move(bridgeGpio));
+                sensor->setupRead();
+            }
+        });
 
     getter->getConfiguration(
         std::vector<std::string>{sensorTypes.begin(), sensorTypes.end()});
@@ -334,81 +337,81 @@
     boost::asio::steady_timer filterTimer(io);
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&](sdbusplus::message_t& message) {
-        if (message.is_method_error())
-        {
-            std::cerr << "callback method error\n";
-            return;
-        }
-        sensorsChanged->insert(message.get_path());
-        // this implicitly cancels the timer
-        filterTimer.expires_after(std::chrono::seconds(1));
+            if (message.is_method_error())
+            {
+                std::cerr << "callback method error\n";
+                return;
+            }
+            sensorsChanged->insert(message.get_path());
+            // this implicitly cancels the timer
+            filterTimer.expires_after(std::chrono::seconds(1));
 
-        filterTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
-            {
-                /* we were canceled*/
-                return;
-            }
-            if (ec)
-            {
-                std::cerr << "timer error\n";
-                return;
-            }
-            createSensors(io, objectServer, sensors, systemBus, sensorsChanged,
-                          UpdateType::init);
-        });
-    };
+            filterTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    /* we were canceled*/
+                    return;
+                }
+                if (ec)
+                {
+                    std::cerr << "timer error\n";
+                    return;
+                }
+                createSensors(io, objectServer, sensors, systemBus,
+                              sensorsChanged, UpdateType::init);
+            });
+        };
 
     boost::asio::steady_timer cpuFilterTimer(io);
     std::function<void(sdbusplus::message_t&)> cpuPresenceHandler =
         [&](sdbusplus::message_t& message) {
-        std::string path = message.get_path();
-        boost::to_lower(path);
+            std::string path = message.get_path();
+            boost::to_lower(path);
 
-        sdbusplus::message::object_path cpuPath(path);
-        std::string cpuName = cpuPath.filename();
-        if (!cpuName.starts_with("cpu"))
-        {
-            return; // not interested
-        }
-        size_t index = 0;
-        try
-        {
-            index = std::stoi(path.substr(path.size() - 1));
-        }
-        catch (const std::invalid_argument&)
-        {
-            std::cerr << "Found invalid path " << path << "\n";
-            return;
-        }
-
-        std::string objectName;
-        boost::container::flat_map<std::string, std::variant<bool>> values;
-        message.read(objectName, values);
-        auto findPresence = values.find("Present");
-        if (findPresence != values.end())
-        {
-            cpuPresence[index] = std::get<bool>(findPresence->second);
-        }
-
-        // this implicitly cancels the timer
-        cpuFilterTimer.expires_after(std::chrono::seconds(1));
-
-        cpuFilterTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
+            sdbusplus::message::object_path cpuPath(path);
+            std::string cpuName = cpuPath.filename();
+            if (!cpuName.starts_with("cpu"))
             {
-                /* we were canceled*/
+                return; // not interested
+            }
+            size_t index = 0;
+            try
+            {
+                index = std::stoi(path.substr(path.size() - 1));
+            }
+            catch (const std::invalid_argument&)
+            {
+                std::cerr << "Found invalid path " << path << "\n";
                 return;
             }
-            if (ec)
+
+            std::string objectName;
+            boost::container::flat_map<std::string, std::variant<bool>> values;
+            message.read(objectName, values);
+            auto findPresence = values.find("Present");
+            if (findPresence != values.end())
             {
-                std::cerr << "timer error\n";
-                return;
+                cpuPresence[index] = std::get<bool>(findPresence->second);
             }
-            createSensors(io, objectServer, sensors, systemBus, nullptr,
-                          UpdateType::cpuPresenceChange);
-        });
-    };
+
+            // this implicitly cancels the timer
+            cpuFilterTimer.expires_after(std::chrono::seconds(1));
+
+            cpuFilterTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    /* we were canceled*/
+                    return;
+                }
+                if (ec)
+                {
+                    std::cerr << "timer error\n";
+                    return;
+                }
+                createSensors(io, objectServer, sensors, systemBus, nullptr,
+                              UpdateType::cpuPresenceChange);
+            });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(*systemBus, sensorTypes, eventHandler);
diff --git a/src/ChassisIntrusionSensor.cpp b/src/ChassisIntrusionSensor.cpp
index 52c254a..2c1e391 100644
--- a/src/ChassisIntrusionSensor.cpp
+++ b/src/ChassisIntrusionSensor.cpp
@@ -199,28 +199,30 @@
 
 void ChassisIntrusionGpioSensor::pollSensorStatus()
 {
-    mGpioFd.async_wait(boost::asio::posix::stream_descriptor::wait_read,
-                       [this](const boost::system::error_code& ec) {
-        if (ec == boost::system::errc::bad_file_descriptor)
-        {
-            return; // we're being destroyed
-        }
-
-        if (ec)
-        {
-            std::cerr << "Error on GPIO based intrusion sensor wait event\n";
-        }
-        else
-        {
-            int value = readSensor();
-            if (value >= 0)
+    mGpioFd.async_wait(
+        boost::asio::posix::stream_descriptor::wait_read,
+        [this](const boost::system::error_code& ec) {
+            if (ec == boost::system::errc::bad_file_descriptor)
             {
-                updateValue(value);
+                return; // we're being destroyed
             }
-            // trigger next polling
-            pollSensorStatus();
-        }
-    });
+
+            if (ec)
+            {
+                std::cerr
+                    << "Error on GPIO based intrusion sensor wait event\n";
+            }
+            else
+            {
+                int value = readSensor();
+                if (value >= 0)
+                {
+                    updateValue(value);
+                }
+                // trigger next polling
+                pollSensorStatus();
+            }
+        });
 }
 
 int ChassisIntrusionHwmonSensor::readSensor()
@@ -349,8 +351,8 @@
     mIface->register_property(
         "Status", mValue,
         [&](const std::string& req, std::string& propertyValue) {
-        return setSensorValue(req, propertyValue);
-    });
+            return setSensorValue(req, propertyValue);
+        });
     std::string rearmStr = mAutoRearm ? autoRearmStr : manualRearmStr;
     mIface->register_property("Rearm", rearmStr);
     mIface->initialize();
@@ -359,8 +361,7 @@
 
 ChassisIntrusionSensor::ChassisIntrusionSensor(
     bool autoRearm, sdbusplus::asio::object_server& objServer) :
-    mValue(normalValStr),
-    mAutoRearm(autoRearm), mObjServer(objServer)
+    mValue(normalValStr), mAutoRearm(autoRearm), mObjServer(objServer)
 {
     mIface = mObjServer.add_interface("/xyz/openbmc_project/Chassis/Intrusion",
                                       "xyz.openbmc_project.Chassis.Intrusion");
@@ -369,14 +370,13 @@
 ChassisIntrusionPchSensor::ChassisIntrusionPchSensor(
     bool autoRearm, boost::asio::io_context& io,
     sdbusplus::asio::object_server& objServer, int busId, int slaveAddr) :
-    ChassisIntrusionSensor(autoRearm, objServer),
-    mPollTimer(io)
+    ChassisIntrusionSensor(autoRearm, objServer), mPollTimer(io)
 {
     if (busId < 0 || slaveAddr <= 0)
     {
-        throw std::invalid_argument("Invalid i2c bus " + std::to_string(busId) +
-                                    " address " + std::to_string(slaveAddr) +
-                                    "\n");
+        throw std::invalid_argument(
+            "Invalid i2c bus " + std::to_string(busId) + " address " +
+            std::to_string(slaveAddr) + "\n");
     }
 
     mSlaveAddr = slaveAddr;
@@ -413,14 +413,14 @@
 ChassisIntrusionGpioSensor::ChassisIntrusionGpioSensor(
     bool autoRearm, boost::asio::io_context& io,
     sdbusplus::asio::object_server& objServer, bool gpioInverted) :
-    ChassisIntrusionSensor(autoRearm, objServer),
-    mGpioInverted(gpioInverted), mGpioFd(io)
+    ChassisIntrusionSensor(autoRearm, objServer), mGpioInverted(gpioInverted),
+    mGpioFd(io)
 {
     mGpioLine = gpiod::find_line(mPinName);
     if (!mGpioLine)
     {
-        throw std::invalid_argument("Error finding gpio pin name: " + mPinName +
-                                    "\n");
+        throw std::invalid_argument(
+            "Error finding gpio pin name: " + mPinName + "\n");
     }
     mGpioLine.request(
         {"ChassisIntrusionSensor", gpiod::line_request::EVENT_BOTH_EDGES,
@@ -450,8 +450,8 @@
 
     if (paths.empty())
     {
-        throw std::invalid_argument("Hwmon file " + mHwmonName +
-                                    " can't be found in sysfs\n");
+        throw std::invalid_argument(
+            "Hwmon file " + mHwmonName + " can't be found in sysfs\n");
     }
 
     if (paths.size() > 1)
diff --git a/src/DeviceMgmt.cpp b/src/DeviceMgmt.cpp
index 1987c73..6d6c296 100644
--- a/src/DeviceMgmt.cpp
+++ b/src/DeviceMgmt.cpp
@@ -17,9 +17,8 @@
 
 namespace fs = std::filesystem;
 
-std::optional<I2CDeviceParams>
-    getI2CDeviceParams(const I2CDeviceTypeMap& dtmap,
-                       const SensorBaseConfigMap& cfg)
+std::optional<I2CDeviceParams> getI2CDeviceParams(
+    const I2CDeviceTypeMap& dtmap, const SensorBaseConfigMap& cfg)
 {
     auto findType = cfg.find("Type");
     auto findBus = cfg.find("Bus");
diff --git a/src/DeviceMgmt.hpp b/src/DeviceMgmt.hpp
index 84ad8a0..4b4dea8 100644
--- a/src/DeviceMgmt.hpp
+++ b/src/DeviceMgmt.hpp
@@ -28,7 +28,7 @@
 struct I2CDeviceParams
 {
     I2CDeviceParams(const I2CDeviceType& type, uint64_t bus, uint64_t address) :
-        type(&type), bus(bus), address(address){};
+        type(&type), bus(bus), address(address) {};
 
     const I2CDeviceType* type;
     uint64_t bus;
@@ -38,9 +38,8 @@
     bool deviceStatic() const;
 };
 
-std::optional<I2CDeviceParams>
-    getI2CDeviceParams(const I2CDeviceTypeMap& dtmap,
-                       const SensorBaseConfigMap& cfg);
+std::optional<I2CDeviceParams> getI2CDeviceParams(
+    const I2CDeviceTypeMap& dtmap, const SensorBaseConfigMap& cfg);
 
 class I2CDevice
 {
diff --git a/src/ExitAirTempSensor.cpp b/src/ExitAirTempSensor.cpp
index 533c94d..bd8960b 100644
--- a/src/ExitAirTempSensor.cpp
+++ b/src/ExitAirTempSensor.cpp
@@ -81,31 +81,33 @@
 {
     std::function<void(sdbusplus::message_t & message)> eventHandler =
         [callback{std::move(callback)}](sdbusplus::message_t& message) {
-        std::string objectName;
-        boost::container::flat_map<std::string, std::variant<double, int64_t>>
-            values;
-        message.read(objectName, values);
-        auto findValue = values.find("Value");
-        if (findValue == values.end())
-        {
-            return;
-        }
-        double value = std::visit(VariantToDoubleVisitor(), findValue->second);
-        if (std::isnan(value))
-        {
-            return;
-        }
+            std::string objectName;
+            boost::container::flat_map<std::string,
+                                       std::variant<double, int64_t>>
+                values;
+            message.read(objectName, values);
+            auto findValue = values.find("Value");
+            if (findValue == values.end())
+            {
+                return;
+            }
+            double value =
+                std::visit(VariantToDoubleVisitor(), findValue->second);
+            if (std::isnan(value))
+            {
+                return;
+            }
 
-        callback(value, message);
-    };
-    matches.emplace_back(connection,
-                         "type='signal',"
-                         "member='PropertiesChanged',interface='org."
-                         "freedesktop.DBus.Properties',path_"
-                         "namespace='/xyz/openbmc_project/sensors/" +
-                             std::string(type) +
-                             "',arg0='xyz.openbmc_project.Sensor.Value'",
-                         std::move(eventHandler));
+            callback(value, message);
+        };
+    matches.emplace_back(
+        connection,
+        "type='signal',"
+        "member='PropertiesChanged',interface='org."
+        "freedesktop.DBus.Properties',path_"
+        "namespace='/xyz/openbmc_project/sensors/" +
+            std::string(type) + "',arg0='xyz.openbmc_project.Sensor.Value'",
+        std::move(eventHandler));
 }
 
 static void setMaxPWM(const std::shared_ptr<sdbusplus::asio::connection>& conn,
@@ -116,51 +118,52 @@
         std::vector<std::pair<std::string, std::vector<std::string>>>>>;
 
     conn->async_method_call(
-        [conn, value](const boost::system::error_code ec,
-                      const GetSubTreeType& ret) {
-        if (ec)
-        {
-            std::cerr << "Error calling mapper\n";
-            return;
-        }
-        for (const auto& [path, objDict] : ret)
-        {
-            if (objDict.empty())
+        [conn,
+         value](const boost::system::error_code ec, const GetSubTreeType& ret) {
+            if (ec)
             {
+                std::cerr << "Error calling mapper\n";
                 return;
             }
-            const std::string& owner = objDict.begin()->first;
+            for (const auto& [path, objDict] : ret)
+            {
+                if (objDict.empty())
+                {
+                    return;
+                }
+                const std::string& owner = objDict.begin()->first;
 
-            conn->async_method_call(
-                [conn, value, owner,
-                 path{path}](const boost::system::error_code ec,
-                             const std::variant<std::string>& classType) {
-                if (ec)
-                {
-                    std::cerr << "Error getting pid class\n";
-                    return;
-                }
-                const auto* classStr = std::get_if<std::string>(&classType);
-                if (classStr == nullptr || *classStr != "fan")
-                {
-                    return;
-                }
                 conn->async_method_call(
-                    [](boost::system::error_code& ec) {
-                    if (ec)
-                    {
-                        std::cerr << "Error setting pid class\n";
-                        return;
-                    }
-                },
-                    owner, path, "org.freedesktop.DBus.Properties", "Set",
-                    pidConfigurationType, "OutLimitMax",
-                    std::variant<double>(value));
-            },
-                owner, path, "org.freedesktop.DBus.Properties", "Get",
-                pidConfigurationType, "Class");
-        }
-    },
+                    [conn, value, owner,
+                     path{path}](const boost::system::error_code ec,
+                                 const std::variant<std::string>& classType) {
+                        if (ec)
+                        {
+                            std::cerr << "Error getting pid class\n";
+                            return;
+                        }
+                        const auto* classStr =
+                            std::get_if<std::string>(&classType);
+                        if (classStr == nullptr || *classStr != "fan")
+                        {
+                            return;
+                        }
+                        conn->async_method_call(
+                            [](boost::system::error_code& ec) {
+                                if (ec)
+                                {
+                                    std::cerr << "Error setting pid class\n";
+                                    return;
+                                }
+                            },
+                            owner, path, "org.freedesktop.DBus.Properties",
+                            "Set", pidConfigurationType, "OutLimitMax",
+                            std::variant<double>(value));
+                    },
+                    owner, path, "org.freedesktop.DBus.Properties", "Get",
+                    pidConfigurationType, "Class");
+            }
+        },
         mapper::busName, mapper::path, mapper::interface, mapper::subtree, "/",
         0, std::array<std::string, 1>{pidConfigurationType});
 }
@@ -207,83 +210,86 @@
     setupSensorMatch(
         matches, *dbusConnection, "fan_tach",
         [weakRef](const double& value, sdbusplus::message_t& message) {
-        auto self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
-        self->tachReadings[message.get_path()] = value;
-        if (self->tachRanges.find(message.get_path()) == self->tachRanges.end())
-        {
-            // calls update reading after updating ranges
-            self->addTachRanges(message.get_sender(), message.get_path());
-        }
-        else
-        {
-            self->updateReading();
-        }
-    });
+            auto self = weakRef.lock();
+            if (!self)
+            {
+                return;
+            }
+            self->tachReadings[message.get_path()] = value;
+            if (self->tachRanges.find(message.get_path()) ==
+                self->tachRanges.end())
+            {
+                // calls update reading after updating ranges
+                self->addTachRanges(message.get_sender(), message.get_path());
+            }
+            else
+            {
+                self->updateReading();
+            }
+        });
 
     dbusConnection->async_method_call(
         [weakRef](const boost::system::error_code ec,
                   const std::variant<double> cfmVariant) {
-        auto self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
-
-        uint64_t maxRpm = 100;
-        if (!ec)
-        {
-            const auto* cfm = std::get_if<double>(&cfmVariant);
-            if (cfm != nullptr && *cfm >= minSystemCfm)
+            auto self = weakRef.lock();
+            if (!self)
             {
-                maxRpm = self->getMaxRpm(*cfm);
+                return;
             }
-        }
-        self->pwmLimitIface->register_property("Limit", maxRpm);
-        self->pwmLimitIface->initialize();
-        setMaxPWM(self->dbusConnection, maxRpm);
-    },
+
+            uint64_t maxRpm = 100;
+            if (!ec)
+            {
+                const auto* cfm = std::get_if<double>(&cfmVariant);
+                if (cfm != nullptr && *cfm >= minSystemCfm)
+                {
+                    maxRpm = self->getMaxRpm(*cfm);
+                }
+            }
+            self->pwmLimitIface->register_property("Limit", maxRpm);
+            self->pwmLimitIface->initialize();
+            setMaxPWM(self->dbusConnection, maxRpm);
+        },
         settingsDaemon, cfmSettingPath, "org.freedesktop.DBus.Properties",
         "Get", cfmSettingIface, "Limit");
 
-    matches.emplace_back(*dbusConnection,
-                         "type='signal',"
-                         "member='PropertiesChanged',interface='org."
-                         "freedesktop.DBus.Properties',path='" +
-                             std::string(cfmSettingPath) + "',arg0='" +
-                             std::string(cfmSettingIface) + "'",
-                         [weakRef](sdbusplus::message_t& message) {
-        auto self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
-        boost::container::flat_map<std::string, std::variant<double>> values;
-        std::string objectName;
-        message.read(objectName, values);
-        const auto findValue = values.find("Limit");
-        if (findValue == values.end())
-        {
-            return;
-        }
-        auto* const reading = std::get_if<double>(&(findValue->second));
-        if (reading == nullptr)
-        {
-            std::cerr << "Got CFM Limit of wrong type\n";
-            return;
-        }
-        if (*reading < minSystemCfm && *reading != 0)
-        {
-            std::cerr << "Illegal CFM setting detected\n";
-            return;
-        }
-        uint64_t maxRpm = self->getMaxRpm(*reading);
-        self->pwmLimitIface->set_property("Limit", maxRpm);
-        setMaxPWM(self->dbusConnection, maxRpm);
-    });
+    matches.emplace_back(
+        *dbusConnection,
+        "type='signal',"
+        "member='PropertiesChanged',interface='org."
+        "freedesktop.DBus.Properties',path='" +
+            std::string(cfmSettingPath) + "',arg0='" +
+            std::string(cfmSettingIface) + "'",
+        [weakRef](sdbusplus::message_t& message) {
+            auto self = weakRef.lock();
+            if (!self)
+            {
+                return;
+            }
+            boost::container::flat_map<std::string, std::variant<double>>
+                values;
+            std::string objectName;
+            message.read(objectName, values);
+            const auto findValue = values.find("Limit");
+            if (findValue == values.end())
+            {
+                return;
+            }
+            auto* const reading = std::get_if<double>(&(findValue->second));
+            if (reading == nullptr)
+            {
+                std::cerr << "Got CFM Limit of wrong type\n";
+                return;
+            }
+            if (*reading < minSystemCfm && *reading != 0)
+            {
+                std::cerr << "Illegal CFM setting detected\n";
+                return;
+            }
+            uint64_t maxRpm = self->getMaxRpm(*reading);
+            self->pwmLimitIface->set_property("Limit", maxRpm);
+            setMaxPWM(self->dbusConnection, maxRpm);
+        });
 }
 
 CFMSensor::~CFMSensor()
@@ -311,21 +317,21 @@
     dbusConnection->async_method_call(
         [weakRef, path](const boost::system::error_code ec,
                         const SensorBaseConfigMap& data) {
-        if (ec)
-        {
-            std::cerr << "Error getting properties from " << path << "\n";
-            return;
-        }
-        auto self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
-        double max = loadVariant<double>(data, "MaxValue");
-        double min = loadVariant<double>(data, "MinValue");
-        self->tachRanges[path] = std::make_pair(min, max);
-        self->updateReading();
-    },
+            if (ec)
+            {
+                std::cerr << "Error getting properties from " << path << "\n";
+                return;
+            }
+            auto self = weakRef.lock();
+            if (!self)
+            {
+                return;
+            }
+            double max = loadVariant<double>(data, "MaxValue");
+            double min = loadVariant<double>(data, "MinValue");
+            self->tachRanges[path] = std::make_pair(min, max);
+            self->updateReading();
+        },
         serviceName, path, "org.freedesktop.DBus.Properties", "GetAll",
         "xyz.openbmc_project.Sensor.Value");
 }
@@ -544,101 +550,103 @@
     std::weak_ptr<ExitAirTempSensor> weakRef = weak_from_this();
     for (const std::string type : matchTypes)
     {
-        setupSensorMatch(matches, *dbusConnection, type,
-                         [weakRef, type](const double& value,
-                                         sdbusplus::message_t& message) {
+        setupSensorMatch(
+            matches, *dbusConnection, type,
+            [weakRef,
+             type](const double& value, sdbusplus::message_t& message) {
+                auto self = weakRef.lock();
+                if (!self)
+                {
+                    return;
+                }
+                if (type == "power")
+                {
+                    std::string path = message.get_path();
+                    if (path.find("PS") != std::string::npos &&
+                        path.ends_with("Input_Power"))
+                    {
+                        self->powerReadings[message.get_path()] = value;
+                    }
+                }
+                else if (type == inletTemperatureSensor)
+                {
+                    self->inletTemp = value;
+                }
+                self->updateReading();
+            });
+    }
+    dbusConnection->async_method_call(
+        [weakRef](boost::system::error_code ec,
+                  const std::variant<double>& value) {
+            if (ec)
+            {
+                // sensor not ready yet
+                return;
+            }
             auto self = weakRef.lock();
             if (!self)
             {
                 return;
             }
-            if (type == "power")
-            {
-                std::string path = message.get_path();
-                if (path.find("PS") != std::string::npos &&
-                    path.ends_with("Input_Power"))
-                {
-                    self->powerReadings[message.get_path()] = value;
-                }
-            }
-            else if (type == inletTemperatureSensor)
-            {
-                self->inletTemp = value;
-            }
-            self->updateReading();
-        });
-    }
-    dbusConnection->async_method_call(
-        [weakRef](boost::system::error_code ec,
-                  const std::variant<double>& value) {
-        if (ec)
-        {
-            // sensor not ready yet
-            return;
-        }
-        auto self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
-        self->inletTemp = std::visit(VariantToDoubleVisitor(), value);
-    },
+            self->inletTemp = std::visit(VariantToDoubleVisitor(), value);
+        },
         "xyz.openbmc_project.HwmonTempSensor",
         std::string("/xyz/openbmc_project/sensors/") + inletTemperatureSensor,
         properties::interface, properties::get, sensorValueInterface, "Value");
     dbusConnection->async_method_call(
         [weakRef](boost::system::error_code ec, const GetSubTreeType& subtree) {
-        if (ec)
-        {
-            std::cerr << "Error contacting mapper\n";
-            return;
-        }
-        auto self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
-        for (const auto& [path, matches] : subtree)
-        {
-            size_t lastSlash = path.rfind('/');
-            if (lastSlash == std::string::npos || lastSlash == path.size() ||
-                matches.empty())
+            if (ec)
             {
-                continue;
+                std::cerr << "Error contacting mapper\n";
+                return;
             }
-            std::string sensorName = path.substr(lastSlash + 1);
-            if (sensorName.starts_with("PS") &&
-                sensorName.ends_with("Input_Power"))
+            auto self = weakRef.lock();
+            if (!self)
             {
-                // lambda capture requires a proper variable (not a structured
-                // binding)
-                const std::string& cbPath = path;
-                self->dbusConnection->async_method_call(
-                    [weakRef, cbPath](boost::system::error_code ec,
-                                      const std::variant<double>& value) {
-                    if (ec)
-                    {
-                        std::cerr << "Error getting value from " << cbPath
-                                  << "\n";
-                    }
-                    auto self = weakRef.lock();
-                    if (!self)
-                    {
-                        return;
-                    }
-                    double reading = std::visit(VariantToDoubleVisitor(),
-                                                value);
-                    if constexpr (debug)
-                    {
-                        std::cerr << cbPath << "Reading " << reading << "\n";
-                    }
-                    self->powerReadings[cbPath] = reading;
-                },
-                    matches[0].first, cbPath, properties::interface,
-                    properties::get, sensorValueInterface, "Value");
+                return;
             }
-        }
-    },
+            for (const auto& [path, matches] : subtree)
+            {
+                size_t lastSlash = path.rfind('/');
+                if (lastSlash == std::string::npos ||
+                    lastSlash == path.size() || matches.empty())
+                {
+                    continue;
+                }
+                std::string sensorName = path.substr(lastSlash + 1);
+                if (sensorName.starts_with("PS") &&
+                    sensorName.ends_with("Input_Power"))
+                {
+                    // lambda capture requires a proper variable (not a
+                    // structured binding)
+                    const std::string& cbPath = path;
+                    self->dbusConnection->async_method_call(
+                        [weakRef, cbPath](boost::system::error_code ec,
+                                          const std::variant<double>& value) {
+                            if (ec)
+                            {
+                                std::cerr << "Error getting value from "
+                                          << cbPath << "\n";
+                            }
+                            auto self = weakRef.lock();
+                            if (!self)
+                            {
+                                return;
+                            }
+                            double reading =
+                                std::visit(VariantToDoubleVisitor(), value);
+                            if constexpr (debug)
+                            {
+                                std::cerr
+                                    << cbPath << "Reading " << reading << "\n";
+                            }
+                            self->powerReadings[cbPath] = reading;
+                        },
+                        matches[0].first, cbPath, properties::interface,
+                        properties::get, sensorValueInterface, "Value");
+                }
+            }
+        },
         mapper::busName, mapper::path, mapper::interface, mapper::subtree,
         "/xyz/openbmc_project/sensors/power", 0,
         std::array<const char*, 1>{sensorValueInterface});
@@ -873,63 +881,67 @@
     auto getter = std::make_shared<GetSensorConfiguration>(
         dbusConnection, [&objectServer, &dbusConnection,
                          &exitAirSensor](const ManagedObjectType& resp) {
-        cfmSensors.clear();
-        for (const auto& [path, interfaces] : resp)
-        {
-            for (const auto& [intf, cfg] : interfaces)
+            cfmSensors.clear();
+            for (const auto& [path, interfaces] : resp)
             {
-                if (intf == configInterfaceName(exitAirType))
+                for (const auto& [intf, cfg] : interfaces)
                 {
-                    // thresholds should be under the same path
-                    std::vector<thresholds::Threshold> sensorThresholds;
-                    parseThresholdsFromConfig(interfaces, sensorThresholds);
+                    if (intf == configInterfaceName(exitAirType))
+                    {
+                        // thresholds should be under the same path
+                        std::vector<thresholds::Threshold> sensorThresholds;
+                        parseThresholdsFromConfig(interfaces, sensorThresholds);
 
-                    std::string name = loadVariant<std::string>(cfg, "Name");
-                    exitAirSensor = nullptr;
-                    exitAirSensor = std::make_shared<ExitAirTempSensor>(
-                        dbusConnection, name, path.str, objectServer,
-                        std::move(sensorThresholds));
-                    exitAirSensor->powerFactorMin =
-                        loadVariant<double>(cfg, "PowerFactorMin");
-                    exitAirSensor->powerFactorMax =
-                        loadVariant<double>(cfg, "PowerFactorMax");
-                    exitAirSensor->qMin = loadVariant<double>(cfg, "QMin");
-                    exitAirSensor->qMax = loadVariant<double>(cfg, "QMax");
-                    exitAirSensor->alphaS = loadVariant<double>(cfg, "AlphaS");
-                    exitAirSensor->alphaF = loadVariant<double>(cfg, "AlphaF");
-                }
-                else if (intf == configInterfaceName(cfmType))
-                {
-                    // thresholds should be under the same path
-                    std::vector<thresholds::Threshold> sensorThresholds;
-                    parseThresholdsFromConfig(interfaces, sensorThresholds);
-                    std::string name = loadVariant<std::string>(cfg, "Name");
-                    auto sensor = std::make_shared<CFMSensor>(
-                        dbusConnection, name, path.str, objectServer,
-                        std::move(sensorThresholds), exitAirSensor);
-                    loadVariantPathArray(cfg, "Tachs", sensor->tachs);
-                    sensor->maxCFM = loadVariant<double>(cfg, "MaxCFM");
+                        std::string name =
+                            loadVariant<std::string>(cfg, "Name");
+                        exitAirSensor = nullptr;
+                        exitAirSensor = std::make_shared<ExitAirTempSensor>(
+                            dbusConnection, name, path.str, objectServer,
+                            std::move(sensorThresholds));
+                        exitAirSensor->powerFactorMin =
+                            loadVariant<double>(cfg, "PowerFactorMin");
+                        exitAirSensor->powerFactorMax =
+                            loadVariant<double>(cfg, "PowerFactorMax");
+                        exitAirSensor->qMin = loadVariant<double>(cfg, "QMin");
+                        exitAirSensor->qMax = loadVariant<double>(cfg, "QMax");
+                        exitAirSensor->alphaS =
+                            loadVariant<double>(cfg, "AlphaS");
+                        exitAirSensor->alphaF =
+                            loadVariant<double>(cfg, "AlphaF");
+                    }
+                    else if (intf == configInterfaceName(cfmType))
+                    {
+                        // thresholds should be under the same path
+                        std::vector<thresholds::Threshold> sensorThresholds;
+                        parseThresholdsFromConfig(interfaces, sensorThresholds);
+                        std::string name =
+                            loadVariant<std::string>(cfg, "Name");
+                        auto sensor = std::make_shared<CFMSensor>(
+                            dbusConnection, name, path.str, objectServer,
+                            std::move(sensorThresholds), exitAirSensor);
+                        loadVariantPathArray(cfg, "Tachs", sensor->tachs);
+                        sensor->maxCFM = loadVariant<double>(cfg, "MaxCFM");
 
-                    // change these into percent upon getting the data
-                    sensor->c1 = loadVariant<double>(cfg, "C1") / 100;
-                    sensor->c2 = loadVariant<double>(cfg, "C2") / 100;
-                    sensor->tachMinPercent =
-                        loadVariant<double>(cfg, "TachMinPercent");
-                    sensor->tachMaxPercent =
-                        loadVariant<double>(cfg, "TachMaxPercent");
-                    sensor->createMaxCFMIface();
-                    sensor->setupMatches();
+                        // change these into percent upon getting the data
+                        sensor->c1 = loadVariant<double>(cfg, "C1") / 100;
+                        sensor->c2 = loadVariant<double>(cfg, "C2") / 100;
+                        sensor->tachMinPercent =
+                            loadVariant<double>(cfg, "TachMinPercent");
+                        sensor->tachMaxPercent =
+                            loadVariant<double>(cfg, "TachMaxPercent");
+                        sensor->createMaxCFMIface();
+                        sensor->setupMatches();
 
-                    cfmSensors.emplace_back(std::move(sensor));
+                        cfmSensors.emplace_back(std::move(sensor));
+                    }
                 }
             }
-        }
-        if (exitAirSensor)
-        {
-            exitAirSensor->setupMatches();
-            exitAirSensor->updateReading();
-        }
-    });
+            if (exitAirSensor)
+            {
+                exitAirSensor->setupMatches();
+                exitAirSensor->updateReading();
+            }
+        });
     getter->getConfiguration(
         std::vector<std::string>(monitorTypes.begin(), monitorTypes.end()));
 }
@@ -951,20 +963,20 @@
 
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&](sdbusplus::message_t&) {
-        configTimer.expires_after(std::chrono::seconds(1));
-        // create a timer because normally multiple properties change
-        configTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
-            {
-                return; // we're being canceled
-            }
-            createSensor(objectServer, sensor, systemBus);
-            if (!sensor)
-            {
-                std::cout << "Configuration not detected\n";
-            }
-        });
-    };
+            configTimer.expires_after(std::chrono::seconds(1));
+            // create a timer because normally multiple properties change
+            configTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    return; // we're being canceled
+                }
+                createSensor(objectServer, sensor, systemBus);
+                if (!sensor)
+                {
+                    std::cout << "Configuration not detected\n";
+                }
+            });
+        };
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(*systemBus, monitorTypes, eventHandler);
 
diff --git a/src/ExternalSensor.cpp b/src/ExternalSensor.cpp
index bce0a31..506823a 100644
--- a/src/ExternalSensor.cpp
+++ b/src/ExternalSensor.cpp
@@ -59,8 +59,8 @@
             objectServer.add_interface(objectPath, interface);
     }
 
-    association = objectServer.add_interface(objectPath,
-                                             association::interface);
+    association =
+        objectServer.add_interface(objectPath, association::interface);
     setInitialProperties(sensorUnits);
 
     if constexpr (debug)
diff --git a/src/ExternalSensor.hpp b/src/ExternalSensor.hpp
index 6f5b3db..c3a7103 100644
--- a/src/ExternalSensor.hpp
+++ b/src/ExternalSensor.hpp
@@ -14,15 +14,14 @@
     public std::enable_shared_from_this<ExternalSensor>
 {
   public:
-    ExternalSensor(const std::string& objectType,
-                   sdbusplus::asio::object_server& objectServer,
-                   std::shared_ptr<sdbusplus::asio::connection>& conn,
-                   const std::string& sensorName,
-                   const std::string& sensorUnits,
-                   std::vector<thresholds::Threshold>&& thresholdsIn,
-                   const std::string& sensorConfiguration, double maxReading,
-                   double minReading, double timeoutSecs,
-                   const PowerState& powerState);
+    ExternalSensor(
+        const std::string& objectType,
+        sdbusplus::asio::object_server& objectServer,
+        std::shared_ptr<sdbusplus::asio::connection>& conn,
+        const std::string& sensorName, const std::string& sensorUnits,
+        std::vector<thresholds::Threshold>&& thresholdsIn,
+        const std::string& sensorConfiguration, double maxReading,
+        double minReading, double timeoutSecs, const PowerState& powerState);
     ~ExternalSensor() override;
 
     // Call this immediately after calling the constructor
diff --git a/src/ExternalSensorMain.cpp b/src/ExternalSensorMain.cpp
index 3beb5b9..9bd7a4d 100644
--- a/src/ExternalSensorMain.cpp
+++ b/src/ExternalSensorMain.cpp
@@ -59,10 +59,11 @@
 
 static const char* sensorType = "ExternalSensor";
 
-void updateReaper(boost::container::flat_map<
-                      std::string, std::shared_ptr<ExternalSensor>>& sensors,
-                  boost::asio::steady_timer& timer,
-                  const std::chrono::steady_clock::time_point& now)
+void updateReaper(
+    boost::container::flat_map<std::string, std::shared_ptr<ExternalSensor>>&
+        sensors,
+    boost::asio::steady_timer& timer,
+    const std::chrono::steady_clock::time_point& now)
 {
     // First pass, reap all stale sensors
     for (const auto& [name, sensor] : sensors)
@@ -169,169 +170,172 @@
         dbusConnection,
         [&objectServer, &sensors, &dbusConnection, sensorsChanged,
          &reaperTimer](const ManagedObjectType& sensorConfigurations) {
-        bool firstScan = (sensorsChanged == nullptr);
+            bool firstScan = (sensorsChanged == nullptr);
 
-        for (const std::pair<sdbusplus::message::object_path, SensorData>&
-                 sensor : sensorConfigurations)
-        {
-            const std::string& interfacePath = sensor.first.str;
-            const SensorData& sensorData = sensor.second;
+            for (const std::pair<sdbusplus::message::object_path, SensorData>&
+                     sensor : sensorConfigurations)
+            {
+                const std::string& interfacePath = sensor.first.str;
+                const SensorData& sensorData = sensor.second;
 
-            auto sensorBase = sensorData.find(configInterfaceName(sensorType));
-            if (sensorBase == sensorData.end())
-            {
-                std::cerr << "Base configuration not found for "
-                          << interfacePath << "\n";
-                continue;
-            }
-
-            const SensorBaseConfiguration& baseConfiguration = *sensorBase;
-            const SensorBaseConfigMap& baseConfigMap = baseConfiguration.second;
-
-            // MinValue and MinValue are mandatory numeric parameters
-            auto minFound = baseConfigMap.find("MinValue");
-            if (minFound == baseConfigMap.end())
-            {
-                std::cerr << "MinValue parameter not found for "
-                          << interfacePath << "\n";
-                continue;
-            }
-            double minValue = std::visit(VariantToDoubleVisitor(),
-                                         minFound->second);
-            if (!std::isfinite(minValue))
-            {
-                std::cerr << "MinValue parameter not parsed for "
-                          << interfacePath << "\n";
-                continue;
-            }
-
-            auto maxFound = baseConfigMap.find("MaxValue");
-            if (maxFound == baseConfigMap.end())
-            {
-                std::cerr << "MaxValue parameter not found for "
-                          << interfacePath << "\n";
-                continue;
-            }
-            double maxValue = std::visit(VariantToDoubleVisitor(),
-                                         maxFound->second);
-            if (!std::isfinite(maxValue))
-            {
-                std::cerr << "MaxValue parameter not parsed for "
-                          << interfacePath << "\n";
-                continue;
-            }
-
-            double timeoutSecs = 0.0;
-
-            // Timeout is an optional numeric parameter
-            auto timeoutFound = baseConfigMap.find("Timeout");
-            if (timeoutFound != baseConfigMap.end())
-            {
-                timeoutSecs = std::visit(VariantToDoubleVisitor(),
-                                         timeoutFound->second);
-            }
-            if (!std::isfinite(timeoutSecs) || (timeoutSecs < 0.0))
-            {
-                std::cerr << "Timeout parameter not parsed for "
-                          << interfacePath << "\n";
-                continue;
-            }
-
-            std::string sensorName;
-            std::string sensorUnits;
-
-            // Name and Units are mandatory string parameters
-            auto nameFound = baseConfigMap.find("Name");
-            if (nameFound == baseConfigMap.end())
-            {
-                std::cerr << "Name parameter not found for " << interfacePath
-                          << "\n";
-                continue;
-            }
-            sensorName = std::visit(VariantToStringVisitor(),
-                                    nameFound->second);
-            if (sensorName.empty())
-            {
-                std::cerr << "Name parameter not parsed for " << interfacePath
-                          << "\n";
-                continue;
-            }
-
-            auto unitsFound = baseConfigMap.find("Units");
-            if (unitsFound == baseConfigMap.end())
-            {
-                std::cerr << "Units parameter not found for " << interfacePath
-                          << "\n";
-                continue;
-            }
-            sensorUnits = std::visit(VariantToStringVisitor(),
-                                     unitsFound->second);
-            if (sensorUnits.empty())
-            {
-                std::cerr << "Units parameter not parsed for " << interfacePath
-                          << "\n";
-                continue;
-            }
-
-            // on rescans, only update sensors we were signaled by
-            auto findSensor = sensors.find(sensorName);
-            if (!firstScan && (findSensor != sensors.end()))
-            {
-                std::string suffixName = "/";
-                suffixName += findSensor->second->name;
-                bool found = false;
-                for (auto it = sensorsChanged->begin();
-                     it != sensorsChanged->end(); it++)
+                auto sensorBase =
+                    sensorData.find(configInterfaceName(sensorType));
+                if (sensorBase == sensorData.end())
                 {
-                    std::string suffixIt = "/";
-                    suffixIt += *it;
-                    if (suffixIt.ends_with(suffixName))
-                    {
-                        sensorsChanged->erase(it);
-                        findSensor->second = nullptr;
-                        found = true;
-                        if constexpr (debug)
-                        {
-                            std::cerr << "ExternalSensor " << sensorName
-                                      << " change found\n";
-                        }
-                        break;
-                    }
-                }
-                if (!found)
-                {
+                    std::cerr << "Base configuration not found for "
+                              << interfacePath << "\n";
                     continue;
                 }
+
+                const SensorBaseConfiguration& baseConfiguration = *sensorBase;
+                const SensorBaseConfigMap& baseConfigMap =
+                    baseConfiguration.second;
+
+                // MinValue and MinValue are mandatory numeric parameters
+                auto minFound = baseConfigMap.find("MinValue");
+                if (minFound == baseConfigMap.end())
+                {
+                    std::cerr << "MinValue parameter not found for "
+                              << interfacePath << "\n";
+                    continue;
+                }
+                double minValue =
+                    std::visit(VariantToDoubleVisitor(), minFound->second);
+                if (!std::isfinite(minValue))
+                {
+                    std::cerr << "MinValue parameter not parsed for "
+                              << interfacePath << "\n";
+                    continue;
+                }
+
+                auto maxFound = baseConfigMap.find("MaxValue");
+                if (maxFound == baseConfigMap.end())
+                {
+                    std::cerr << "MaxValue parameter not found for "
+                              << interfacePath << "\n";
+                    continue;
+                }
+                double maxValue =
+                    std::visit(VariantToDoubleVisitor(), maxFound->second);
+                if (!std::isfinite(maxValue))
+                {
+                    std::cerr << "MaxValue parameter not parsed for "
+                              << interfacePath << "\n";
+                    continue;
+                }
+
+                double timeoutSecs = 0.0;
+
+                // Timeout is an optional numeric parameter
+                auto timeoutFound = baseConfigMap.find("Timeout");
+                if (timeoutFound != baseConfigMap.end())
+                {
+                    timeoutSecs = std::visit(VariantToDoubleVisitor(),
+                                             timeoutFound->second);
+                }
+                if (!std::isfinite(timeoutSecs) || (timeoutSecs < 0.0))
+                {
+                    std::cerr << "Timeout parameter not parsed for "
+                              << interfacePath << "\n";
+                    continue;
+                }
+
+                std::string sensorName;
+                std::string sensorUnits;
+
+                // Name and Units are mandatory string parameters
+                auto nameFound = baseConfigMap.find("Name");
+                if (nameFound == baseConfigMap.end())
+                {
+                    std::cerr << "Name parameter not found for "
+                              << interfacePath << "\n";
+                    continue;
+                }
+                sensorName =
+                    std::visit(VariantToStringVisitor(), nameFound->second);
+                if (sensorName.empty())
+                {
+                    std::cerr << "Name parameter not parsed for "
+                              << interfacePath << "\n";
+                    continue;
+                }
+
+                auto unitsFound = baseConfigMap.find("Units");
+                if (unitsFound == baseConfigMap.end())
+                {
+                    std::cerr << "Units parameter not found for "
+                              << interfacePath << "\n";
+                    continue;
+                }
+                sensorUnits =
+                    std::visit(VariantToStringVisitor(), unitsFound->second);
+                if (sensorUnits.empty())
+                {
+                    std::cerr << "Units parameter not parsed for "
+                              << interfacePath << "\n";
+                    continue;
+                }
+
+                // on rescans, only update sensors we were signaled by
+                auto findSensor = sensors.find(sensorName);
+                if (!firstScan && (findSensor != sensors.end()))
+                {
+                    std::string suffixName = "/";
+                    suffixName += findSensor->second->name;
+                    bool found = false;
+                    for (auto it = sensorsChanged->begin();
+                         it != sensorsChanged->end(); it++)
+                    {
+                        std::string suffixIt = "/";
+                        suffixIt += *it;
+                        if (suffixIt.ends_with(suffixName))
+                        {
+                            sensorsChanged->erase(it);
+                            findSensor->second = nullptr;
+                            found = true;
+                            if constexpr (debug)
+                            {
+                                std::cerr << "ExternalSensor " << sensorName
+                                          << " change found\n";
+                            }
+                            break;
+                        }
+                    }
+                    if (!found)
+                    {
+                        continue;
+                    }
+                }
+
+                std::vector<thresholds::Threshold> sensorThresholds;
+                if (!parseThresholdsFromConfig(sensorData, sensorThresholds))
+                {
+                    std::cerr << "error populating thresholds for "
+                              << sensorName << "\n";
+                }
+
+                PowerState readState = getPowerState(baseConfigMap);
+
+                auto& sensorEntry = sensors[sensorName];
+                sensorEntry = nullptr;
+
+                sensorEntry = std::make_shared<ExternalSensor>(
+                    sensorType, objectServer, dbusConnection, sensorName,
+                    sensorUnits, std::move(sensorThresholds), interfacePath,
+                    maxValue, minValue, timeoutSecs, readState);
+                sensorEntry->initWriteHook(
+                    [&sensors, &reaperTimer](
+                        const std::chrono::steady_clock::time_point& now) {
+                        updateReaper(sensors, reaperTimer, now);
+                    });
+
+                if constexpr (debug)
+                {
+                    std::cerr
+                        << "ExternalSensor " << sensorName << " created\n";
+                }
             }
-
-            std::vector<thresholds::Threshold> sensorThresholds;
-            if (!parseThresholdsFromConfig(sensorData, sensorThresholds))
-            {
-                std::cerr << "error populating thresholds for " << sensorName
-                          << "\n";
-            }
-
-            PowerState readState = getPowerState(baseConfigMap);
-
-            auto& sensorEntry = sensors[sensorName];
-            sensorEntry = nullptr;
-
-            sensorEntry = std::make_shared<ExternalSensor>(
-                sensorType, objectServer, dbusConnection, sensorName,
-                sensorUnits, std::move(sensorThresholds), interfacePath,
-                maxValue, minValue, timeoutSecs, readState);
-            sensorEntry->initWriteHook(
-                [&sensors, &reaperTimer](
-                    const std::chrono::steady_clock::time_point& now) {
-                updateReaper(sensors, reaperTimer, now);
-            });
-
-            if constexpr (debug)
-            {
-                std::cerr << "ExternalSensor " << sensorName << " created\n";
-            }
-        }
-    });
+        });
 
     getter->getConfiguration(std::vector<std::string>{sensorType});
 }
@@ -356,8 +360,8 @@
         std::make_shared<boost::container::flat_set<std::string>>();
     boost::asio::steady_timer reaperTimer(io);
 
-    boost::asio::post(io,
-                      [&objectServer, &sensors, &systemBus, &reaperTimer]() {
+    boost::asio::post(io, [&objectServer, &sensors, &systemBus,
+                           &reaperTimer]() {
         createSensors(objectServer, sensors, systemBus, nullptr, reaperTimer);
     });
 
@@ -365,39 +369,40 @@
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&objectServer, &sensors, &systemBus, &sensorsChanged, &filterTimer,
          &reaperTimer](sdbusplus::message_t& message) mutable {
-        if (message.is_method_error())
-        {
-            std::cerr << "callback method error\n";
-            return;
-        }
-
-        const auto* messagePath = message.get_path();
-        sensorsChanged->insert(messagePath);
-        if constexpr (debug)
-        {
-            std::cerr << "ExternalSensor change event received: " << messagePath
-                      << "\n";
-        }
-
-        // this implicitly cancels the timer
-        filterTimer.expires_after(std::chrono::seconds(1));
-
-        filterTimer.async_wait(
-            [&objectServer, &sensors, &systemBus, &sensorsChanged,
-             &reaperTimer](const boost::system::error_code& ec) mutable {
-            if (ec != boost::system::errc::success)
+            if (message.is_method_error())
             {
-                if (ec != boost::asio::error::operation_aborted)
-                {
-                    std::cerr << "callback error: " << ec.message() << "\n";
-                }
+                std::cerr << "callback method error\n";
                 return;
             }
 
-            createSensors(objectServer, sensors, systemBus, sensorsChanged,
-                          reaperTimer);
-        });
-    };
+            const auto* messagePath = message.get_path();
+            sensorsChanged->insert(messagePath);
+            if constexpr (debug)
+            {
+                std::cerr << "ExternalSensor change event received: "
+                          << messagePath << "\n";
+            }
+
+            // this implicitly cancels the timer
+            filterTimer.expires_after(std::chrono::seconds(1));
+
+            filterTimer.async_wait(
+                [&objectServer, &sensors, &systemBus, &sensorsChanged,
+                 &reaperTimer](const boost::system::error_code& ec) mutable {
+                    if (ec != boost::system::errc::success)
+                    {
+                        if (ec != boost::asio::error::operation_aborted)
+                        {
+                            std::cerr
+                                << "callback error: " << ec.message() << "\n";
+                        }
+                        return;
+                    }
+
+                    createSensors(objectServer, sensors, systemBus,
+                                  sensorsChanged, reaperTimer);
+                });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(
diff --git a/src/FanMain.cpp b/src/FanMain.cpp
index 8061d4c..4087472 100644
--- a/src/FanMain.cpp
+++ b/src/FanMain.cpp
@@ -228,42 +228,42 @@
     conn->async_method_call(
         [&objectServer, &sensors](boost::system::error_code& ec,
                                   const ManagedObjectType& managedObj) {
-        if (ec)
-        {
-            std::cerr << "Error calling entity manager \n";
-            return;
-        }
-        for (const auto& [path, interfaces] : managedObj)
-        {
-            for (const auto& [intf, cfg] : interfaces)
+            if (ec)
             {
-                if (intf == redundancyConfiguration)
+                std::cerr << "Error calling entity manager \n";
+                return;
+            }
+            for (const auto& [path, interfaces] : managedObj)
+            {
+                for (const auto& [intf, cfg] : interfaces)
                 {
-                    // currently only support one
-                    auto findCount = cfg.find("AllowedFailures");
-                    if (findCount == cfg.end())
+                    if (intf == redundancyConfiguration)
                     {
-                        std::cerr << "Malformed redundancy record \n";
+                        // currently only support one
+                        auto findCount = cfg.find("AllowedFailures");
+                        if (findCount == cfg.end())
+                        {
+                            std::cerr << "Malformed redundancy record \n";
+                            return;
+                        }
+                        std::vector<std::string> sensorList;
+
+                        for (const auto& [name, sensor] : sensors)
+                        {
+                            sensorList.push_back(
+                                "/xyz/openbmc_project/sensors/fan_tach/" +
+                                sensor->name);
+                        }
+                        systemRedundancy.reset();
+                        systemRedundancy.emplace(RedundancySensor(
+                            std::get<uint64_t>(findCount->second), sensorList,
+                            objectServer, path));
+
                         return;
                     }
-                    std::vector<std::string> sensorList;
-
-                    for (const auto& [name, sensor] : sensors)
-                    {
-                        sensorList.push_back(
-                            "/xyz/openbmc_project/sensors/fan_tach/" +
-                            sensor->name);
-                    }
-                    systemRedundancy.reset();
-                    systemRedundancy.emplace(
-                        RedundancySensor(std::get<uint64_t>(findCount->second),
-                                         sensorList, objectServer, path));
-
-                    return;
                 }
             }
-        }
-    },
+        },
         "xyz.openbmc_project.EntityManager", "/xyz/openbmc_project/inventory",
         "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
 }
@@ -282,314 +282,322 @@
     size_t retries = 0)
 {
     auto getter = std::make_shared<GetSensorConfiguration>(
-        dbusConnection, [&io, &objectServer, &tachSensors, &pwmSensors,
-                         &presenceSensors, &dbusConnection, sensorsChanged](
-                            const ManagedObjectType& sensorConfigurations) {
-        bool firstScan = sensorsChanged == nullptr;
-        std::vector<fs::path> paths;
-        if (!findFiles(fs::path("/sys/class/hwmon"), R"(fan\d+_input)", paths))
-        {
-            std::cerr << "No fan sensors in system\n";
-            return;
-        }
-
-        // iterate through all found fan sensors, and try to match them with
-        // configuration
-        for (const auto& path : paths)
-        {
-            std::smatch match;
-            std::string pathStr = path.string();
-
-            std::regex_search(pathStr, match, inputRegex);
-            std::string indexStr = *(match.begin() + 1);
-
-            fs::path directory = path.parent_path();
-            FanTypes fanType = getFanType(directory);
-            std::string cfgIntf = configInterfaceName(sensorTypes[fanType]);
-
-            // convert to 0 based
-            size_t index = std::stoul(indexStr) - 1;
-
-            const char* baseType = nullptr;
-            const SensorData* sensorData = nullptr;
-            const std::string* interfacePath = nullptr;
-            const SensorBaseConfiguration* baseConfiguration = nullptr;
-            for (const auto& [path, cfgData] : sensorConfigurations)
+        dbusConnection,
+        [&io, &objectServer, &tachSensors, &pwmSensors, &presenceSensors,
+         &dbusConnection,
+         sensorsChanged](const ManagedObjectType& sensorConfigurations) {
+            bool firstScan = sensorsChanged == nullptr;
+            std::vector<fs::path> paths;
+            if (!findFiles(fs::path("/sys/class/hwmon"), R"(fan\d+_input)",
+                           paths))
             {
-                // find the base of the configuration to see if indexes
-                // match
-                auto sensorBaseFind = cfgData.find(cfgIntf);
-                if (sensorBaseFind == cfgData.end())
-                {
-                    continue;
-                }
+                std::cerr << "No fan sensors in system\n";
+                return;
+            }
 
-                baseConfiguration = &(*sensorBaseFind);
-                interfacePath = &path.str;
-                baseType = sensorTypes[fanType];
+            // iterate through all found fan sensors, and try to match them with
+            // configuration
+            for (const auto& path : paths)
+            {
+                std::smatch match;
+                std::string pathStr = path.string();
 
-                auto findIndex = baseConfiguration->second.find("Index");
-                if (findIndex == baseConfiguration->second.end())
-                {
-                    std::cerr << baseConfiguration->first << " missing index\n";
-                    continue;
-                }
-                unsigned int configIndex = std::visit(
-                    VariantToUnsignedIntVisitor(), findIndex->second);
-                if (configIndex != index)
-                {
-                    continue;
-                }
-                if (fanType == FanTypes::aspeed ||
-                    fanType == FanTypes::nuvoton || fanType == FanTypes::hpe)
-                {
-                    // there will be only 1 aspeed or nuvoton or hpe sensor
-                    // object in sysfs, we found the fan
-                    sensorData = &cfgData;
-                    break;
-                }
-                if (fanType == FanTypes::i2c)
-                {
-                    std::string deviceName =
-                        fs::read_symlink(directory / "device").filename();
+                std::regex_search(pathStr, match, inputRegex);
+                std::string indexStr = *(match.begin() + 1);
 
-                    size_t bus = 0;
-                    size_t addr = 0;
-                    if (!getDeviceBusAddr(deviceName, bus, addr))
+                fs::path directory = path.parent_path();
+                FanTypes fanType = getFanType(directory);
+                std::string cfgIntf = configInterfaceName(sensorTypes[fanType]);
+
+                // convert to 0 based
+                size_t index = std::stoul(indexStr) - 1;
+
+                const char* baseType = nullptr;
+                const SensorData* sensorData = nullptr;
+                const std::string* interfacePath = nullptr;
+                const SensorBaseConfiguration* baseConfiguration = nullptr;
+                for (const auto& [path, cfgData] : sensorConfigurations)
+                {
+                    // find the base of the configuration to see if indexes
+                    // match
+                    auto sensorBaseFind = cfgData.find(cfgIntf);
+                    if (sensorBaseFind == cfgData.end())
                     {
                         continue;
                     }
 
-                    auto findBus = baseConfiguration->second.find("Bus");
-                    auto findAddress =
-                        baseConfiguration->second.find("Address");
-                    if (findBus == baseConfiguration->second.end() ||
-                        findAddress == baseConfiguration->second.end())
+                    baseConfiguration = &(*sensorBaseFind);
+                    interfacePath = &path.str;
+                    baseType = sensorTypes[fanType];
+
+                    auto findIndex = baseConfiguration->second.find("Index");
+                    if (findIndex == baseConfiguration->second.end())
                     {
-                        std::cerr << baseConfiguration->first
-                                  << " missing bus or address\n";
+                        std::cerr
+                            << baseConfiguration->first << " missing index\n";
                         continue;
                     }
-                    unsigned int configBus = std::visit(
-                        VariantToUnsignedIntVisitor(), findBus->second);
-                    unsigned int configAddress = std::visit(
-                        VariantToUnsignedIntVisitor(), findAddress->second);
-
-                    if (configBus == bus && configAddress == addr)
+                    unsigned int configIndex = std::visit(
+                        VariantToUnsignedIntVisitor(), findIndex->second);
+                    if (configIndex != index)
                     {
+                        continue;
+                    }
+                    if (fanType == FanTypes::aspeed ||
+                        fanType == FanTypes::nuvoton ||
+                        fanType == FanTypes::hpe)
+                    {
+                        // there will be only 1 aspeed or nuvoton or hpe sensor
+                        // object in sysfs, we found the fan
                         sensorData = &cfgData;
                         break;
                     }
-                }
-            }
-            if (sensorData == nullptr)
-            {
-                std::cerr << "failed to find match for " << path.string()
-                          << "\n";
-                continue;
-            }
-
-            auto findSensorName = baseConfiguration->second.find("Name");
-
-            if (findSensorName == baseConfiguration->second.end())
-            {
-                std::cerr << "could not determine configuration name for "
-                          << path.string() << "\n";
-                continue;
-            }
-            std::string sensorName =
-                std::get<std::string>(findSensorName->second);
-
-            // on rescans, only update sensors we were signaled by
-            auto findSensor = tachSensors.find(sensorName);
-            if (!firstScan && findSensor != tachSensors.end())
-            {
-                bool found = false;
-                for (auto it = sensorsChanged->begin();
-                     it != sensorsChanged->end(); it++)
-                {
-                    if (it->ends_with(findSensor->second->name))
+                    if (fanType == FanTypes::i2c)
                     {
-                        sensorsChanged->erase(it);
-                        findSensor->second = nullptr;
-                        found = true;
-                        break;
+                        std::string deviceName =
+                            fs::read_symlink(directory / "device").filename();
+
+                        size_t bus = 0;
+                        size_t addr = 0;
+                        if (!getDeviceBusAddr(deviceName, bus, addr))
+                        {
+                            continue;
+                        }
+
+                        auto findBus = baseConfiguration->second.find("Bus");
+                        auto findAddress =
+                            baseConfiguration->second.find("Address");
+                        if (findBus == baseConfiguration->second.end() ||
+                            findAddress == baseConfiguration->second.end())
+                        {
+                            std::cerr << baseConfiguration->first
+                                      << " missing bus or address\n";
+                            continue;
+                        }
+                        unsigned int configBus = std::visit(
+                            VariantToUnsignedIntVisitor(), findBus->second);
+                        unsigned int configAddress = std::visit(
+                            VariantToUnsignedIntVisitor(), findAddress->second);
+
+                        if (configBus == bus && configAddress == addr)
+                        {
+                            sensorData = &cfgData;
+                            break;
+                        }
                     }
                 }
-                if (!found)
+                if (sensorData == nullptr)
                 {
+                    std::cerr
+                        << "failed to find match for " << path.string() << "\n";
                     continue;
                 }
-            }
-            std::vector<thresholds::Threshold> sensorThresholds;
-            if (!parseThresholdsFromConfig(*sensorData, sensorThresholds))
-            {
-                std::cerr << "error populating thresholds for " << sensorName
-                          << "\n";
-            }
 
-            auto presenceConfig =
-                sensorData->find(cfgIntf + std::string(".Presence"));
+                auto findSensorName = baseConfiguration->second.find("Name");
 
-            std::shared_ptr<PresenceSensor> presenceSensor(nullptr);
-
-            // presence sensors are optional
-            if (presenceConfig != sensorData->end())
-            {
-                auto findPolarity = presenceConfig->second.find("Polarity");
-                auto findPinName = presenceConfig->second.find("PinName");
-
-                if (findPinName == presenceConfig->second.end() ||
-                    findPolarity == presenceConfig->second.end())
+                if (findSensorName == baseConfiguration->second.end())
                 {
-                    std::cerr << "Malformed Presence Configuration\n";
+                    std::cerr << "could not determine configuration name for "
+                              << path.string() << "\n";
+                    continue;
                 }
-                else
-                {
-                    bool inverted =
-                        std::get<std::string>(findPolarity->second) == "Low";
-                    const auto* pinName =
-                        std::get_if<std::string>(&findPinName->second);
+                std::string sensorName =
+                    std::get<std::string>(findSensorName->second);
 
-                    if (pinName != nullptr)
+                // on rescans, only update sensors we were signaled by
+                auto findSensor = tachSensors.find(sensorName);
+                if (!firstScan && findSensor != tachSensors.end())
+                {
+                    bool found = false;
+                    for (auto it = sensorsChanged->begin();
+                         it != sensorsChanged->end(); it++)
                     {
-                        auto findPresenceSensor =
-                            presenceSensors.find(*pinName);
-                        if (findPresenceSensor != presenceSensors.end())
+                        if (it->ends_with(findSensor->second->name))
                         {
-                            auto p = findPresenceSensor->second.lock();
-                            if (p)
-                            {
-                                presenceSensor = p;
-                            }
-                        }
-                        if (!presenceSensor)
-                        {
-                            presenceSensor = std::make_shared<PresenceSensor>(
-                                *pinName, inverted, io, sensorName);
-                            presenceSensors[*pinName] = presenceSensor;
+                            sensorsChanged->erase(it);
+                            findSensor->second = nullptr;
+                            found = true;
+                            break;
                         }
                     }
-                    else
+                    if (!found)
                     {
-                        std::cerr << "Malformed Presence pinName for sensor "
-                                  << sensorName << " \n";
-                    }
-                }
-            }
-            std::optional<RedundancySensor>* redundancy = nullptr;
-            if (fanType == FanTypes::aspeed)
-            {
-                redundancy = &systemRedundancy;
-            }
-
-            PowerState powerState = getPowerState(baseConfiguration->second);
-
-            constexpr double defaultMaxReading = 25000;
-            constexpr double defaultMinReading = 0;
-            std::pair<double, double> limits =
-                std::make_pair(defaultMinReading, defaultMaxReading);
-
-            auto connector =
-                sensorData->find(cfgIntf + std::string(".Connector"));
-
-            std::optional<std::string> led;
-            std::string pwmName;
-            fs::path pwmPath;
-
-            // The Mutable parameter is optional, defaulting to false
-            bool isValueMutable = false;
-            if (connector != sensorData->end())
-            {
-                auto findPwm = connector->second.find("Pwm");
-                if (findPwm != connector->second.end())
-                {
-                    size_t pwm = std::visit(VariantToUnsignedIntVisitor(),
-                                            findPwm->second);
-                    if (!findPwmPath(directory, pwm, pwmPath))
-                    {
-                        std::cerr << "Connector for " << sensorName
-                                  << " no pwm channel found!\n";
                         continue;
                     }
+                }
+                std::vector<thresholds::Threshold> sensorThresholds;
+                if (!parseThresholdsFromConfig(*sensorData, sensorThresholds))
+                {
+                    std::cerr << "error populating thresholds for "
+                              << sensorName << "\n";
+                }
 
-                    fs::path pwmEnableFile = "pwm" + std::to_string(pwm + 1) +
-                                             "_enable";
-                    fs::path enablePath = pwmPath.parent_path() / pwmEnableFile;
-                    enablePwm(enablePath);
+                auto presenceConfig =
+                    sensorData->find(cfgIntf + std::string(".Presence"));
 
-                    /* use pwm name override if found in configuration else
-                     * use default */
-                    auto findOverride = connector->second.find("PwmName");
-                    if (findOverride != connector->second.end())
+                std::shared_ptr<PresenceSensor> presenceSensor(nullptr);
+
+                // presence sensors are optional
+                if (presenceConfig != sensorData->end())
+                {
+                    auto findPolarity = presenceConfig->second.find("Polarity");
+                    auto findPinName = presenceConfig->second.find("PinName");
+
+                    if (findPinName == presenceConfig->second.end() ||
+                        findPolarity == presenceConfig->second.end())
                     {
-                        pwmName = std::visit(VariantToStringVisitor(),
-                                             findOverride->second);
+                        std::cerr << "Malformed Presence Configuration\n";
                     }
                     else
                     {
-                        pwmName = "Pwm_" + std::to_string(pwm + 1);
-                    }
+                        bool inverted = std::get<std::string>(
+                                            findPolarity->second) == "Low";
+                        const auto* pinName =
+                            std::get_if<std::string>(&findPinName->second);
 
-                    // Check PWM sensor mutability
-                    auto findMutable = connector->second.find("Mutable");
-                    if (findMutable != connector->second.end())
-                    {
-                        const auto* ptrMutable =
-                            std::get_if<bool>(&(findMutable->second));
-                        if (ptrMutable != nullptr)
+                        if (pinName != nullptr)
                         {
-                            isValueMutable = *ptrMutable;
+                            auto findPresenceSensor =
+                                presenceSensors.find(*pinName);
+                            if (findPresenceSensor != presenceSensors.end())
+                            {
+                                auto p = findPresenceSensor->second.lock();
+                                if (p)
+                                {
+                                    presenceSensor = p;
+                                }
+                            }
+                            if (!presenceSensor)
+                            {
+                                presenceSensor =
+                                    std::make_shared<PresenceSensor>(
+                                        *pinName, inverted, io, sensorName);
+                                presenceSensors[*pinName] = presenceSensor;
+                            }
+                        }
+                        else
+                        {
+                            std::cerr
+                                << "Malformed Presence pinName for sensor "
+                                << sensorName << " \n";
                         }
                     }
                 }
-                else
+                std::optional<RedundancySensor>* redundancy = nullptr;
+                if (fanType == FanTypes::aspeed)
                 {
-                    std::cerr << "Connector for " << sensorName
-                              << " missing pwm!\n";
+                    redundancy = &systemRedundancy;
                 }
 
-                auto findLED = connector->second.find("LED");
-                if (findLED != connector->second.end())
+                PowerState powerState =
+                    getPowerState(baseConfiguration->second);
+
+                constexpr double defaultMaxReading = 25000;
+                constexpr double defaultMinReading = 0;
+                std::pair<double, double> limits =
+                    std::make_pair(defaultMinReading, defaultMaxReading);
+
+                auto connector =
+                    sensorData->find(cfgIntf + std::string(".Connector"));
+
+                std::optional<std::string> led;
+                std::string pwmName;
+                fs::path pwmPath;
+
+                // The Mutable parameter is optional, defaulting to false
+                bool isValueMutable = false;
+                if (connector != sensorData->end())
                 {
-                    const auto* ledName =
-                        std::get_if<std::string>(&(findLED->second));
-                    if (ledName == nullptr)
+                    auto findPwm = connector->second.find("Pwm");
+                    if (findPwm != connector->second.end())
                     {
-                        std::cerr << "Wrong format for LED of " << sensorName
-                                  << "\n";
+                        size_t pwm = std::visit(VariantToUnsignedIntVisitor(),
+                                                findPwm->second);
+                        if (!findPwmPath(directory, pwm, pwmPath))
+                        {
+                            std::cerr << "Connector for " << sensorName
+                                      << " no pwm channel found!\n";
+                            continue;
+                        }
+
+                        fs::path pwmEnableFile =
+                            "pwm" + std::to_string(pwm + 1) + "_enable";
+                        fs::path enablePath =
+                            pwmPath.parent_path() / pwmEnableFile;
+                        enablePwm(enablePath);
+
+                        /* use pwm name override if found in configuration else
+                         * use default */
+                        auto findOverride = connector->second.find("PwmName");
+                        if (findOverride != connector->second.end())
+                        {
+                            pwmName = std::visit(VariantToStringVisitor(),
+                                                 findOverride->second);
+                        }
+                        else
+                        {
+                            pwmName = "Pwm_" + std::to_string(pwm + 1);
+                        }
+
+                        // Check PWM sensor mutability
+                        auto findMutable = connector->second.find("Mutable");
+                        if (findMutable != connector->second.end())
+                        {
+                            const auto* ptrMutable =
+                                std::get_if<bool>(&(findMutable->second));
+                            if (ptrMutable != nullptr)
+                            {
+                                isValueMutable = *ptrMutable;
+                            }
+                        }
                     }
                     else
                     {
-                        led = *ledName;
+                        std::cerr << "Connector for " << sensorName
+                                  << " missing pwm!\n";
                     }
+
+                    auto findLED = connector->second.find("LED");
+                    if (findLED != connector->second.end())
+                    {
+                        const auto* ledName =
+                            std::get_if<std::string>(&(findLED->second));
+                        if (ledName == nullptr)
+                        {
+                            std::cerr << "Wrong format for LED of "
+                                      << sensorName << "\n";
+                        }
+                        else
+                        {
+                            led = *ledName;
+                        }
+                    }
+                }
+
+                findLimits(limits, baseConfiguration);
+
+                enableFanInput(path);
+
+                auto& tachSensor = tachSensors[sensorName];
+                tachSensor = nullptr;
+                tachSensor = std::make_shared<TachSensor>(
+                    path.string(), baseType, objectServer, dbusConnection,
+                    presenceSensor, redundancy, io, sensorName,
+                    std::move(sensorThresholds), *interfacePath, limits,
+                    powerState, led);
+                tachSensor->setupRead();
+
+                if (!pwmPath.empty() && fs::exists(pwmPath) &&
+                    (pwmSensors.count(pwmPath) == 0U))
+                {
+                    pwmSensors[pwmPath] = std::make_unique<PwmSensor>(
+                        pwmName, pwmPath, dbusConnection, objectServer,
+                        *interfacePath, "Fan", isValueMutable);
                 }
             }
 
-            findLimits(limits, baseConfiguration);
-
-            enableFanInput(path);
-
-            auto& tachSensor = tachSensors[sensorName];
-            tachSensor = nullptr;
-            tachSensor = std::make_shared<TachSensor>(
-                path.string(), baseType, objectServer, dbusConnection,
-                presenceSensor, redundancy, io, sensorName,
-                std::move(sensorThresholds), *interfacePath, limits, powerState,
-                led);
-            tachSensor->setupRead();
-
-            if (!pwmPath.empty() && fs::exists(pwmPath) &&
-                (pwmSensors.count(pwmPath) == 0U))
-            {
-                pwmSensors[pwmPath] = std::make_unique<PwmSensor>(
-                    pwmName, pwmPath, dbusConnection, objectServer,
-                    *interfacePath, "Fan", isValueMutable);
-            }
-        }
-
-        createRedundancySensor(tachSensors, dbusConnection, objectServer);
-    });
+            createRedundancySensor(tachSensors, dbusConnection, objectServer);
+        });
     getter->getConfiguration(
         std::vector<std::string>{sensorTypes.begin(), sensorTypes.end()},
         retries);
@@ -622,30 +630,30 @@
     boost::asio::steady_timer filterTimer(io);
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&](sdbusplus::message_t& message) {
-        if (message.is_method_error())
-        {
-            std::cerr << "callback method error\n";
-            return;
-        }
-        sensorsChanged->insert(message.get_path());
-        // this implicitly cancels the timer
-        filterTimer.expires_after(std::chrono::seconds(1));
+            if (message.is_method_error())
+            {
+                std::cerr << "callback method error\n";
+                return;
+            }
+            sensorsChanged->insert(message.get_path());
+            // this implicitly cancels the timer
+            filterTimer.expires_after(std::chrono::seconds(1));
 
-        filterTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
-            {
-                /* we were canceled*/
-                return;
-            }
-            if (ec)
-            {
-                std::cerr << "timer error\n";
-                return;
-            }
-            createSensors(io, objectServer, tachSensors, pwmSensors,
-                          presenceSensors, systemBus, sensorsChanged, 5);
-        });
-    };
+            filterTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    /* we were canceled*/
+                    return;
+                }
+                if (ec)
+                {
+                    std::cerr << "timer error\n";
+                    return;
+                }
+                createSensors(io, objectServer, tachSensors, pwmSensors,
+                              presenceSensors, systemBus, sensorsChanged, 5);
+            });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(*systemBus, sensorTypes, eventHandler);
@@ -653,8 +661,8 @@
     // redundancy sensor
     std::function<void(sdbusplus::message_t&)> redundancyHandler =
         [&tachSensors, &systemBus, &objectServer](sdbusplus::message_t&) {
-        createRedundancySensor(tachSensors, systemBus, objectServer);
-    };
+            createRedundancySensor(tachSensors, systemBus, objectServer);
+        };
     auto match = std::make_unique<sdbusplus::bus::match_t>(
         static_cast<sdbusplus::bus_t&>(*systemBus),
         "type='signal',member='PropertiesChanged',path_namespace='" +
diff --git a/src/FileHandle.cpp b/src/FileHandle.cpp
index cb33e90..90bf64b 100644
--- a/src/FileHandle.cpp
+++ b/src/FileHandle.cpp
@@ -19,7 +19,7 @@
     }
 }
 
-FileHandle::FileHandle(int fdIn) : fd(fdIn){};
+FileHandle::FileHandle(int fdIn) : fd(fdIn) {};
 
 FileHandle::FileHandle(FileHandle&& in) noexcept : fd(in.fd)
 {
diff --git a/src/HwmonTempMain.cpp b/src/HwmonTempMain.cpp
index ec64c43..956e9e5 100644
--- a/src/HwmonTempMain.cpp
+++ b/src/HwmonTempMain.cpp
@@ -120,8 +120,8 @@
     const std::string pathStr = path.string();
     if (pathStr.ends_with("_raw"))
     {
-        std::string pathOffsetStr = pathStr.substr(0, pathStr.size() - 4) +
-                                    "_offset";
+        std::string pathOffsetStr =
+            pathStr.substr(0, pathStr.size() - 4) + "_offset";
         std::optional<double> tmpOffsetValue = readFile(pathOffsetStr, 1.0);
         // In case there is nothing to read skip this device
         // This is not an error condition see lore
@@ -131,8 +131,8 @@
             tmpSensorParameters.offsetValue = *tmpOffsetValue;
         }
 
-        std::string pathScaleStr = pathStr.substr(0, pathStr.size() - 4) +
-                                   "_scale";
+        std::string pathScaleStr =
+            pathStr.substr(0, pathStr.size() - 4) + "_scale";
         std::optional<double> tmpScaleValue = readFile(pathScaleStr, 1.0);
         // In case there is nothing to read skip this device
         // This is not an error condition see lore
@@ -276,229 +276,173 @@
         dbusConnection,
         [&io, &objectServer, &sensors, &dbusConnection, sensorsChanged,
          activateOnly](const ManagedObjectType& sensorConfigurations) {
-        bool firstScan = sensorsChanged == nullptr;
+            bool firstScan = sensorsChanged == nullptr;
 
-        SensorConfigMap configMap = buildSensorConfigMap(sensorConfigurations);
+            SensorConfigMap configMap =
+                buildSensorConfigMap(sensorConfigurations);
 
-        auto devices = instantiateDevices(sensorConfigurations, sensors,
-                                          sensorTypes);
+            auto devices =
+                instantiateDevices(sensorConfigurations, sensors, sensorTypes);
 
-        // IIO _raw devices look like this on sysfs:
-        //     /sys/bus/iio/devices/iio:device0/in_temp_raw
-        //     /sys/bus/iio/devices/iio:device0/in_temp_offset
-        //     /sys/bus/iio/devices/iio:device0/in_temp_scale
-        //
-        // Other IIO devices look like this on sysfs:
-        //     /sys/bus/iio/devices/iio:device1/in_temp_input
-        //     /sys/bus/iio/devices/iio:device1/in_pressure_input
-        std::vector<fs::path> paths;
-        fs::path root("/sys/bus/iio/devices");
-        findFiles(root, R"(in_temp\d*_(input|raw))", paths);
-        findFiles(root, R"(in_pressure\d*_(input|raw))", paths);
-        findFiles(root, R"(in_humidityrelative\d*_(input|raw))", paths);
-        findFiles(fs::path("/sys/class/hwmon"), R"(temp\d+_input)", paths);
+            // IIO _raw devices look like this on sysfs:
+            //     /sys/bus/iio/devices/iio:device0/in_temp_raw
+            //     /sys/bus/iio/devices/iio:device0/in_temp_offset
+            //     /sys/bus/iio/devices/iio:device0/in_temp_scale
+            //
+            // Other IIO devices look like this on sysfs:
+            //     /sys/bus/iio/devices/iio:device1/in_temp_input
+            //     /sys/bus/iio/devices/iio:device1/in_pressure_input
+            std::vector<fs::path> paths;
+            fs::path root("/sys/bus/iio/devices");
+            findFiles(root, R"(in_temp\d*_(input|raw))", paths);
+            findFiles(root, R"(in_pressure\d*_(input|raw))", paths);
+            findFiles(root, R"(in_humidityrelative\d*_(input|raw))", paths);
+            findFiles(fs::path("/sys/class/hwmon"), R"(temp\d+_input)", paths);
 
-        // iterate through all found temp and pressure sensors,
-        // and try to match them with configuration
-        for (auto& path : paths)
-        {
-            std::smatch match;
-            const std::string pathStr = path.string();
-            auto directory = path.parent_path();
-            fs::path device;
-
-            std::string deviceName;
-            std::error_code ec;
-            if (pathStr.starts_with("/sys/bus/iio/devices"))
+            // iterate through all found temp and pressure sensors,
+            // and try to match them with configuration
+            for (auto& path : paths)
             {
-                device = fs::canonical(directory, ec);
-                if (ec)
+                std::smatch match;
+                const std::string pathStr = path.string();
+                auto directory = path.parent_path();
+                fs::path device;
+
+                std::string deviceName;
+                std::error_code ec;
+                if (pathStr.starts_with("/sys/bus/iio/devices"))
                 {
-                    std::cerr << "Fail to find device in path [" << pathStr
-                              << "]\n";
-                    continue;
-                }
-                deviceName = device.parent_path().stem();
-            }
-            else
-            {
-                device = fs::canonical(directory / "device", ec);
-                if (ec)
-                {
-                    std::cerr << "Fail to find device in path [" << pathStr
-                              << "]\n";
-                    continue;
-                }
-                deviceName = device.stem();
-            }
-
-            uint64_t bus = 0;
-            uint64_t addr = 0;
-            if (!getDeviceBusAddr(deviceName, bus, addr))
-            {
-                continue;
-            }
-
-            auto thisSensorParameters = getSensorParameters(path);
-            auto findSensorCfg = configMap.find({bus, addr});
-            if (findSensorCfg == configMap.end())
-            {
-                continue;
-            }
-
-            const std::string& interfacePath = findSensorCfg->second.sensorPath;
-            auto findI2CDev = devices.find(interfacePath);
-
-            std::shared_ptr<I2CDevice> i2cDev;
-            if (findI2CDev != devices.end())
-            {
-                // If we're only looking to activate newly-instantiated i2c
-                // devices and this sensor's underlying device was already there
-                // before this call, there's nothing more to do here.
-                if (activateOnly && !findI2CDev->second.second)
-                {
-                    continue;
-                }
-                i2cDev = findI2CDev->second.first;
-            }
-
-            const SensorData& sensorData = findSensorCfg->second.sensorData;
-            std::string sensorType = findSensorCfg->second.interface;
-            auto pos = sensorType.find_last_of('.');
-            if (pos != std::string::npos)
-            {
-                sensorType = sensorType.substr(pos + 1);
-            }
-            const SensorBaseConfigMap& baseConfigMap =
-                findSensorCfg->second.config;
-            std::vector<std::string>& hwmonName = findSensorCfg->second.name;
-
-            // Temperature has "Name", pressure has "Name1"
-            auto findSensorName = baseConfigMap.find("Name");
-            int index = 1;
-            if (thisSensorParameters.typeName == "pressure" ||
-                thisSensorParameters.typeName == "humidity")
-            {
-                findSensorName = baseConfigMap.find("Name1");
-                index = 2;
-            }
-
-            if (findSensorName == baseConfigMap.end())
-            {
-                std::cerr << "could not determine configuration name for "
-                          << deviceName << "\n";
-                continue;
-            }
-            std::string sensorName =
-                std::get<std::string>(findSensorName->second);
-            // on rescans, only update sensors we were signaled by
-            auto findSensor = sensors.find(sensorName);
-            if (!firstScan && findSensor != sensors.end())
-            {
-                bool found = false;
-                auto it = sensorsChanged->begin();
-                while (it != sensorsChanged->end())
-                {
-                    if (it->ends_with(findSensor->second->name))
+                    device = fs::canonical(directory, ec);
+                    if (ec)
                     {
-                        it = sensorsChanged->erase(it);
-                        findSensor->second = nullptr;
-                        found = true;
-                        break;
+                        std::cerr << "Fail to find device in path [" << pathStr
+                                  << "]\n";
+                        continue;
                     }
-                    ++it;
-                }
-                if (!found)
-                {
-                    continue;
-                }
-            }
-
-            std::vector<thresholds::Threshold> sensorThresholds;
-
-            if (!parseThresholdsFromConfig(sensorData, sensorThresholds,
-                                           nullptr, &index))
-            {
-                std::cerr << "error populating thresholds for " << sensorName
-                          << " index " << index << "\n";
-            }
-
-            float pollRate = getPollRate(baseConfigMap, pollRateDefault);
-            PowerState readState = getPowerState(baseConfigMap);
-
-            auto permitSet = getPermitSet(baseConfigMap);
-            auto& sensor = sensors[sensorName];
-            if (!activateOnly)
-            {
-                sensor = nullptr;
-            }
-            auto hwmonFile = getFullHwmonFilePath(directory.string(), "temp1",
-                                                  permitSet);
-            if (pathStr.starts_with("/sys/bus/iio/devices"))
-            {
-                hwmonFile = pathStr;
-            }
-            if (hwmonFile)
-            {
-                if (sensor != nullptr)
-                {
-                    sensor->activate(*hwmonFile, i2cDev);
+                    deviceName = device.parent_path().stem();
                 }
                 else
                 {
-                    sensor = std::make_shared<HwmonTempSensor>(
-                        *hwmonFile, sensorType, objectServer, dbusConnection,
-                        io, sensorName, std::move(sensorThresholds),
-                        thisSensorParameters, pollRate, interfacePath,
-                        readState, i2cDev);
-                    sensor->setupRead();
+                    device = fs::canonical(directory / "device", ec);
+                    if (ec)
+                    {
+                        std::cerr << "Fail to find device in path [" << pathStr
+                                  << "]\n";
+                        continue;
+                    }
+                    deviceName = device.stem();
                 }
-            }
-            hwmonName.erase(
-                remove(hwmonName.begin(), hwmonName.end(), sensorName),
-                hwmonName.end());
 
-            // Looking for keys like "Name1" for temp2_input,
-            // "Name2" for temp3_input, etc.
-            int i = 0;
-            while (true)
-            {
-                ++i;
-                auto findKey = baseConfigMap.find("Name" + std::to_string(i));
-                if (findKey == baseConfigMap.end())
-                {
-                    break;
-                }
-                std::string sensorName = std::get<std::string>(findKey->second);
-                hwmonFile = getFullHwmonFilePath(directory.string(),
-                                                 "temp" + std::to_string(i + 1),
-                                                 permitSet);
-                if (pathStr.starts_with("/sys/bus/iio/devices"))
+                uint64_t bus = 0;
+                uint64_t addr = 0;
+                if (!getDeviceBusAddr(deviceName, bus, addr))
                 {
                     continue;
                 }
+
+                auto thisSensorParameters = getSensorParameters(path);
+                auto findSensorCfg = configMap.find({bus, addr});
+                if (findSensorCfg == configMap.end())
+                {
+                    continue;
+                }
+
+                const std::string& interfacePath =
+                    findSensorCfg->second.sensorPath;
+                auto findI2CDev = devices.find(interfacePath);
+
+                std::shared_ptr<I2CDevice> i2cDev;
+                if (findI2CDev != devices.end())
+                {
+                    // If we're only looking to activate newly-instantiated i2c
+                    // devices and this sensor's underlying device was already
+                    // there before this call, there's nothing more to do here.
+                    if (activateOnly && !findI2CDev->second.second)
+                    {
+                        continue;
+                    }
+                    i2cDev = findI2CDev->second.first;
+                }
+
+                const SensorData& sensorData = findSensorCfg->second.sensorData;
+                std::string sensorType = findSensorCfg->second.interface;
+                auto pos = sensorType.find_last_of('.');
+                if (pos != std::string::npos)
+                {
+                    sensorType = sensorType.substr(pos + 1);
+                }
+                const SensorBaseConfigMap& baseConfigMap =
+                    findSensorCfg->second.config;
+                std::vector<std::string>& hwmonName =
+                    findSensorCfg->second.name;
+
+                // Temperature has "Name", pressure has "Name1"
+                auto findSensorName = baseConfigMap.find("Name");
+                int index = 1;
+                if (thisSensorParameters.typeName == "pressure" ||
+                    thisSensorParameters.typeName == "humidity")
+                {
+                    findSensorName = baseConfigMap.find("Name1");
+                    index = 2;
+                }
+
+                if (findSensorName == baseConfigMap.end())
+                {
+                    std::cerr << "could not determine configuration name for "
+                              << deviceName << "\n";
+                    continue;
+                }
+                std::string sensorName =
+                    std::get<std::string>(findSensorName->second);
+                // on rescans, only update sensors we were signaled by
+                auto findSensor = sensors.find(sensorName);
+                if (!firstScan && findSensor != sensors.end())
+                {
+                    bool found = false;
+                    auto it = sensorsChanged->begin();
+                    while (it != sensorsChanged->end())
+                    {
+                        if (it->ends_with(findSensor->second->name))
+                        {
+                            it = sensorsChanged->erase(it);
+                            findSensor->second = nullptr;
+                            found = true;
+                            break;
+                        }
+                        ++it;
+                    }
+                    if (!found)
+                    {
+                        continue;
+                    }
+                }
+
+                std::vector<thresholds::Threshold> sensorThresholds;
+
+                if (!parseThresholdsFromConfig(sensorData, sensorThresholds,
+                                               nullptr, &index))
+                {
+                    std::cerr << "error populating thresholds for "
+                              << sensorName << " index " << index << "\n";
+                }
+
+                float pollRate = getPollRate(baseConfigMap, pollRateDefault);
+                PowerState readState = getPowerState(baseConfigMap);
+
+                auto permitSet = getPermitSet(baseConfigMap);
+                auto& sensor = sensors[sensorName];
+                if (!activateOnly)
+                {
+                    sensor = nullptr;
+                }
+                auto hwmonFile = getFullHwmonFilePath(directory.string(),
+                                                      "temp1", permitSet);
+                if (pathStr.starts_with("/sys/bus/iio/devices"))
+                {
+                    hwmonFile = pathStr;
+                }
                 if (hwmonFile)
                 {
-                    // To look up thresholds for these additional sensors,
-                    // match on the Index property in the threshold data
-                    // where the index comes from the sysfs file we're on,
-                    // i.e. index = 2 for temp2_input.
-                    int index = i + 1;
-                    std::vector<thresholds::Threshold> thresholds;
-
-                    if (!parseThresholdsFromConfig(sensorData, thresholds,
-                                                   nullptr, &index))
-                    {
-                        std::cerr << "error populating thresholds for "
-                                  << sensorName << " index " << index << "\n";
-                    }
-
-                    auto& sensor = sensors[sensorName];
-                    if (!activateOnly)
-                    {
-                        sensor = nullptr;
-                    }
-
                     if (sensor != nullptr)
                     {
                         sensor->activate(*hwmonFile, i2cDev);
@@ -508,22 +452,84 @@
                         sensor = std::make_shared<HwmonTempSensor>(
                             *hwmonFile, sensorType, objectServer,
                             dbusConnection, io, sensorName,
-                            std::move(thresholds), thisSensorParameters,
+                            std::move(sensorThresholds), thisSensorParameters,
                             pollRate, interfacePath, readState, i2cDev);
                         sensor->setupRead();
                     }
                 }
-
                 hwmonName.erase(
                     remove(hwmonName.begin(), hwmonName.end(), sensorName),
                     hwmonName.end());
+
+                // Looking for keys like "Name1" for temp2_input,
+                // "Name2" for temp3_input, etc.
+                int i = 0;
+                while (true)
+                {
+                    ++i;
+                    auto findKey =
+                        baseConfigMap.find("Name" + std::to_string(i));
+                    if (findKey == baseConfigMap.end())
+                    {
+                        break;
+                    }
+                    std::string sensorName =
+                        std::get<std::string>(findKey->second);
+                    hwmonFile = getFullHwmonFilePath(
+                        directory.string(), "temp" + std::to_string(i + 1),
+                        permitSet);
+                    if (pathStr.starts_with("/sys/bus/iio/devices"))
+                    {
+                        continue;
+                    }
+                    if (hwmonFile)
+                    {
+                        // To look up thresholds for these additional sensors,
+                        // match on the Index property in the threshold data
+                        // where the index comes from the sysfs file we're on,
+                        // i.e. index = 2 for temp2_input.
+                        int index = i + 1;
+                        std::vector<thresholds::Threshold> thresholds;
+
+                        if (!parseThresholdsFromConfig(sensorData, thresholds,
+                                                       nullptr, &index))
+                        {
+                            std::cerr
+                                << "error populating thresholds for "
+                                << sensorName << " index " << index << "\n";
+                        }
+
+                        auto& sensor = sensors[sensorName];
+                        if (!activateOnly)
+                        {
+                            sensor = nullptr;
+                        }
+
+                        if (sensor != nullptr)
+                        {
+                            sensor->activate(*hwmonFile, i2cDev);
+                        }
+                        else
+                        {
+                            sensor = std::make_shared<HwmonTempSensor>(
+                                *hwmonFile, sensorType, objectServer,
+                                dbusConnection, io, sensorName,
+                                std::move(thresholds), thisSensorParameters,
+                                pollRate, interfacePath, readState, i2cDev);
+                            sensor->setupRead();
+                        }
+                    }
+
+                    hwmonName.erase(
+                        remove(hwmonName.begin(), hwmonName.end(), sensorName),
+                        hwmonName.end());
+                }
+                if (hwmonName.empty())
+                {
+                    configMap.erase(findSensorCfg);
+                }
             }
-            if (hwmonName.empty())
-            {
-                configMap.erase(findSensorCfg);
-            }
-        }
-    });
+        });
     std::vector<std::string> types(sensorTypes.size());
     for (const auto& [type, dt] : sensorTypes)
     {
@@ -615,30 +621,30 @@
     boost::asio::steady_timer filterTimer(io);
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&](sdbusplus::message_t& message) {
-        if (message.is_method_error())
-        {
-            std::cerr << "callback method error\n";
-            return;
-        }
-        sensorsChanged->insert(message.get_path());
-        // this implicitly cancels the timer
-        filterTimer.expires_after(std::chrono::seconds(1));
+            if (message.is_method_error())
+            {
+                std::cerr << "callback method error\n";
+                return;
+            }
+            sensorsChanged->insert(message.get_path());
+            // this implicitly cancels the timer
+            filterTimer.expires_after(std::chrono::seconds(1));
 
-        filterTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
-            {
-                /* we were canceled*/
-                return;
-            }
-            if (ec)
-            {
-                std::cerr << "timer error\n";
-                return;
-            }
-            createSensors(io, objectServer, sensors, systemBus, sensorsChanged,
-                          false);
-        });
-    };
+            filterTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    /* we were canceled*/
+                    return;
+                }
+                if (ec)
+                {
+                    std::cerr << "timer error\n";
+                    return;
+                }
+                createSensors(io, objectServer, sensors, systemBus,
+                              sensorsChanged, false);
+            });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(*systemBus, sensorTypes, eventHandler);
@@ -651,8 +657,8 @@
         "type='signal',member='InterfacesRemoved',arg0path='" +
             std::string(inventoryPath) + "/'",
         [&sensors](sdbusplus::message_t& msg) {
-        interfaceRemoved(msg, sensors);
-    });
+            interfaceRemoved(msg, sensors);
+        });
 
     matches.emplace_back(std::move(ifaceRemovedMatch));
 
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 0afacf8..eab7349 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -77,15 +77,15 @@
     {
         std::string interface = thresholds::getInterface(threshold.level);
         thresholdInterfaces[static_cast<size_t>(threshold.level)] =
-            objectServer.add_interface("/xyz/openbmc_project/sensors/" +
-                                           thisSensorParameters.typeName + "/" +
-                                           name,
-                                       interface);
+            objectServer.add_interface(
+                "/xyz/openbmc_project/sensors/" +
+                    thisSensorParameters.typeName + "/" + name,
+                interface);
     }
-    association = objectServer.add_interface("/xyz/openbmc_project/sensors/" +
-                                                 thisSensorParameters.typeName +
-                                                 "/" + name,
-                                             association::interface);
+    association = objectServer.add_interface(
+        "/xyz/openbmc_project/sensors/" + thisSensorParameters.typeName + "/" +
+            name,
+        association::interface);
     setInitialProperties(thisSensorParameters.units);
 }
 
@@ -140,12 +140,12 @@
     inputDev.async_read_some_at(
         0, boost::asio::buffer(readBuf),
         [weakRef](const boost::system::error_code& ec, std::size_t bytesRead) {
-        std::shared_ptr<HwmonTempSensor> self = weakRef.lock();
-        if (self)
-        {
-            self->handleResponse(ec, bytesRead);
-        }
-    });
+            std::shared_ptr<HwmonTempSensor> self = weakRef.lock();
+            if (self)
+            {
+                self->handleResponse(ec, bytesRead);
+            }
+        });
 }
 
 void HwmonTempSensor::restartRead()
@@ -181,8 +181,8 @@
     {
         const char* bufEnd = readBuf.data() + bytesRead;
         int nvalue = 0;
-        std::from_chars_result ret = std::from_chars(readBuf.data(), bufEnd,
-                                                     nvalue);
+        std::from_chars_result ret =
+            std::from_chars(readBuf.data(), bufEnd, nvalue);
         if (ret.ec != std::errc())
         {
             incrementError();
diff --git a/src/IntelCPUSensor.cpp b/src/IntelCPUSensor.cpp
index e21f4b0..dfe09fd 100644
--- a/src/IntelCPUSensor.cpp
+++ b/src/IntelCPUSensor.cpp
@@ -169,13 +169,14 @@
     std::weak_ptr<IntelCPUSensor> weakRef = weak_from_this();
     inputDev.async_wait(boost::asio::posix::descriptor_base::wait_read,
                         [weakRef](const boost::system::error_code& ec) {
-        std::shared_ptr<IntelCPUSensor> self = weakRef.lock();
+                            std::shared_ptr<IntelCPUSensor> self =
+                                weakRef.lock();
 
-        if (self)
-        {
-            self->handleResponse(ec);
-        }
-    });
+                            if (self)
+                            {
+                                self->handleResponse(ec);
+                            }
+                        });
 }
 
 void IntelCPUSensor::updateMinMaxValues()
@@ -204,8 +205,8 @@
             {
                 const auto& [suffix, oldValue, dbusName] = vectorItem;
                 auto attrPath = boost::replace_all_copy(path, fileItem, suffix);
-                if (auto newVal = readFile(attrPath,
-                                           IntelCPUSensor::sensorScaleFactor))
+                if (auto newVal =
+                        readFile(attrPath, IntelCPUSensor::sensorScaleFactor))
                 {
                     updateProperty(sensorInterface, oldValue, *newVal,
                                    dbusName);
diff --git a/src/IntelCPUSensor.hpp b/src/IntelCPUSensor.hpp
index 88e6040..0c55c6c 100644
--- a/src/IntelCPUSensor.hpp
+++ b/src/IntelCPUSensor.hpp
@@ -70,8 +70,8 @@
     {
         return false;
     }
-    std::string gpioName = std::visit(VariantToStringVisitor(),
-                                      findName->second);
+    std::string gpioName =
+        std::visit(VariantToStringVisitor(), findName->second);
 
     auto findIndex = cpuPresence.find(gpioName);
     if (findIndex != cpuPresence.end())
diff --git a/src/IntelCPUSensorMain.cpp b/src/IntelCPUSensorMain.cpp
index 7d14915..4ad0853 100644
--- a/src/IntelCPUSensorMain.cpp
+++ b/src/IntelCPUSensorMain.cpp
@@ -82,8 +82,7 @@
 {
     CPUConfig(const uint64_t& bus, const uint64_t& addr,
               const std::string& name, const State& state) :
-        bus(bus),
-        addr(addr), name(name), state(state)
+        bus(bus), addr(addr), name(name), state(state)
     {}
     int bus;
     int addr;
@@ -140,20 +139,20 @@
     bool isWordEnd = true;
     std::transform(sensorName.begin(), sensorName.end(), sensorName.begin(),
                    [&isWordEnd](int c) {
-        if (std::isspace(c) != 0)
-        {
-            isWordEnd = true;
-        }
-        else
-        {
-            if (isWordEnd)
-            {
-                isWordEnd = false;
-                return std::toupper(c);
-            }
-        }
-        return c;
-    });
+                       if (std::isspace(c) != 0)
+                       {
+                           isWordEnd = true;
+                       }
+                       else
+                       {
+                           if (isWordEnd)
+                           {
+                               isWordEnd = false;
+                               return std::toupper(c);
+                           }
+                       }
+                       return c;
+                   });
     return sensorName;
 }
 
@@ -304,8 +303,8 @@
             std::cerr << "could not determine CPU ID for " << hwmonName << "\n";
             continue;
         }
-        int cpuId = std::visit(VariantToUnsignedIntVisitor(),
-                               findCpuId->second);
+        int cpuId =
+            std::visit(VariantToUnsignedIntVisitor(), findCpuId->second);
 
         auto directory = hwmonNamePath.parent_path();
         std::vector<fs::path> inputPaths;
@@ -326,8 +325,8 @@
             }
             auto& [type, nr, item] = *fileParts;
             auto inputPathStr = inputPath.string();
-            auto labelPath = boost::replace_all_copy(inputPathStr, item,
-                                                     "label");
+            auto labelPath =
+                boost::replace_all_copy(inputPathStr, item, "label");
             std::ifstream labelFile(labelPath);
             if (!labelFile.good())
             {
@@ -569,8 +568,8 @@
 
                 // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
                 if (peci_RdPkgConfig(config.addr, PECI_MBX_INDEX_DDR_DIMM_TEMP,
-                                     rank, 4, pkgConfig.data(),
-                                     &cc) == PECI_CC_SUCCESS)
+                                     rank, 4, pkgConfig.data(), &cc) ==
+                    PECI_CC_SUCCESS)
                 {
                     // Depending on CPU generation, both 0 and 0xFF can be used
                     // to indicate no DIMM presence
@@ -607,8 +606,8 @@
                     uint8_t cc = 0;
 
                     if (peci_RdPkgConfig(config.addr, PECI_MBX_INDEX_CPU_ID, 0,
-                                         4, pkgConfig.data(),
-                                         &cc) == PECI_CC_SUCCESS)
+                                         4, pkgConfig.data(), &cc) ==
+                        PECI_CC_SUCCESS)
                     {
                         std::cout << config.name << " is detected\n";
                         if (!exportDevice(config))
@@ -629,8 +628,8 @@
                 else if (newState == State::READY)
                 {
                     rescanDelaySeconds = 5;
-                    std::cout << "DIMM(s) on " << config.name
-                              << " is/are detected\n";
+                    std::cout
+                        << "DIMM(s) on " << config.name << " is/are detected\n";
                 }
             }
 
@@ -729,10 +728,10 @@
                 {
                     continue;
                 }
-                std::string nameRaw = std::visit(VariantToStringVisitor(),
-                                                 findName->second);
-                std::string name = std::regex_replace(nameRaw, illegalDbusRegex,
-                                                      "_");
+                std::string nameRaw =
+                    std::visit(VariantToStringVisitor(), findName->second);
+                std::string name =
+                    std::regex_replace(nameRaw, illegalDbusRegex, "_");
 
                 auto present = std::optional<bool>();
                 // if we can't detect it via gpio, we set presence later
@@ -763,14 +762,14 @@
                     std::cerr << "Can't find 'Bus' setting in " << name << "\n";
                     continue;
                 }
-                uint64_t bus = std::visit(VariantToUnsignedIntVisitor(),
-                                          findBus->second);
+                uint64_t bus =
+                    std::visit(VariantToUnsignedIntVisitor(), findBus->second);
 
                 auto findAddress = cfg.find("Address");
                 if (findAddress == cfg.end())
                 {
-                    std::cerr << "Can't find 'Address' setting in " << name
-                              << "\n";
+                    std::cerr
+                        << "Can't find 'Address' setting in " << name << "\n";
                     continue;
                 }
                 uint64_t addr = std::visit(VariantToUnsignedIntVisitor(),
@@ -828,33 +827,33 @@
 
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&](sdbusplus::message_t& message) {
-        if (message.is_method_error())
-        {
-            std::cerr << "callback method error\n";
-            return;
-        }
-
-        if (debug)
-        {
-            std::cout << message.get_path() << " is changed\n";
-        }
-
-        // this implicitly cancels the timer
-        filterTimer.expires_after(std::chrono::seconds(1));
-        filterTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
+            if (message.is_method_error())
             {
-                return; // we're being canceled
+                std::cerr << "callback method error\n";
+                return;
             }
 
-            if (getCpuConfig(systemBus, cpuConfigs, sensorConfigs,
-                             objectServer))
+            if (debug)
             {
-                detectCpuAsync(pingTimer, creationTimer, io, objectServer,
-                               systemBus, cpuConfigs, sensorConfigs);
+                std::cout << message.get_path() << " is changed\n";
             }
-        });
-    };
+
+            // this implicitly cancels the timer
+            filterTimer.expires_after(std::chrono::seconds(1));
+            filterTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    return; // we're being canceled
+                }
+
+                if (getCpuConfig(systemBus, cpuConfigs, sensorConfigs,
+                                 objectServer))
+                {
+                    detectCpuAsync(pingTimer, creationTimer, io, objectServer,
+                                   systemBus, cpuConfigs, sensorConfigs);
+                }
+            });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(*systemBus, sensorTypes, eventHandler);
diff --git a/src/IntrusionSensorMain.cpp b/src/IntrusionSensorMain.cpp
index a0cf1b7..c94727a 100644
--- a/src/IntrusionSensorMain.cpp
+++ b/src/IntrusionSensorMain.cpp
@@ -201,9 +201,9 @@
                     pSensor->start();
                     if (debug)
                     {
-                        std::cout << "find matched bus " << busId
-                                  << ", matched slave addr " << slaveAddr
-                                  << "\n";
+                        std::cout
+                            << "find matched bus " << busId
+                            << ", matched slave addr " << slaveAddr << "\n";
                     }
                     return;
                 }
@@ -243,47 +243,48 @@
 {
     auto getter = std::make_shared<GetSensorConfiguration>(
         dbusConnection, [](const ManagedObjectType& sensorConfigurations) {
-        // Get NIC name and save to map
-        lanInfoMap.clear();
-        for (const auto& [path, cfgData] : sensorConfigurations)
-        {
-            const std::pair<std::string, SensorBaseConfigMap>*
-                baseConfiguration = nullptr;
-
-            // find base configuration
-            auto sensorBase = cfgData.find(configInterfaceName(nicType));
-            if (sensorBase == cfgData.end())
+            // Get NIC name and save to map
+            lanInfoMap.clear();
+            for (const auto& [path, cfgData] : sensorConfigurations)
             {
-                continue;
-            }
-            baseConfiguration = &(*sensorBase);
+                const std::pair<std::string, SensorBaseConfigMap>*
+                    baseConfiguration = nullptr;
 
-            auto findEthIndex = baseConfiguration->second.find("EthIndex");
-            auto findName = baseConfiguration->second.find("Name");
-
-            if (findEthIndex != baseConfiguration->second.end() &&
-                findName != baseConfiguration->second.end())
-            {
-                const auto* pEthIndex =
-                    std::get_if<uint64_t>(&findEthIndex->second);
-                const auto* pName = std::get_if<std::string>(&findName->second);
-                if (pEthIndex != nullptr && pName != nullptr)
+                // find base configuration
+                auto sensorBase = cfgData.find(configInterfaceName(nicType));
+                if (sensorBase == cfgData.end())
                 {
-                    lanInfoMap[*pEthIndex] = *pName;
-                    if (debugLanLeash)
+                    continue;
+                }
+                baseConfiguration = &(*sensorBase);
+
+                auto findEthIndex = baseConfiguration->second.find("EthIndex");
+                auto findName = baseConfiguration->second.find("Name");
+
+                if (findEthIndex != baseConfiguration->second.end() &&
+                    findName != baseConfiguration->second.end())
+                {
+                    const auto* pEthIndex =
+                        std::get_if<uint64_t>(&findEthIndex->second);
+                    const auto* pName =
+                        std::get_if<std::string>(&findName->second);
+                    if (pEthIndex != nullptr && pName != nullptr)
                     {
-                        std::cout << "find name of eth" << *pEthIndex << " is "
-                                  << *pName << "\n";
+                        lanInfoMap[*pEthIndex] = *pName;
+                        if (debugLanLeash)
+                        {
+                            std::cout << "find name of eth" << *pEthIndex
+                                      << " is " << *pName << "\n";
+                        }
                     }
                 }
             }
-        }
 
-        if (lanInfoMap.empty())
-        {
-            std::cerr << "can't find matched NIC name. \n";
-        }
-    });
+            if (lanInfoMap.empty())
+            {
+                std::cerr << "can't find matched NIC name. \n";
+            }
+        });
 
     getter->getConfiguration(
         std::vector<std::string>{nicTypes.begin(), nicTypes.end()});
@@ -366,8 +367,8 @@
     {
         std::string strEthNum = "eth" + std::to_string(ethNum) + lanInfo;
         const auto* strState = newLanConnected ? "connected" : "lost";
-        const auto* strMsgId = newLanConnected ? "OpenBMC.0.1.LanRegained"
-                                               : "OpenBMC.0.1.LanLost";
+        const auto* strMsgId =
+            newLanConnected ? "OpenBMC.0.1.LanRegained" : "OpenBMC.0.1.LanLost";
 
         lg2::info("{ETHDEV} LAN leash {STATE}", "ETHDEV", strEthNum, "STATE",
                   strState, "REDFISH_MESSAGE_ID", strMsgId,
@@ -431,39 +432,38 @@
         pathSuffixMap[pathSuffix] = ethNum;
         if (debugLanLeash)
         {
-            std::cout << "ethNum = " << std::to_string(ethNum)
-                      << ", ifindex = " << line
-                      << ", pathSuffix = " << pathSuffix << "\n";
+            std::cout << "ethNum = " << std::to_string(ethNum) << ", ifindex = "
+                      << line << ", pathSuffix = " << pathSuffix << "\n";
         }
 
         // init lan connected status from networkd
         conn->async_method_call(
             [ethNum](boost::system::error_code ec,
                      const std::variant<std::string>& property) {
-            lanStatusMap[ethNum] = false;
-            if (ec)
-            {
-                std::cerr << "Error reading init status of eth" << ethNum
-                          << "\n";
-                return;
-            }
-            const std::string* pState = std::get_if<std::string>(&property);
-            if (pState == nullptr)
-            {
-                std::cerr << "Unable to read lan status value\n";
-                return;
-            }
-            bool isLanConnected = (*pState == "routable" ||
-                                   *pState == "carrier" ||
-                                   *pState == "degraded");
-            if (debugLanLeash)
-            {
-                std::cout << "ethNum = " << std::to_string(ethNum)
-                          << ", init LAN status = "
-                          << (isLanConnected ? "true" : "false") << "\n";
-            }
-            lanStatusMap[ethNum] = isLanConnected;
-        },
+                lanStatusMap[ethNum] = false;
+                if (ec)
+                {
+                    std::cerr
+                        << "Error reading init status of eth" << ethNum << "\n";
+                    return;
+                }
+                const std::string* pState = std::get_if<std::string>(&property);
+                if (pState == nullptr)
+                {
+                    std::cerr << "Unable to read lan status value\n";
+                    return;
+                }
+                bool isLanConnected =
+                    (*pState == "routable" || *pState == "carrier" ||
+                     *pState == "degraded");
+                if (debugLanLeash)
+                {
+                    std::cout << "ethNum = " << std::to_string(ethNum)
+                              << ", init LAN status = "
+                              << (isLanConnected ? "true" : "false") << "\n";
+                }
+                lanStatusMap[ethNum] = isLanConnected;
+            },
             "org.freedesktop.network1",
             "/org/freedesktop/network1/link/_" + pathSuffix,
             "org.freedesktop.DBus.Properties", "Get",
@@ -493,23 +493,24 @@
     boost::asio::steady_timer filterTimer(io);
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&](sdbusplus::message_t& message) {
-        if (message.is_method_error())
-        {
-            std::cerr << "callback method error\n";
-            return;
-        }
-        // this implicitly cancels the timer
-        filterTimer.expires_after(std::chrono::seconds(1));
-        filterTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
+            if (message.is_method_error())
             {
-                // timer was cancelled
+                std::cerr << "callback method error\n";
                 return;
             }
-            std::cout << "rescan due to configuration change \n";
-            createSensorsFromConfig(io, objServer, systemBus, intrusionSensor);
-        });
-    };
+            // this implicitly cancels the timer
+            filterTimer.expires_after(std::chrono::seconds(1));
+            filterTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    // timer was cancelled
+                    return;
+                }
+                std::cout << "rescan due to configuration change \n";
+                createSensorsFromConfig(io, objServer, systemBus,
+                                        intrusionSensor);
+            });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(
@@ -532,13 +533,13 @@
                 std::string(inventoryPath) + "',arg0namespace='" +
                 configInterfaceName(nicType) + "'",
             [&systemBus](sdbusplus::message_t& msg) {
-            if (msg.is_method_error())
-            {
-                std::cerr << "callback method error\n";
-                return;
-            }
-            getNicNameInfo(systemBus);
-        });
+                if (msg.is_method_error())
+                {
+                    std::cerr << "callback method error\n";
+                    return;
+                }
+                getNicNameInfo(systemBus);
+            });
     }
 
     io.run();
diff --git a/src/IpmbSDRSensor.cpp b/src/IpmbSDRSensor.cpp
index 299ff80..c23ddea 100644
--- a/src/IpmbSDRSensor.cpp
+++ b/src/IpmbSDRSensor.cpp
@@ -21,8 +21,7 @@
 IpmbSDRDevice::IpmbSDRDevice(
     std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
     uint8_t cmdAddr) :
-    commandAddress(cmdAddr << 2),
-    hostIndex(cmdAddr + 1), conn(dbusConnection)
+    commandAddress(cmdAddr << 2), hostIndex(cmdAddr + 1), conn(dbusConnection)
 {}
 
 bool validateStatus(boost::system::error_code ec,
@@ -52,36 +51,37 @@
     conn->async_method_call(
         [weakRef](boost::system::error_code ec,
                   const IpmbMethodType& response) {
-        auto self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
+            auto self = weakRef.lock();
+            if (!self)
+            {
+                return;
+            }
 
-        auto status = std::bind_front(validateStatus, ec, response);
-        if (!status(self->hostIndex))
-        {
-            return;
-        }
+            auto status = std::bind_front(validateStatus, ec, response);
+            if (!status(self->hostIndex))
+            {
+                return;
+            }
 
-        const std::vector<uint8_t>& data = std::get<5>(response);
-        const size_t sdrInfoDataSize = 14;
+            const std::vector<uint8_t>& data = std::get<5>(response);
+            const size_t sdrInfoDataSize = 14;
 
-        if (data.size() < sdrInfoDataSize)
-        {
-            std::cerr << " IPMB Get SDR Repository Info data is empty for host "
-                      << self->hostIndex << "\n";
-            return;
-        }
+            if (data.size() < sdrInfoDataSize)
+            {
+                std::cerr
+                    << " IPMB Get SDR Repository Info data is empty for host "
+                    << self->hostIndex << "\n";
+                return;
+            }
 
-        constexpr uint8_t recordCountLSB = 1;
-        constexpr uint8_t recordCountMSB = 2;
+            constexpr uint8_t recordCountLSB = 1;
+            constexpr uint8_t recordCountMSB = 2;
 
-        uint16_t recordCount = (data[recordCountMSB] << 8) |
-                               data[recordCountLSB];
+            uint16_t recordCount = (data[recordCountMSB] << 8) |
+                                   data[recordCountLSB];
 
-        self->reserveSDRRepository(recordCount);
-    },
+            self->reserveSDRRepository(recordCount);
+        },
         ipmbService, ipmbDbusPath, ipmbInterface, ipmbMethod, commandAddress,
         sdr::netfnStorageReq, lun, sdr::cmdStorageGetSdrInfo, sdrCommandData);
 }
@@ -94,32 +94,33 @@
     conn->async_method_call(
         [weakRef, recordCount](boost::system::error_code ec,
                                const IpmbMethodType& response) {
-        auto self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
+            auto self = weakRef.lock();
+            if (!self)
+            {
+                return;
+            }
 
-        auto status = std::bind_front(validateStatus, ec, response);
-        if (!status(self->hostIndex))
-        {
-            return;
-        }
+            auto status = std::bind_front(validateStatus, ec, response);
+            if (!status(self->hostIndex))
+            {
+                return;
+            }
 
-        const std::vector<uint8_t>& data = std::get<5>(response);
-        const size_t sdrReserveDataSize = 2;
+            const std::vector<uint8_t>& data = std::get<5>(response);
+            const size_t sdrReserveDataSize = 2;
 
-        if (data.size() < sdrReserveDataSize)
-        {
-            std::cerr << " IPMB SDR Reserve Repository data is empty for host "
-                      << self->hostIndex << "\n";
-            return;
-        }
-        uint8_t resrvIDLSB = data[0];
-        uint8_t resrvIDMSB = data[1];
+            if (data.size() < sdrReserveDataSize)
+            {
+                std::cerr
+                    << " IPMB SDR Reserve Repository data is empty for host "
+                    << self->hostIndex << "\n";
+                return;
+            }
+            uint8_t resrvIDLSB = data[0];
+            uint8_t resrvIDMSB = data[1];
 
-        self->getSDRSensorData(recordCount, resrvIDLSB, resrvIDMSB);
-    },
+            self->getSDRSensorData(recordCount, resrvIDLSB, resrvIDMSB);
+        },
         ipmbService, ipmbDbusPath, ipmbInterface, ipmbMethod, commandAddress,
         sdr::netfnStorageReq, lun, sdr::cmdStorageReserveSdr, sdrCommandData);
 }
@@ -139,30 +140,30 @@
     conn->async_method_call(
         [weakRef, recordCount, resrvIDLSB, resrvIDMSB](
             boost::system::error_code ec, const IpmbMethodType& response) {
-        auto self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
+            auto self = weakRef.lock();
+            if (!self)
+            {
+                return;
+            }
 
-        auto status = std::bind_front(validateStatus, ec, response);
-        if (!status(self->hostIndex))
-        {
-            return;
-        }
+            auto status = std::bind_front(validateStatus, ec, response);
+            if (!status(self->hostIndex))
+            {
+                return;
+            }
 
-        const std::vector<uint8_t>& data = std::get<5>(response);
-        const size_t sdrSensorDataSize = 18;
+            const std::vector<uint8_t>& data = std::get<5>(response);
+            const size_t sdrSensorDataSize = 18;
 
-        if (data.size() < sdrSensorDataSize)
-        {
-            std::cerr << "IPMB SDR sensor data is empty for host "
-                      << self->hostIndex << "\n";
-            return;
-        }
+            if (data.size() < sdrSensorDataSize)
+            {
+                std::cerr << "IPMB SDR sensor data is empty for host "
+                          << self->hostIndex << "\n";
+                return;
+            }
 
-        self->handleSDRData(data, recordCount, resrvIDLSB, resrvIDMSB);
-    },
+            self->handleSDRData(data, recordCount, resrvIDLSB, resrvIDMSB);
+        },
         ipmbService, ipmbDbusPath, ipmbInterface, ipmbMethod, commandAddress,
         sdr::netfnStorageReq, lun, sdr::cmdStorageGetSdr, commandData);
 }
@@ -271,17 +272,17 @@
      * mDataByte    - Byte 28 - 8 bits LSB
      * mTolDataByte - Byte 29 - 2 bits MSB [7-6]
      */
-    uint16_t mData = ((sdrDataBytes[sdrtype01::mTolDataByte] & 0xC0)
-                      << bitShiftMsb) |
-                     sdrDataBytes[sdrtype01::mDataByte];
+    uint16_t mData =
+        ((sdrDataBytes[sdrtype01::mTolDataByte] & 0xC0) << bitShiftMsb) |
+        sdrDataBytes[sdrtype01::mDataByte];
 
     /* bData        - 10 bits
      * bDataByte    - Byte 30 - 8 bits LSB
      * bAcuDataByte - Byte 31 - 2 bits MSB [7-6]
      */
-    uint16_t bData = ((sdrDataBytes[sdrtype01::bAcuDataByte] & 0xC0)
-                      << bitShiftMsb) |
-                     sdrDataBytes[sdrtype01::bDataByte];
+    uint16_t bData =
+        ((sdrDataBytes[sdrtype01::bAcuDataByte] & 0xC0) << bitShiftMsb) |
+        sdrDataBytes[sdrtype01::bDataByte];
 
     /* rbExpDataByte (Byte 33) represents the exponent value
      *  Bit [3-0] - B Exponent 2's complement signed bit.
diff --git a/src/IpmbSensor.cpp b/src/IpmbSensor.cpp
index fbc4b7d..fc6cc7a 100644
--- a/src/IpmbSensor.cpp
+++ b/src/IpmbSensor.cpp
@@ -60,14 +60,13 @@
 
 static constexpr const char* sensorPathPrefix = "/xyz/openbmc_project/sensors/";
 
-IpmbSensor::IpmbSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
-                       boost::asio::io_context& io,
-                       const std::string& sensorName,
-                       const std::string& sensorConfiguration,
-                       sdbusplus::asio::object_server& objectServer,
-                       std::vector<thresholds::Threshold>&& thresholdData,
-                       uint8_t deviceAddress, uint8_t hostSMbusIndex,
-                       const float pollRate, std::string& sensorTypeName) :
+IpmbSensor::IpmbSensor(
+    std::shared_ptr<sdbusplus::asio::connection>& conn,
+    boost::asio::io_context& io, const std::string& sensorName,
+    const std::string& sensorConfiguration,
+    sdbusplus::asio::object_server& objectServer,
+    std::vector<thresholds::Threshold>&& thresholdData, uint8_t deviceAddress,
+    uint8_t hostSMbusIndex, const float pollRate, std::string& sensorTypeName) :
     Sensor(escapeName(sensorName), std::move(thresholdData),
            sensorConfiguration, "IpmbSensor", false, false, ipmbMaxReading,
            ipmbMinReading, conn, PowerState::on),
@@ -156,8 +155,8 @@
     dbusConnection->async_method_call(
         [weakRef{weak_from_this()}](const boost::system::error_code& ec,
                                     const IpmbMethodType& response) {
-        initCmdCb(weakRef, ec, response);
-    },
+            initCmdCb(weakRef, ec, response);
+        },
         "xyz.openbmc_project.Ipmi.Channel.Ipmb",
         "/xyz/openbmc_project/Ipmi/Channel/Ipmb", "org.openbmc.Ipmb",
         "sendRequest", commandAddress, netfn, lun, *initCommand, initData);
@@ -478,17 +477,17 @@
     waitTimer.expires_after(std::chrono::milliseconds(sensorPollMs));
     waitTimer.async_wait(
         [weakRef{weak_from_this()}](const boost::system::error_code& ec) {
-        if (ec == boost::asio::error::operation_aborted)
-        {
-            return; // we're being canceled
-        }
-        std::shared_ptr<IpmbSensor> self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
-        self->sendIpmbRequest();
-    });
+            if (ec == boost::asio::error::operation_aborted)
+            {
+                return; // we're being canceled
+            }
+            std::shared_ptr<IpmbSensor> self = weakRef.lock();
+            if (!self)
+            {
+                return;
+            }
+            self->sendIpmbRequest();
+        });
 }
 
 void IpmbSensor::sendIpmbRequest()
@@ -502,13 +501,13 @@
     dbusConnection->async_method_call(
         [weakRef{weak_from_this()}](boost::system::error_code ec,
                                     const IpmbMethodType& response) {
-        std::shared_ptr<IpmbSensor> self = weakRef.lock();
-        if (!self)
-        {
-            return;
-        }
-        self->ipmbRequestCompletionCb(ec, response);
-    },
+            std::shared_ptr<IpmbSensor> self = weakRef.lock();
+            if (!self)
+            {
+                return;
+            }
+            self->ipmbRequestCompletionCb(ec, response);
+        },
         "xyz.openbmc_project.Ipmi.Channel.Ipmb",
         "/xyz/openbmc_project/Ipmi/Channel/Ipmb", "org.openbmc.Ipmb",
         "sendRequest", commandAddress, netfn, lun, command, commandData);
@@ -602,77 +601,80 @@
     }
     dbusConnection->async_method_call(
         [&](boost::system::error_code ec, const ManagedObjectType& resp) {
-        if (ec)
-        {
-            std::cerr << "Error contacting entity manager\n";
-            return;
-        }
-        for (const auto& [path, interfaces] : resp)
-        {
-            for (const auto& [intf, cfg] : interfaces)
+            if (ec)
             {
-                if (intf != configInterfaceName(sensorType))
-                {
-                    continue;
-                }
-                std::string name = loadVariant<std::string>(cfg, "Name");
-
-                std::vector<thresholds::Threshold> sensorThresholds;
-                if (!parseThresholdsFromConfig(interfaces, sensorThresholds))
-                {
-                    std::cerr << "error populating thresholds " << name << "\n";
-                }
-                uint8_t deviceAddress = loadVariant<uint8_t>(cfg, "Address");
-
-                std::string sensorClass = loadVariant<std::string>(cfg,
-                                                                   "Class");
-
-                uint8_t hostSMbusIndex = hostSMbusIndexDefault;
-                auto findSmType = cfg.find("HostSMbusIndex");
-                if (findSmType != cfg.end())
-                {
-                    hostSMbusIndex = std::visit(VariantToUnsignedIntVisitor(),
-                                                findSmType->second);
-                }
-
-                float pollRate = getPollRate(cfg, pollRateDefault);
-
-                uint8_t ipmbBusIndex = ipmbBusIndexDefault;
-                auto findBusType = cfg.find("Bus");
-                if (findBusType != cfg.end())
-                {
-                    ipmbBusIndex = std::visit(VariantToUnsignedIntVisitor(),
-                                              findBusType->second);
-                    std::cerr << "Ipmb Bus Index for " << name << " is "
-                              << static_cast<int>(ipmbBusIndex) << "\n";
-                }
-
-                /* Default sensor type is "temperature" */
-                std::string sensorTypeName = "temperature";
-                auto findType = cfg.find("SensorType");
-                if (findType != cfg.end())
-                {
-                    sensorTypeName = std::visit(VariantToStringVisitor(),
-                                                findType->second);
-                }
-
-                auto& sensor = sensors[name];
-                sensor = nullptr;
-                sensor = std::make_shared<IpmbSensor>(
-                    dbusConnection, io, name, path, objectServer,
-                    std::move(sensorThresholds), deviceAddress, hostSMbusIndex,
-                    pollRate, sensorTypeName);
-
-                sensor->parseConfigValues(cfg);
-                if (!(sensor->sensorClassType(sensorClass)))
-                {
-                    continue;
-                }
-                sensor->sensorSubType(sensorTypeName);
-                sensor->init();
+                std::cerr << "Error contacting entity manager\n";
+                return;
             }
-        }
-    },
+            for (const auto& [path, interfaces] : resp)
+            {
+                for (const auto& [intf, cfg] : interfaces)
+                {
+                    if (intf != configInterfaceName(sensorType))
+                    {
+                        continue;
+                    }
+                    std::string name = loadVariant<std::string>(cfg, "Name");
+
+                    std::vector<thresholds::Threshold> sensorThresholds;
+                    if (!parseThresholdsFromConfig(interfaces,
+                                                   sensorThresholds))
+                    {
+                        std::cerr
+                            << "error populating thresholds " << name << "\n";
+                    }
+                    uint8_t deviceAddress =
+                        loadVariant<uint8_t>(cfg, "Address");
+
+                    std::string sensorClass =
+                        loadVariant<std::string>(cfg, "Class");
+
+                    uint8_t hostSMbusIndex = hostSMbusIndexDefault;
+                    auto findSmType = cfg.find("HostSMbusIndex");
+                    if (findSmType != cfg.end())
+                    {
+                        hostSMbusIndex = std::visit(
+                            VariantToUnsignedIntVisitor(), findSmType->second);
+                    }
+
+                    float pollRate = getPollRate(cfg, pollRateDefault);
+
+                    uint8_t ipmbBusIndex = ipmbBusIndexDefault;
+                    auto findBusType = cfg.find("Bus");
+                    if (findBusType != cfg.end())
+                    {
+                        ipmbBusIndex = std::visit(VariantToUnsignedIntVisitor(),
+                                                  findBusType->second);
+                        std::cerr << "Ipmb Bus Index for " << name << " is "
+                                  << static_cast<int>(ipmbBusIndex) << "\n";
+                    }
+
+                    /* Default sensor type is "temperature" */
+                    std::string sensorTypeName = "temperature";
+                    auto findType = cfg.find("SensorType");
+                    if (findType != cfg.end())
+                    {
+                        sensorTypeName = std::visit(VariantToStringVisitor(),
+                                                    findType->second);
+                    }
+
+                    auto& sensor = sensors[name];
+                    sensor = nullptr;
+                    sensor = std::make_shared<IpmbSensor>(
+                        dbusConnection, io, name, path, objectServer,
+                        std::move(sensorThresholds), deviceAddress,
+                        hostSMbusIndex, pollRate, sensorTypeName);
+
+                    sensor->parseConfigValues(cfg);
+                    if (!(sensor->sensorClassType(sensorClass)))
+                    {
+                        continue;
+                    }
+                    sensor->sensorSubType(sensorTypeName);
+                    sensor->init();
+                }
+            }
+        },
         entityManagerName, "/xyz/openbmc_project/inventory",
         "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
 }
diff --git a/src/IpmbSensorMain.cpp b/src/IpmbSensorMain.cpp
index 9223264..5e38dd2 100644
--- a/src/IpmbSensorMain.cpp
+++ b/src/IpmbSensorMain.cpp
@@ -104,27 +104,28 @@
 
     initCmdTimer = std::make_unique<boost::asio::steady_timer>(io);
 
-    boost::asio::post(
-        io, [&]() { createSensors(io, objectServer, sensors, systemBus); });
+    boost::asio::post(io, [&]() {
+        createSensors(io, objectServer, sensors, systemBus);
+    });
 
     boost::asio::steady_timer configTimer(io);
 
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&](sdbusplus::message_t&) {
-        configTimer.expires_after(std::chrono::seconds(1));
-        // create a timer because normally multiple properties change
-        configTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
-            {
-                return; // we're being canceled
-            }
-            createSensors(io, objectServer, sensors, systemBus);
-            if (sensors.empty())
-            {
-                std::cout << "Configuration not detected\n";
-            }
-        });
-    };
+            configTimer.expires_after(std::chrono::seconds(1));
+            // create a timer because normally multiple properties change
+            configTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    return; // we're being canceled
+                }
+                createSensors(io, objectServer, sensors, systemBus);
+                if (sensors.empty())
+                {
+                    std::cout << "Configuration not detected\n";
+                }
+            });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(
@@ -143,8 +144,8 @@
             std::string(inventoryPath) + "',arg0namespace='" +
             configInterfaceName(sdrInterface) + "'",
         [&systemBus](sdbusplus::message_t& msg) {
-        sdrHandler(sdrsensor, msg, systemBus);
-    });
+            sdrHandler(sdrsensor, msg, systemBus);
+        });
 
     // Watch for entity-manager to remove configuration interfaces
     // so the corresponding sensors can be removed.
diff --git a/src/MCUTempSensor.cpp b/src/MCUTempSensor.cpp
index 48d2300..205521e 100644
--- a/src/MCUTempSensor.cpp
+++ b/src/MCUTempSensor.cpp
@@ -61,14 +61,13 @@
 
 boost::container::flat_map<std::string, std::unique_ptr<MCUTempSensor>> sensors;
 
-MCUTempSensor::MCUTempSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
-                             boost::asio::io_context& io,
-                             const std::string& sensorName,
-                             const std::string& sensorConfiguration,
-                             sdbusplus::asio::object_server& objectServer,
-                             std::vector<thresholds::Threshold>&& thresholdData,
-                             uint8_t busId, uint8_t mcuAddress,
-                             uint8_t tempReg) :
+MCUTempSensor::MCUTempSensor(
+    std::shared_ptr<sdbusplus::asio::connection>& conn,
+    boost::asio::io_context& io, const std::string& sensorName,
+    const std::string& sensorConfiguration,
+    sdbusplus::asio::object_server& objectServer,
+    std::vector<thresholds::Threshold>&& thresholdData, uint8_t busId,
+    uint8_t mcuAddress, uint8_t tempReg) :
     Sensor(escapeName(sensorName), std::move(thresholdData),
            sensorConfiguration, "MCUTempSensor", false, false,
            mcuTempMaxReading, mcuTempMinReading, conn),
@@ -215,57 +214,60 @@
     dbusConnection->async_method_call(
         [&io, &objectServer, &dbusConnection, &sensors](
             boost::system::error_code ec, const ManagedObjectType& resp) {
-        if (ec)
-        {
-            std::cerr << "Error contacting entity manager\n";
-            return;
-        }
-        for (const auto& [path, interfaces] : resp)
-        {
-            for (const auto& [intf, cfg] : interfaces)
+            if (ec)
             {
-                if (intf != configInterfaceName(sensorType))
-                {
-                    continue;
-                }
-                std::string name = loadVariant<std::string>(cfg, "Name");
-
-                std::vector<thresholds::Threshold> sensorThresholds;
-                if (!parseThresholdsFromConfig(interfaces, sensorThresholds))
-                {
-                    std::cerr << "error populating thresholds for " << name
-                              << "\n";
-                }
-
-                uint8_t busId = loadVariant<uint8_t>(cfg, "Bus");
-                uint8_t mcuAddress = loadVariant<uint8_t>(cfg, "Address");
-                uint8_t tempReg = loadVariant<uint8_t>(cfg, "Reg");
-
-                std::string sensorClass = loadVariant<std::string>(cfg,
-                                                                   "Class");
-
-                if constexpr (debug)
-                {
-                    std::cerr << "Configuration parsed for \n\t" << intf << "\n"
-                              << "with\n"
-                              << "\tName: " << name << "\n"
-                              << "\tBus: " << static_cast<int>(busId) << "\n"
-                              << "\tAddress: " << static_cast<int>(mcuAddress)
-                              << "\n"
-                              << "\tReg: " << static_cast<int>(tempReg) << "\n"
-                              << "\tClass: " << sensorClass << "\n";
-                }
-
-                auto& sensor = sensors[name];
-
-                sensor = std::make_unique<MCUTempSensor>(
-                    dbusConnection, io, name, path, objectServer,
-                    std::move(sensorThresholds), busId, mcuAddress, tempReg);
-
-                sensor->init();
+                std::cerr << "Error contacting entity manager\n";
+                return;
             }
-        }
-    },
+            for (const auto& [path, interfaces] : resp)
+            {
+                for (const auto& [intf, cfg] : interfaces)
+                {
+                    if (intf != configInterfaceName(sensorType))
+                    {
+                        continue;
+                    }
+                    std::string name = loadVariant<std::string>(cfg, "Name");
+
+                    std::vector<thresholds::Threshold> sensorThresholds;
+                    if (!parseThresholdsFromConfig(interfaces,
+                                                   sensorThresholds))
+                    {
+                        std::cerr << "error populating thresholds for " << name
+                                  << "\n";
+                    }
+
+                    uint8_t busId = loadVariant<uint8_t>(cfg, "Bus");
+                    uint8_t mcuAddress = loadVariant<uint8_t>(cfg, "Address");
+                    uint8_t tempReg = loadVariant<uint8_t>(cfg, "Reg");
+
+                    std::string sensorClass =
+                        loadVariant<std::string>(cfg, "Class");
+
+                    if constexpr (debug)
+                    {
+                        std::cerr
+                            << "Configuration parsed for \n\t" << intf << "\n"
+                            << "with\n"
+                            << "\tName: " << name << "\n"
+                            << "\tBus: " << static_cast<int>(busId) << "\n"
+                            << "\tAddress: " << static_cast<int>(mcuAddress)
+                            << "\n"
+                            << "\tReg: " << static_cast<int>(tempReg) << "\n"
+                            << "\tClass: " << sensorClass << "\n";
+                    }
+
+                    auto& sensor = sensors[name];
+
+                    sensor = std::make_unique<MCUTempSensor>(
+                        dbusConnection, io, name, path, objectServer,
+                        std::move(sensorThresholds), busId, mcuAddress,
+                        tempReg);
+
+                    sensor->init();
+                }
+            }
+        },
         entityManagerName, "/xyz/openbmc_project/inventory",
         "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
 }
@@ -279,33 +281,34 @@
 
     systemBus->request_name("xyz.openbmc_project.MCUTempSensor");
 
-    boost::asio::post(
-        io, [&]() { createSensors(io, objectServer, sensors, systemBus); });
+    boost::asio::post(io, [&]() {
+        createSensors(io, objectServer, sensors, systemBus);
+    });
 
     boost::asio::steady_timer configTimer(io);
 
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&](sdbusplus::message_t&) {
-        configTimer.expires_after(std::chrono::seconds(1));
-        // create a timer because normally multiple properties change
-        configTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
-            {
-                return; // we're being canceled
-            }
-            // config timer error
-            if (ec)
-            {
-                std::cerr << "timer error\n";
-                return;
-            }
-            createSensors(io, objectServer, sensors, systemBus);
-            if (sensors.empty())
-            {
-                std::cout << "Configuration not detected\n";
-            }
-        });
-    };
+            configTimer.expires_after(std::chrono::seconds(1));
+            // create a timer because normally multiple properties change
+            configTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    return; // we're being canceled
+                }
+                // config timer error
+                if (ec)
+                {
+                    std::cerr << "timer error\n";
+                    return;
+                }
+                createSensors(io, objectServer, sensors, systemBus);
+                if (sensors.empty())
+                {
+                    std::cout << "Configuration not detected\n";
+                }
+            });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(
diff --git a/src/NVMeBasicContext.cpp b/src/NVMeBasicContext.cpp
index eb5ecd9..64549a4 100644
--- a/src/NVMeBasicContext.cpp
+++ b/src/NVMeBasicContext.cpp
@@ -288,11 +288,11 @@
     boost::asio::async_write(
         reqStream, boost::asio::buffer(command->data(), command->size()),
         [command](boost::system::error_code ec, std::size_t) {
-        if (ec)
-        {
-            std::cerr << "Got error writing basic query: " << ec << "\n";
-        }
-    });
+            if (ec)
+            {
+                std::cerr << "Got error writing basic query: " << ec << "\n";
+            }
+        });
 
     auto response = std::make_shared<boost::asio::streambuf>();
     response->prepare(1);
@@ -301,70 +301,70 @@
     boost::asio::async_read(
         respStream, *response,
         [response](const boost::system::error_code& ec, std::size_t n) {
-        if (ec)
-        {
-            std::cerr << "Got error completing basic query: " << ec << "\n";
-            return static_cast<std::size_t>(0);
-        }
+            if (ec)
+            {
+                std::cerr << "Got error completing basic query: " << ec << "\n";
+                return static_cast<std::size_t>(0);
+            }
 
-        if (n == 0)
-        {
-            return static_cast<std::size_t>(1);
-        }
+            if (n == 0)
+            {
+                return static_cast<std::size_t>(1);
+            }
 
-        std::istream is(response.get());
-        size_t len = static_cast<std::size_t>(is.peek());
+            std::istream is(response.get());
+            size_t len = static_cast<std::size_t>(is.peek());
 
-        if (n > len + 1)
-        {
-            std::cerr << "Query stream has become unsynchronised: "
-                      << "n: " << n << ", "
-                      << "len: " << len << "\n";
-            return static_cast<std::size_t>(0);
-        }
+            if (n > len + 1)
+            {
+                std::cerr << "Query stream has become unsynchronised: "
+                          << "n: " << n << ", "
+                          << "len: " << len << "\n";
+                return static_cast<std::size_t>(0);
+            }
 
-        if (n == len + 1)
-        {
-            return static_cast<std::size_t>(0);
-        }
+            if (n == len + 1)
+            {
+                return static_cast<std::size_t>(0);
+            }
 
-        if (n > 1)
-        {
-            return len + 1 - n;
-        }
+            if (n > 1)
+            {
+                return len + 1 - n;
+            }
 
-        response->prepare(len);
-        return len;
-    },
+            response->prepare(len);
+            return len;
+        },
         [weakSelf{weak_from_this()}, sensor, response](
             const boost::system::error_code& ec, std::size_t length) mutable {
-        if (ec)
-        {
-            std::cerr << "Got error reading basic query: " << ec << "\n";
-            return;
-        }
+            if (ec)
+            {
+                std::cerr << "Got error reading basic query: " << ec << "\n";
+                return;
+            }
 
-        if (length == 0)
-        {
-            std::cerr << "Invalid message length: " << length << "\n";
-            return;
-        }
+            if (length == 0)
+            {
+                std::cerr << "Invalid message length: " << length << "\n";
+                return;
+            }
 
-        if (auto self = weakSelf.lock())
-        {
-            /* Deserialise the response */
-            response->consume(1); /* Drop the length byte */
-            std::istream is(response.get());
-            std::vector<char> data(response->size());
-            is.read(data.data(), response->size());
+            if (auto self = weakSelf.lock())
+            {
+                /* Deserialise the response */
+                response->consume(1); /* Drop the length byte */
+                std::istream is(response.get());
+                std::vector<char> data(response->size());
+                is.read(data.data(), response->size());
 
-            /* Update the sensor */
-            self->processResponse(sensor, data.data(), data.size());
+                /* Update the sensor */
+                self->processResponse(sensor, data.data(), data.size());
 
-            /* Enqueue processing of the next sensor */
-            self->readAndProcessNVMeSensor();
-        }
-    });
+                /* Enqueue processing of the next sensor */
+                self->readAndProcessNVMeSensor();
+            }
+        });
 }
 
 void NVMeBasicContext::pollNVMeDevices()
diff --git a/src/NVMeSensorMain.cpp b/src/NVMeSensorMain.cpp
index 5f0222d..2fe295d 100644
--- a/src/NVMeSensorMain.cpp
+++ b/src/NVMeSensorMain.cpp
@@ -57,9 +57,8 @@
     return nvmeDeviceMap;
 }
 
-static std::optional<int>
-    extractBusNumber(const std::string& path,
-                     const SensorBaseConfigMap& properties)
+static std::optional<int> extractBusNumber(
+    const std::string& path, const SensorBaseConfigMap& properties)
 {
     auto findBus = properties.find("Bus");
     if (findBus == properties.end())
@@ -86,9 +85,8 @@
     return std::visit(VariantToUnsignedIntVisitor(), findSlaveAddr->second);
 }
 
-static std::optional<std::string>
-    extractSensorName(const std::string& path,
-                      const SensorBaseConfigMap& properties)
+static std::optional<std::string> extractSensorName(
+    const std::string& path, const SensorBaseConfigMap& properties)
 {
     auto findSensorName = properties.find("Name");
     if (findSensorName == properties.end())
@@ -132,9 +130,8 @@
     return std::stoi(rootName.substr(0, dash));
 }
 
-static std::shared_ptr<NVMeContext>
-    provideRootBusContext(boost::asio::io_context& io, NVMEMap& map,
-                          int rootBus)
+static std::shared_ptr<NVMeContext> provideRootBusContext(
+    boost::asio::io_context& io, NVMEMap& map, int rootBus)
 {
     auto findRoot = map.find(rootBus);
     if (findRoot != map.end())
@@ -176,10 +173,10 @@
         }
 
         const SensorBaseConfigMap& sensorConfig = sensorBase->second;
-        std::optional<int> busNumber = extractBusNumber(interfacePath,
-                                                        sensorConfig);
-        std::optional<std::string> sensorName = extractSensorName(interfacePath,
-                                                                  sensorConfig);
+        std::optional<int> busNumber =
+            extractBusNumber(interfacePath, sensorConfig);
+        std::optional<std::string> sensorName =
+            extractSensorName(interfacePath, sensorConfig);
         uint8_t slaveAddr = extractSlaveAddr(interfacePath, sensorConfig);
         std::optional<int> rootBus = deriveRootBus(busNumber);
 
@@ -231,9 +228,9 @@
     auto getter = std::make_shared<GetSensorConfiguration>(
         dbusConnection, [&io, &objectServer, &dbusConnection](
                             const ManagedObjectType& sensorConfigurations) {
-        handleSensorConfigurations(io, objectServer, dbusConnection,
-                                   sensorConfigurations);
-    });
+            handleSensorConfigurations(io, objectServer, dbusConnection,
+                                       sensorConfigurations);
+        });
     getter->getConfiguration(std::vector<std::string>{NVMeSensor::sensorType});
 }
 
@@ -284,24 +281,24 @@
     boost::asio::steady_timer filterTimer(io);
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&filterTimer, &io, &objectServer, &systemBus](sdbusplus::message_t&) {
-        // this implicitly cancels the timer
-        filterTimer.expires_after(std::chrono::seconds(1));
+            // this implicitly cancels the timer
+            filterTimer.expires_after(std::chrono::seconds(1));
 
-        filterTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
-            {
-                return; // we're being canceled
-            }
+            filterTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    return; // we're being canceled
+                }
 
-            if (ec)
-            {
-                std::cerr << "Error: " << ec.message() << "\n";
-                return;
-            }
+                if (ec)
+                {
+                    std::cerr << "Error: " << ec.message() << "\n";
+                    return;
+                }
 
-            createSensors(io, objectServer, systemBus);
-        });
-    };
+                createSensors(io, objectServer, systemBus);
+            });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(
@@ -315,8 +312,8 @@
         "type='signal',member='InterfacesRemoved',arg0path='" +
             std::string(inventoryPath) + "/'",
         [](sdbusplus::message_t& msg) {
-        interfaceRemoved(msg, nvmeDeviceMap);
-    });
+            interfaceRemoved(msg, nvmeDeviceMap);
+        });
 
     setupManufacturingModeMatch(*systemBus);
     io.run();
diff --git a/src/PSUEvent.cpp b/src/PSUEvent.cpp
index 8a83f37..438faa2 100644
--- a/src/PSUEvent.cpp
+++ b/src/PSUEvent.cpp
@@ -45,8 +45,7 @@
     boost::asio::io_context& io, const std::string& psuName,
     const PowerState& powerState, EventPathList& eventPathList,
     GroupEventPathList& groupEventPathList, const std::string& combineEventName,
-    double pollRate) :
-    objServer(objectServer)
+    double pollRate) : objServer(objectServer)
 {
     std::string psuNameEscaped = sensor_paths::escapePathForDbus(psuName);
     eventInterface = objServer.add_interface(
@@ -146,10 +145,9 @@
     std::shared_ptr<std::set<std::string>> asserts,
     std::shared_ptr<std::set<std::string>> combineEvent,
     std::shared_ptr<bool> state, const std::string& psuName, double pollRate) :
-    eventInterface(std::move(eventInterface)),
-    asserts(std::move(asserts)), combineEvent(std::move(combineEvent)),
-    assertState(std::move(state)), path(path), eventName(eventName),
-    readState(powerState), waitTimer(io),
+    eventInterface(std::move(eventInterface)), asserts(std::move(asserts)),
+    combineEvent(std::move(combineEvent)), assertState(std::move(state)),
+    path(path), eventName(eventName), readState(powerState), waitTimer(io),
 
     inputDev(io, path, boost::asio::random_access_file::read_only),
     psuName(psuName), groupEventName(groupEventName), systemBus(conn)
@@ -210,12 +208,12 @@
         0, boost::asio::buffer(buffer->data(), buffer->size() - 1),
         [weakRef, buffer{buffer}](const boost::system::error_code& ec,
                                   std::size_t bytesTransferred) {
-        std::shared_ptr<PSUSubEvent> self = weakRef.lock();
-        if (self)
-        {
-            self->handleResponse(ec, bytesTransferred);
-        }
-    });
+            std::shared_ptr<PSUSubEvent> self = weakRef.lock();
+            if (self)
+            {
+                self->handleResponse(ec, bytesTransferred);
+            }
+        });
 }
 
 void PSUSubEvent::restartRead()
diff --git a/src/PSUSensor.cpp b/src/PSUSensor.cpp
index db632b6..3c02b93 100644
--- a/src/PSUSensor.cpp
+++ b/src/PSUSensor.cpp
@@ -44,17 +44,16 @@
 
 static constexpr bool debug = false;
 
-PSUSensor::PSUSensor(const std::string& path, const std::string& objectType,
-                     sdbusplus::asio::object_server& objectServer,
-                     std::shared_ptr<sdbusplus::asio::connection>& conn,
-                     boost::asio::io_context& io, const std::string& sensorName,
-                     std::vector<thresholds::Threshold>&& thresholdsIn,
-                     const std::string& sensorConfiguration,
-                     const PowerState& powerState,
-                     const std::string& sensorUnits, unsigned int factor,
-                     double max, double min, double offset,
-                     const std::string& label, size_t tSize, double pollRate,
-                     const std::shared_ptr<I2CDevice>& i2cDevice) :
+PSUSensor::PSUSensor(
+    const std::string& path, const std::string& objectType,
+    sdbusplus::asio::object_server& objectServer,
+    std::shared_ptr<sdbusplus::asio::connection>& conn,
+    boost::asio::io_context& io, const std::string& sensorName,
+    std::vector<thresholds::Threshold>&& thresholdsIn,
+    const std::string& sensorConfiguration, const PowerState& powerState,
+    const std::string& sensorUnits, unsigned int factor, double max, double min,
+    double offset, const std::string& label, size_t tSize, double pollRate,
+    const std::shared_ptr<I2CDevice>& i2cDevice) :
     Sensor(escapeName(sensorName), std::move(thresholdsIn), sensorConfiguration,
            objectType, false, false, max, min, conn, powerState),
     i2cDevice(i2cDevice), objServer(objectServer),
@@ -168,14 +167,14 @@
         0, boost::asio::buffer(buffer->data(), buffer->size() - 1),
         [weak, buffer{buffer}](const boost::system::error_code& ec,
                                size_t bytesRead) {
-        std::shared_ptr<PSUSensor> self = weak.lock();
-        if (!self)
-        {
-            return;
-        }
+            std::shared_ptr<PSUSensor> self = weak.lock();
+            if (!self)
+            {
+                return;
+            }
 
-        self->handleResponse(ec, bytesRead);
-    });
+            self->handleResponse(ec, bytesRead);
+        });
 }
 
 void PSUSensor::restartRead()
diff --git a/src/PSUSensor.hpp b/src/PSUSensor.hpp
index f9b738f..09601f8 100644
--- a/src/PSUSensor.hpp
+++ b/src/PSUSensor.hpp
@@ -69,9 +69,8 @@
   public:
     PSUProperty(std::string name, double max, double min, unsigned int factor,
                 double offset) :
-        labelTypeName(std::move(name)),
-        maxReading(max), minReading(min), sensorScaleFactor(factor),
-        sensorOffset(offset)
+        labelTypeName(std::move(name)), maxReading(max), minReading(min),
+        sensorScaleFactor(factor), sensorOffset(offset)
     {}
     ~PSUProperty() = default;
 
diff --git a/src/PSUSensorMain.cpp b/src/PSUSensorMain.cpp
index 2b159c3..ad37956 100644
--- a/src/PSUSensorMain.cpp
+++ b/src/PSUSensorMain.cpp
@@ -251,12 +251,11 @@
     }
 }
 
-static void
-    checkPWMSensor(const fs::path& sensorPath, std::string& labelHead,
-                   const std::string& interfacePath,
-                   std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
-                   sdbusplus::asio::object_server& objectServer,
-                   const std::string& psuName)
+static void checkPWMSensor(
+    const fs::path& sensorPath, std::string& labelHead,
+    const std::string& interfacePath,
+    std::shared_ptr<sdbusplus::asio::connection>& dbusConnection,
+    sdbusplus::asio::object_server& objectServer, const std::string& psuName)
 {
     if (!labelHead.starts_with("fan"))
     {
@@ -265,8 +264,8 @@
     std::string labelHeadIndex = labelHead.substr(3);
 
     const std::string& sensorPathStr = sensorPath.string();
-    const std::string& pwmPathStr = boost::replace_all_copy(sensorPathStr,
-                                                            "input", "target");
+    const std::string& pwmPathStr =
+        boost::replace_all_copy(sensorPathStr, "input", "target");
     std::ifstream pwmFile(pwmPathStr);
     if (!pwmFile.good())
     {
@@ -486,11 +485,11 @@
         if (!firstScan)
         {
             std::string psuNameStr = "/" + escapeName(*psuName);
-            auto it = std::find_if(sensorsChanged->begin(),
-                                   sensorsChanged->end(),
-                                   [psuNameStr](std::string& s) {
-                return s.ends_with(psuNameStr);
-            });
+            auto it =
+                std::find_if(sensorsChanged->begin(), sensorsChanged->end(),
+                             [psuNameStr](std::string& s) {
+                                 return s.ends_with(psuNameStr);
+                             });
 
             if (it == sensorsChanged->end())
             {
@@ -604,8 +603,8 @@
                     }
                     // hwmon *_input filename with number:
                     // temp1, temp2, temp3, ...
-                    labelHead = sensorNameStr.substr(0,
-                                                     sensorNameStr.find('_'));
+                    labelHead =
+                        sensorNameStr.substr(0, sensorNameStr.find('_'));
                 }
                 else
                 {
@@ -954,8 +953,8 @@
                 ++numCreated;
                 if constexpr (debug)
                 {
-                    std::cerr << "Created " << numCreated
-                              << " sensors so far\n";
+                    std::cerr
+                        << "Created " << numCreated << " sensors so far\n";
                 }
             }
         }
@@ -1057,9 +1056,9 @@
     auto getter = std::make_shared<GetSensorConfiguration>(
         dbusConnection, [&io, &objectServer, &dbusConnection, sensorsChanged,
                          activateOnly](const ManagedObjectType& sensorConfigs) {
-        createSensorsCallback(io, objectServer, dbusConnection, sensorConfigs,
-                              sensorsChanged, activateOnly);
-    });
+            createSensorsCallback(io, objectServer, dbusConnection,
+                                  sensorConfigs, sensorsChanged, activateOnly);
+        });
     std::vector<std::string> types(sensorTypes.size());
     for (const auto& [type, dt] : sensorTypes)
     {
@@ -1148,8 +1147,8 @@
 
     propertyInitialize();
 
-    auto powerCallBack = [&io, &objectServer, &systemBus](PowerState type,
-                                                          bool state) {
+    auto powerCallBack = [&io, &objectServer,
+                          &systemBus](PowerState type, bool state) {
         powerStateChanged(type, state, sensors, io, objectServer, systemBus);
     };
 
@@ -1161,80 +1160,81 @@
     boost::asio::steady_timer filterTimer(io);
     std::function<void(sdbusplus::message_t&)> eventHandler =
         [&](sdbusplus::message_t& message) {
-        if (message.is_method_error())
-        {
-            std::cerr << "callback method error\n";
-            return;
-        }
-        sensorsChanged->insert(message.get_path());
-        filterTimer.expires_after(std::chrono::seconds(3));
-        filterTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
+            if (message.is_method_error())
             {
+                std::cerr << "callback method error\n";
                 return;
             }
-            if (ec)
-            {
-                std::cerr << "timer error\n";
-            }
-            createSensors(io, objectServer, systemBus, sensorsChanged, false);
-        });
-    };
+            sensorsChanged->insert(message.get_path());
+            filterTimer.expires_after(std::chrono::seconds(3));
+            filterTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    return;
+                }
+                if (ec)
+                {
+                    std::cerr << "timer error\n";
+                }
+                createSensors(io, objectServer, systemBus, sensorsChanged,
+                              false);
+            });
+        };
 
     boost::asio::steady_timer cpuFilterTimer(io);
     std::function<void(sdbusplus::message_t&)> cpuPresenceHandler =
         [&](sdbusplus::message_t& message) {
-        std::string path = message.get_path();
-        boost::to_lower(path);
+            std::string path = message.get_path();
+            boost::to_lower(path);
 
-        sdbusplus::message::object_path cpuPath(path);
-        std::string cpuName = cpuPath.filename();
-        if (!cpuName.starts_with("cpu"))
-        {
-            return;
-        }
-        size_t index = 0;
-        try
-        {
-            index = std::stoi(path.substr(path.size() - 1));
-        }
-        catch (const std::invalid_argument&)
-        {
-            std::cerr << "Found invalid path " << path << "\n";
-            return;
-        }
-
-        std::string objectName;
-        boost::container::flat_map<std::string, std::variant<bool>> values;
-        message.read(objectName, values);
-        auto findPresence = values.find("Present");
-        try
-        {
-            cpuPresence[index] = std::get<bool>(findPresence->second);
-        }
-        catch (const std::bad_variant_access& err)
-        {
-            return;
-        }
-
-        if (!cpuPresence[index])
-        {
-            return;
-        }
-        cpuFilterTimer.expires_after(std::chrono::seconds(1));
-        cpuFilterTimer.async_wait([&](const boost::system::error_code& ec) {
-            if (ec == boost::asio::error::operation_aborted)
+            sdbusplus::message::object_path cpuPath(path);
+            std::string cpuName = cpuPath.filename();
+            if (!cpuName.starts_with("cpu"))
             {
                 return;
             }
-            if (ec)
+            size_t index = 0;
+            try
             {
-                std::cerr << "timer error\n";
+                index = std::stoi(path.substr(path.size() - 1));
+            }
+            catch (const std::invalid_argument&)
+            {
+                std::cerr << "Found invalid path " << path << "\n";
                 return;
             }
-            createSensors(io, objectServer, systemBus, nullptr, false);
-        });
-    };
+
+            std::string objectName;
+            boost::container::flat_map<std::string, std::variant<bool>> values;
+            message.read(objectName, values);
+            auto findPresence = values.find("Present");
+            try
+            {
+                cpuPresence[index] = std::get<bool>(findPresence->second);
+            }
+            catch (const std::bad_variant_access& err)
+            {
+                return;
+            }
+
+            if (!cpuPresence[index])
+            {
+                return;
+            }
+            cpuFilterTimer.expires_after(std::chrono::seconds(1));
+            cpuFilterTimer.async_wait([&](const boost::system::error_code& ec) {
+                if (ec == boost::asio::error::operation_aborted)
+                {
+                    return;
+                }
+                if (ec)
+                {
+                    std::cerr << "timer error\n";
+                    return;
+                }
+                createSensors(io, objectServer, systemBus, nullptr, false);
+            });
+        };
 
     std::vector<std::unique_ptr<sdbusplus::bus::match_t>> matches =
         setupPropertiesChangedMatches(*systemBus, sensorTypes, eventHandler);
diff --git a/src/PwmSensor.cpp b/src/PwmSensor.cpp
index 2a431eb..a06d7c4 100644
--- a/src/PwmSensor.cpp
+++ b/src/PwmSensor.cpp
@@ -41,8 +41,8 @@
                      sdbusplus::asio::object_server& objectServer,
                      const std::string& sensorConfiguration,
                      const std::string& sensorType, bool isValueMutable) :
-    sysPath(sysPath),
-    objectServer(objectServer), name(sensor_paths::escapePathForDbus(pwmname))
+    sysPath(sysPath), objectServer(objectServer),
+    name(sensor_paths::escapePathForDbus(pwmname))
 {
     // add interface under sensor and Control.FanPwm as Control is used
     // in obmc project, also add sensor so it can be viewed as a sensor
@@ -69,49 +69,50 @@
     sensorInterface->register_property(
         "Value", fValue,
         [this](const double& req, double& resp) {
-        if (!std::isfinite(req))
-        {
-            // Reject attempted change, if to NaN or other non-numeric
-            return -1;
-        }
-        if (req > 100.0 || req < 0.0)
-        {
-            // TODO(): It does not seem desirable to halt daemon here,
-            // probably should just reject the change, continue running?
-            throw std::runtime_error("Value out of range");
-            return -1;
-        }
+            if (!std::isfinite(req))
+            {
+                // Reject attempted change, if to NaN or other non-numeric
+                return -1;
+            }
+            if (req > 100.0 || req < 0.0)
+            {
+                // TODO(): It does not seem desirable to halt daemon here,
+                // probably should just reject the change, continue running?
+                throw std::runtime_error("Value out of range");
+                return -1;
+            }
 
-        double reqValue = (req / 100.0) * pwmMax;
-        double respValue = (resp / 100.0) * pwmMax;
-        auto reqInt = static_cast<uint32_t>(std::round(reqValue));
-        auto respInt = static_cast<uint32_t>(std::round(respValue));
-        // Avoid floating-point equality, compare as integers
-        if (reqInt == respInt)
-        {
-            return 1;
-        }
-        setValue(reqInt);
-        resp = req;
+            double reqValue = (req / 100.0) * pwmMax;
+            double respValue = (resp / 100.0) * pwmMax;
+            auto reqInt = static_cast<uint32_t>(std::round(reqValue));
+            auto respInt = static_cast<uint32_t>(std::round(respValue));
+            // Avoid floating-point equality, compare as integers
+            if (reqInt == respInt)
+            {
+                return 1;
+            }
+            setValue(reqInt);
+            resp = req;
 
-        controlInterface->signal_property("Target");
-
-        return 1;
-    },
-        [this](double& curVal) {
-        double currScaled = (curVal / 100.0) * pwmMax;
-        auto currInt = static_cast<uint32_t>(std::round(currScaled));
-        auto getInt = getValue();
-        // Avoid floating-point equality, compare as integers
-        if (currInt != getInt)
-        {
-            double getScaled = 100.0 * (static_cast<double>(getInt) / pwmMax);
-            curVal = getScaled;
             controlInterface->signal_property("Target");
-            sensorInterface->signal_property("Value");
-        }
-        return curVal;
-    });
+
+            return 1;
+        },
+        [this](double& curVal) {
+            double currScaled = (curVal / 100.0) * pwmMax;
+            auto currInt = static_cast<uint32_t>(std::round(currScaled));
+            auto getInt = getValue();
+            // Avoid floating-point equality, compare as integers
+            if (currInt != getInt)
+            {
+                double getScaled =
+                    100.0 * (static_cast<double>(getInt) / pwmMax);
+                curVal = getScaled;
+                controlInterface->signal_property("Target");
+                sensorInterface->signal_property("Value");
+            }
+            return curVal;
+        });
     // pwm sensor interface is in percent
     sensorInterface->register_property("MaxValue", static_cast<double>(100));
     sensorInterface->register_property("MinValue", static_cast<double>(0));
@@ -123,37 +124,37 @@
     controlInterface->register_property(
         "Target", static_cast<uint64_t>(pwmValue),
         [this](const uint64_t& req, uint64_t& resp) {
-        if (req > static_cast<uint64_t>(targetIfaceMax))
-        {
-            throw std::runtime_error("Value out of range");
-            return -1;
-        }
-        if (req == resp)
-        {
-            return 1;
-        }
-        auto scaledValue = static_cast<double>(req) / targetIfaceMax;
-        auto roundValue = std::round(scaledValue * pwmMax);
-        setValue(static_cast<uint32_t>(roundValue));
-        resp = req;
+            if (req > static_cast<uint64_t>(targetIfaceMax))
+            {
+                throw std::runtime_error("Value out of range");
+                return -1;
+            }
+            if (req == resp)
+            {
+                return 1;
+            }
+            auto scaledValue = static_cast<double>(req) / targetIfaceMax;
+            auto roundValue = std::round(scaledValue * pwmMax);
+            setValue(static_cast<uint32_t>(roundValue));
+            resp = req;
 
-        sensorInterface->signal_property("Value");
-
-        return 1;
-    },
-        [this](uint64_t& curVal) {
-        auto getInt = getValue();
-        auto scaledValue = static_cast<double>(getInt) / pwmMax;
-        auto roundValue = std::round(scaledValue * targetIfaceMax);
-        auto value = static_cast<uint64_t>(roundValue);
-        if (curVal != value)
-        {
-            curVal = value;
-            controlInterface->signal_property("Target");
             sensorInterface->signal_property("Value");
-        }
-        return curVal;
-    });
+
+            return 1;
+        },
+        [this](uint64_t& curVal) {
+            auto getInt = getValue();
+            auto scaledValue = static_cast<double>(getInt) / pwmMax;
+            auto roundValue = std::round(scaledValue * targetIfaceMax);
+            auto value = static_cast<uint64_t>(roundValue);
+            if (curVal != value)
+            {
+                curVal = value;
+                controlInterface->signal_property("Target");
+                sensorInterface->signal_property("Value");
+            }
+            return curVal;
+        });
 
     sensorInterface->initialize();
     controlInterface->initialize();
diff --git a/src/TachSensor.cpp b/src/TachSensor.cpp
index b31c1b7..7a57f5a 100644
--- a/src/TachSensor.cpp
+++ b/src/TachSensor.cpp
@@ -44,17 +44,17 @@
 
 static constexpr unsigned int pwmPollMs = 500;
 
-TachSensor::TachSensor(const std::string& path, const std::string& objectType,
-                       sdbusplus::asio::object_server& objectServer,
-                       std::shared_ptr<sdbusplus::asio::connection>& conn,
-                       std::shared_ptr<PresenceSensor>& presenceSensor,
-                       std::optional<RedundancySensor>* redundancy,
-                       boost::asio::io_context& io, const std::string& fanName,
-                       std::vector<thresholds::Threshold>&& thresholdsIn,
-                       const std::string& sensorConfiguration,
-                       const std::pair<double, double>& limits,
-                       const PowerState& powerState,
-                       const std::optional<std::string>& ledIn) :
+TachSensor::TachSensor(
+    const std::string& path, const std::string& objectType,
+    sdbusplus::asio::object_server& objectServer,
+    std::shared_ptr<sdbusplus::asio::connection>& conn,
+    std::shared_ptr<PresenceSensor>& presenceSensor,
+    std::optional<RedundancySensor>* redundancy, boost::asio::io_context& io,
+    const std::string& fanName,
+    std::vector<thresholds::Threshold>&& thresholdsIn,
+    const std::string& sensorConfiguration,
+    const std::pair<double, double>& limits, const PowerState& powerState,
+    const std::optional<std::string>& ledIn) :
     Sensor(escapeName(fanName), std::move(thresholdsIn), sensorConfiguration,
            objectType, false, false, limits.second, limits.first, conn,
            powerState),
@@ -119,12 +119,12 @@
     inputDev.async_read_some_at(
         0, boost::asio::buffer(readBuf),
         [weakRef](const boost::system::error_code& ec, std::size_t bytesRead) {
-        std::shared_ptr<TachSensor> self = weakRef.lock();
-        if (self)
-        {
-            self->handleResponse(ec, bytesRead);
-        }
-    });
+            std::shared_ptr<TachSensor> self = weakRef.lock();
+            if (self)
+            {
+                self->handleResponse(ec, bytesRead);
+            }
+        });
 }
 
 void TachSensor::restartRead(size_t pollTime)
@@ -173,8 +173,8 @@
         {
             const char* bufEnd = readBuf.data() + bytesRead;
             int nvalue = 0;
-            std::from_chars_result ret = std::from_chars(readBuf.data(), bufEnd,
-                                                         nvalue);
+            std::from_chars_result ret =
+                std::from_chars(readBuf.data(), bufEnd, nvalue);
             if (ret.ec != std::errc())
             {
                 incrementError();
@@ -216,8 +216,7 @@
 PresenceSensor::PresenceSensor(const std::string& gpioName, bool inverted,
                                boost::asio::io_context& io,
                                const std::string& name) :
-    gpioLine(gpiod::find_line(gpioName)),
-    gpioFd(io), name(name)
+    gpioLine(gpiod::find_line(gpioName)), gpioFd(io), name(name)
 {
     if (!gpioLine)
     {
@@ -261,21 +260,22 @@
 {
     gpioFd.async_wait(boost::asio::posix::stream_descriptor::wait_read,
                       [this](const boost::system::error_code& ec) {
-        if (ec == boost::system::errc::bad_file_descriptor)
-        {
-            return; // we're being destroyed
-        }
-        if (ec)
-        {
-            std::cerr << "Error on presence sensor " << name << " \n";
-            ;
-        }
-        else
-        {
-            read();
-        }
-        monitorPresence();
-    });
+                          if (ec == boost::system::errc::bad_file_descriptor)
+                          {
+                              return; // we're being destroyed
+                          }
+                          if (ec)
+                          {
+                              std::cerr << "Error on presence sensor " << name
+                                        << " \n";
+                              ;
+                          }
+                          else
+                          {
+                              read();
+                          }
+                          monitorPresence();
+                      });
 }
 
 void PresenceSensor::read()
diff --git a/src/Thresholds.cpp b/src/Thresholds.cpp
index 42c634f..fc252ac 100644
--- a/src/Thresholds.cpp
+++ b/src/Thresholds.cpp
@@ -101,8 +101,8 @@
         auto hysteresisFind = cfg.find("Hysteresis");
         if (hysteresisFind != cfg.end())
         {
-            hysteresis = std::visit(VariantToDoubleVisitor(),
-                                    hysteresisFind->second);
+            hysteresis =
+                std::visit(VariantToDoubleVisitor(), hysteresisFind->second);
         }
 
         auto directionFind = cfg.find("Direction");
@@ -115,11 +115,11 @@
                       << intf << "\n";
             return false;
         }
-        unsigned int severity = std::visit(VariantToUnsignedIntVisitor(),
-                                           severityFind->second);
+        unsigned int severity =
+            std::visit(VariantToUnsignedIntVisitor(), severityFind->second);
 
-        std::string directions = std::visit(VariantToStringVisitor(),
-                                            directionFind->second);
+        std::string directions =
+            std::visit(VariantToStringVisitor(), directionFind->second);
 
         Level level = findThresholdLevel(severity);
         Direction direction = findThresholdDirection(directions);
@@ -142,64 +142,65 @@
 {
     for (size_t ii = 0; ii < thresholdCount; ii++)
     {
-        std::string thresholdInterface = baseInterface + ".Thresholds" +
-                                         std::to_string(ii);
+        std::string thresholdInterface =
+            baseInterface + ".Thresholds" + std::to_string(ii);
         conn->async_method_call(
             [&, path, threshold, thresholdInterface,
              labelMatch](const boost::system::error_code& ec,
                          const SensorBaseConfigMap& result) {
-            if (ec)
-            {
-                return; // threshold not supported
-            }
-
-            if (!labelMatch.empty())
-            {
-                auto labelFind = result.find("Label");
-                if (labelFind == result.end())
-                {
-                    std::cerr << "No label in threshold configuration\n";
-                    return;
-                }
-                std::string label = std::visit(VariantToStringVisitor(),
-                                               labelFind->second);
-                if (label != labelMatch)
-                {
-                    return;
-                }
-            }
-
-            auto directionFind = result.find("Direction");
-            auto severityFind = result.find("Severity");
-            auto valueFind = result.find("Value");
-            if (valueFind == result.end() || severityFind == result.end() ||
-                directionFind == result.end())
-            {
-                std::cerr << "Malformed threshold in configuration\n";
-                return;
-            }
-            unsigned int severity = std::visit(VariantToUnsignedIntVisitor(),
-                                               severityFind->second);
-
-            std::string dir = std::visit(VariantToStringVisitor(),
-                                         directionFind->second);
-            if ((findThresholdLevel(severity) != threshold.level) ||
-                (findThresholdDirection(dir) != threshold.direction))
-            {
-                return; // not the droid we're looking for
-            }
-
-            std::variant<double> value(threshold.value);
-            conn->async_method_call(
-                [](const boost::system::error_code& ec) {
                 if (ec)
                 {
-                    std::cerr << "Error setting threshold " << ec << "\n";
+                    return; // threshold not supported
                 }
+
+                if (!labelMatch.empty())
+                {
+                    auto labelFind = result.find("Label");
+                    if (labelFind == result.end())
+                    {
+                        std::cerr << "No label in threshold configuration\n";
+                        return;
+                    }
+                    std::string label =
+                        std::visit(VariantToStringVisitor(), labelFind->second);
+                    if (label != labelMatch)
+                    {
+                        return;
+                    }
+                }
+
+                auto directionFind = result.find("Direction");
+                auto severityFind = result.find("Severity");
+                auto valueFind = result.find("Value");
+                if (valueFind == result.end() || severityFind == result.end() ||
+                    directionFind == result.end())
+                {
+                    std::cerr << "Malformed threshold in configuration\n";
+                    return;
+                }
+                unsigned int severity = std::visit(
+                    VariantToUnsignedIntVisitor(), severityFind->second);
+
+                std::string dir =
+                    std::visit(VariantToStringVisitor(), directionFind->second);
+                if ((findThresholdLevel(severity) != threshold.level) ||
+                    (findThresholdDirection(dir) != threshold.direction))
+                {
+                    return; // not the droid we're looking for
+                }
+
+                std::variant<double> value(threshold.value);
+                conn->async_method_call(
+                    [](const boost::system::error_code& ec) {
+                        if (ec)
+                        {
+                            std::cerr
+                                << "Error setting threshold " << ec << "\n";
+                        }
+                    },
+                    entityManagerName, path, "org.freedesktop.DBus.Properties",
+                    "Set", thresholdInterface, "Value", value);
             },
-                entityManagerName, path, "org.freedesktop.DBus.Properties",
-                "Set", thresholdInterface, "Value", value);
-        },
             entityManagerName, path, "org.freedesktop.DBus.Properties",
             "GetAll", thresholdInterface);
     }
@@ -217,8 +218,8 @@
             continue;
         }
 
-        std::string property = Sensor::propertyLevel(threshold.level,
-                                                     threshold.direction);
+        std::string property =
+            Sensor::propertyLevel(threshold.level, threshold.direction);
         if (property.empty())
         {
             continue;
@@ -292,10 +293,10 @@
                 thresholdChanges.emplace_back(threshold, true, value);
                 if (++cLoTrue < assertLogCount)
                 {
-                    std::cerr << "Sensor " << sensor->name << " low threshold "
-                              << threshold.value << " assert: value "
-                              << sensor->value << " raw data "
-                              << sensor->rawValue << "\n";
+                    std::cerr
+                        << "Sensor " << sensor->name << " low threshold "
+                        << threshold.value << " assert: value " << sensor->value
+                        << " raw data " << sensor->rawValue << "\n";
                 }
             }
             else if (value > (threshold.value + threshold.hysteresis))
@@ -514,8 +515,8 @@
             for (const auto& t : map.at(item))
             {
                 const auto& [suffix, level, direction, offset] = t;
-                auto attrPath = boost::replace_all_copy(inputPath, item,
-                                                        suffix);
+                auto attrPath =
+                    boost::replace_all_copy(inputPath, item, suffix);
                 if (auto val = readFile(attrPath, scaleFactor))
                 {
                     *val += offset;
diff --git a/src/Thresholds.hpp b/src/Thresholds.hpp
index 352c55c..6338290 100644
--- a/src/Thresholds.hpp
+++ b/src/Thresholds.hpp
@@ -36,8 +36,8 @@
         const Level& lev, const Direction& dir, const double& val,
         const double hysteresis = std::numeric_limits<double>::quiet_NaN(),
         bool write = true) :
-        level(lev),
-        direction(dir), value(val), hysteresis(hysteresis), writeable(write)
+        level(lev), direction(dir), value(val), hysteresis(hysteresis),
+        writeable(write)
     {}
     Level level;
     Direction direction;
diff --git a/src/Utils.cpp b/src/Utils.cpp
index e3cbfeb..ac0778d 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -95,10 +95,9 @@
  * @return a string to the full path of the file to create a temp sensor with or
  * nullopt to indicate that no sensor should be created for this basename.
  */
-std::optional<std::string>
-    getFullHwmonFilePath(const std::string& directory,
-                         const std::string& hwmonBaseName,
-                         const std::set<std::string>& permitSet)
+std::optional<std::string> getFullHwmonFilePath(
+    const std::string& directory, const std::string& hwmonBaseName,
+    const std::set<std::string>& permitSet)
 {
     std::optional<std::string> result;
     std::string filename;
@@ -354,27 +353,28 @@
     conn->async_method_call(
         [conn, retries](boost::system::error_code ec,
                         const std::variant<std::string>& state) {
-        if (ec)
-        {
-            if (retries != 0U)
+            if (ec)
             {
-                auto timer = std::make_shared<boost::asio::steady_timer>(
-                    conn->get_io_context());
-                timer->expires_after(std::chrono::seconds(15));
-                timer->async_wait(
-                    [timer, conn, retries](boost::system::error_code) {
-                    getPowerStatus(conn, retries - 1);
-                });
+                if (retries != 0U)
+                {
+                    auto timer = std::make_shared<boost::asio::steady_timer>(
+                        conn->get_io_context());
+                    timer->expires_after(std::chrono::seconds(15));
+                    timer->async_wait(
+                        [timer, conn, retries](boost::system::error_code) {
+                            getPowerStatus(conn, retries - 1);
+                        });
+                    return;
+                }
+
+                // we commonly come up before power control, we'll capture the
+                // property change later
+                std::cerr << "error getting power status " << ec.message()
+                          << "\n";
                 return;
             }
-
-            // we commonly come up before power control, we'll capture the
-            // property change later
-            std::cerr << "error getting power status " << ec.message() << "\n";
-            return;
-        }
-        powerStatusOn = std::get<std::string>(state).ends_with(".Running");
-    },
+            powerStatusOn = std::get<std::string>(state).ends_with(".Running");
+        },
         power::busname, power::path, properties::interface, properties::get,
         power::interface, power::property);
 }
@@ -386,29 +386,30 @@
     conn->async_method_call(
         [conn, retries](boost::system::error_code ec,
                         const std::variant<std::string>& state) {
-        if (ec)
-        {
-            if (retries != 0U)
+            if (ec)
             {
-                auto timer = std::make_shared<boost::asio::steady_timer>(
-                    conn->get_io_context());
-                timer->expires_after(std::chrono::seconds(15));
-                timer->async_wait(
-                    [timer, conn, retries](boost::system::error_code) {
-                    getPostStatus(conn, retries - 1);
-                });
+                if (retries != 0U)
+                {
+                    auto timer = std::make_shared<boost::asio::steady_timer>(
+                        conn->get_io_context());
+                    timer->expires_after(std::chrono::seconds(15));
+                    timer->async_wait(
+                        [timer, conn, retries](boost::system::error_code) {
+                            getPostStatus(conn, retries - 1);
+                        });
+                    return;
+                }
+                // we commonly come up before power control, we'll capture the
+                // property change later
+                std::cerr << "error getting post status " << ec.message()
+                          << "\n";
                 return;
             }
-            // we commonly come up before power control, we'll capture the
-            // property change later
-            std::cerr << "error getting post status " << ec.message() << "\n";
-            return;
-        }
-        const auto& value = std::get<std::string>(state);
-        biosHasPost = (value != "Inactive") &&
-                      (value != "xyz.openbmc_project.State.OperatingSystem."
-                                "Status.OSStatus.Inactive");
-    },
+            const auto& value = std::get<std::string>(state);
+            biosHasPost = (value != "Inactive") &&
+                          (value != "xyz.openbmc_project.State.OperatingSystem."
+                                    "Status.OSStatus.Inactive");
+        },
         post::busname, post::path, properties::interface, properties::get,
         post::interface, post::property);
 }
@@ -420,28 +421,29 @@
     conn->async_method_call(
         [conn, retries](boost::system::error_code ec,
                         const std::variant<std::string>& state) {
-        if (ec)
-        {
-            if (retries != 0U)
+            if (ec)
             {
-                auto timer = std::make_shared<boost::asio::steady_timer>(
-                    conn->get_io_context());
-                timer->expires_after(std::chrono::seconds(15));
-                timer->async_wait(
-                    [timer, conn, retries](boost::system::error_code) {
-                    getChassisStatus(conn, retries - 1);
-                });
+                if (retries != 0U)
+                {
+                    auto timer = std::make_shared<boost::asio::steady_timer>(
+                        conn->get_io_context());
+                    timer->expires_after(std::chrono::seconds(15));
+                    timer->async_wait(
+                        [timer, conn, retries](boost::system::error_code) {
+                            getChassisStatus(conn, retries - 1);
+                        });
+                    return;
+                }
+
+                // we commonly come up before power control, we'll capture the
+                // property change later
+                std::cerr << "error getting chassis power status "
+                          << ec.message() << "\n";
                 return;
             }
-
-            // we commonly come up before power control, we'll capture the
-            // property change later
-            std::cerr << "error getting chassis power status " << ec.message()
-                      << "\n";
-            return;
-        }
-        chassisStatusOn = std::get<std::string>(state).ends_with(chassis::sOn);
-    },
+            chassisStatusOn =
+                std::get<std::string>(state).ends_with(chassis::sOn);
+        },
         chassis::busname, chassis::path, properties::interface, properties::get,
         chassis::interface, chassis::property);
 }
@@ -465,40 +467,40 @@
             "',path='" + std::string(power::path) + "',arg0='" +
             std::string(power::interface) + "'",
         [hostStatusCallback](sdbusplus::message_t& message) {
-        std::string objectName;
-        boost::container::flat_map<std::string, std::variant<std::string>>
-            values;
-        message.read(objectName, values);
-        auto findState = values.find(power::property);
-        if (findState != values.end())
-        {
-            bool on =
-                std::get<std::string>(findState->second).ends_with(".Running");
-            if (!on)
+            std::string objectName;
+            boost::container::flat_map<std::string, std::variant<std::string>>
+                values;
+            message.read(objectName, values);
+            auto findState = values.find(power::property);
+            if (findState != values.end())
             {
-                timer.cancel();
-                powerStatusOn = false;
-                hostStatusCallback(PowerState::on, powerStatusOn);
-                return;
+                bool on = std::get<std::string>(findState->second)
+                              .ends_with(".Running");
+                if (!on)
+                {
+                    timer.cancel();
+                    powerStatusOn = false;
+                    hostStatusCallback(PowerState::on, powerStatusOn);
+                    return;
+                }
+                // on comes too quickly
+                timer.expires_after(std::chrono::seconds(10));
+                timer.async_wait(
+                    [hostStatusCallback](boost::system::error_code ec) {
+                        if (ec == boost::asio::error::operation_aborted)
+                        {
+                            return;
+                        }
+                        if (ec)
+                        {
+                            std::cerr << "Timer error " << ec.message() << "\n";
+                            return;
+                        }
+                        powerStatusOn = true;
+                        hostStatusCallback(PowerState::on, powerStatusOn);
+                    });
             }
-            // on comes too quickly
-            timer.expires_after(std::chrono::seconds(10));
-            timer.async_wait(
-                [hostStatusCallback](boost::system::error_code ec) {
-                if (ec == boost::asio::error::operation_aborted)
-                {
-                    return;
-                }
-                if (ec)
-                {
-                    std::cerr << "Timer error " << ec.message() << "\n";
-                    return;
-                }
-                powerStatusOn = true;
-                hostStatusCallback(PowerState::on, powerStatusOn);
-            });
-        }
-    });
+        });
 
     postMatch = std::make_unique<sdbusplus::bus::match_t>(
         static_cast<sdbusplus::bus_t&>(*conn),
@@ -506,20 +508,21 @@
             "',path='" + std::string(post::path) + "',arg0='" +
             std::string(post::interface) + "'",
         [hostStatusCallback](sdbusplus::message_t& message) {
-        std::string objectName;
-        boost::container::flat_map<std::string, std::variant<std::string>>
-            values;
-        message.read(objectName, values);
-        auto findState = values.find(post::property);
-        if (findState != values.end())
-        {
-            auto& value = std::get<std::string>(findState->second);
-            biosHasPost = (value != "Inactive") &&
-                          (value != "xyz.openbmc_project.State.OperatingSystem."
-                                    "Status.OSStatus.Inactive");
-            hostStatusCallback(PowerState::biosPost, biosHasPost);
-        }
-    });
+            std::string objectName;
+            boost::container::flat_map<std::string, std::variant<std::string>>
+                values;
+            message.read(objectName, values);
+            auto findState = values.find(post::property);
+            if (findState != values.end())
+            {
+                auto& value = std::get<std::string>(findState->second);
+                biosHasPost =
+                    (value != "Inactive") &&
+                    (value != "xyz.openbmc_project.State.OperatingSystem."
+                              "Status.OSStatus.Inactive");
+                hostStatusCallback(PowerState::biosPost, biosHasPost);
+            }
+        });
 
     chassisMatch = std::make_unique<sdbusplus::bus::match_t>(
         static_cast<sdbusplus::bus_t&>(*conn),
@@ -528,40 +531,40 @@
             std::string(chassis::interface) + "'",
         [hostStatusCallback = std::move(hostStatusCallback)](
             sdbusplus::message_t& message) {
-        std::string objectName;
-        boost::container::flat_map<std::string, std::variant<std::string>>
-            values;
-        message.read(objectName, values);
-        auto findState = values.find(chassis::property);
-        if (findState != values.end())
-        {
-            bool on = std::get<std::string>(findState->second)
-                          .ends_with(chassis::sOn);
-            if (!on)
+            std::string objectName;
+            boost::container::flat_map<std::string, std::variant<std::string>>
+                values;
+            message.read(objectName, values);
+            auto findState = values.find(chassis::property);
+            if (findState != values.end())
             {
-                timerChassisOn.cancel();
-                chassisStatusOn = false;
-                hostStatusCallback(PowerState::chassisOn, chassisStatusOn);
-                return;
+                bool on = std::get<std::string>(findState->second)
+                              .ends_with(chassis::sOn);
+                if (!on)
+                {
+                    timerChassisOn.cancel();
+                    chassisStatusOn = false;
+                    hostStatusCallback(PowerState::chassisOn, chassisStatusOn);
+                    return;
+                }
+                // on comes too quickly
+                timerChassisOn.expires_after(std::chrono::seconds(10));
+                timerChassisOn.async_wait([hostStatusCallback](
+                                              boost::system::error_code ec) {
+                    if (ec == boost::asio::error::operation_aborted)
+                    {
+                        return;
+                    }
+                    if (ec)
+                    {
+                        std::cerr << "Timer error " << ec.message() << "\n";
+                        return;
+                    }
+                    chassisStatusOn = true;
+                    hostStatusCallback(PowerState::chassisOn, chassisStatusOn);
+                });
             }
-            // on comes too quickly
-            timerChassisOn.expires_after(std::chrono::seconds(10));
-            timerChassisOn.async_wait(
-                [hostStatusCallback](boost::system::error_code ec) {
-                if (ec == boost::asio::error::operation_aborted)
-                {
-                    return;
-                }
-                if (ec)
-                {
-                    std::cerr << "Timer error " << ec.message() << "\n";
-                    return;
-                }
-                chassisStatusOn = true;
-                hostStatusCallback(PowerState::chassisOn, chassisStatusOn);
-            });
-        }
-    });
+        });
     getPowerStatus(conn);
     getPostStatus(conn);
     getChassisStatus(conn);
@@ -672,21 +675,21 @@
     conn->async_method_call(
         [association, path](const boost::system::error_code ec,
                             const GetSubTreeType& subtree) {
-        // The parent of the config is always the inventory object, and may be
-        // the associated chassis. If the parent is not itself a chassis or
-        // board, the sensor is associated with the system chassis.
-        std::string parent = fs::path(path).parent_path().string();
-        if (ec)
-        {
-            // In case of error, set the default associations and
-            // initialize the association Interface.
-            setInventoryAssociation(association, parent, parent);
-            return;
-        }
-        setInventoryAssociation(
-            association, parent,
-            findContainingChassis(parent, subtree).value_or(parent));
-    },
+            // The parent of the config is always the inventory object, and may
+            // be the associated chassis. If the parent is not itself a chassis
+            // or board, the sensor is associated with the system chassis.
+            std::string parent = fs::path(path).parent_path().string();
+            if (ec)
+            {
+                // In case of error, set the default associations and
+                // initialize the association Interface.
+                setInventoryAssociation(association, parent, parent);
+                return;
+            }
+            setInventoryAssociation(
+                association, parent,
+                findContainingChassis(parent, subtree).value_or(parent));
+        },
         mapper::busName, mapper::path, mapper::interface, "GetSubTree",
         "/xyz/openbmc_project/inventory/system", 2, allInterfaces);
 }
@@ -764,62 +767,67 @@
     static std::unique_ptr<sdbusplus::bus::match_t> specialModeIntfMatch =
         std::make_unique<sdbusplus::bus::match_t>(
             conn, filterSpecialModeIntfAdd, [](sdbusplus::message_t& m) {
-        sdbusplus::message::object_path path;
-        using PropertyMap =
-            boost::container::flat_map<std::string, std::variant<std::string>>;
-        boost::container::flat_map<std::string, PropertyMap> interfaceAdded;
-        m.read(path, interfaceAdded);
-        auto intfItr = interfaceAdded.find(specialModeInterface);
-        if (intfItr == interfaceAdded.end())
-        {
-            return;
-        }
-        PropertyMap& propertyList = intfItr->second;
-        auto itr = propertyList.find("SpecialMode");
-        if (itr == propertyList.end())
-        {
-            std::cerr << "error getting  SpecialMode property "
-                      << "\n";
-            return;
-        }
-        auto* manufacturingModeStatus = std::get_if<std::string>(&itr->second);
-        handleSpecialModeChange(*manufacturingModeStatus);
-    });
+                sdbusplus::message::object_path path;
+                using PropertyMap =
+                    boost::container::flat_map<std::string,
+                                               std::variant<std::string>>;
+                boost::container::flat_map<std::string, PropertyMap>
+                    interfaceAdded;
+                m.read(path, interfaceAdded);
+                auto intfItr = interfaceAdded.find(specialModeInterface);
+                if (intfItr == interfaceAdded.end())
+                {
+                    return;
+                }
+                PropertyMap& propertyList = intfItr->second;
+                auto itr = propertyList.find("SpecialMode");
+                if (itr == propertyList.end())
+                {
+                    std::cerr << "error getting  SpecialMode property "
+                              << "\n";
+                    return;
+                }
+                auto* manufacturingModeStatus =
+                    std::get_if<std::string>(&itr->second);
+                handleSpecialModeChange(*manufacturingModeStatus);
+            });
 
     const std::string filterSpecialModeChange =
         rules::type::signal() + rules::member("PropertiesChanged") +
         rules::interface("org.freedesktop.DBus.Properties") +
         rules::argN(0, specialModeInterface);
     static std::unique_ptr<sdbusplus::bus::match_t> specialModeChangeMatch =
-        std::make_unique<sdbusplus::bus::match_t>(conn, filterSpecialModeChange,
-                                                  [](sdbusplus::message_t& m) {
-        std::string interfaceName;
-        boost::container::flat_map<std::string, std::variant<std::string>>
-            propertiesChanged;
+        std::make_unique<sdbusplus::bus::match_t>(
+            conn, filterSpecialModeChange, [](sdbusplus::message_t& m) {
+                std::string interfaceName;
+                boost::container::flat_map<std::string,
+                                           std::variant<std::string>>
+                    propertiesChanged;
 
-        m.read(interfaceName, propertiesChanged);
-        auto itr = propertiesChanged.find("SpecialMode");
-        if (itr == propertiesChanged.end())
-        {
-            return;
-        }
-        auto* manufacturingModeStatus = std::get_if<std::string>(&itr->second);
-        handleSpecialModeChange(*manufacturingModeStatus);
-    });
+                m.read(interfaceName, propertiesChanged);
+                auto itr = propertiesChanged.find("SpecialMode");
+                if (itr == propertiesChanged.end())
+                {
+                    return;
+                }
+                auto* manufacturingModeStatus =
+                    std::get_if<std::string>(&itr->second);
+                handleSpecialModeChange(*manufacturingModeStatus);
+            });
 
     conn.async_method_call(
         [](const boost::system::error_code ec,
            const std::variant<std::string>& getManufactMode) {
-        if (ec)
-        {
-            std::cerr << "error getting  SpecialMode status " << ec.message()
-                      << "\n";
-            return;
-        }
-        const auto* manufacturingModeStatus =
-            std::get_if<std::string>(&getManufactMode);
-        handleSpecialModeChange(*manufacturingModeStatus);
-    },
+            if (ec)
+            {
+                std::cerr << "error getting  SpecialMode status "
+                          << ec.message() << "\n";
+                return;
+            }
+            const auto* manufacturingModeStatus =
+                std::get_if<std::string>(&getManufactMode);
+            handleSpecialModeChange(*manufacturingModeStatus);
+        },
         "xyz.openbmc_project.SpecialMode",
         "/xyz/openbmc_project/security/special_mode",
         "org.freedesktop.DBus.Properties", "Get", specialModeInterface,
diff --git a/src/Utils.hpp b/src/Utils.hpp
index d76f954..78a6ecd 100644
--- a/src/Utils.hpp
+++ b/src/Utils.hpp
@@ -59,10 +59,9 @@
 };
 
 std::optional<std::string> openAndRead(const std::string& hwmonFile);
-std::optional<std::string>
-    getFullHwmonFilePath(const std::string& directory,
-                         const std::string& hwmonBaseName,
-                         const std::set<std::string>& permitSet);
+std::optional<std::string> getFullHwmonFilePath(
+    const std::string& directory, const std::string& hwmonBaseName,
+    const std::set<std::string>& permitSet);
 std::set<std::string> getPermitSet(const SensorBaseConfigMap& config);
 bool findFiles(const std::filesystem::path& dirPath,
                std::string_view matchString,
@@ -198,8 +197,8 @@
     auto findPowerState = cfg.find("PowerState");
     if (findPowerState != cfg.end())
     {
-        std::string powerState = std::visit(VariantToStringVisitor(),
-                                            findPowerState->second);
+        std::string powerState =
+            std::visit(VariantToStringVisitor(), findPowerState->second);
         setReadState(powerState, state);
     }
     return state;
@@ -225,11 +224,11 @@
 {
     conn->async_method_call(
         [name](const boost::system::error_code ec) {
-        if (ec)
-        {
-            std::cerr << "Failed to set LED " << name << "\n";
-        }
-    },
+            if (ec)
+            {
+                std::cerr << "Failed to set LED " << name << "\n";
+            }
+        },
         "xyz.openbmc_project.LED.GroupManager",
         "/xyz/openbmc_project/led/groups/" + name, properties::interface,
         properties::set, "xyz.openbmc_project.Led.Group", "Asserted",
@@ -247,8 +246,7 @@
     GetSensorConfiguration(
         std::shared_ptr<sdbusplus::asio::connection> connection,
         std::function<void(ManagedObjectType& resp)>&& callbackFunc) :
-        dbusConnection(std::move(connection)),
-        callback(std::move(callbackFunc))
+        dbusConnection(std::move(connection)), callback(std::move(callbackFunc))
     {}
 
     void getPath(const std::string& path, const std::string& interface,
@@ -263,31 +261,31 @@
         self->dbusConnection->async_method_call(
             [self, path, interface, owner, retries](
                 const boost::system::error_code ec, SensorBaseConfigMap& data) {
-            if (ec)
-            {
-                std::cerr << "Error getting " << path << ": retries left"
-                          << retries - 1 << "\n";
-                if (retries == 0U)
+                if (ec)
                 {
-                    return;
-                }
-                auto timer = std::make_shared<boost::asio::steady_timer>(
-                    self->dbusConnection->get_io_context());
-                timer->expires_after(std::chrono::seconds(10));
-                timer->async_wait([self, timer, path, interface, owner,
-                                   retries](boost::system::error_code ec) {
-                    if (ec)
+                    std::cerr << "Error getting " << path << ": retries left"
+                              << retries - 1 << "\n";
+                    if (retries == 0U)
                     {
-                        std::cerr << "Timer error!\n";
                         return;
                     }
-                    self->getPath(path, interface, owner, retries - 1);
-                });
-                return;
-            }
+                    auto timer = std::make_shared<boost::asio::steady_timer>(
+                        self->dbusConnection->get_io_context());
+                    timer->expires_after(std::chrono::seconds(10));
+                    timer->async_wait([self, timer, path, interface, owner,
+                                       retries](boost::system::error_code ec) {
+                        if (ec)
+                        {
+                            std::cerr << "Timer error!\n";
+                            return;
+                        }
+                        self->getPath(path, interface, owner, retries - 1);
+                    });
+                    return;
+                }
 
-            self->respData[path][interface] = std::move(data);
-        },
+                self->respData[path][interface] = std::move(data);
+            },
             owner, path, "org.freedesktop.DBus.Properties", "GetAll",
             interface);
     }
@@ -310,51 +308,52 @@
         dbusConnection->async_method_call(
             [self, interfaces, retries](const boost::system::error_code ec,
                                         const GetSubTreeType& ret) {
-            if (ec)
-            {
-                std::cerr << "Error calling mapper\n";
-                if (retries == 0U)
+                if (ec)
                 {
-                    return;
-                }
-                auto timer = std::make_shared<boost::asio::steady_timer>(
-                    self->dbusConnection->get_io_context());
-                timer->expires_after(std::chrono::seconds(10));
-                timer->async_wait([self, timer, interfaces,
-                                   retries](boost::system::error_code ec) {
-                    if (ec)
+                    std::cerr << "Error calling mapper\n";
+                    if (retries == 0U)
                     {
-                        std::cerr << "Timer error!\n";
                         return;
                     }
-                    self->getConfiguration(interfaces, retries - 1);
-                });
+                    auto timer = std::make_shared<boost::asio::steady_timer>(
+                        self->dbusConnection->get_io_context());
+                    timer->expires_after(std::chrono::seconds(10));
+                    timer->async_wait([self, timer, interfaces,
+                                       retries](boost::system::error_code ec) {
+                        if (ec)
+                        {
+                            std::cerr << "Timer error!\n";
+                            return;
+                        }
+                        self->getConfiguration(interfaces, retries - 1);
+                    });
 
-                return;
-            }
-            for (const auto& [path, objDict] : ret)
-            {
-                if (objDict.empty())
-                {
                     return;
                 }
-                const std::string& owner = objDict.begin()->first;
-
-                for (const std::string& interface : objDict.begin()->second)
+                for (const auto& [path, objDict] : ret)
                 {
-                    // anything that starts with a requested configuration
-                    // is good
-                    if (std::find_if(interfaces.begin(), interfaces.end(),
-                                     [interface](const std::string& possible) {
-                        return interface.starts_with(possible);
-                    }) == interfaces.end())
+                    if (objDict.empty())
                     {
-                        continue;
+                        return;
                     }
-                    self->getPath(path, interface, owner);
+                    const std::string& owner = objDict.begin()->first;
+
+                    for (const std::string& interface : objDict.begin()->second)
+                    {
+                        // anything that starts with a requested configuration
+                        // is good
+                        if (std::find_if(
+                                interfaces.begin(), interfaces.end(),
+                                [interface](const std::string& possible) {
+                                    return interface.starts_with(possible);
+                                }) == interfaces.end())
+                        {
+                            continue;
+                        }
+                        self->getPath(path, interface, owner);
+                    }
                 }
-            }
-        },
+            },
             mapper::busName, mapper::path, mapper::interface, mapper::subtree,
             "/", 0, interfaces);
     }
diff --git a/src/sensor.hpp b/src/sensor.hpp
index 7d22160..82798dc 100644
--- a/src/sensor.hpp
+++ b/src/sensor.hpp
@@ -267,8 +267,8 @@
         sensorInterface->register_property("MinValue", minValue);
         sensorInterface->register_property(
             "Value", value, [this](const double& newValue, double& oldValue) {
-            return setSensorValue(newValue, oldValue);
-        });
+                return setSensorValue(newValue, oldValue);
+            });
 
         fillMissingThresholds();
 
@@ -288,36 +288,36 @@
                 continue;
             }
 
-            std::string level = propertyLevel(threshold.level,
-                                              threshold.direction);
-            std::string alarm = propertyAlarm(threshold.level,
-                                              threshold.direction);
+            std::string level =
+                propertyLevel(threshold.level, threshold.direction);
+            std::string alarm =
+                propertyAlarm(threshold.level, threshold.direction);
 
             if ((level.empty()) || (alarm.empty()))
             {
                 continue;
             }
-            size_t thresSize = label.empty() ? thresholds.size()
-                                             : thresholdSize;
+            size_t thresSize =
+                label.empty() ? thresholds.size() : thresholdSize;
             iface->register_property(
                 level, threshold.value,
                 [&, label, thresSize](const double& request, double& oldValue) {
-                oldValue = request; // todo, just let the config do this?
-                threshold.value = request;
-                thresholds::persistThreshold(configurationPath, configInterface,
-                                             threshold, dbusConnection,
-                                             thresSize, label);
-                // Invalidate previously remembered value,
-                // so new thresholds will be checked during next update,
-                // even if sensor reading remains unchanged.
-                value = std::numeric_limits<double>::quiet_NaN();
+                    oldValue = request; // todo, just let the config do this?
+                    threshold.value = request;
+                    thresholds::persistThreshold(
+                        configurationPath, configInterface, threshold,
+                        dbusConnection, thresSize, label);
+                    // Invalidate previously remembered value,
+                    // so new thresholds will be checked during next update,
+                    // even if sensor reading remains unchanged.
+                    value = std::numeric_limits<double>::quiet_NaN();
 
-                // Although tempting, don't call checkThresholds() from here
-                // directly. Let the regular sensor monitor call the same
-                // using updateValue(), which can check conditions like
-                // poweron, etc., before raising any event.
-                return 1;
-            });
+                    // Although tempting, don't call checkThresholds() from here
+                    // directly. Let the regular sensor monitor call the same
+                    // using updateValue(), which can check conditions like
+                    // poweron, etc., before raising any event.
+                    return 1;
+                });
             iface->register_property(alarm, false);
         }
         if (!sensorInterface->initialize())
@@ -359,17 +359,17 @@
                     availableInterfaceName);
             availableInterface->register_property(
                 "Available", true, [this](const bool propIn, bool& old) {
-                if (propIn == old)
-                {
+                    if (propIn == old)
+                    {
+                        return 1;
+                    }
+                    old = propIn;
+                    if (!propIn)
+                    {
+                        updateValue(std::numeric_limits<double>::quiet_NaN());
+                    }
                     return 1;
-                }
-                old = propIn;
-                if (!propIn)
-                {
-                    updateValue(std::numeric_limits<double>::quiet_NaN());
-                }
-                return 1;
-            });
+                });
             availableInterface->initialize();
         }
         if (!operationalInterface)
diff --git a/tests/test_Utils.cpp b/tests/test_Utils.cpp
index b46db7b..8192475 100644
--- a/tests/test_Utils.cpp
+++ b/tests/test_Utils.cpp
@@ -115,9 +115,9 @@
 TEST_F(TestUtils, findFiles_in_peci_no_match)
 {
     std::vector<fs::path> foundPaths;
-    auto ret = findFiles(peciDir,
-                         R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/aaa$)",
-                         foundPaths, 6);
+    auto ret =
+        findFiles(peciDir, R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/aaa$)",
+                  foundPaths, 6);
 
     EXPECT_TRUE(ret);
     EXPECT_TRUE(foundPaths.empty());
@@ -126,9 +126,9 @@
 TEST_F(TestUtils, findFiles_in_peci_match)
 {
     std::vector<fs::path> foundPaths;
-    auto ret = findFiles(peciDir,
-                         R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/name$)",
-                         foundPaths, 6);
+    auto ret =
+        findFiles(peciDir, R"(peci-\d+/\d+-.+/peci-.+/hwmon/hwmon\d+/name$)",
+                  foundPaths, 6);
     EXPECT_TRUE(ret);
     EXPECT_EQ(foundPaths.size(), 1U);
 
@@ -166,9 +166,9 @@
 TEST_F(TestUtils, findFiles_in_sub_peci_match)
 {
     std::vector<fs::path> foundPaths;
-    auto ret = findFiles(peciDir / "peci-0",
-                         R"(\d+-.+/peci-.+/hwmon/hwmon\d+/name$)", foundPaths,
-                         5);
+    auto ret =
+        findFiles(peciDir / "peci-0", R"(\d+-.+/peci-.+/hwmon/hwmon\d+/name$)",
+                  foundPaths, 5);
     EXPECT_TRUE(ret);
     EXPECT_EQ(foundPaths.size(), 1U);
 
