psu-ng: Fix for interfacesAdded

The presentAddedMatch was not properly being triggered when the power
supply interfaces was added in order to populate the Present property.
The method used for added is different from when it is changed. Add in a
function to handle when the inventory interface is added with the
Present property.

Tested:
    In simulator, on startup, check journal for power supply present.
    obmcutil poweron
    Verify no error logged for missing power supply
    Remove power supply
    Verify journal shows driver missing, driver unbound.
    Verify error logged for missing power supply.
    Install power supply
    Verify journal shows driver bound for present power supply.
    obmcutil poweroff
    Delete error for missing power supply.
    obmcutil poweron
    Verify no error logged for missing power supply.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I70daeac597bdbdc9f069459707768a45edfa7ef2
diff --git a/phosphor-power-supply/power_supply.cpp b/phosphor-power-supply/power_supply.cpp
index 72403ed..63697f4 100644
--- a/phosphor-power-supply/power_supply.cpp
+++ b/phosphor-power-supply/power_supply.cpp
@@ -200,6 +200,36 @@
     }
 }
 
+void PowerSupply::inventoryAdded(sdbusplus::message::message& msg)
+{
+    sdbusplus::message::object_path path;
+    msg.read(path);
+    // Make sure the signal is for the PSU inventory path
+    if (path == inventoryPath)
+    {
+        std::map<std::string, std::map<std::string, std::variant<bool>>>
+            interfaces;
+        // Get map of interfaces and their properties
+        msg.read(interfaces);
+
+        auto properties = interfaces.find(INVENTORY_IFACE);
+        if (properties != interfaces.end())
+        {
+            auto property = properties->second.find(PRESENT_PROP);
+            if (property != properties->second.end())
+            {
+                present = std::get<bool>(property->second);
+
+                log<level::INFO>(fmt::format("Power Supply {} Present {}",
+                                             inventoryPath, present)
+                                     .c_str());
+
+                updateInventory();
+            }
+        }
+    }
+}
+
 void PowerSupply::updateInventory()
 {
     using namespace phosphor::pmbus;