Commit 5cfdaab5 authored by Michael Ott's avatar Michael Ott
Browse files

Create sensor names from mqttsuffix if not configured otherwise and vice...

Create sensor names from mqttsuffix if not configured otherwise and vice versa. For sensor groups that use entities, create group name from entity name if not configured otherwise.
parent a0b4c12f
......@@ -385,6 +385,17 @@ protected:
sBase.setSubsampling(std::stoi(val.second.data()));
}
}
if (sBase.getName().size() == 0) {
size_t pos = sBase.getMqtt().find_last_of('/');
if (pos != std::string::npos) {
pos++;
} else {
pos = 0;
}
sBase.setName(sBase.getMqtt().substr(pos));
} else if (sBase.getMqtt().size() == 0) {
sBase.setMqtt('/' + sBase.getName());
}
sensorBase(sBase, config);
return true;
}
......@@ -487,6 +498,11 @@ protected:
if (it->second == g.second->getEntity()) {
SG_Ptr group = std::make_shared<SGroup>(*(g.second));
group->setEntity(&sEntity);
if (group->getGroupName().size() > 0) {
group->setGroupName(sEntity.getName() + "::" + group->getGroupName());
} else {
group->setGroupName(sEntity.getName());
}
storeSensorGroup(group);
}
}
......@@ -534,7 +550,12 @@ protected:
SG_Ptr group = std::make_shared<SGroup>(val.second.data());
if(readSensorGroup(*group, val.second)) {
group->setEntity(&sEntity);
storeSensorGroup(group);
if (group->getGroupName().size() > 0) {
group->setGroupName(sEntity.getName() + "::" + group->getGroupName());
} else {
group->setGroupName(sEntity.getName());
}
storeSensorGroup(group);
} else {
LOG(warning) << _groupName << " " << group->getGroupName()
<< " could not be read! Omitting";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment