/devices show productid, fix top level attributes for main device
#include <QProcess>
#include "de_web_plugin.h"
#include "de_web_plugin_private.h"
+#include "device_descriptions.h"
#include "json.h"
#include "rest_devices.h"
#include "utils/utils.h"
@@ -208,6 +209,13 @@ int RestDevices::getDevice(const ApiRequest &req, ApiResponse &rsp)
return REQ_READY_SEND;
}
+ const DeviceDescription ddf = plugin->deviceDescriptions->get(device);
+
+ if (ddf.isValid())
+ {
+ rsp.map["productid"] = ddf.product;
+ }
+
QVariantList subDevices;
for (const auto &sub : device->subDevices())
@@ -219,7 +227,8 @@ int RestDevices::getDevice(const ApiRequest &req, ApiResponse &rsp)
auto *item = sub->itemForIndex(i);
Q_ASSERT(item);
- if (item->descriptor().suffix == RStateLastUpdated)
+ if (item->descriptor().suffix == RStateLastUpdated ||
+ item->descriptor().suffix == RAttrId)
{
continue;
}
@@ -236,9 +245,12 @@ int RestDevices::getDevice(const ApiRequest &req, ApiResponse &rsp)
if (item->descriptor().suffix == RAttrLastSeen || item->descriptor().suffix == RAttrLastAnnounced ||
item->descriptor().suffix == RAttrManufacturerName || item->descriptor().suffix == RAttrModelId ||
item->descriptor().suffix == RAttrSwVersion || item->descriptor().suffix == RAttrName)
+ {
+ if (!rsp.map.contains(ls.at(1)))
{
rsp.map[ls.at(1)] = item->toString(); // top level attribute
}
+ }
else if (ls.at(0) == QLatin1String("attr"))
{
map[ls.at(1)] = item->toVariant(); // sub device top level attribute
