Fix discovery, update documentation and debug prints according to review
parent
9996d2db9f
commit
90a6c87e5a
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
nymea plugin for go-eCharger smart wallbox for electic vehicles.
|
||||
|
||||
In order to make nymea work with go-e, please make sure you have enable `API V2` in the official app.
|
||||
In order to integrate go-eChargers with nymea, please make sure the `API V2` is enabled in the go-eCharger app.
|
||||
|
||||
If you are using the original go-e App or other client services to communicate with the wallbox, disable MQTT during the setup in order to make
|
||||
sure all services are able to communicate with the wallbox.
|
||||
There is no support for multiple MQTT clients on go-e devices, thus nymea defaults to HTTP to prevent constant
|
||||
reconfiguration trough the clients.
|
||||
Please note that that using the `MQTT interface` for connecting, may prevent other applications or services to connect to the go-eCharger wallbox.
|
||||
|
||||
The preferred way of communicating would be MQTT (API V2), default is HTTP (API V1).
|
||||
|
||||
|
|
|
|||
|
|
@ -39,12 +39,7 @@ GoeDiscovery::GoeDiscovery(NetworkAccessManager *networkAccessManager, NetworkDe
|
|||
m_networkAccessManager(networkAccessManager),
|
||||
m_networkDeviceDiscovery(networkDeviceDiscovery)
|
||||
{
|
||||
m_gracePeriodTimer.setSingleShot(true);
|
||||
m_gracePeriodTimer.setInterval(3000);
|
||||
connect(&m_gracePeriodTimer, &QTimer::timeout, this, [this](){
|
||||
qCDebug(dcGoECharger()) << "Discovery: Grace period timer triggered.";
|
||||
finishDiscovery();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
GoeDiscovery::~GoeDiscovery()
|
||||
|
|
@ -58,7 +53,6 @@ void GoeDiscovery::startDiscovery()
|
|||
// Clean up
|
||||
m_discoveryResults.clear();
|
||||
m_verifiedNetworkDeviceInfos.clear();
|
||||
m_gracePeriodTimer.stop();
|
||||
|
||||
m_startDateTime = QDateTime::currentDateTime();
|
||||
|
||||
|
|
@ -90,7 +84,10 @@ void GoeDiscovery::startDiscovery()
|
|||
// If there might be some response after the grace period time,
|
||||
// we don't care any more since there might just waiting for some timeouts...
|
||||
// If there would be a device, it would have responded.
|
||||
m_gracePeriodTimer.start();
|
||||
QTimer::singleShot(3000, this, [this](){
|
||||
qCDebug(dcGoECharger()) << "Discovery: Grace period timer triggered.";
|
||||
finishDiscovery();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -176,8 +173,6 @@ void GoeDiscovery::checkNetworkDeviceApiV1(const NetworkDeviceInfo &networkDevic
|
|||
qCDebug(dcGoECharger()) << "Discovery:" << networkDeviceInfo.address().toString() << "API V1 verification returned JSON data but not the right one. Continue...";
|
||||
}
|
||||
|
||||
// Check if we are done with all checks
|
||||
verifyDiscoveryFinished();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -228,19 +223,9 @@ void GoeDiscovery::checkNetworkDeviceApiV2(const NetworkDeviceInfo &networkDevic
|
|||
} else {
|
||||
qCDebug(dcGoECharger()) << "Discovery:" << networkDeviceInfo.address().toString() << "API V2 verification returned JSON data but not the right one. Continue...";
|
||||
}
|
||||
|
||||
// Check if we are done with all checks
|
||||
verifyDiscoveryFinished();
|
||||
});
|
||||
}
|
||||
|
||||
void GoeDiscovery::verifyDiscoveryFinished()
|
||||
{
|
||||
if (!m_discoveryReply && m_verifiedNetworkDeviceInfos.count() == m_discoveredNetworkDeviceInfos.count()) {
|
||||
finishDiscovery();
|
||||
}
|
||||
}
|
||||
|
||||
void GoeDiscovery::cleanupPendingReplies()
|
||||
{
|
||||
foreach (QNetworkReply *reply, m_pendingReplies) {
|
||||
|
|
@ -253,7 +238,6 @@ void GoeDiscovery::finishDiscovery()
|
|||
{
|
||||
qint64 durationMilliSeconds = QDateTime::currentMSecsSinceEpoch() - m_startDateTime.toMSecsSinceEpoch();
|
||||
qCInfo(dcGoECharger()) << "Discovery: Finished the discovery process. Found" << m_discoveryResults.count() << "go-eChargers in" << QTime::fromMSecsSinceStartOfDay(durationMilliSeconds).toString("mm:ss.zzz");
|
||||
m_gracePeriodTimer.stop();
|
||||
cleanupPendingReplies();
|
||||
emit discoveryFinished();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ signals:
|
|||
|
||||
private:
|
||||
QDateTime m_startDateTime;
|
||||
QTimer m_gracePeriodTimer;
|
||||
NetworkAccessManager *m_networkAccessManager = nullptr;
|
||||
NetworkDeviceDiscovery *m_networkDeviceDiscovery = nullptr;
|
||||
NetworkDeviceDiscoveryReply *m_discoveryReply = nullptr;
|
||||
|
|
@ -82,7 +81,6 @@ private slots:
|
|||
void checkNetworkDeviceApiV1(const NetworkDeviceInfo &networkDeviceInfo);
|
||||
void checkNetworkDeviceApiV2(const NetworkDeviceInfo &networkDeviceInfo);
|
||||
|
||||
void verifyDiscoveryFinished();
|
||||
void cleanupPendingReplies();
|
||||
|
||||
void finishDiscovery();
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ void IntegrationPluginGoECharger::discoverThings(ThingDiscoveryInfo *info)
|
|||
void IntegrationPluginGoECharger::setupThing(ThingSetupInfo *info)
|
||||
{
|
||||
Thing *thing = info->thing();
|
||||
qCDebug(dcGoECharger()) << "Set up" << thing << thing->params();
|
||||
qCDebug(dcGoECharger()) << "Setting up" << thing << thing->params();
|
||||
|
||||
MacAddress macAddress = MacAddress(thing->paramValue(goeHomeThingMacAddressParamTypeId).toString());
|
||||
if (!macAddress.isValid()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue