05.03., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

Commit db1fb0ce authored by Michael Ott's avatar Michael Ott

Check for valid entity pointer in constructSensorTopics()

parent a3f7e7a8
......@@ -465,11 +465,14 @@ class ConfiguratorTemplateEntity : public ConfiguratorTemplate<SBase, SGroup> {
// Sensor names are adjusted according to the respective MQTT topics
for (auto &g : _sensorGroups) {
for (auto &s : g->acquireSensors()) {
s->setMqtt(MQTTChecker::formatTopic(_mqttPrefix) +
MQTTChecker::formatTopic(g->getEntity()->getMqttPart()) +
MQTTChecker::formatTopic(g->getMqttPart()) +
MQTTChecker::formatTopic(s->getMqtt()));
s->setName(s->getMqtt());
std::string mqtt = MQTTChecker::formatTopic(_mqttPrefix);
if (g->getEntity()) {
mqtt.append(MQTTChecker::formatTopic(g->getEntity()->getMqttPart()));
}
mqtt.append(MQTTChecker::formatTopic(g->getMqttPart()));
mqtt.append(MQTTChecker::formatTopic(s->getMqtt()));
s->setMqtt(mqtt);
s->setName(mqtt);
SensorMetadata *sm = s->getMetadata();
if (sm) {
sm->setPublicName(s->getMqtt());
......
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