diff --git a/README.md b/README.md
index 243cf77..9f5bef1 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,42 @@
 RESET_OUT
 POWER_BUTTON
 POWER_OUT
+POST_COMPLETE
+PS_PWROK
+SIO_ONCONTROL
+SIO_POWER_GOOD
+SIO_S5
+
+x86-power-control uses default json file (power-config-host0.json) for GPIO configuration.
+However this can be customized by producing your own power-config-host0.json file.
+
+Definitions can be configured by two type:
+
+1. GPIO
+
+ For the platform having direct GPIO access can use the type GPIO and define like below.
+
+    {
+        "Name" : "PostComplete",
+        "LineName" : "POST_COMPLETE",
+        "Type" : "GPIO"
+    },
+
+2. DBUS
+
+ For the platform not having direct GPIO access can use dbus based event monitor by using the type DBUS.
+
+    {
+        "Name" : "PowerButton",
+        "DbusName" : "xyz.openbmc_project.Chassis.Event",
+        "Path" : "/xyz/openbmc_project/Chassis/Event",
+        "Interface" : "xyz.openbmc_project.Chassis.Event",
+        "Property" : "PowerButton_Host1",
+        "Type" : "DBUS"
+    },
+
+ x86-power-control will monitor the property change from the given DbusName and take appropriate action.
+ *define Property as a bool variable.
 
 On an aspeed, these are generally connected to E0, E1, E2, and E3 respectively.
 An example of this is available in the s2600WF config.
diff --git a/power-control-x86/CMakeLists.txt b/power-control-x86/CMakeLists.txt
index ba06ed4..0216891 100644
--- a/power-control-x86/CMakeLists.txt
+++ b/power-control-x86/CMakeLists.txt
@@ -51,7 +51,7 @@
   SERVICE_FILES
   ${PROJECT_SOURCE_DIR}/service_files/chassis-system-reset.service
   ${PROJECT_SOURCE_DIR}/service_files/chassis-system-reset.target
-  ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Control.Power.service
+  ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Control.Power@.service
   )
 
 set(
diff --git a/power-control-x86/config/power-config-host0.json b/power-control-x86/config/power-config-host0.json
index ca9a86a..62be21c 100644
--- a/power-control-x86/config/power-config-host0.json
+++ b/power-control-x86/config/power-config-host0.json
@@ -1,18 +1,66 @@
 {
-  "gpio_configs":{
-      "IdButton": "ID_BUTTON",
-      "NMIButton": "NMI_BUTTON",
-      "NMIOut": "NMI_OUT",
-      "PostComplete": "POST_COMPLETE",
-      "PwrButton": "POWER_BUTTON",
-      "PwrOK": "PS_PWROK",
-      "PwrOut": "POWER_OUT",
-      "RstButton": "RESET_BUTTON",
-      "RstOut": "RESET_OUT",
-      "SIOOnCtl": "SIO_ONCONTROL",
-      "SIOPwrGd": "SIO_POWER_GOOD",
-      "SIOS5": "SIO_S5"
+  "gpio_configs":[
+    {
+        "Name" : "IdButton",
+        "LineName" : "ID_BUTTON",
+        "Type" : "GPIO"
     },
+    {
+        "Name" : "NMIButton",
+        "LineName" : "NMI_BUTTON",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "NMIOut",
+        "LineName" : "NMI_OUT",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "PostComplete",
+        "LineName" : "POST_COMPLETE",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "PowerButton",
+        "LineName" : "POWER_BUTTON",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "PowerOk",
+        "LineName" : "PS_PWROK",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "PowerOut",
+        "LineName" : "POWER_OUT",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "ResetButton",
+        "LineName" : "RESET_BUTTON",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "ResetOut",
+        "LineName" : "RESET_OUT",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "SioOnControl",
+        "LineName" : "SIO_ONCONTROL",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "SioPowerGood",
+        "LineName" : "SIO_POWER_GOOD",
+        "Type" : "GPIO"
+    },
+    {
+        "Name" : "SIOS5",
+        "LineName" : "SIO_S5",
+        "Type" : "GPIO"
+    }
+],
   "timing_configs":{
       "PowerPulseMs": 200,
       "ForceOffPulseMs": 15000,
@@ -25,4 +73,3 @@
       "PowerOffSaveMs": 7000
     }
 }
-
diff --git a/power-control-x86/service_files/xyz.openbmc_project.Chassis.Control.Power.service b/power-control-x86/service_files/xyz.openbmc_project.Chassis.Control.Power.service
deleted file mode 100644
index a80235e..0000000
--- a/power-control-x86/service_files/xyz.openbmc_project.Chassis.Control.Power.service
+++ /dev/null
@@ -1,13 +0,0 @@
-[Unit]
-Description=Intel Power Control
-
-[Service]
-Restart=always
-RestartSec=3
-ExecStart=/usr/bin/power-control
-Type=dbus
-BusName=xyz.openbmc_project.State.Host
-
-[Install]
-WantedBy=sysinit.target
-
diff --git a/power-control-x86/service_files/xyz.openbmc_project.Chassis.Control.Power@.service b/power-control-x86/service_files/xyz.openbmc_project.Chassis.Control.Power@.service
new file mode 100644
index 0000000..4d676c2
--- /dev/null
+++ b/power-control-x86/service_files/xyz.openbmc_project.Chassis.Control.Power@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Intel Power Control for the Host %i
+ConditionPathExists=/usr/share/x86-power-control/power-config-host%i.json
+
+[Service]
+Restart=always
+RestartSec=3
+ExecStart=/usr/bin/power-control %i
+Type=dbus
+BusName=xyz.openbmc_project.State.Host%i
+
+[Install]
+WantedBy=sysinit.target
diff --git a/power-control-x86/src/power_control.cpp b/power-control-x86/src/power_control.cpp
index 2222735..5781d6a 100644
--- a/power-control-x86/src/power_control.cpp
+++ b/power-control-x86/src/power_control.cpp
@@ -39,19 +39,72 @@
 
 static std::string node = "0";
 
-static std::string powerOutName;
-static std::string powerOkName;
-static std::string resetOutName;
-static std::string nmiOutName;
-static std::string sioPwrGoodName;
-static std::string sioOnControlName;
-static std::string sioS5Name;
-static std::string postCompleteName;
-static std::string powerButtonName;
-static std::string resetButtonName;
-static std::string idButtonName;
-static std::string nmiButtonName;
+enum class DbusConfigType
+{
+    name = 1,
+    path,
+    interface,
+    property
+};
+boost::container::flat_map<DbusConfigType, std::string> dbusParams = {
+    {DbusConfigType::name, "DbusName"},
+    {DbusConfigType::path, "Path"},
+    {DbusConfigType::interface, "Interface"},
+    {DbusConfigType::property, "Property"}};
 
+enum class ConfigType
+{
+    GPIO = 1,
+    DBUS
+};
+
+struct ConfigData
+{
+    std::string name;
+    std::string lineName;
+    std::string dbusName;
+    std::string path;
+    std::string interface;
+    ConfigType type;
+};
+
+static ConfigData powerOutConfig;
+static ConfigData powerOkConfig;
+static ConfigData resetOutConfig;
+static ConfigData nmiOutConfig;
+static ConfigData sioPwrGoodConfig;
+static ConfigData sioOnControlConfig;
+static ConfigData sioS5Config;
+static ConfigData postCompleteConfig;
+static ConfigData powerButtonConfig;
+static ConfigData resetButtonConfig;
+static ConfigData idButtonConfig;
+static ConfigData nmiButtonConfig;
+// map for storing list of gpio parameters whose config are to be read from x86
+// power control json config
+boost::container::flat_map<std::string, ConfigData*> powerSignalMap = {
+    {"PowerOut", &powerOutConfig},
+    {"PowerOk", &powerOkConfig},
+    {"ResetOut", &resetOutConfig},
+    {"NMIOut", &nmiOutConfig},
+    {"SioPowerGood", &sioPwrGoodConfig},
+    {"SioOnControl", &sioOnControlConfig},
+    {"SIOS5", &sioS5Config},
+    {"PostComplete", &postCompleteConfig},
+    {"PowerButton", &powerButtonConfig},
+    {"ResetButton", &resetButtonConfig},
+    {"IdButton", &idButtonConfig},
+    {"NMIButton", &nmiButtonConfig}
+
+};
+
+static std::string hostDbusName = "xyz.openbmc_project.State.Host";
+static std::string chassisDbusName = "xyz.openbmc_project.State.Chassis";
+static std::string osDbusName = "xyz.openbmc_project.State.OperatingSystem";
+static std::string buttonDbusName = "xyz.openbmc_project.Chassis.Buttons";
+static std::string nmiDbusName = "xyz.openbmc_project.Control.Host.NMI";
+static std::string rstCauseDbusName =
+    "xyz.openbmc_project.Control.Host.RestartCause";
 static std::shared_ptr<sdbusplus::asio::dbus_interface> hostIface;
 static std::shared_ptr<sdbusplus::asio::dbus_interface> chassisIface;
 #ifdef CHASSIS_SYSTEM_RESET
@@ -69,15 +122,17 @@
 static gpiod::line resetButtonMask;
 static bool nmiButtonMasked = false;
 
-static int powerPulseTimeMs = 200;
-static int forceOffPulseTimeMs = 15000;
-static int resetPulseTimeMs = 500;
-static int powerCycleTimeMs = 5000;
-static int sioPowerGoodWatchdogTimeMs = 1000;
-static int psPowerOKWatchdogTimeMs = 8000;
-static int gracefulPowerOffTimeS = 5 * 60;
-static int warmResetCheckTimeMs = 500;
-static int powerOffSaveTimeMs = 7000;
+// This map contains all timer values that are to be read from json config
+boost::container::flat_map<std::string, int> TimerMap = {
+    {"powerPulseTimeMs", 200},
+    {"forceOffPulseTimeMs", 15000},
+    {"resetPulseTimeMs", 500},
+    {"powerCycleTimeMs", 5000},
+    {"sioPowerGoodWatchdogTimeMs", 1000},
+    {"psPowerOKWatchdogTimeMs", 8000},
+    {"gracefulPowerOffTimeS", (5 * 60)},
+    {"warmResetCheckTimeMs", 500},
+    {"powerOffSaveTimeMs", 7000}};
 
 const static std::filesystem::path powerControlDir = "/var/lib/power-control";
 const static constexpr std::string_view powerStateFile = "power-state";
@@ -453,7 +508,7 @@
 static void savePowerState(const PowerState state)
 {
     powerStateSaveTimer.expires_after(
-        std::chrono::milliseconds(powerOffSaveTimeMs));
+        std::chrono::milliseconds(TimerMap["powerOffSaveTimeMs"]));
     powerStateSaveTimer.async_wait([state](const boost::system::error_code ec) {
         if (ec)
         {
@@ -612,7 +667,7 @@
         "MESSAGE=PowerControl: system power good failed to assert (VR failure)",
         "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s",
         "OpenBMC.0.1.SystemPowerGoodFailed", "REDFISH_MESSAGE_ARGS=%d",
-        sioPowerGoodWatchdogTimeMs, NULL);
+        TimerMap["sioPowerGoodWatchdogTimeMs"], NULL);
 }
 
 static void psPowerOKFailedLog()
@@ -621,7 +676,7 @@
         "MESSAGE=PowerControl: power supply power good failed to assert",
         "PRIORITY=%i", LOG_INFO, "REDFISH_MESSAGE_ID=%s",
         "OpenBMC.0.1.PowerSupplyPowerGoodFailed", "REDFISH_MESSAGE_ARGS=%d",
-        psPowerOKWatchdogTimeMs, NULL);
+        TimerMap["psPowerOKWatchdogTimeMs"], NULL);
 }
 
 static void powerRestorePolicyLog()
@@ -1089,12 +1144,12 @@
                               const int durationMs)
 {
     // If the requested GPIO is masked, use the mask line to set the output
-    if (powerButtonMask && name == power_control::powerOutName)
+    if (powerButtonMask && name == powerOutConfig.lineName)
     {
         return setMaskedGPIOOutputForMs(powerButtonMask, name, value,
                                         durationMs);
     }
-    if (resetButtonMask && name == power_control::resetOutName)
+    if (resetButtonMask && name == resetOutConfig.lineName)
     {
         return setMaskedGPIOOutputForMs(resetButtonMask, name, value,
                                         durationMs);
@@ -1131,18 +1186,20 @@
 
 static void powerOn()
 {
-    setGPIOOutputForMs(power_control::powerOutName, 0, powerPulseTimeMs);
+    setGPIOOutputForMs(powerOutConfig.lineName, 0,
+                       TimerMap["powerPulseTimeMs"]);
 }
 
 static void gracefulPowerOff()
 {
-    setGPIOOutputForMs(power_control::powerOutName, 0, powerPulseTimeMs);
+    setGPIOOutputForMs(powerOutConfig.lineName, 0,
+                       TimerMap["powerPulseTimeMs"]);
 }
 
 static void forcePowerOff()
 {
-    if (setGPIOOutputForMs(power_control::powerOutName, 0,
-                           forceOffPulseTimeMs) < 0)
+    if (setGPIOOutputForMs(powerOutConfig.lineName, 0,
+                           TimerMap["forceOffPulseTimeMs"]) < 0)
     {
         return;
     }
@@ -1183,7 +1240,8 @@
 
 static void reset()
 {
-    setGPIOOutputForMs(power_control::resetOutName, 0, resetPulseTimeMs);
+    setGPIOOutputForMs(resetOutConfig.lineName, 0,
+                       TimerMap["resetPulseTimeMs"]);
 }
 
 static void gracefulPowerOffTimerStart()
@@ -1191,7 +1249,7 @@
     phosphor::logging::log<phosphor::logging::level::INFO>(
         "Graceful power-off timer started");
     gracefulPowerOffTimer.expires_after(
-        std::chrono::seconds(gracefulPowerOffTimeS));
+        std::chrono::seconds(TimerMap["gracefulPowerOffTimeS"]));
     gracefulPowerOffTimer.async_wait([](const boost::system::error_code ec) {
         if (ec)
         {
@@ -1218,7 +1276,8 @@
 {
     phosphor::logging::log<phosphor::logging::level::INFO>(
         "Power-cycle timer started");
-    powerCycleTimer.expires_after(std::chrono::milliseconds(powerCycleTimeMs));
+    powerCycleTimer.expires_after(
+        std::chrono::milliseconds(TimerMap["powerCycleTimeMs"]));
     powerCycleTimer.async_wait([](const boost::system::error_code ec) {
         if (ec)
         {
@@ -1246,7 +1305,7 @@
     phosphor::logging::log<phosphor::logging::level::INFO>(
         "power supply power OK watchdog timer started");
     psPowerOKWatchdogTimer.expires_after(
-        std::chrono::milliseconds(psPowerOKWatchdogTimeMs));
+        std::chrono::milliseconds(TimerMap["psPowerOKWatchdogTimeMs"]));
     psPowerOKWatchdogTimer.async_wait([](const boost::system::error_code ec) {
         if (ec)
         {
@@ -1275,7 +1334,7 @@
     phosphor::logging::log<phosphor::logging::level::INFO>(
         "Warm reset check timer started");
     warmResetCheckTimer.expires_after(
-        std::chrono::milliseconds(warmResetCheckTimeMs));
+        std::chrono::milliseconds(TimerMap["warmResetCheckTimeMs"]));
     warmResetCheckTimer.async_wait([](const boost::system::error_code ec) {
         if (ec)
         {
@@ -1464,7 +1523,7 @@
     phosphor::logging::log<phosphor::logging::level::INFO>(
         "SIO power good watchdog timer started");
     sioPowerGoodWatchdogTimer.expires_after(
-        std::chrono::milliseconds(sioPowerGoodWatchdogTimeMs));
+        std::chrono::milliseconds(TimerMap["sioPowerGoodWatchdogTimeMs"]));
     sioPowerGoodWatchdogTimer.async_wait(
         [](const boost::system::error_code ec) {
             if (ec)
@@ -2027,13 +2086,14 @@
 
     phosphor::logging::log<phosphor::logging::level::INFO>("NMI out action");
     nmiOutLine.set_value(value);
-    std::string logMsg = nmiOutName + " set to " + std::to_string(value);
+    std::string logMsg =
+        nmiOutConfig.lineName + " set to " + std::to_string(value);
     phosphor::logging::log<phosphor::logging::level::INFO>(logMsg.c_str());
     gpioAssertTimer.expires_after(std::chrono::milliseconds(nmiOutPulseTimeMs));
     gpioAssertTimer.async_wait([](const boost::system::error_code ec) {
         // restore the NMI_OUT GPIO line back to the opposite value
         nmiOutLine.set_value(!value);
-        std::string logMsg = nmiOutName + " released";
+        std::string logMsg = nmiOutConfig.lineName + " released";
         phosphor::logging::log<phosphor::logging::level::INFO>(logMsg.c_str());
         if (ec)
         {
@@ -2041,8 +2101,8 @@
             // completion.
             if (ec != boost::asio::error::operation_aborted)
             {
-                std::string errMsg =
-                    nmiOutName + " async_wait failed: " + ec.message();
+                std::string errMsg = nmiOutConfig.lineName +
+                                     " async_wait failed: " + ec.message();
                 phosphor::logging::log<phosphor::logging::level::ERR>(
                     errMsg.c_str());
             }
@@ -2281,131 +2341,648 @@
             "loadConfigValues : Cannot open config path");
         return -1;
     }
-    auto data = nlohmann::json::parse(configFile, nullptr);
+    auto jsonData = nlohmann::json::parse(configFile, nullptr);
 
-    if (data.is_discarded())
+    if (jsonData.is_discarded())
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(
             "Power config readings JSON parser failure");
         return -1;
     }
-    auto gpios = data["gpio_configs"];
-    auto timers = data["timing_configs"];
+    auto gpios = jsonData["gpio_configs"];
+    auto timers = jsonData["timing_configs"];
 
-    if (gpios.contains("IdButton"))
+    ConfigData* tempGpioData;
+
+    for (nlohmann::json& gpioConfig : gpios)
     {
-        idButtonName = gpios["IdButton"];
+        if (!gpioConfig.contains("Name"))
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "The 'Name' field must be defined in Json file");
+            return -1;
+        }
+
+        // Iterate through the powersignal map to check if the gpio json config
+        // entry is valid
+        std::string gpioName = gpioConfig["Name"];
+        auto signalMapIter = powerSignalMap.find(gpioName);
+        if (signalMapIter == powerSignalMap.end())
+        {
+            std::string errMsg = "Undefined Name  : " + gpioName;
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                errMsg.c_str());
+            return -1;
+        }
+
+        // assign the power signal name to the corresponding structure reference
+        // from map then fillup the structure with coressponding json config
+        // value
+        tempGpioData = signalMapIter->second;
+        tempGpioData->name = gpioName;
+
+        if (!gpioConfig.contains("Type"))
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "The \'Type\' field must be defined in Json file");
+            return -1;
+        }
+
+        std::string signalType = gpioConfig["Type"];
+        if (signalType == "GPIO")
+        {
+            tempGpioData->type = ConfigType::GPIO;
+        }
+        else if (signalType == "DBUS")
+        {
+            tempGpioData->type = ConfigType::DBUS;
+        }
+        else
+        {
+            std::string errMsg = "Undefined Type : " + signalType;
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                errMsg.c_str());
+            return -1;
+        }
+
+        if (tempGpioData->type == ConfigType::GPIO)
+        {
+            if (gpioConfig.contains("LineName"))
+            {
+                tempGpioData->lineName = gpioConfig["LineName"];
+            }
+            else
+            {
+                phosphor::logging::log<phosphor::logging::level::ERR>(
+                    "The \'LineName\' field must be defined for GPIO "
+                    "configuration");
+                return -1;
+            }
+        }
+        else
+        {
+            // if dbus based gpio config is defined read and update the dbus
+            // params corresponding to the gpio config instance
+            for (auto& [key, dbusParamName] : dbusParams)
+            {
+                if (!gpios.contains(dbusParamName))
+                {
+                    std::string errMsg =
+                        "The " + dbusParamName +
+                        "field must be defined for Dbus configuration ";
+                    phosphor::logging::log<phosphor::logging::level::ERR>(
+                        errMsg.c_str());
+                    return -1;
+                }
+            }
+            tempGpioData->dbusName = gpios[dbusParams[DbusConfigType::name]];
+            tempGpioData->path = gpios[dbusParams[DbusConfigType::path]];
+            tempGpioData->interface =
+                gpios[dbusParams[DbusConfigType::interface]];
+            tempGpioData->lineName =
+                gpios[dbusParams[DbusConfigType::property]];
+        }
     }
 
-    if (gpios.contains("NMIButton"))
+    // read and store the timer values from json config to Timer Map
+    for (auto& [key, timerValue] : TimerMap)
     {
-        nmiButtonName = gpios["NMIButton"];
+        if (timers.contains(key.c_str()))
+        {
+            timerValue = timers[key.c_str()];
+        }
     }
 
-    if (gpios.contains("NMIOut"))
-    {
-        nmiOutName = gpios["NMIOut"];
-    }
-
-    if (gpios.contains("PostComplete"))
-    {
-        postCompleteName = gpios["PostComplete"];
-    }
-
-    if (gpios.contains("PwrButton"))
-    {
-        powerButtonName = gpios["PwrButton"];
-    }
-
-    if (gpios.contains("PwrOK"))
-    {
-        powerOkName = gpios["PwrOK"];
-    }
-
-    if (gpios.contains("PwrOut"))
-    {
-        powerOutName = gpios["PwrOut"];
-    }
-
-    if (gpios.contains("RstButton"))
-    {
-        resetButtonName = gpios["RstButton"];
-    }
-
-    if (gpios.contains("RstOut"))
-    {
-        resetOutName = gpios["RstOut"];
-    }
-
-    if (gpios.contains("SIOOnCtl"))
-    {
-        sioOnControlName = gpios["SIOOnCtl"];
-    }
-
-    if (gpios.contains("SIOPwrGd"))
-    {
-        sioPwrGoodName = gpios["SIOPwrGd"];
-    }
-
-    if (gpios.contains("SIOS5"))
-    {
-        sioS5Name = gpios["SIOS5"];
-    }
-
-    if (timers.contains("PowerPulseMs"))
-    {
-        powerPulseTimeMs = timers["PowerPulseMs"];
-    }
-
-    if (timers.contains("ForceOffPulseMs"))
-    {
-        forceOffPulseTimeMs = timers["ForceOffPulseMs"];
-    }
-
-    if (timers.contains("ResetPulseMs"))
-    {
-        resetPulseTimeMs = timers["ResetPulseMs"];
-    }
-
-    if (timers.contains("PowerCycleMs"))
-    {
-        powerCycleTimeMs = timers["PowerCycleMs"];
-    }
-
-    if (timers.contains("SioPowerGoodWatchdogMs"))
-    {
-        sioPowerGoodWatchdogTimeMs = timers["SioPowerGoodWatchdogMs"];
-    }
-
-    if (timers.contains("PsPowerOKWatchdogMs"))
-    {
-        psPowerOKWatchdogTimeMs = timers["PsPowerOKWatchdogMs"];
-    }
-
-    if (timers.contains("GracefulPowerOffS"))
-    {
-        gracefulPowerOffTimeS = timers["GracefulPowerOffS"];
-    }
-
-    if (timers.contains("WarmResetCheckMs"))
-    {
-        warmResetCheckTimeMs = timers["WarmResetCheckMs"];
-    }
-
-    if (timers.contains("PowerOffSaveMs"))
-    {
-        powerOffSaveTimeMs = timers["PowerOffSaveMs"];
-    }
     return 0;
 }
+inline static sdbusplus::bus::match::match powerButtonEventMonitor()
+{
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+        bool value = false;
+        std::string thresholdInterface;
+        std::string event;
+        boost::container::flat_map<std::string, std::variant<bool>>
+            propertiesChanged;
+        try
+        {
 
+            msg.read(thresholdInterface, propertiesChanged);
+
+            if (propertiesChanged.empty())
+            {
+                return;
+            }
+            event = propertiesChanged.begin()->first;
+
+            if (event.empty() || event != powerButtonConfig.lineName)
+            {
+                return;
+            }
+
+            value = std::get<bool>(propertiesChanged.begin()->second);
+        }
+        catch (std::exception& e)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "exception during reading dbus property : powerButtonConfig");
+            return;
+        }
+
+        if (value == false)
+        {
+            powerButtonPressLog();
+            powerButtonIface->set_property("ButtonPressed", true);
+            if (!powerButtonMask)
+            {
+                sendPowerControlEvent(Event::powerButtonPressed);
+                addRestartCause(RestartCause::powerButton);
+            }
+            else
+            {
+                phosphor::logging::log<phosphor::logging::level::ERR>(
+                    "power button press masked\n");
+            }
+        }
+        else
+        {
+            powerButtonIface->set_property("ButtonPressed", false);
+        }
+    };
+
+    sdbusplus::bus::match::match pulseEventMatcher(
+        static_cast<sdbusplus::bus::bus&>(*conn),
+        "type='signal',interface='org.freedesktop.DBus.Properties',member='"
+        "PropertiesChanged',arg0='" +
+            powerButtonConfig.dbusName + "'",
+        std::move(pulseEventMatcherCallback));
+
+    return pulseEventMatcher;
+}
+
+inline static sdbusplus::bus::match::match resetButtonEventMonitor()
+{
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+        bool value = false;
+        std::string thresholdInterface;
+        std::string event;
+        boost::container::flat_map<std::string, std::variant<bool>>
+            propertiesChanged;
+        try
+        {
+            msg.read(thresholdInterface, propertiesChanged);
+
+            if (propertiesChanged.empty())
+            {
+                return;
+            }
+            event = propertiesChanged.begin()->first;
+
+            if (event.empty() || event != resetButtonConfig.lineName)
+            {
+                return;
+            }
+
+            value = std::get<bool>(propertiesChanged.begin()->second);
+        }
+        catch (std::exception& e)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "exception during reading dbus property : resetButtonConfig");
+            return;
+        }
+
+        if (value == false)
+        {
+            resetButtonPressLog();
+            resetButtonIface->set_property("ButtonPressed", true);
+            if (!resetButtonMask)
+            {
+                sendPowerControlEvent(Event::resetButtonPressed);
+                addRestartCause(RestartCause::resetButton);
+            }
+            else
+            {
+                phosphor::logging::log<phosphor::logging::level::ERR>(
+                    "reset button press masked");
+            }
+        }
+        else
+        {
+            resetButtonIface->set_property("ButtonPressed", false);
+        }
+    };
+
+    sdbusplus::bus::match::match pulseEventMatcher(
+        static_cast<sdbusplus::bus::bus&>(*conn),
+        "type='signal',interface='org.freedesktop.DBus.Properties',member='"
+        "PropertiesChanged',arg0='" +
+            resetButtonConfig.dbusName + "'",
+        std::move(pulseEventMatcherCallback));
+
+    return pulseEventMatcher;
+}
+
+inline static sdbusplus::bus::match::match powerOkEventMonitor()
+{
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+        bool value = false;
+        std::string thresholdInterface;
+        std::string event;
+        boost::container::flat_map<std::string, std::variant<bool>>
+            propertiesChanged;
+        try
+        {
+            msg.read(thresholdInterface, propertiesChanged);
+
+            if (propertiesChanged.empty())
+            {
+                return;
+            }
+            event = propertiesChanged.begin()->first;
+
+            if (event.empty() || event != powerOkConfig.lineName)
+            {
+                return;
+            }
+
+            value = std::get<bool>(propertiesChanged.begin()->second);
+        }
+        catch (std::exception& e)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "exception during reading dbus property : powerOkConfig");
+            return;
+        }
+
+        Event powerControlEvent =
+            value ? Event::psPowerOKAssert : Event::psPowerOKDeAssert;
+        sendPowerControlEvent(powerControlEvent);
+    };
+
+    sdbusplus::bus::match::match pulseEventMatcher(
+        static_cast<sdbusplus::bus::bus&>(*conn),
+        "type='signal',interface='org.freedesktop.DBus.Properties',member='"
+        "PropertiesChanged',arg0='" +
+            powerOkConfig.dbusName + "'",
+        std::move(pulseEventMatcherCallback));
+
+    return pulseEventMatcher;
+}
+
+inline static sdbusplus::bus::match::match sioPwrGoodEventMonitor()
+{
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+        bool value = false;
+        std::string thresholdInterface;
+        std::string event;
+        boost::container::flat_map<std::string, std::variant<bool>>
+            propertiesChanged;
+        try
+        {
+            msg.read(thresholdInterface, propertiesChanged);
+
+            if (propertiesChanged.empty())
+            {
+                return;
+            }
+            event = propertiesChanged.begin()->first;
+
+            if (event.empty() || event != sioPwrGoodConfig.lineName)
+            {
+                return;
+            }
+
+            value = std::get<bool>(propertiesChanged.begin()->second);
+        }
+        catch (std::exception& e)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "exception during reading dbus property : sioPwrGoodConfig");
+            return;
+        }
+
+        Event powerControlEvent =
+            value ? Event::sioPowerGoodAssert : Event::sioPowerGoodDeAssert;
+
+        sendPowerControlEvent(powerControlEvent);
+    };
+
+    sdbusplus::bus::match::match pulseEventMatcher(
+        static_cast<sdbusplus::bus::bus&>(*conn),
+        "type='signal',interface='org.freedesktop.DBus.Properties',member='"
+        "PropertiesChanged',arg0='" +
+            sioPwrGoodConfig.dbusName + "'",
+        std::move(pulseEventMatcherCallback));
+
+    return pulseEventMatcher;
+}
+
+inline static sdbusplus::bus::match::match sioOnControlEventMonitor()
+{
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+        bool value = false;
+        std::string thresholdInterface;
+        std::string event;
+        boost::container::flat_map<std::string, std::variant<bool>>
+            propertiesChanged;
+        try
+        {
+            msg.read(thresholdInterface, propertiesChanged);
+
+            if (propertiesChanged.empty())
+            {
+                return;
+            }
+            event = propertiesChanged.begin()->first;
+
+            if (event.empty() || event != sioOnControlConfig.lineName)
+            {
+                return;
+            }
+
+            value = std::get<bool>(propertiesChanged.begin()->second);
+        }
+        catch (std::exception& e)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "exception during reading dbus property : sioOnControlConfig");
+            return;
+        }
+
+        std::string errMsg =
+            "SIO_ONCONTROL value changed : " + std::to_string(value);
+        phosphor::logging::log<phosphor::logging::level::ERR>(errMsg.c_str());
+    };
+
+    sdbusplus::bus::match::match pulseEventMatcher(
+        static_cast<sdbusplus::bus::bus&>(*conn),
+        "type='signal',interface='org.freedesktop.DBus.Properties',member='"
+        "PropertiesChanged',arg0='" +
+            sioOnControlConfig.dbusName + "'",
+        std::move(pulseEventMatcherCallback));
+
+    return pulseEventMatcher;
+}
+
+inline static sdbusplus::bus::match::match sioS5EventMonitor()
+{
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+        bool value = false;
+        std::string thresholdInterface;
+        std::string event;
+        boost::container::flat_map<std::string, std::variant<bool>>
+            propertiesChanged;
+        try
+        {
+            msg.read(thresholdInterface, propertiesChanged);
+
+            if (propertiesChanged.empty())
+            {
+                return;
+            }
+            event = propertiesChanged.begin()->first;
+
+            if (event.empty() || event != sioS5Config.lineName)
+            {
+                return;
+            }
+
+            value = std::get<bool>(propertiesChanged.begin()->second);
+        }
+        catch (std::exception& e)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "exception during reading dbus property : sioS5Config");
+            return;
+        }
+
+        Event powerControlEvent =
+            value ? Event::sioS5DeAssert : Event::sioS5Assert;
+        sendPowerControlEvent(powerControlEvent);
+    };
+
+    sdbusplus::bus::match::match pulseEventMatcher(
+        static_cast<sdbusplus::bus::bus&>(*conn),
+        "type='signal',interface='org.freedesktop.DBus.Properties',member='"
+        "PropertiesChanged',arg0='" +
+            sioS5Config.dbusName + "'",
+        std::move(pulseEventMatcherCallback));
+
+    return pulseEventMatcher;
+}
+
+inline static sdbusplus::bus::match::match nmiButtonEventMonitor()
+{
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+        bool value = false;
+        std::string thresholdInterface;
+        std::string event;
+        boost::container::flat_map<std::string, std::variant<bool>>
+            propertiesChanged;
+        try
+        {
+            msg.read(thresholdInterface, propertiesChanged);
+
+            if (propertiesChanged.empty())
+            {
+                return;
+            }
+            event = propertiesChanged.begin()->first;
+            if (event.empty() || event != nmiButtonConfig.lineName)
+            {
+                return;
+            }
+
+            value = std::get<bool>(propertiesChanged.begin()->second);
+        }
+        catch (std::exception& e)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "exception during reading dbus property : nmiButtonConfig");
+            return;
+        }
+
+        if (value)
+        {
+            nmiButtonIface->set_property("ButtonPressed", false);
+        }
+        else
+        {
+            nmiButtonPressLog();
+            nmiButtonIface->set_property("ButtonPressed", true);
+            if (nmiButtonMasked)
+            {
+                phosphor::logging::log<phosphor::logging::level::ERR>(
+                    "NMI button press masked");
+            }
+            else
+            {
+                setNmiSource();
+            }
+        }
+    };
+
+    sdbusplus::bus::match::match pulseEventMatcher(
+        static_cast<sdbusplus::bus::bus&>(*conn),
+        "type='signal',interface='org.freedesktop.DBus.Properties',member='"
+        "PropertiesChanged',arg0='" +
+            nmiButtonConfig.dbusName + "'",
+        std::move(pulseEventMatcherCallback));
+
+    return pulseEventMatcher;
+}
+
+inline static sdbusplus::bus::match::match idButtonEventMonitor()
+{
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+        bool value = false;
+        std::string thresholdInterface;
+        std::string event;
+        boost::container::flat_map<std::string, std::variant<bool>>
+            propertiesChanged;
+
+        try
+        {
+
+            msg.read(thresholdInterface, propertiesChanged);
+
+            if (propertiesChanged.empty())
+            {
+                return;
+            }
+            event = propertiesChanged.begin()->first;
+
+            if (event.empty() | event != idButtonConfig.lineName)
+            {
+                return;
+            }
+
+            value = std::get<bool>(propertiesChanged.begin()->second);
+        }
+        catch (std::exception& e)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "exception during reading dbus property : idButtonConfig");
+            return;
+        }
+
+        if (value)
+        {
+            idButtonIface->set_property("ButtonPressed", false);
+        }
+        else
+        {
+            idButtonIface->set_property("ButtonPressed", true);
+        }
+    };
+
+    sdbusplus::bus::match::match pulseEventMatcher(
+        static_cast<sdbusplus::bus::bus&>(*conn),
+        "type='signal',interface='org.freedesktop.DBus.Properties',member='"
+        "PropertiesChanged',arg0='" +
+            idButtonConfig.dbusName + "'",
+        std::move(pulseEventMatcherCallback));
+
+    return pulseEventMatcher;
+}
+
+inline static sdbusplus::bus::match::match postCompleteEventMonitor()
+{
+    auto pulseEventMatcherCallback = [](sdbusplus::message::message& msg) {
+        bool value = false;
+        std::string thresholdInterface;
+        std::string event;
+        boost::container::flat_map<std::string, std::variant<bool>>
+            propertiesChanged;
+        try
+        {
+
+            msg.read(thresholdInterface, propertiesChanged);
+
+            if (propertiesChanged.empty())
+            {
+                return;
+            }
+            event = propertiesChanged.begin()->first;
+
+            if (event.empty() | event != postCompleteConfig.lineName)
+            {
+                return;
+            }
+
+            value = std::get<bool>(propertiesChanged.begin()->second);
+        }
+        catch (std::exception& e)
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "exception during reading dbus property : postCompleteConfig");
+            return;
+        }
+
+        if (value)
+        {
+            sendPowerControlEvent(Event::postCompleteDeAssert);
+            osIface->set_property("OperatingSystemState",
+                                  std::string("Inactive"));
+        }
+        else
+        {
+            sendPowerControlEvent(Event::postCompleteAssert);
+            osIface->set_property("OperatingSystemState",
+                                  std::string("Standby"));
+        }
+    };
+
+    sdbusplus::bus::match::match pulseEventMatcher(
+        static_cast<sdbusplus::bus::bus&>(*conn),
+        "type='signal',path='" + postCompleteConfig.path +
+            "',interface='org.freedesktop.DBus.Properties',member='"
+            "PropertiesChanged',arg0='" +
+            postCompleteConfig.dbusName + "'",
+        std::move(pulseEventMatcherCallback));
+
+    return pulseEventMatcher;
+}
+
+int getProperty(ConfigData& configData)
+{
+    auto method = conn->new_method_call(
+        configData.dbusName.c_str(), configData.path.c_str(),
+        "org.freedesktop.DBus.Properties", "Get");
+    method.append(configData.interface.c_str(), configData.lineName.c_str());
+
+    auto reply = conn->call(method);
+    if (reply.is_method_error())
+    {
+        phosphor::logging::log<phosphor::logging::level::ERR>(
+            "Error reading from Bus");
+        return -1;
+    }
+    std::variant<int> resp;
+    reply.read(resp);
+    auto respValue = std::get_if<int>(&resp);
+    if (!respValue)
+    {
+        phosphor::logging::log<phosphor::logging::level::ERR>(
+            "Error reading response");
+        return -1;
+    }
+    return (*respValue);
+}
 } // namespace power_control
 
 int main(int argc, char* argv[])
 {
     using namespace power_control;
-    phosphor::logging::log<phosphor::logging::level::INFO>(
-        "Start Chassis power control service...");
+
+    if (argc > 1)
+    {
+        node = argv[1];
+    }
+    std::string infoMsg =
+        "Start Chassis power control service for host : " + node;
+    phosphor::logging::log<phosphor::logging::level::INFO>(infoMsg.c_str());
+
     conn = std::make_shared<sdbusplus::asio::connection>(io);
 
     // Load GPIO's through json config file
@@ -2415,15 +2992,23 @@
         phosphor::logging::log<phosphor::logging::level::ERR>(errMsg.c_str());
     }
 
-    // Request all the dbus names
-    conn->request_name("xyz.openbmc_project.State.Host");
-    conn->request_name("xyz.openbmc_project.State.Chassis");
-    conn->request_name("xyz.openbmc_project.State.OperatingSystem");
-    conn->request_name("xyz.openbmc_project.Chassis.Buttons");
-    conn->request_name("xyz.openbmc_project.Control.Host.NMI");
-    conn->request_name("xyz.openbmc_project.Control.Host.RestartCause");
+    hostDbusName = "xyz.openbmc_project.State.Host" + node;
+    chassisDbusName = "xyz.openbmc_project.State.Chassis" + node;
+    osDbusName = "xyz.openbmc_project.State.OperatingSystem" + node;
+    buttonDbusName = "xyz.openbmc_project.Chassis.Buttons" + node;
+    nmiDbusName = "xyz.openbmc_project.Control.Host.NMI" + node;
+    rstCauseDbusName = "xyz.openbmc_project.Control.Host.RestartCause" + node;
 
-    if (sioPwrGoodName.empty() || sioOnControlName.empty() || sioS5Name.empty())
+    // Request all the dbus names
+    conn->request_name(hostDbusName.c_str());
+    conn->request_name(chassisDbusName.c_str());
+    conn->request_name(osDbusName.c_str());
+    conn->request_name(buttonDbusName.c_str());
+    conn->request_name(nmiDbusName.c_str());
+    conn->request_name(rstCauseDbusName.c_str());
+
+    if (sioPwrGoodConfig.lineName.empty() ||
+        sioOnControlConfig.lineName.empty() || sioS5Config.lineName.empty())
     {
         sioEnabled = false;
         phosphor::logging::log<phosphor::logging::level::INFO>(
@@ -2431,14 +3016,20 @@
     }
 
     // Request PS_PWROK GPIO events
-    if (!powerOkName.empty())
+    if (powerOkConfig.type == ConfigType::GPIO)
     {
-        if (!requestGPIOEvents(powerOkName, psPowerOKHandler, psPowerOKLine,
-                               psPowerOKEvent))
+        if (!requestGPIOEvents(powerOkConfig.lineName, psPowerOKHandler,
+                               psPowerOKLine, psPowerOKEvent))
         {
             return -1;
         }
     }
+    else if (powerOkConfig.type == ConfigType::DBUS)
+    {
+
+        static sdbusplus::bus::match::match powerOkEventMonitor =
+            power_control::powerOkEventMonitor();
+    }
     else
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -2449,69 +3040,130 @@
     if (sioEnabled == true)
     {
         // Request SIO_POWER_GOOD GPIO events
-        if (!requestGPIOEvents(sioPwrGoodName, sioPowerGoodHandler,
-                               sioPowerGoodLine, sioPowerGoodEvent))
+        if (sioPwrGoodConfig.type == ConfigType::GPIO)
         {
+            if (!requestGPIOEvents(sioPwrGoodConfig.lineName,
+                                   sioPowerGoodHandler, sioPowerGoodLine,
+                                   sioPowerGoodEvent))
+            {
+                return -1;
+            }
+        }
+        else if (sioPwrGoodConfig.type == ConfigType::DBUS)
+        {
+            static sdbusplus::bus::match::match sioPwrGoodEventMonitor =
+                power_control::sioPwrGoodEventMonitor();
+        }
+        else
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "sioPwrGood name should be configured from json config file");
             return -1;
         }
 
         // Request SIO_ONCONTROL GPIO events
