fixed coffee make actions
parent
8a5ad0dbf3
commit
a32d279e56
|
|
@ -437,6 +437,118 @@ void HomeConnect::getProgramsActiveOption(const QString &haId, const QString &op
|
|||
});
|
||||
}
|
||||
|
||||
QUuid HomeConnect::selectProgram(const QString &haId, const QString &programKey, QList<HomeConnect::Option> options)
|
||||
{
|
||||
QUuid commandId = QUuid::createUuid();
|
||||
QUrl url = QUrl(m_baseControlUrl+"/api/homeappliances/"+haId+"/programs/selected");
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", "Bearer "+m_accessToken);
|
||||
request.setRawHeader("Accept-Language", "en-US");
|
||||
request.setRawHeader("accept", "application/vnd.bsh.sdk.v1+json");
|
||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/vnd.bsh.sdk.v1+json");
|
||||
|
||||
QJsonDocument doc;
|
||||
QJsonObject data;
|
||||
data.insert("key", programKey);
|
||||
if (!options.isEmpty()) {
|
||||
QJsonArray optionsArray;
|
||||
Q_FOREACH(Option option, options) {
|
||||
QJsonObject optionObject;
|
||||
optionObject["key"] = option.key;
|
||||
optionObject["value"] = option.value.toString();
|
||||
if (!option.unit.isEmpty())
|
||||
optionObject["unit"] = option.unit;
|
||||
optionsArray.append(optionObject);
|
||||
}
|
||||
data.insert("options", optionsArray);
|
||||
}
|
||||
QJsonObject obj;
|
||||
obj.insert("data", data);
|
||||
doc.setObject(obj);
|
||||
QNetworkReply *reply = m_networkManager->put(request, doc.toJson());
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, commandId, reply]{
|
||||
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if (status != 204) {
|
||||
emit commandExecuted(commandId, false);
|
||||
QByteArray rawData = reply->readAll();
|
||||
qCDebug(dcHomeConnect()) << "Selected program" << rawData;
|
||||
QJsonParseError error;
|
||||
QJsonDocument data = QJsonDocument::fromJson(rawData, &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCDebug(dcHomeConnect()) << "Selected program: Received invalide JSON object";
|
||||
return;
|
||||
}
|
||||
if (data.toVariant().toMap().contains("error")) {
|
||||
qCWarning(dcHomeConnect()) << "Start program" << data.toVariant().toMap().value("error").toMap().value("description").toString();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
emit commandExecuted(commandId, true);
|
||||
}
|
||||
});
|
||||
return commandId;
|
||||
}
|
||||
|
||||
QUuid HomeConnect::setSelectedProgramOptions(const QString &haId, QList<HomeConnect::Option> options)
|
||||
{
|
||||
if (options.isEmpty())
|
||||
return "";
|
||||
|
||||
QUuid commandId = QUuid::createUuid();
|
||||
QUrl url = QUrl(m_baseControlUrl+"/api/homeappliances/"+haId+"/programs/selected/options");
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", "Bearer "+m_accessToken);
|
||||
request.setRawHeader("Accept-Language", "en-US");
|
||||
request.setRawHeader("accept", "application/vnd.bsh.sdk.v1+json");
|
||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/vnd.bsh.sdk.v1+json");
|
||||
|
||||
QJsonDocument doc;
|
||||
QVariantMap data;
|
||||
QVariantList optionsArray;
|
||||
Q_FOREACH(Option option, options) {
|
||||
QVariantMap optionObject;
|
||||
optionObject["key"] = option.key;
|
||||
optionObject["value"] = option.value;
|
||||
if (!option.unit.isEmpty())
|
||||
optionObject["unit"] = option.unit;
|
||||
optionsArray.append(optionObject);
|
||||
}
|
||||
data.insert("options", optionsArray);
|
||||
QVariantMap obj;
|
||||
obj.insert("data", data);
|
||||
doc.setObject(QJsonObject::fromVariantMap(obj));
|
||||
qCDebug(dcHomeConnect()) << "Selected Program Options" << doc.toJson();
|
||||
|
||||
QNetworkReply *reply = m_networkManager->put(request, doc.toJson());
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, commandId, reply]{
|
||||
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if (status != 204) {
|
||||
emit commandExecuted(commandId, false);
|
||||
QByteArray rawData = reply->readAll();
|
||||
qCDebug(dcHomeConnect()) << "Selected program" << rawData;
|
||||
QJsonParseError error;
|
||||
QJsonDocument data = QJsonDocument::fromJson(rawData, &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCDebug(dcHomeConnect()) << "Selected program options: Received invalide JSON object";
|
||||
return;
|
||||
}
|
||||
if (data.toVariant().toMap().contains("error")) {
|
||||
qCWarning(dcHomeConnect()) << "Selected program options:" << data.toVariant().toMap().value("error").toMap().value("description").toString();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
emit commandExecuted(commandId, true);
|
||||
}
|
||||
});
|
||||
return commandId;
|
||||
}
|
||||
|
||||
QUuid HomeConnect::startProgram(const QString &haId, const QString &programKey, QList<HomeConnect::Option> options)
|
||||
{
|
||||
QUuid commandId = QUuid::createUuid();
|
||||
|
|
@ -456,7 +568,8 @@ QUuid HomeConnect::startProgram(const QString &haId, const QString &programKey,
|
|||
QJsonObject optionObject;
|
||||
optionObject["key"] = option.key;
|
||||
optionObject["value"] = option.value.toString();
|
||||
optionObject["unit"] = option.unit;
|
||||
if (!option.unit.isEmpty())
|
||||
optionObject["unit"] = option.unit;
|
||||
optionsArray.append(optionObject);
|
||||
}
|
||||
data.insert("options", optionsArray);
|
||||
|
|
@ -467,21 +580,22 @@ QUuid HomeConnect::startProgram(const QString &haId, const QString &programKey,
|
|||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, commandId, reply]{
|
||||
|
||||
//TODO check status
|
||||
QJsonParseError error;
|
||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCDebug(dcHomeConnect()) << "Start program: Received invalide JSON object";
|
||||
return;
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if (status != 204) {
|
||||
emit commandExecuted(commandId, false);
|
||||
QJsonParseError error;
|
||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCDebug(dcHomeConnect()) << "Start program: Received invalide JSON object";
|
||||
return;
|
||||
}
|
||||
qCDebug(dcHomeConnect()) << "Start program response" << data.toJson();
|
||||
if (data.toVariant().toMap().contains("error")) {
|
||||
qCWarning(dcHomeConnect()) << "Start program" << data.toVariant().toMap().value("error").toMap().value("description").toString();
|
||||
}
|
||||
} else {
|
||||
emit commandExecuted(commandId, true);
|
||||
}
|
||||
qCDebug(dcHomeConnect()) << "Start program response" << data.toJson();
|
||||
if (data.toVariant().toMap().contains("data")) {
|
||||
QVariantMap dataMap = data.toVariant().toMap().value("data").toMap();
|
||||
qCDebug(dcHomeConnect()) << "key" << dataMap.value("key").toString() << "value" << dataMap.value("value").toString() << dataMap.value("unit").toString();
|
||||
} else if (data.toVariant().toMap().contains("error")) {
|
||||
qCWarning(dcHomeConnect()) << "Start program" << data.toVariant().toMap().value("error").toMap().value("description").toString();
|
||||
}
|
||||
emit commandExecuted(commandId, true);
|
||||
});
|
||||
return commandId;
|
||||
}
|
||||
|
|
@ -500,9 +614,13 @@ QUuid HomeConnect::stopProgram(const QString &haId)
|
|||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, commandId, reply]{
|
||||
|
||||
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QByteArray rawData = reply->readAll();
|
||||
emit commandExecuted(commandId, checkStatusCode(status, rawData));
|
||||
if (status != 204) {
|
||||
emit commandExecuted(commandId, false);
|
||||
} else {
|
||||
emit commandExecuted(commandId, true);
|
||||
}
|
||||
});
|
||||
return commandId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ public:
|
|||
void getProgramsActive(const QString &haId); //Get program which is currently executed
|
||||
void getProgramsSelected(const QString &haId); //Get the program which is currently selected
|
||||
void getProgramsActiveOption(const QString &haId, const QString &optionKey);
|
||||
QUuid selectProgram(const QString &haId, const QString &programKey, QList<Option> options);
|
||||
QUuid setSelectedProgramOptions(const QString &haId, QList<Option> options);
|
||||
QUuid startProgram(const QString &haId, const QString &programKey, QList<Option> options);
|
||||
QUuid stopProgram(const QString &haId);
|
||||
|
||||
|
|
@ -165,7 +167,7 @@ private slots:
|
|||
signals:
|
||||
void connectionChanged(bool connected);
|
||||
void authenticationStatusChanged(bool authenticated);
|
||||
void commandExecuted(QUuid commandId,bool success);
|
||||
void commandExecuted(const QUuid &commandId, bool success);
|
||||
|
||||
void receivedHomeAppliances(const QList<HomeAppliance> &appliances);
|
||||
void receivedStatusList(const QString &haId, const QHash<QString, QVariant> &statusList);
|
||||
|
|
|
|||
|
|
@ -102,20 +102,42 @@ IntegrationPluginHomeConnect::IntegrationPluginHomeConnect()
|
|||
m_progressStateTypeIds.insert(coffeeMakerThingClassId, coffeeMakerProgressStateTypeId);
|
||||
|
||||
m_endTimerStateTypeIds.insert(ovenThingClassId, ovenEndTimeStateTypeId);
|
||||
m_endTimerStateTypeIds.insert(washerThingClassId, washerEndTimeStateTypeId);
|
||||
m_endTimerStateTypeIds.insert(dryerThingClassId, dryerEndTimeStateTypeId);
|
||||
m_endTimerStateTypeIds.insert(dishwasherThingClassId, dishwasherEndTimeStateTypeId);
|
||||
|
||||
m_startActionTypeIds.insert(ovenThingClassId, ovenStartActionTypeId);
|
||||
m_startActionTypeIds.insert(washerThingClassId, washerStartActionTypeId);
|
||||
m_startActionTypeIds.insert(dryerThingClassId, dryerStartActionTypeId);
|
||||
m_startActionTypeIds.insert(dishwasherThingClassId, dishwasherStartActionTypeId);
|
||||
m_startActionTypeIds.insert(coffeeMakerThingClassId, coffeeMakerStartActionTypeId);
|
||||
|
||||
m_stopActionTypeIds.insert(ovenThingClassId, ovenStopActionTypeId);
|
||||
m_stopActionTypeIds.insert(washerThingClassId, washerStopActionTypeId);
|
||||
m_stopActionTypeIds.insert(dryerThingClassId, dryerStopActionTypeId);
|
||||
m_stopActionTypeIds.insert(dishwasherThingClassId, dishwasherStopActionTypeId);
|
||||
m_stopActionTypeIds.insert(coffeeMakerThingClassId, coffeeMakerStopActionTypeId);
|
||||
|
||||
m_programFinishedEventTypeIds.insert(ovenThingClassId, ovenProgramFinishedEventTypeId);
|
||||
m_programFinishedEventTypeIds.insert(dryerThingClassId, dryerProgramFinishedEventTypeId);
|
||||
m_programFinishedEventTypeIds.insert(coffeeMakerThingClassId, coffeeMakerProgramFinishedEventTypeId);
|
||||
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.VeryMild", "Very mild");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.Mild", "Mild");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.MildPlus", "Mild +");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.Normal", "Normal");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.NormalPlug", "Normal +");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.Strong", "Strong");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.StrongPlus", "Strong +");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.VeryStrong", "Very strong");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.VeryStrongPlus", "Very strong +");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.ExtraStrong", "Extra strong");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.DoubleShot", "Double shot");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.DoubleShotPlus", "Double shot +");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.DoubleShotPlusPlus", "Double shot ++");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.TribleShot", "Trible shot");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.TribleShotPlus", "Trible shot +");
|
||||
m_coffeeStrengthTypes.insert("ConsumerProducts.CoffeeMaker.EnumType.BeanAmount.CoffeeGround", "Coffee ground");
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::startPairing(ThingPairingInfo *info)
|
||||
|
|
@ -306,15 +328,7 @@ void IntegrationPluginHomeConnect::executeAction(ThingActionInfo *info)
|
|||
}
|
||||
QString haid = thing->paramValue(m_idParamTypeIds.value(thing->thingClassId())).toString();
|
||||
|
||||
if (m_startActionTypeIds.values().contains(action.actionTypeId())) {
|
||||
QUuid requestId;
|
||||
QList<HomeConnect::Option> options;
|
||||
requestId = homeConnect->startProgram(haid, m_selectedProgram.value(thing), options);
|
||||
m_pendingActions.insert(requestId, info);
|
||||
connect(info, &ThingActionInfo::aborted, [requestId, this] {
|
||||
m_pendingActions.remove(requestId);
|
||||
});
|
||||
} else if (m_stopActionTypeIds.values().contains(action.actionTypeId())) {
|
||||
if (m_stopActionTypeIds.values().contains(action.actionTypeId())) {
|
||||
QUuid requestId;
|
||||
requestId = homeConnect->stopProgram(haid);
|
||||
m_pendingActions.insert(requestId, info);
|
||||
|
|
@ -322,14 +336,83 @@ void IntegrationPluginHomeConnect::executeAction(ThingActionInfo *info)
|
|||
m_pendingActions.remove(requestId);
|
||||
});
|
||||
} else if (thing->thingClassId() == ovenThingClassId) {
|
||||
//set temperature
|
||||
if (action.actionTypeId() == ovenStartActionTypeId) {
|
||||
if (!m_selectedProgram.contains(thing)) {
|
||||
homeConnect->getProgramsSelected(haid);
|
||||
return info->finish(Thing::ThingErrorMissingParameter, tr("Please select a program first"));
|
||||
}
|
||||
QUuid requestId;
|
||||
HomeConnect::Option startTime;
|
||||
startTime.key = "BSH.Common.Option.StartInRelative";
|
||||
startTime.unit = "seconds";
|
||||
startTime.value = action.param(dishwasherStartActionStartTimeParamTypeId).value().toInt() * 60;
|
||||
requestId = homeConnect->startProgram(haid, m_selectedProgram.value(thing), QList<HomeConnect::Option>() << startTime);
|
||||
connect(info, &ThingActionInfo::aborted, [requestId, this] {
|
||||
m_pendingActions.remove(requestId);
|
||||
});
|
||||
}
|
||||
} else if (thing->thingClassId() == coffeeMakerThingClassId) {
|
||||
if (action.actionTypeId() == coffeeMakerTemperatureActionTypeId) {
|
||||
//TODO
|
||||
QUuid requestId;
|
||||
QList<HomeConnect::Option> options;
|
||||
HomeConnect::Option coffeeTemperature;
|
||||
coffeeTemperature.key = "ConsumerProducts.CoffeeMaker.Option.CoffeeTemperature";
|
||||
if (action.param(coffeeMakerTemperatureActionTemperatureParamTypeId).value().toString() == "Normal") {
|
||||
coffeeTemperature.value = "ConsumerProducts.CoffeeMaker.EnumType.CoffeeTemperature.90C";
|
||||
} else if (action.param(coffeeMakerTemperatureActionTemperatureParamTypeId).value().toString() == "High") {
|
||||
coffeeTemperature.value = "ConsumerProducts.CoffeeMaker.EnumType.CoffeeTemperature.94C";
|
||||
} else if (action.param(coffeeMakerTemperatureActionTemperatureParamTypeId).value().toString() == "Very high") {
|
||||
coffeeTemperature.value = "ConsumerProducts.CoffeeMaker.EnumType.CoffeeTemperature.95C";
|
||||
}
|
||||
options.append(coffeeTemperature);
|
||||
requestId = homeConnect->setSelectedProgramOptions(haid, options);
|
||||
m_pendingActions.insert(requestId, info);
|
||||
connect(info, &ThingActionInfo::aborted, [requestId, this] {
|
||||
m_pendingActions.remove(requestId);
|
||||
});
|
||||
|
||||
} else if (action.actionTypeId() == coffeeMakerStrengthActionTypeId) {
|
||||
//TODO
|
||||
QUuid requestId;
|
||||
QList<HomeConnect::Option> options;
|
||||
HomeConnect::Option beanAmount;
|
||||
beanAmount.key = "ConsumerProducts.CoffeeMaker.Option.BeanAmount";
|
||||
QString coffeeStrength = action.param(coffeeMakerStrengthActionStrengthParamTypeId).value().toString();
|
||||
if (m_coffeeStrengthTypes.values().contains(coffeeStrength)) {
|
||||
beanAmount.value = m_coffeeStrengthTypes.key(coffeeStrength);
|
||||
} else {
|
||||
qCWarning(dcHomeConnect()) << "Unhandled coffee strength action param" << coffeeStrength;
|
||||
}
|
||||
options.append(beanAmount);
|
||||
requestId = homeConnect->setSelectedProgramOptions(haid, options);
|
||||
m_pendingActions.insert(requestId, info);
|
||||
connect(info, &ThingActionInfo::aborted, [requestId, this] {
|
||||
m_pendingActions.remove(requestId);
|
||||
});
|
||||
|
||||
} else if (action.actionTypeId() == coffeeMakerFillQuantityActionTypeId) {
|
||||
//TODO
|
||||
QUuid requestId;
|
||||
QList<HomeConnect::Option> options;
|
||||
HomeConnect::Option fillQuantity;
|
||||
fillQuantity.key = "ConsumerProducts.CoffeeMaker.Option.FillQuantity";
|
||||
fillQuantity.unit = "ml";
|
||||
fillQuantity.value = qRound(action.param(coffeeMakerFillQuantityActionFillQuantityParamTypeId).value().toInt()/10.00)*10;
|
||||
options.append(fillQuantity);
|
||||
requestId = homeConnect->setSelectedProgramOptions(haid, options);
|
||||
m_pendingActions.insert(requestId, info);
|
||||
connect(info, &ThingActionInfo::aborted, [requestId, this] {
|
||||
m_pendingActions.remove(requestId);
|
||||
});
|
||||
} else if (action.actionTypeId() == coffeeMakerStartActionTypeId) {
|
||||
if (!m_selectedProgram.contains(thing)) {
|
||||
homeConnect->getProgramsSelected(haid);
|
||||
return info->finish(Thing::ThingErrorMissingParameter, tr("Please select a program first"));
|
||||
}
|
||||
QUuid requestId;
|
||||
requestId = homeConnect->startProgram(haid, m_selectedProgram.value(thing), QList<HomeConnect::Option>());
|
||||
m_pendingActions.insert(requestId, info);
|
||||
connect(info, &ThingActionInfo::aborted, [requestId, this] {
|
||||
m_pendingActions.remove(requestId);
|
||||
});
|
||||
}
|
||||
} else if (thing->thingClassId() == fridgeThingClassId) {
|
||||
if (action.actionTypeId() == fridgeFridgeTemperatureSettingActionTypeId) {
|
||||
|
|
@ -338,8 +421,22 @@ void IntegrationPluginHomeConnect::executeAction(ThingActionInfo *info)
|
|||
//TODO
|
||||
}
|
||||
} else if (thing->thingClassId() == dishwasherThingClassId) {
|
||||
if (action.actionTypeId() == dishwasherStartTimeActionTypeId) {
|
||||
//TODO
|
||||
if (action.actionTypeId() == dishwasherStartActionTypeId) {
|
||||
if (!m_selectedProgram.contains(thing)) {
|
||||
homeConnect->getProgramsSelected(haid);
|
||||
return info->finish(Thing::ThingErrorMissingParameter, tr("Please select a program first"));
|
||||
}
|
||||
QUuid requestId;
|
||||
HomeConnect::Option startTime;
|
||||
startTime.key = "BSH.Common.Option.StartInRelative";
|
||||
startTime.unit = "seconds";
|
||||
startTime.value = action.param(dishwasherStartActionStartTimeParamTypeId).value().toInt() * 60;
|
||||
requestId = homeConnect->startProgram(haid, m_selectedProgram.value(thing), QList<HomeConnect::Option>() << startTime);
|
||||
connect(info, &ThingActionInfo::aborted, [requestId, this] {
|
||||
m_pendingActions.remove(requestId);
|
||||
});
|
||||
} else {
|
||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled actionTypeId: %1").arg(action.actionTypeId().toString()).toUtf8());
|
||||
}
|
||||
} else {
|
||||
Q_ASSERT_X(false, "executeAction", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
||||
|
|
@ -405,7 +502,6 @@ void IntegrationPluginHomeConnect::browserItem(BrowserItemResult *result)
|
|||
|
||||
void IntegrationPluginHomeConnect::executeBrowserItem(BrowserActionInfo *info)
|
||||
{
|
||||
Q_UNUSED(info)
|
||||
Thing *thing = info->thing();
|
||||
qCDebug(dcHomeConnect()) << "Execute browse item called " << thing->name();
|
||||
|
||||
|
|
@ -413,9 +509,19 @@ void IntegrationPluginHomeConnect::executeBrowserItem(BrowserActionInfo *info)
|
|||
if (!homeConnect)
|
||||
return;
|
||||
QString haid = thing->paramValue(m_idParamTypeIds.value(thing->thingClassId())).toString();
|
||||
QList<HomeConnect::Option> options;
|
||||
//TODO add options like set temperature or start time
|
||||
homeConnect->startProgram(haid, info->browserAction().itemId(), options);
|
||||
|
||||
QUuid requestId = homeConnect->selectProgram(haid, info->browserAction().itemId(), QList<HomeConnect::Option> ());
|
||||
m_selectedProgram.insert(thing, info->browserAction().itemId());
|
||||
|
||||
connect(homeConnect, &HomeConnect::commandExecuted, info, [requestId, info] (const QUuid &commandId, bool success) {
|
||||
if (requestId == commandId) {
|
||||
if (success) {
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
} else {
|
||||
info->finish(Thing::ThingErrorHardwareNotAvailable);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::parseKey(Thing *thing, const QString &key, const QVariant &value)
|
||||
|
|
@ -431,8 +537,8 @@ void IntegrationPluginHomeConnect::parseKey(Thing *thing, const QString &key, co
|
|||
if (m_selectedProgramStateTypeIds.contains(thing->thingClassId())) {
|
||||
thing->setStateValue(m_selectedProgramStateTypeIds.value(thing->thingClassId()), value.toString().split('.').last());
|
||||
}
|
||||
m_selectedProgram.insert(thing, value.toString());
|
||||
} else if (key == "BSH.Common.Root.ActiveProgram") {
|
||||
|
||||
// Option Changes
|
||||
} else if (key == "Cooking.Oven.Option.SetpointTemperature") {
|
||||
thing->setStateValue(ovenTargetTemperatureStateTypeId, value);
|
||||
|
|
@ -448,41 +554,12 @@ void IntegrationPluginHomeConnect::parseKey(Thing *thing, const QString &key, co
|
|||
} else if (key == "LaundryCare.Dryer.Option.DryingTarget") {
|
||||
//TODO
|
||||
} else if (key == "ConsumerProducts.CoffeeMaker.Option.BeanAmount") {
|
||||
QString beanAmount = value.toString().split(".").last();
|
||||
if (beanAmount == "VeryMild") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Very mild");
|
||||
} else if (beanAmount == "Mild") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Mild");
|
||||
} else if (beanAmount == "MildPlus") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Mild +");
|
||||
} else if (beanAmount == "Normal") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Normal");
|
||||
} else if (beanAmount == "NormalPlus") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Normal +");
|
||||
} else if (beanAmount == "Strong") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Strong");
|
||||
} else if (beanAmount == "StrongPlus") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Strong +");
|
||||
} else if (beanAmount == "VeryStrong") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Very strong");
|
||||
} else if (beanAmount == "VeryStringPlus") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Very strong +");
|
||||
} else if (beanAmount == "ExtraStrong") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Extra strong");
|
||||
} else if (beanAmount == "DoubleShot") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Double shot");
|
||||
} else if (beanAmount == "DoubleShotPlus") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Double shot +");
|
||||
} else if (beanAmount == "DoubleShotPlusPlus") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Double shot ++");
|
||||
} else if (beanAmount == "TripleShot") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Triple shot");
|
||||
} else if (beanAmount == "TripleShotPlus") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Triple shot +");
|
||||
} else if (beanAmount == "CoffeeGround") {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, "Coffee ground");
|
||||
QString beanAmount = value.toString();
|
||||
if (m_coffeeStrengthTypes.contains(beanAmount)) {
|
||||
thing->setStateValue(coffeeMakerStrengthStateTypeId, m_coffeeStrengthTypes.value(beanAmount));
|
||||
} else {
|
||||
qCWarning(dcHomeConnect()) << "Unhandled bean amount" << beanAmount;
|
||||
}
|
||||
|
||||
} else if (key == "ConsumerProducts.CoffeeMaker.Option.FillQuantity") {
|
||||
thing->setStateValue(coffeeMakerFillQuantityStateTypeId, value);
|
||||
} else if (key == "ConsumerProducts.CoffeeMaker.Option.CoffeeTemperature") {
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ private:
|
|||
|
||||
QHash<ThingClassId, EventTypeId> m_programFinishedEventTypeIds;
|
||||
|
||||
QHash<QString, QString> m_coffeeStrengthTypes;
|
||||
|
||||
HomeConnect *createHomeConnection();
|
||||
|
||||
void parseKey(Thing *thing, const QString &key, const QVariant &value);
|
||||
|
|
|
|||
|
|
@ -205,7 +205,18 @@
|
|||
{
|
||||
"id": "c7b9b467-6ac5-4870-8874-da977fa30987",
|
||||
"name": "start",
|
||||
"displayName": "Start"
|
||||
"displayName": "Start",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "27de74b5-265a-4c9f-bd3e-f58ab5c81a1f",
|
||||
"name": "startTime",
|
||||
"displayName": "Start time",
|
||||
"defaultValue": 0,
|
||||
"minValue": 0,
|
||||
"type": "int",
|
||||
"unit": "Minutes"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0467aeed-b275-4e5f-a288-1a600465b582",
|
||||
|
|
@ -314,18 +325,6 @@
|
|||
"defaultValue": "None",
|
||||
"type": "QString"
|
||||
},
|
||||
{
|
||||
"id": "27de74b5-265a-4c9f-bd3e-f58ab5c81a1f",
|
||||
"name": "startTime",
|
||||
"displayName": "Start time",
|
||||
"displayNameEvent": "Start time changed",
|
||||
"displayNameAction": "Set start time",
|
||||
"defaultValue": 0,
|
||||
"minValue": 0,
|
||||
"type": "int",
|
||||
"unit": "Minutes",
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"id": "f61cd171-2e8e-434c-98f9-e7fc7df1c928",
|
||||
"name": "endTime",
|
||||
|
|
@ -339,7 +338,18 @@
|
|||
{
|
||||
"id": "7dc1e238-cdc2-42e8-9a2a-e93d497966d9",
|
||||
"name": "start",
|
||||
"displayName": "Start"
|
||||
"displayName": "Start",
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "9b87bcc9-4d0d-4cd8-bd14-c2e48ef8cb1f",
|
||||
"name": "startTime",
|
||||
"displayName": "Start time",
|
||||
"defaultValue": 0,
|
||||
"minValue": 0,
|
||||
"type": "int",
|
||||
"unit": "Minutes"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "c2c7e1bd-bf0f-4ded-93e0-e4d770f03f6f",
|
||||
|
|
@ -946,6 +956,41 @@
|
|||
"defaultValue": true,
|
||||
"cached": false,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": "a7680cc1-528c-47ac-a917-d9f3866e9504",
|
||||
"name": "localControlState",
|
||||
"displayName": "Local control state",
|
||||
"displayNameEvent": "Local control state changed",
|
||||
"defaultValue": false,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": "d1cf12ef-c0e9-452f-99bf-5e65a4dd622c",
|
||||
"name": "operationState",
|
||||
"displayName": "Operation state",
|
||||
"displayNameEvent": "Operation state changed",
|
||||
"defaultValue": "Inactive",
|
||||
"type": "QString",
|
||||
"possibleValues": [
|
||||
"Inactive",
|
||||
"Ready",
|
||||
"Delayed start",
|
||||
"Run",
|
||||
"Pause",
|
||||
"Action required",
|
||||
"Finished",
|
||||
"Error",
|
||||
"Aborting"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "09e73cec-5b98-4d31-86fb-cd671f210196",
|
||||
"name": "ventingLevel",
|
||||
"displayName": "Venting level",
|
||||
"displayNameEvent": "Venting level changed",
|
||||
"defaultValue": 0,
|
||||
"type": "int"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -973,6 +1018,25 @@
|
|||
"defaultValue": true,
|
||||
"cached": false,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": "ac2b896e-d7ff-4b17-affa-ad5bdc486640",
|
||||
"name": "operationState",
|
||||
"displayName": "Operation state",
|
||||
"displayNameEvent": "Operation state changed",
|
||||
"defaultValue": "Inactive",
|
||||
"type": "QString",
|
||||
"possibleValues": [
|
||||
"Inactive",
|
||||
"Ready",
|
||||
"Delayed start",
|
||||
"Run",
|
||||
"Pause",
|
||||
"Action required",
|
||||
"Finished",
|
||||
"Error",
|
||||
"Aborting"
|
||||
]
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
|
|
@ -1017,6 +1081,25 @@
|
|||
"defaultValue": true,
|
||||
"cached": false,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": "9aed899f-09cc-4f20-965a-9724372a1093",
|
||||
"name": "operationState",
|
||||
"displayName": "Operation state",
|
||||
"displayNameEvent": "Operation state changed",
|
||||
"defaultValue": "Inactive",
|
||||
"type": "QString",
|
||||
"possibleValues": [
|
||||
"Inactive",
|
||||
"Ready",
|
||||
"Delayed start",
|
||||
"Run",
|
||||
"Pause",
|
||||
"Action required",
|
||||
"Finished",
|
||||
"Error",
|
||||
"Aborting"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue