From ac8bbae26d136b7d9326947f8c4a9735f75b3baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 7 Jun 2021 15:03:41 +0200 Subject: [PATCH] Use proper client id for MQTT and add discovery create method and evcharger interface --- goecharger/integrationplugingoecharger.cpp | 6 ++++-- goecharger/integrationplugingoecharger.json | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/goecharger/integrationplugingoecharger.cpp b/goecharger/integrationplugingoecharger.cpp index bcd41d04..0a6c5dde 100644 --- a/goecharger/integrationplugingoecharger.cpp +++ b/goecharger/integrationplugingoecharger.cpp @@ -242,10 +242,12 @@ QNetworkRequest IntegrationPluginGoECharger::buildConfigurationRequest(const QHo void IntegrationPluginGoECharger::setupMqttChannel(ThingSetupInfo *info, const QHostAddress &address, const QVariantMap &statusMap) { Thing *thing = info->thing(); - QString statusTopic = QString("go-eCharger/%1/status").arg(statusMap.value("sse").toString()); + QString serialNumber = statusMap.value("sse").toString(); + QString clientId = QString("go-eCharger:%1:%2").arg(serialNumber).arg(statusMap.value("rbc").toInt()); + QString statusTopic = QString("go-eCharger/%1/status").arg(serialNumber); qCDebug(dcGoECharger()) << "Setting up mqtt channel for" << thing << address.toString() << statusTopic; - MqttChannel *channel = hardwareManager()->mqttProvider()->createChannel(thing->id().toString(), address, {statusTopic}); + MqttChannel *channel = hardwareManager()->mqttProvider()->createChannel(clientId, address, {statusTopic}); if (!channel) { qCWarning(dcGoECharger()) << "Failed to create MQTT channel for" << thing; info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Error creating MQTT channel. Please check MQTT server settings.")); diff --git a/goecharger/integrationplugingoecharger.json b/goecharger/integrationplugingoecharger.json index 000bda8f..a0f5eee1 100644 --- a/goecharger/integrationplugingoecharger.json +++ b/goecharger/integrationplugingoecharger.json @@ -12,8 +12,8 @@ "name": "goeHome", "displayName": "go-eCharger Home", "id": "3b663d51-fdb5-4944-b409-c07f7933877e", - "createMethods": ["User"], - "interfaces": ["connectable"], + "createMethods": ["Discovery", "User"], + "interfaces": ["evcharger", "connectable"], "paramTypes": [ { "id": "4342b72c-99d0-41a5-abc6-ea6c1cc1352c",