-        if (!requestGPIOEvents(sioOnControlName, sioOnControlHandler,
-                               sioOnControlLine, sioOnControlEvent))
+        if (sioOnControlConfig.type == ConfigType::GPIO)
         {
+            if (!requestGPIOEvents(sioOnControlConfig.lineName,
+                                   sioOnControlHandler, sioOnControlLine,
+                                   sioOnControlEvent))
+            {
+                return -1;
+            }
+        }
+        else if (sioOnControlConfig.type == ConfigType::DBUS)
+        {
+            static sdbusplus::bus::match::match sioOnControlEventMonitor =
+                power_control::sioOnControlEventMonitor();
+        }
+        else
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "sioOnControl name should be configured from json"
+                "config file\n");
             return -1;
         }
 
         // Request SIO_S5 GPIO events
-        if (!requestGPIOEvents(sioS5Name, sioS5Handler, sioS5Line, sioS5Event))
+        if (sioS5Config.type == ConfigType::GPIO)
         {
+            if (!requestGPIOEvents(sioS5Config.lineName, sioS5Handler,
+                                   sioS5Line, sioS5Event))
+            {
+                return -1;
+            }
+        }
+        else if (sioS5Config.type == ConfigType::DBUS)
+        {
+            static sdbusplus::bus::match::match sioS5EventMonitor =
+                power_control::sioS5EventMonitor();
+        }
+        else
+        {
+            phosphor::logging::log<phosphor::logging::level::ERR>(
+                "sioS5 name should be configured from json config file");
             return -1;
         }
     }
 
     // Request POWER_BUTTON GPIO events
