From ecd2562b26638aba2d5cf968104576e88a1b6cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Thu, 26 Aug 2021 09:14:06 +0200 Subject: [PATCH] Add plugedIn interface state for goE-Charger --- goecharger/integrationplugingoecharger.cpp | 8 ++++++++ goecharger/integrationplugingoecharger.json | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/goecharger/integrationplugingoecharger.cpp b/goecharger/integrationplugingoecharger.cpp index 9a76348e..d8c278f3 100644 --- a/goecharger/integrationplugingoecharger.cpp +++ b/goecharger/integrationplugingoecharger.cpp @@ -266,15 +266,19 @@ void IntegrationPluginGoECharger::update(Thing *thing, const QVariantMap &status switch (carState) { case CarStateReadyNoCar: thing->setStateValue(goeHomeCarStatusStateTypeId, "Ready but no vehicle connected"); + thing->setStateValue(goeHomePluggedInStateTypeId, false); break; case CarStateCharging: thing->setStateValue(goeHomeCarStatusStateTypeId, "Vehicle loads"); + thing->setStateValue(goeHomePluggedInStateTypeId, true); break; case CarStateWaitForCar: thing->setStateValue(goeHomeCarStatusStateTypeId, "Waiting for vehicle"); + thing->setStateValue(goeHomePluggedInStateTypeId, false); break; case CarStateChargedCarConnected: thing->setStateValue(goeHomeCarStatusStateTypeId, "Charging finished and vehicle still connected"); + thing->setStateValue(goeHomePluggedInStateTypeId, true); break; } @@ -403,6 +407,7 @@ void IntegrationPluginGoECharger::setupMqttChannel(ThingSetupInfo *info, const Q qCDebug(dcGoECharger()) << "Configured successfully MQTT server" << thing << channel->serverAddress().toString(); } + // Configure the port QNetworkRequest request = buildConfigurationRequest(address, QString("mcp=%1").arg(channel->serverPort())); qCDebug(dcGoECharger()) << "Configure nymea mqtt server port on" << thing << request.url().toString(); QNetworkReply *reply = hardwareManager()->networkManager()->sendCustomRequest(request, "SET"); @@ -432,6 +437,7 @@ void IntegrationPluginGoECharger::setupMqttChannel(ThingSetupInfo *info, const Q qCDebug(dcGoECharger()) << "Configured successfully MQTT server" << thing << channel->serverPort(); } + // Username QNetworkRequest request = buildConfigurationRequest(address, QString("mcu=%1").arg(channel->username())); qCDebug(dcGoECharger()) << "Configure nymea mqtt server user name on" << thing << request.url().toString(); QNetworkReply *reply = hardwareManager()->networkManager()->sendCustomRequest(request, "SET"); @@ -461,6 +467,7 @@ void IntegrationPluginGoECharger::setupMqttChannel(ThingSetupInfo *info, const Q qCDebug(dcGoECharger()) << "Configured successfully MQTT server" << thing << channel->username(); } + // Password QNetworkRequest request = buildConfigurationRequest(address, QString("mck=%1").arg(channel->password())); qCDebug(dcGoECharger()) << "Configure nymea mqtt server password on" << thing << request.url().toString(); QNetworkReply *reply = hardwareManager()->networkManager()->sendCustomRequest(request, "SET"); @@ -490,6 +497,7 @@ void IntegrationPluginGoECharger::setupMqttChannel(ThingSetupInfo *info, const Q qCDebug(dcGoECharger()) << "Configured successfully MQTT server" << thing << channel->password(); } + // Enable MQTT QNetworkRequest request = buildConfigurationRequest(address, QString("mce=1")); qCDebug(dcGoECharger()) << "Enable custom mqtt server on" << thing << request.url().toString(); QNetworkReply *reply = hardwareManager()->networkManager()->sendCustomRequest(request, "SET"); diff --git a/goecharger/integrationplugingoecharger.json b/goecharger/integrationplugingoecharger.json index d27255dc..414e0c75 100644 --- a/goecharger/integrationplugingoecharger.json +++ b/goecharger/integrationplugingoecharger.json @@ -53,6 +53,14 @@ "defaultValue": "Ready but no vehicle connected", "suggestLogging": true }, + { + "id": "6cb155b1-0831-47bc-8657-17ca68716684", + "name": "pluggedIn", + "displayName": "Car plugged in", + "displayNameEvent": "Car plugged in changed", + "type": "bool", + "defaultValue": false + }, { "id": "d80e1ed8-c3ae-4b68-bf86-21b4d7b2b201", "name": "access",