fixed typos
This commit is contained in:
parent
03069c3d76
commit
2ae998e707
@ -168,28 +168,30 @@ void IntegrationPluginHomeConnect::startPairing(ThingPairingInfo *info)
|
|||||||
QString scope = "IdentifyAppliance Monitor Settings Dishwasher Washer Dryer WasherDryer Refrigerator Freezer WineCooler CoffeeMaker Hood CookProcessor";
|
QString scope = "IdentifyAppliance Monitor Settings Dishwasher Washer Dryer WasherDryer Refrigerator Freezer WineCooler CoffeeMaker Hood CookProcessor";
|
||||||
if (controlEnabled) {
|
if (controlEnabled) {
|
||||||
scope.append(" Control");
|
scope.append(" Control");
|
||||||
qCDebug(dcHomeConnect()) << "Conrol scope is enabled";
|
qCDebug(dcHomeConnect()) << "Control scope is enabled";
|
||||||
}
|
}
|
||||||
if (simulationMode) {
|
if (simulationMode) {
|
||||||
qCDebug(dcHomeConnect()) << "Simulation mode is enabled";
|
qCDebug(dcHomeConnect()) << "Simulation mode is enabled";
|
||||||
}
|
}
|
||||||
QUrl url = homeConnect->getLoginUrl(QUrl("https://127.0.0.1:8888"), scope);
|
QUrl url = homeConnect->getLoginUrl(QUrl("https://127.0.0.1:8888"), scope);
|
||||||
info->setOAuthUrl(url);
|
qCDebug(dcHomeConnect()) << "Checking if the HomeConnect server is reachable: https://simulator.home-connect.com/security/oauth";
|
||||||
QNetworkReply *reply = hardwareManager()->networkManager()->get(QNetworkRequest(url)); // Check if the host is reachable
|
QNetworkReply *reply = hardwareManager()->networkManager()->get(QNetworkRequest(QUrl("https://simulator.home-connect.com/security/oauth")));
|
||||||
connect(reply, &QNetworkReply::finished, info, &QNetworkReply::deleteLater);
|
connect(reply, &QNetworkReply::finished, info, &QNetworkReply::deleteLater);
|
||||||
connect(reply, &QNetworkReply::finished, info, [reply, info, homeConnect, url, this] {
|
connect(reply, &QNetworkReply::finished, info, [reply, info, homeConnect, url, this] {
|
||||||
|
|
||||||
if (reply->error() == QNetworkReply::NetworkError::NoError) {
|
if (reply->error() != QNetworkReply::NetworkError::HostNotFoundError) {
|
||||||
|
qCDebug(dcHomeConnect()) << "HomeConnect server is reachable";
|
||||||
m_setupHomeConnectConnections.insert(info->thingId(), homeConnect);
|
m_setupHomeConnectConnections.insert(info->thingId(), homeConnect);
|
||||||
connect(info, &ThingPairingInfo::aborted, this, [info, this] {m_setupHomeConnectConnections.take(info->thingId())->deleteLater();});
|
connect(info, &ThingPairingInfo::aborted, this, [info, this] {m_setupHomeConnectConnections.take(info->thingId())->deleteLater();});
|
||||||
|
info->setOAuthUrl(url);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
} else {
|
} else {
|
||||||
qCDebug(dcHomeConnect()) << "Got online check error" << reply->errorString();
|
qCWarning(dcHomeConnect()) << "Got online check error" << reply->error() << reply->errorString();
|
||||||
info->finish(Thing::ThingErrorSetupFailed, tr("HomeConnect server not reachable, please check the internet connection"));
|
info->finish(Thing::ThingErrorSetupFailed, tr("HomeConnect server not reachable, please check the internet connection"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcHomeConnect()) << "Unhandled pairing metod!";
|
qCWarning(dcHomeConnect()) << "Unhandled pairing method!";
|
||||||
info->finish(Thing::ThingErrorCreationMethodNotSupported);
|
info->finish(Thing::ThingErrorCreationMethodNotSupported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,20 +201,20 @@ void IntegrationPluginHomeConnect::confirmPairing(ThingPairingInfo *info, const
|
|||||||
Q_UNUSED(username);
|
Q_UNUSED(username);
|
||||||
|
|
||||||
if (info->thingClassId() == homeConnectAccountThingClassId) {
|
if (info->thingClassId() == homeConnectAccountThingClassId) {
|
||||||
|
qCDebug(dcHomeConnect()) << "Confirm pairing" << info->thingName();
|
||||||
QUrl url(secret);
|
QUrl url(secret);
|
||||||
QUrlQuery query(url);
|
QUrlQuery query(url);
|
||||||
QByteArray authorizationCode = query.queryItemValue("code").toLocal8Bit();
|
QByteArray authorizationCode = query.queryItemValue("code").toLocal8Bit();
|
||||||
if (authorizationCode.isEmpty()) {
|
if (authorizationCode.isEmpty()) {
|
||||||
qCWarning(dcHomeConnect()) << "No authorization code received.";
|
qCWarning(dcHomeConnect()) << "No authorization code received.";
|
||||||
info->finish(Thing::ThingErrorSetupFailed);
|
return info->finish(Thing::ThingErrorAuthenticationFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
HomeConnect *homeConnect = m_setupHomeConnectConnections.value(info->thingId());
|
HomeConnect *homeConnect = m_setupHomeConnectConnections.value(info->thingId());
|
||||||
if (!homeConnect) {
|
if (!homeConnect) {
|
||||||
qWarning(dcHomeConnect()) << "No HomeConnect connection found for device:" << info->thingName();
|
qWarning(dcHomeConnect()) << "No HomeConnect connection found for device:" << info->thingName();
|
||||||
m_setupHomeConnectConnections.remove(info->thingId());
|
m_setupHomeConnectConnections.remove(info->thingId());
|
||||||
info->finish(Thing::ThingErrorHardwareFailure);
|
return info->finish(Thing::ThingErrorHardwareFailure);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
qCDebug(dcHomeConnect()) << "Authorization code" << authorizationCode.mid(0, 4)+QString().fill('*', authorizationCode.length()-4) ;
|
qCDebug(dcHomeConnect()) << "Authorization code" << authorizationCode.mid(0, 4)+QString().fill('*', authorizationCode.length()-4) ;
|
||||||
homeConnect->getAccessTokenFromAuthorizationCode(authorizationCode);
|
homeConnect->getAccessTokenFromAuthorizationCode(authorizationCode);
|
||||||
@ -235,6 +237,7 @@ void IntegrationPluginHomeConnect::setupThing(ThingSetupInfo *info)
|
|||||||
{
|
{
|
||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
|
|
||||||
|
qCDebug(dcHomeConnect()) << "Setuo thing" << thing->name();
|
||||||
if (thing->thingClassId() == homeConnectAccountThingClassId) {
|
if (thing->thingClassId() == homeConnectAccountThingClassId) {
|
||||||
bool simulationMode = configValue(homeConnectPluginSimulationModeParamTypeId).toBool();
|
bool simulationMode = configValue(homeConnectPluginSimulationModeParamTypeId).toBool();
|
||||||
HomeConnect *homeConnect;
|
HomeConnect *homeConnect;
|
||||||
@ -296,6 +299,7 @@ void IntegrationPluginHomeConnect::setupThing(ThingSetupInfo *info)
|
|||||||
|
|
||||||
void IntegrationPluginHomeConnect::postSetupThing(Thing *thing)
|
void IntegrationPluginHomeConnect::postSetupThing(Thing *thing)
|
||||||
{
|
{
|
||||||
|
qCDebug(dcHomeConnect()) << "Post setup thing" << thing->name();
|
||||||
if (!m_pluginTimer15min) {
|
if (!m_pluginTimer15min) {
|
||||||
m_pluginTimer15min = hardwareManager()->pluginTimerManager()->registerTimer(60*15);
|
m_pluginTimer15min = hardwareManager()->pluginTimerManager()->registerTimer(60*15);
|
||||||
connect(m_pluginTimer15min, &PluginTimer::timeout, this, [this]() {
|
connect(m_pluginTimer15min, &PluginTimer::timeout, this, [this]() {
|
||||||
@ -345,8 +349,10 @@ void IntegrationPluginHomeConnect::executeAction(ThingActionInfo *info)
|
|||||||
{
|
{
|
||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
Action action = info->action();
|
Action action = info->action();
|
||||||
|
qCDebug(dcHomeConnect()) << "Executing action" << thing->name() << action.actionTypeId();
|
||||||
HomeConnect *homeConnect = m_homeConnectConnections.value(myThings().findById(thing->parentId()));
|
HomeConnect *homeConnect = m_homeConnectConnections.value(myThings().findById(thing->parentId()));
|
||||||
if (!homeConnect) {
|
if (!homeConnect) {
|
||||||
|
qCWarning(dcHomeConnect()) << "HomeConnection account not found";
|
||||||
return info->finish(Thing::ThingErrorHardwareNotAvailable);
|
return info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||||
}
|
}
|
||||||
QString haid = thing->paramValue(m_idParamTypeIds.value(thing->thingClassId())).toString();
|
QString haid = thing->paramValue(m_idParamTypeIds.value(thing->thingClassId())).toString();
|
||||||
@ -359,7 +365,7 @@ void IntegrationPluginHomeConnect::executeAction(ThingActionInfo *info)
|
|||||||
m_pendingActions.remove(requestId);
|
m_pendingActions.remove(requestId);
|
||||||
});
|
});
|
||||||
} else if (thing->thingClassId() == ovenThingClassId) {
|
} else if (thing->thingClassId() == ovenThingClassId) {
|
||||||
//Oven control is only allowed with an additional agreement with home connect
|
qCWarning(dcHomeConnect()) << "Oven control is only allowed with an additional agreement with home connect";
|
||||||
} else if (thing->thingClassId() == coffeeMakerThingClassId) {
|
} else if (thing->thingClassId() == coffeeMakerThingClassId) {
|
||||||
if (action.actionTypeId() == coffeeMakerTemperatureActionTypeId) {
|
if (action.actionTypeId() == coffeeMakerTemperatureActionTypeId) {
|
||||||
QUuid requestId;
|
QUuid requestId;
|
||||||
@ -424,7 +430,7 @@ void IntegrationPluginHomeConnect::executeAction(ThingActionInfo *info)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (thing->thingClassId() == fridgeThingClassId) {
|
} else if (thing->thingClassId() == fridgeThingClassId) {
|
||||||
//Fridge control is only allowed with an additional agreement with home connect
|
qCWarning(dcHomeConnect()) << "Fridge control is only allowed with an additional agreement with home connect";
|
||||||
} else if (thing->thingClassId() == dishwasherThingClassId) {
|
} else if (thing->thingClassId() == dishwasherThingClassId) {
|
||||||
if (action.actionTypeId() == dishwasherStartActionTypeId) {
|
if (action.actionTypeId() == dishwasherStartActionTypeId) {
|
||||||
if (!m_selectedProgram.contains(thing)) {
|
if (!m_selectedProgram.contains(thing)) {
|
||||||
@ -491,11 +497,11 @@ void IntegrationPluginHomeConnect::executeAction(ThingActionInfo *info)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (thing->thingClassId() == cleaningRobotThingClassId) {
|
} else if (thing->thingClassId() == cleaningRobotThingClassId) {
|
||||||
//Home Connect: Program support is planned to be released in 2020.
|
qCWarning(dcHomeConnect()) << "Program support is planned to be released in 2020." << thing->name();
|
||||||
} else if (thing->thingClassId() == cookTopThingClassId) {
|
} else if (thing->thingClassId() == cookTopThingClassId) {
|
||||||
//Home Connect: Program support is planned to be released in 2020.
|
qCWarning(dcHomeConnect()) << "Program support is planned to be released in 2020." << thing->name();
|
||||||
} else if (thing->thingClassId() == hoodThingClassId) {
|
} else if (thing->thingClassId() == hoodThingClassId) {
|
||||||
//Home Connect: Program support is planned to be released in 2020.
|
qCWarning(dcHomeConnect()) << "Program support is planned to be released in 2020." << thing->name();
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
||||||
}
|
}
|
||||||
@ -555,8 +561,9 @@ void IntegrationPluginHomeConnect::browserItem(BrowserItemResult *result)
|
|||||||
connect(homeConnect, &HomeConnect::receivedAvailablePrograms, result, [result, this] (const QString &haid, const QStringList &programs) {
|
connect(homeConnect, &HomeConnect::receivedAvailablePrograms, result, [result, this] (const QString &haid, const QStringList &programs) {
|
||||||
if (result->thing()->paramValue(m_idParamTypeIds.value(result->thing()->thingClassId())).toString() == haid) {
|
if (result->thing()->paramValue(m_idParamTypeIds.value(result->thing()->thingClassId())).toString() == haid) {
|
||||||
if (programs.contains(result->item().id())) {
|
if (programs.contains(result->item().id())) {
|
||||||
result->item().setDisplayName(result->item().id());
|
BrowserItem item =result->item();
|
||||||
result->finish(Thing::ThingErrorNoError);
|
item.setDisplayName(result->item().id());
|
||||||
|
result->finish(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user