-    if (!powerButtonName.empty())
+    if (powerButtonConfig.type == ConfigType::GPIO)
     {
-        if (!requestGPIOEvents(powerButtonName, powerButtonHandler,
+        if (!requestGPIOEvents(powerButtonConfig.lineName, powerButtonHandler,
                                powerButtonLine, powerButtonEvent))
         {
             return -1;
         }
     }
-    else
+    else if (powerButtonConfig.type == ConfigType::DBUS)
     {
-        phosphor::logging::log<phosphor::logging::level::ERR>(
-            "powerButton name should be configured from json config file");
-        return -1;
+        static sdbusplus::bus::match::match powerButtonEventMonitor =
+            power_control::powerButtonEventMonitor();
     }
 
     // Request RESET_BUTTON GPIO events
-    if (!resetButtonName.empty())
+    if (resetButtonConfig.type == ConfigType::GPIO)
     {
-        if (!requestGPIOEvents(resetButtonName, resetButtonHandler,
+        if (!requestGPIOEvents(resetButtonConfig.lineName, resetButtonHandler,
                                resetButtonLine, resetButtonEvent))
         {
             return -1;
         }
     }
-    else
+    else if (resetButtonConfig.type == ConfigType::DBUS)
     {
-        phosphor::logging::log<phosphor::logging::level::INFO>(
-            "ResetButton not defined...");
+        static sdbusplus::bus::match::match resetButtonEventMonitor =
+            power_control::resetButtonEventMonitor();
     }
 
     // Request NMI_BUTTON GPIO events
-    if (!nmiButtonName.empty())
+    if (nmiButtonConfig.type == ConfigType::GPIO)
     {
-        requestGPIOEvents(nmiButtonName, nmiButtonHandler, nmiButtonLine,
-                          nmiButtonEvent);
+        if (!nmiButtonConfig.lineName.empty())
+        {
+            requestGPIOEvents(nmiButtonConfig.lineName, nmiButtonHandler,
+                              nmiButtonLine, nmiButtonEvent);
+        }
+    }
+    else if (nmiButtonConfig.type == ConfigType::DBUS)
+    {
+        static sdbusplus::bus::match::match nmiButtonEventMonitor =
+            power_control::nmiButtonEventMonitor();
     }
 
     // Request ID_BUTTON GPIO events
-    if (!idButtonName.empty())
+    if (idButtonConfig.type == ConfigType::GPIO)
     {
-        requestGPIOEvents(idButtonName, idButtonHandler, idButtonLine,
-                          idButtonEvent);
+        if (!idButtonConfig.lineName.empty())
+        {
+            requestGPIOEvents(idButtonConfig.lineName, idButtonHandler,
+                              idButtonLine, idButtonEvent);
+        }
+    }
+    else if (idButtonConfig.type == ConfigType::DBUS)
+    {
+        static sdbusplus::bus::match::match idButtonEventMonitor =
+            power_control::idButtonEventMonitor();
     }
 
 #ifdef USE_PLT_RST
@@ -2523,14 +3175,19 @@
 #endif
 
     // Request POST_COMPLETE GPIO events
-    if (!postCompleteName.empty())
+    if (postCompleteConfig.type == ConfigType::GPIO)
     {
-        if (!requestGPIOEvents(postCompleteName, postCompleteHandler,
+        if (!requestGPIOEvents(postCompleteConfig.lineName, postCompleteHandler,
                                postCompleteLine, postCompleteEvent))
         {
             return -1;
         }
     }
+    else if (postCompleteConfig.type == ConfigType::DBUS)
+    {
+        static sdbusplus::bus::match::match postCompleteEventMonitor =
+            power_control::postCompleteEventMonitor();
+    }
     else
     {
         phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -2539,17 +3196,38 @@
     }
 
     // initialize NMI_OUT GPIO.
-    setGPIOOutput(nmiOutName, 0, nmiOutLine);
+    if (!nmiOutConfig.lineName.empty())
+    {
+        setGPIOOutput(nmiOutConfig.lineName, 0, nmiOutLine);
+    }
 
     // Initialize POWER_OUT and RESET_OUT GPIO.
     gpiod::line line;
-    if (!setGPIOOutput(powerOutName, 1, line))
+    if (!powerOutConfig.lineName.empty())
     {
+        if (!setGPIOOutput(powerOutConfig.lineName, 1, line))
+        {
+            return -1;
+        }
+    }
+    else
+    {
+        phosphor::logging::log<phosphor::logging::level::ERR>(
+            "powerOut name should be configured from json config file");
         return -1;
     }
 
-    if (!setGPIOOutput(resetOutName, 1, line))
+    if (!resetOutConfig.lineName.empty())
     {
+        if (!setGPIOOutput(resetOutConfig.lineName, 1, line))
+        {
+            return -1;
+        }
+    }
+    else
+    {
+        phosphor::logging::log<phosphor::logging::level::ERR>(
+            "ResetOut name should be configured from json config file");
         return -1;
     }
 
@@ -2559,9 +3237,20 @@
     // Initialize the power state
     powerState = PowerState::off;
     // Check power good
-    if (psPowerOKLine.get_value() > 0)
+
+    if (powerOkConfig.type == ConfigType::GPIO)
     {
-        powerState = PowerState::on;
+        if (psPowerOKLine.get_value() > 0)
+        {
+            powerState = PowerState::on;
+        }
+    }
+    else
+    {
+        if (getProperty(powerOkConfig))
+        {
+            powerState = PowerState::on;
+        }
     }
 
     // Initialize the power state storage
@@ -2585,8 +3274,9 @@
         sdbusplus::asio::object_server(conn);
 
     // Power Control Interface
-    hostIface = hostServer.add_interface("/xyz/openbmc_project/state/host0",
-                                         "xyz.openbmc_project.State.Host");
+    hostIface =
+        hostServer.add_interface("/xyz/openbmc_project/state/host" + node,
+                                 "xyz.openbmc_project.State.Host");
 
     // Interface for IPMI/Redfish initiated host state transitions
     hostIface->register_property(
@@ -2698,7 +3388,7 @@
 
     // Chassis Control Interface
     chassisIface =
-        chassisServer.add_interface("/xyz/openbmc_project/state/chassis0",
+        chassisServer.add_interface("/xyz/openbmc_project/state/chassis" + node,
                                     "xyz.openbmc_project.State.Chassis");
 
     chassisIface->register_property(
@@ -2780,51 +3470,66 @@
     sdbusplus::asio::object_server buttonsServer =
         sdbusplus::asio::object_server(conn);
 
-    // Power Button Interface
-    powerButtonIface = buttonsServer.add_interface(
-        "/xyz/openbmc_project/chassis/buttons/power",
-        "xyz.openbmc_project.Chassis.Buttons");
-
-    powerButtonIface->register_property(
-        "ButtonMasked", false, [](const bool requested, bool& current) {
-            if (requested)
-            {
-                if (powerButtonMask)
-                {
-                    return 1;
-                }
-                if (!setGPIOOutput(powerOutName, 1, powerButtonMask))
-                {
-                    throw std::runtime_error("Failed to request GPIO");
-                    return 0;
-                }
-                phosphor::logging::log<phosphor::logging::level::INFO>(
-                    "Power Button Masked.");
-            }
-            else
-            {
-                if (!powerButtonMask)
-                {
-                    return 1;
-                }
-                phosphor::logging::log<phosphor::logging::level::INFO>(
-                    "Power Button Un-masked");
-                powerButtonMask.reset();
-            }
-            // Update the mask setting
-            current = requested;
-            return 1;
-        });
-
-    // Check power button state
-    bool powerButtonPressed = powerButtonLine.get_value() == 0;
-    powerButtonIface->register_property("ButtonPressed", powerButtonPressed);
-
-    powerButtonIface->initialize();
-
-    // Reset Button Interface
-    if (!resetButtonName.empty())
+    if (!powerButtonConfig.lineName.empty())
     {
+        // Power Button Interface
+        power_control::powerButtonIface = buttonsServer.add_interface(
+            "/xyz/openbmc_project/chassis/buttons/power",
+            "xyz.openbmc_project.Chassis.Buttons");
+
+        powerButtonIface->register_property(
+            "ButtonMasked", false, [](const bool requested, bool& current) {
+                if (requested)
+                {
+                    if (powerButtonMask)
+                    {
+                        return 1;
+                    }
+                    if (!setGPIOOutput(powerOutConfig.lineName, 1,
+                                       powerButtonMask))
+                    {
+                        throw std::runtime_error("Failed to request GPIO");
+                        return 0;
+                    }
+                    phosphor::logging::log<phosphor::logging::level::INFO>(
+                        "Power Button Masked.");
+                }
+                else
+                {
+                    if (!powerButtonMask)
+                    {
+                        return 1;
+                    }
+                    phosphor::logging::log<phosphor::logging::level::INFO>(
+                        "Power Button Un-masked");
+                    powerButtonMask.reset();
+                }
+                // Update the mask setting
+                current = requested;
+                return 1;
+            });
+
+        // Check power button state
+        bool powerButtonPressed;
+        if (powerButtonConfig.type == ConfigType::GPIO)
+        {
+            powerButtonPressed = powerButtonLine.get_value() == 0;
+        }
+        else
+        {
+            powerButtonPressed = getProperty(powerButtonConfig) == 0;
+        }
+
+        powerButtonIface->register_property("ButtonPressed",
+                                            powerButtonPressed);
+
+        powerButtonIface->initialize();
+    }
+
+    if (!resetButtonConfig.lineName.empty())
+    {
+        // Reset Button Interface
+
         resetButtonIface = buttonsServer.add_interface(
             "/xyz/openbmc_project/chassis/buttons/reset",
             "xyz.openbmc_project.Chassis.Buttons");
@@ -2837,7 +3542,8 @@
                     {
                         return 1;
                     }
-                    if (!setGPIOOutput(resetOutName, 1, resetButtonMask))
+                    if (!setGPIOOutput(resetOutConfig.lineName, 1,
+                                       resetButtonMask))
                     {
                         throw std::runtime_error("Failed to request GPIO");
                         return 0;
@@ -2861,7 +3567,16 @@
             });
 
         // Check reset button state
-        bool resetButtonPressed = resetButtonLine.get_value() == 0;
+        bool resetButtonPressed;
+        if (resetButtonConfig.type == ConfigType::GPIO)
+        {
+            resetButtonPressed = resetButtonLine.get_value() == 0;
+        }
+        else
+        {
+            resetButtonPressed = getProperty(resetButtonConfig) == 0;
+        }
+
         resetButtonIface->register_property("ButtonPressed",
                                             resetButtonPressed);
 
@@ -2900,7 +3615,16 @@
             });
 
         // Check NMI button state
-        bool nmiButtonPressed = nmiButtonLine.get_value() == 0;
+        bool nmiButtonPressed;
+        if (nmiButtonConfig.type == ConfigType::GPIO)
+        {
+            nmiButtonPressed = nmiButtonLine.get_value() == 0;
+        }
+        else
+        {
+            nmiButtonPressed = getProperty(nmiButtonConfig) == 0;
+        }
+
         nmiButtonIface->register_property("ButtonPressed", nmiButtonPressed);
 
         nmiButtonIface->initialize();
@@ -2913,9 +3637,9 @@
             sdbusplus::asio::object_server(conn);
 
         // NMI out Interface
-        nmiOutIface =
-            nmiOutServer.add_interface("/xyz/openbmc_project/control/host0/nmi",
-                                       "xyz.openbmc_project.Control.Host.NMI");
+        nmiOutIface = nmiOutServer.add_interface(
+            "/xyz/openbmc_project/control/host" + node + "/nmi",
+            "xyz.openbmc_project.Control.Host.NMI");
         nmiOutIface->register_method("NMI", nmiReset);
         nmiOutIface->initialize();
     }
@@ -2928,7 +3652,16 @@
             "xyz.openbmc_project.Chassis.Buttons");
 
         // Check ID button state
-        bool idButtonPressed = idButtonLine.get_value() == 0;
+        bool idButtonPressed;
+        if (idButtonConfig.type == ConfigType::GPIO)
+        {
+            idButtonPressed = idButtonLine.get_value() == 0;
+        }
+        else
+        {
+            idButtonPressed = getProperty(idButtonConfig) == 0;
+        }
+
         idButtonIface->register_property("ButtonPressed", idButtonPressed);
 
         idButtonIface->initialize();
@@ -2946,8 +3679,15 @@
     // Get the initial OS state based on POST complete
     //      0: Asserted, OS state is "Standby" (ready to boot)
     //      1: De-Asserted, OS state is "Inactive"
-    std::string osState =
-        postCompleteLine.get_value() > 0 ? "Inactive" : "Standby";
+    std::string osState;
+    if (postCompleteConfig.type == ConfigType::GPIO)
+    {
+        osState = postCompleteLine.get_value() > 0 ? "Inactive" : "Standby";
+    }
+    else
+    {
+        osState = getProperty(postCompleteConfig) > 0 ? "Inactive" : "Standby";
+    }
 
     osIface->register_property("OperatingSystemState", std::string(osState));
 
