Skip to content

Commit

Permalink
Fix uniqueid as RAttrUniqueId
Browse files Browse the repository at this point in the history
  • Loading branch information
manup committed Mar 10, 2018
1 parent 17bb7bf commit 1150cb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions rest_node_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ void RestNodeBase::setId(const QString &id)
*/
const QString &RestNodeBase::uniqueId() const
{
const Resource *r = dynamic_cast<const Resource*>(this);
const ResourceItem *item = r ? r->item(RAttrUniqueId) : 0;
if (item)
{
return item->toString();
}
return m_uid;
}

Expand All @@ -117,6 +123,12 @@ const QString &RestNodeBase::uniqueId() const
*/
void RestNodeBase::setUniqueId(const QString &uid)
{
Resource *r = dynamic_cast<Resource*>(this);
ResourceItem *item = r ? r->addItem(DataTypeString, RAttrUniqueId) : 0;
if (item)
{
item->setValue(uid);
}
m_uid = uid;
}

Expand Down
7 changes: 6 additions & 1 deletion rest_sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,12 @@ bool DeRestPluginPrivate::sensorToMap(const Sensor *sensor, QVariantMap &map, bo
{
map["manufacturername"] = sensor->manufacturer();
}
map["uniqueid"] = sensor->uniqueId();

const ResourceItem *item = sensor->item(RAttrUniqueId);
if (item)
{
map["uniqueid"] = item->toString();
}
map["state"] = state;
map["config"] = config;

Expand Down

0 comments on commit 1150cb9

Please sign in to comment.