Add clientId param and fix reconfigure leak

master
Michael Zanetti 2022-03-04 13:43:31 +01:00
parent 7c6fc0311f
commit 567a3c9ac8
2 changed files with 11 additions and 1 deletions

View File

@ -45,10 +45,13 @@ void IntegrationPluginMqttClient::setupThing(ThingSetupInfo *info)
Thing *thing = info->thing();
MqttClient *client = nullptr;
if (m_clients.contains(thing)) {
delete m_clients.take(thing);
}
if (thing->thingClassId() == internalMqttClientThingClassId) {
client = hardwareManager()->mqttProvider()->createInternalClient(thing->id().toString());
} else if (thing->thingClassId() == mqttClientThingClassId){
client = new MqttClient("nymea-" + thing->id().toString().remove(QRegExp("[{}]")).left(8), this);
client = new MqttClient(thing->paramValue(mqttClientThingClientIdParamTypeId).toString(), this);
client->setUsername(thing->paramValue(mqttClientThingUsernameParamTypeId).toString());
client->setPassword(thing->paramValue(mqttClientThingPasswordParamTypeId).toString());
QString willTopic = thing->paramValue(mqttClientThingWillTopicParamTypeId).toString();

View File

@ -114,6 +114,13 @@
"type": "QString",
"defaultValue": ""
},
{
"id": "621f9054-2b64-4de9-93d2-65bba96a14a3",
"name": "clientId",
"displayName": "Client Id",
"type": "QString",
"defaultValue": "nymea"
},
{
"id": "d8211599-52f7-46f6-a741-a7204b987309",
"name": "password",