added some more states
parent
ff48a4788c
commit
ac9d3804c5
|
|
@ -43,11 +43,9 @@ HomeConnect::HomeConnect(NetworkAccessManager *networkmanager, const QByteArray
|
|||
m_networkManager(networkmanager)
|
||||
|
||||
{
|
||||
if(!m_tokenRefreshTimer) {
|
||||
m_tokenRefreshTimer = new QTimer(this);
|
||||
m_tokenRefreshTimer->setSingleShot(true);
|
||||
connect(m_tokenRefreshTimer, &QTimer::timeout, this, &HomeConnect::onRefreshTimeout);
|
||||
}
|
||||
m_tokenRefreshTimer = new QTimer(this);
|
||||
m_tokenRefreshTimer->setSingleShot(true);
|
||||
connect(m_tokenRefreshTimer, &QTimer::timeout, this, &HomeConnect::onRefreshTimeout);
|
||||
setSimulationMode(simulationMode);
|
||||
}
|
||||
|
||||
|
|
@ -109,9 +107,15 @@ void HomeConnect::onRefreshTimeout()
|
|||
getAccessTokenFromRefreshToken(m_refreshToken);
|
||||
}
|
||||
|
||||
void HomeConnect::checkStatusCode(int status, const QByteArray &payload)
|
||||
bool HomeConnect::checkStatusCode(int status, const QByteArray &payload)
|
||||
{
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(payload);
|
||||
//TODO emit (dis)connected, (un)authenticated,
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(payload, &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcHomeConnect()) << "Received invalide JSON object";
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (status){
|
||||
case 400:
|
||||
|
|
@ -126,16 +130,17 @@ void HomeConnect::checkStatusCode(int status, const QByteArray &payload)
|
|||
qWarning(dcHomeConnect()) << "Expired authorization code.";
|
||||
}
|
||||
}
|
||||
return;
|
||||
return false;
|
||||
case 401:
|
||||
qWarning(dcHomeConnect()) << "Client does not have permission to use this API.";
|
||||
return;
|
||||
return false;
|
||||
case 405:
|
||||
qWarning(dcHomeConnect()) << "Wrong HTTP method used.";
|
||||
return;
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void HomeConnect::getAccessTokenFromRefreshToken(const QByteArray &refreshToken)
|
||||
|
|
@ -174,7 +179,6 @@ void HomeConnect::getAccessTokenFromRefreshToken(const QByteArray &refreshToken)
|
|||
qCDebug(dcHomeConnect()) << "Received invalide JSON object" << data.toJson();
|
||||
return;
|
||||
}
|
||||
qCDebug(dcHomeConnect()) << "get access token from refresh token" << data.toJson();
|
||||
|
||||
if(!data.toVariant().toMap().contains("access_token")) {
|
||||
emit authenticationStatusChanged(false);
|
||||
|
|
@ -233,10 +237,7 @@ void HomeConnect::getAccessTokenFromAuthorizationCode(const QByteArray &authoriz
|
|||
emit authenticationStatusChanged(false);
|
||||
return;
|
||||
}
|
||||
qCDebug(dcHomeConnect()) << "Access token:" << jsonDoc.toVariant().toMap().value("access_token").toString();
|
||||
m_accessToken = jsonDoc.toVariant().toMap().value("access_token").toByteArray();
|
||||
|
||||
qCDebug(dcHomeConnect()) << "Refresh token:" << jsonDoc.toVariant().toMap().value("refresh_token").toString();
|
||||
m_refreshToken = jsonDoc.toVariant().toMap().value("refresh_token").toByteArray();
|
||||
|
||||
if (jsonDoc.toVariant().toMap().contains("expires_in")) {
|
||||
|
|
@ -262,36 +263,30 @@ void HomeConnect::getHomeAppliances()
|
|||
request.setRawHeader("accept", "application/vnd.bsh.sdk.v1+json");
|
||||
|
||||
QNetworkReply *reply = m_networkManager->get(request);
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply](){
|
||||
reply->deleteLater();
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCDebug(dcHomeConnect()) << "Get home appliances: Recieved invalide JSON object";
|
||||
return;
|
||||
}
|
||||
qCDebug(dcHomeConnect()) << "Get home appliances" << data.toJson();
|
||||
if (data.toVariant().toMap().contains("data")) {
|
||||
QVariantMap dataMap = data.toVariant().toMap().value("data").toMap();
|
||||
QList<HomeAppliance> appliances;
|
||||
foreach (const QVariant &variant, dataMap.value("homeappliances").toList()) {
|
||||
QVariantMap obj = variant.toMap();
|
||||
HomeAppliance appliance;
|
||||
appliance.name = obj["name"].toString();
|
||||
appliance.brand = obj["brand"].toString();
|
||||
appliance.vib = obj["vib"].toString();
|
||||
appliance.type = obj["type"].toString();
|
||||
appliance.homeApplianceId = obj["haId"].toString();
|
||||
appliance.enumber = obj["enumber"].toString();
|
||||
appliance.connected = obj["connected"].toBool();
|
||||
appliances.append(appliance);
|
||||
}
|
||||
if (!appliances.isEmpty())
|
||||
emit receivedHomeAppliances(appliances);
|
||||
} else if (data.toVariant().toMap().contains("error")) {
|
||||
qCWarning(dcHomeConnect()) << "Get home appliences" << data.toVariant().toMap().value("error").toMap().value("description").toString();
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QByteArray rawData = reply->readAll();
|
||||
checkStatusCode(status, rawData);
|
||||
QVariantMap dataMap = QJsonDocument::fromJson(rawData).toVariant().toMap().value("data").toMap();
|
||||
|
||||
QList<HomeAppliance> appliances;
|
||||
foreach (const QVariant &variant, dataMap.value("homeappliances").toList()) {
|
||||
QVariantMap obj = variant.toMap();
|
||||
HomeAppliance appliance;
|
||||
appliance.name = obj["name"].toString();
|
||||
appliance.brand = obj["brand"].toString();
|
||||
appliance.vib = obj["vib"].toString();
|
||||
appliance.type = obj["type"].toString();
|
||||
appliance.homeApplianceId = obj["haId"].toString();
|
||||
appliance.enumber = obj["enumber"].toString();
|
||||
appliance.connected = obj["connected"].toBool();
|
||||
appliances.append(appliance);
|
||||
}
|
||||
if (!appliances.isEmpty())
|
||||
emit receivedHomeAppliances(appliances);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -306,16 +301,80 @@ void HomeConnect::getProgramsAvailable(const QString &haId)
|
|||
|
||||
QNetworkReply *reply = m_networkManager->get(request);
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply]{
|
||||
connect(reply, &QNetworkReply::finished, this, [this, haId, reply]{
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCWarning(dcHomeConnect()) << "Get programs available: Recieved invalide JSON object";
|
||||
return;
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QByteArray rawData = reply->readAll();
|
||||
checkStatusCode(status, rawData);
|
||||
|
||||
QVariantMap dataMap = QJsonDocument::fromJson(rawData).toVariant().toMap().value("data").toMap();
|
||||
qCDebug(dcHomeConnect()) << "Get programs available" << dataMap;
|
||||
QVariantList programList = dataMap.value("programs").toList();
|
||||
QStringList programs;
|
||||
Q_FOREACH(QVariant var, programList) {
|
||||
if (var.toMap().contains("key")) {
|
||||
programs.append(var.toMap().value("key").toString());
|
||||
}
|
||||
}
|
||||
qCDebug(dcHomeConnect()) << "Get programs available" << data.toJson();
|
||||
if (!programs.isEmpty())
|
||||
emit receivedAvailablePrograms(haId, programs);
|
||||
});
|
||||
}
|
||||
|
||||
void HomeConnect::getProgramsActive(const QString &haId)
|
||||
{
|
||||
QUrl url = QUrl(m_baseControlUrl+"/api/homeappliances/"+haId+"/programs/active");
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", "Bearer "+m_accessToken);
|
||||
request.setRawHeader("Accept-Language", "en-US");
|
||||
request.setRawHeader("accept", "application/vnd.bsh.sdk.v1+json");
|
||||
|
||||
QNetworkReply *reply = m_networkManager->get(request);
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, haId, reply]{
|
||||
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QByteArray rawData = reply->readAll();
|
||||
checkStatusCode(status, rawData);
|
||||
|
||||
QVariantMap dataMap = QJsonDocument::fromJson(rawData).toVariant().toMap().value("data").toMap();
|
||||
|
||||
qCDebug(dcHomeConnect()) << "Get programs active" << dataMap;
|
||||
QString key = dataMap.value("key").toString();
|
||||
QHash<QString, QVariant> options;
|
||||
Q_FOREACH(QVariant var, dataMap.value("options").toList()) {
|
||||
options.insert(var.toMap().value("key").toString(), var.toMap().value("value"));
|
||||
}
|
||||
emit receivedActiveProgram(haId, key, options);
|
||||
});
|
||||
}
|
||||
|
||||
void HomeConnect::getProgramsSelected(const QString &haId)
|
||||
{
|
||||
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");
|
||||
|
||||
QNetworkReply *reply = m_networkManager->get(request);
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, haId, reply]{
|
||||
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QByteArray rawData = reply->readAll();
|
||||
checkStatusCode(status, rawData);
|
||||
|
||||
QVariantMap dataMap = QJsonDocument::fromJson(rawData).toVariant().toMap().value("data").toMap();
|
||||
qCDebug(dcHomeConnect()) << "Get program selected" << dataMap;
|
||||
QString key = dataMap.value("key").toString();
|
||||
QHash<QString, QVariant> options;
|
||||
Q_FOREACH(QVariant var, dataMap.value("options").toList()) {
|
||||
options.insert(var.toMap().value("key").toString(), var.toMap().value("value"));
|
||||
}
|
||||
emit receivedSelectedProgram(haId, key, options);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -332,20 +391,61 @@ void HomeConnect::getProgramsActiveOption(const QString &haId, const QString &op
|
|||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply]{
|
||||
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QByteArray rawData = reply->readAll();
|
||||
checkStatusCode(status, rawData);
|
||||
|
||||
QVariantMap dataMap = QJsonDocument::fromJson(rawData).toVariant().toMap().value("data").toMap();
|
||||
qCDebug(dcHomeConnect()) << "key" << dataMap.value("key").toString() << "value" << dataMap.value("value").toString() << dataMap.value("unit").toString();
|
||||
});
|
||||
}
|
||||
|
||||
QUuid HomeConnect::startProgram(const QString &haId, const QString &programKey, QList<HomeConnect::Option> options)
|
||||
{
|
||||
QUuid commandId = QUuid::createUuid();
|
||||
QUrl url = QUrl(m_baseControlUrl+"/api/homeappliances/"+haId+"/programs/active");
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", "Bearer "+m_accessToken);
|
||||
request.setRawHeader("Accept-Language", "en-US");
|
||||
request.setRawHeader("accept", "application/vnd.bsh.sdk.v1+json");
|
||||
|
||||
QJsonDocument doc;
|
||||
QJsonObject data;
|
||||
data.insert("key", programKey);
|
||||
QJsonArray optionsArray;
|
||||
Q_FOREACH(Option option, options) {
|
||||
QJsonObject optionObject;
|
||||
optionObject["key"] = option.key;
|
||||
optionObject["value"] = option.value.toString();
|
||||
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]{
|
||||
|
||||
//TODO check status
|
||||
QJsonParseError error;
|
||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCDebug(dcHomeConnect()) << "Get home appliances: Recieved invalide JSON object";
|
||||
qCDebug(dcHomeConnect()) << "Start program: Received invalide JSON object";
|
||||
return;
|
||||
}
|
||||
qCDebug(dcHomeConnect()) << "Get home appliances" << data.toJson();
|
||||
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()) << "Get home appliences" << data.toVariant().toMap().value("error").toMap().value("description").toString();
|
||||
qCWarning(dcHomeConnect()) << "Start program" << data.toVariant().toMap().value("error").toMap().value("description").toString();
|
||||
}
|
||||
emit commandExecuted(commandId, true);
|
||||
});
|
||||
return commandId;
|
||||
}
|
||||
|
||||
void HomeConnect::getStatus(const QString &haid)
|
||||
|
|
@ -361,27 +461,20 @@ void HomeConnect::getStatus(const QString &haid)
|
|||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, haid, reply]{
|
||||
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QByteArray rawData = reply->readAll();
|
||||
checkStatusCode(status, rawData);
|
||||
|
||||
// Remote control activation state
|
||||
// Remote start allowance state
|
||||
// Local control state
|
||||
// Operation state
|
||||
// Door state
|
||||
QVariantMap dataMap = QJsonDocument::fromJson(rawData).toVariant().toMap().value("data").toMap();
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCDebug(dcHomeConnect()) << "Get status: Received invalide JSON object";
|
||||
return;
|
||||
}
|
||||
QHash<QString, QVariant> statusList;
|
||||
qCDebug(dcHomeConnect()) << "Get status" << data.toJson();
|
||||
QVariantList statusVariantList= data.toVariant().toMap().value("data").toMap().value("status").toList();
|
||||
QVariantList statusVariantList= dataMap.value("status").toList();
|
||||
Q_FOREACH(QVariant status, statusVariantList) {
|
||||
QVariantMap map = status.toMap();
|
||||
statusList.insert(map.value("key").toString(), map.value("value"));
|
||||
}
|
||||
emit receivedStatusList(haid, statusList);
|
||||
if (!statusList.isEmpty())
|
||||
emit receivedStatusList(haid, statusList);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -405,27 +498,25 @@ void HomeConnect::getSettings(const QString &haid)
|
|||
|
||||
QNetworkReply *reply = m_networkManager->get(request);
|
||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, reply]{
|
||||
connect(reply, &QNetworkReply::finished, this, [this, haid, reply]{
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
qCDebug(dcHomeConnect()) << "Get settings: Received invalide JSON object";
|
||||
return;
|
||||
}
|
||||
qCDebug(dcHomeConnect()) << "Get settings" << 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()) << "Get settings" << data.toVariant().toMap().value("error").toMap().value("description").toString();
|
||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
QByteArray rawData = reply->readAll();
|
||||
checkStatusCode(status, rawData);
|
||||
|
||||
QVariantMap dataMap = QJsonDocument::fromJson(rawData).toVariant().toMap().value("data").toMap();
|
||||
QVariantList settingsList = dataMap.value("settings").toList();
|
||||
QHash<QString, QVariant> settings;
|
||||
Q_FOREACH(QVariant var, settingsList) {
|
||||
settings.insert(var.toMap().value("key").toString(), var.toMap().value("value"));
|
||||
}
|
||||
if (!settings.isEmpty())
|
||||
emit receivedSettings(haid, settings);
|
||||
});
|
||||
}
|
||||
|
||||
void HomeConnect::connectEventStream()
|
||||
{
|
||||
QUuid commandId = QUuid::createUuid();
|
||||
QUrl url = QUrl(m_baseControlUrl+"/api/homeappliances/events");
|
||||
|
||||
QNetworkRequest request(url);
|
||||
|
|
@ -443,6 +534,7 @@ void HomeConnect::connectEventStream()
|
|||
qCDebug(dcHomeConnect()) << "Event stream: Received invalide JSON object";
|
||||
return;
|
||||
}
|
||||
qCDebug(dcHomeConnect()) << "Event" << data.toJson();
|
||||
if (data.toVariant().toMap().contains("items")) {
|
||||
QList<Event> events;
|
||||
QVariantList itemsList = data.toVariant().toMap().value("items").toList();
|
||||
|
|
@ -485,6 +577,7 @@ QUuid HomeConnect::sendCommand(const QString &haid, const QString &command)
|
|||
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) {
|
||||
|
|
|
|||
|
|
@ -73,8 +73,10 @@ public:
|
|||
QString unit;
|
||||
};
|
||||
|
||||
struct Status {
|
||||
|
||||
struct Option {
|
||||
QString key;
|
||||
QVariant value;
|
||||
QString unit;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -102,20 +104,29 @@ public:
|
|||
void setSimulationMode(bool simulation);
|
||||
|
||||
QUrl getLoginUrl(const QUrl &redirectUrl, const QString &scope);
|
||||
void checkStatusCode(int status, const QByteArray &payload);
|
||||
|
||||
void getAccessTokenFromRefreshToken(const QByteArray &refreshToken);
|
||||
void getAccessTokenFromAuthorizationCode(const QByteArray &authorizationCode);
|
||||
|
||||
void getHomeAppliances();
|
||||
void getHomeAppliance(const QString &haid);
|
||||
// DEFAULT
|
||||
void getHomeAppliances(); // Get all home appliances which are paired with the logged-in user account.
|
||||
void getHomeAppliance(const QString &haid); //Get a specfic home appliances which are paired with the logged-in user account.
|
||||
|
||||
void getProgramsAvailable(const QString &haId);
|
||||
// PROGRAMS
|
||||
void getProgramsAvailable(const QString &haId); //Get all programs which are currently available on the given home appliance
|
||||
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 startProgram(const QString &haId, const QString &programKey, QList<Option> options);
|
||||
|
||||
// STATUS EVENTS
|
||||
void getStatus(const QString &haid);
|
||||
void connectEventStream();
|
||||
|
||||
// SETTINGS
|
||||
void getSettings(const QString &haid);
|
||||
|
||||
void connectEventStream();
|
||||
// COMMANDS
|
||||
QUuid sendCommand(const QString &haid, const QString &command); //commands "BSH.Common.Command.ResumeProgram" & "PauseProgram"
|
||||
|
||||
private:
|
||||
|
|
@ -134,6 +145,7 @@ private:
|
|||
NetworkAccessManager *m_networkManager = nullptr;
|
||||
QTimer *m_tokenRefreshTimer = nullptr;
|
||||
|
||||
bool checkStatusCode(int status, const QByteArray &payload);
|
||||
private slots:
|
||||
void onRefreshTimeout();
|
||||
|
||||
|
|
@ -142,9 +154,12 @@ signals:
|
|||
void authenticationStatusChanged(bool authenticated);
|
||||
void commandExecuted(QUuid commandId,bool success);
|
||||
|
||||
void receivedStatusList(const QString &haId, const QHash<QString, QVariant> &statusList);
|
||||
void receivedHomeAppliances(const QList<HomeAppliance> &appliances);
|
||||
void receivedAvailablePrograms();
|
||||
void receivedEvents(const QList<Event> events);
|
||||
void receivedStatusList(const QString &haId, const QHash<QString, QVariant> &statusList);
|
||||
void receivedAvailablePrograms(const QString &haId, const QStringList &programs);
|
||||
void receivedSettings(const QString &haId, const QHash<QString, QVariant> &settings);
|
||||
void receivedActiveProgram(const QString &haId, const QString &key, const QHash<QString, QVariant> &options);
|
||||
void receivedSelectedProgram(const QString &haId, const QString &key, const QHash<QString, QVariant> &options);
|
||||
void receivedEvents(const QList<Event> &events);
|
||||
};
|
||||
#endif // HOMECONNECT_H
|
||||
|
|
|
|||
|
|
@ -40,35 +40,70 @@
|
|||
|
||||
IntegrationPluginHomeConnect::IntegrationPluginHomeConnect()
|
||||
{
|
||||
m_idParamTypeIds.insert(ovenThingClassId, ovenThingIdParamTypeId);
|
||||
m_idParamTypeIds.insert(fridgeThingClassId, fridgeThingIdParamTypeId);
|
||||
m_idParamTypeIds.insert(dryerThingClassId, dryerThingIdParamTypeId);
|
||||
m_idParamTypeIds.insert(coffeMakerThingClassId, coffeMakerThingIdParamTypeId);
|
||||
m_idParamTypeIds.insert(dishwasherThingClassId, dishwasherThingIdParamTypeId);
|
||||
m_idParamTypeIds.insert(washerThingClassId, washerThingIdParamTypeId);
|
||||
m_idParamTypeIds.insert(ovenThingClassId, ovenThingIdParamTypeId);
|
||||
m_idParamTypeIds.insert(cookTopThingClassId, cookTopThingIdParamTypeId);
|
||||
m_idParamTypeIds.insert(hoodThingClassId, hoodThingIdParamTypeId);
|
||||
m_idParamTypeIds.insert(cleaningRobotThingClassId, cleaningRobotThingIdParamTypeId);
|
||||
|
||||
m_connectedStateTypeIds.insert(ovenThingClassId, ovenConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(fridgeThingClassId, fridgeConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(dryerThingClassId, dryerConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(coffeMakerThingClassId, coffeMakerConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(dishwasherThingClassId, dishwasherConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(washerThingClassId, washerConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(ovenThingClassId, ovenConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(cookTopThingClassId, cookTopConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(cleaningRobotThingClassId, cleaningRobotConnectedStateTypeId);
|
||||
m_connectedStateTypeIds.insert(hoodThingClassId, hoodConnectedStateTypeId);
|
||||
|
||||
m_localControlStateTypeIds.insert(ovenThingClassId, ovenLocalControlStateStateTypeId);
|
||||
//m_localControlStateTypeIds.insert(fridgeThingClassId, fridgeLocalControlStateStateTypeId);
|
||||
//m_localControlStateTypeIds.insert(dryerThingClassId, dryerLocalControlStateTypeId);
|
||||
m_localControlStateTypeIds.insert(coffeMakerThingClassId, coffeMakerLocalControlStateStateTypeId);
|
||||
//m_localControlStateTypeIds.insert(dishwasherThingClassId, dishwasherLocalControlStateStateTypeId);
|
||||
m_localControlStateTypeIds.insert(washerThingClassId, washerLocalControlStateStateTypeId);
|
||||
//m_localControlStateTypeIds.insert(cookTopThingClassId, cookTopLocalControlStateStateTypeId);
|
||||
//m_localControlStateTypeIds.insert(cleaningRobotThingClassId, cleaningRobotLocalControlStateStateTypeId);
|
||||
//m_localControlStateTypeIds.insert(hoodThingClassId, hoodLocalControlStateStateTypeId);
|
||||
|
||||
m_remoteStartAllowanceStateTypeIds.insert(ovenThingClassId, ovenRemoteStartAllowanceStateStateTypeId);
|
||||
//m_remoteStartAllowanceStateTypeIds.insert(fridgeThingClassId, fridgeRemoteStartAllowanceStateStateTypeId);
|
||||
m_remoteStartAllowanceStateTypeIds.insert(dryerThingClassId, dryerRemoteStartAllowanceStateStateTypeId);
|
||||
m_remoteStartAllowanceStateTypeIds.insert(coffeMakerThingClassId, coffeMakerRemoteStartAllowanceStateStateTypeId);
|
||||
m_remoteStartAllowanceStateTypeIds.insert(dishwasherThingClassId, dishwasherRemoteStartAllowanceStateStateTypeId);
|
||||
m_remoteStartAllowanceStateTypeIds.insert(washerThingClassId, washerRemoteStartAllowanceStateStateTypeId);
|
||||
//m_remoteStartAllowanceStateTypeIds.insert(cookTopThingClassId, cookTopRemoteStartAllowanceStateStateTypeId);
|
||||
//m_remoteStartAllowanceStateTypeIds.insert(cleaningRobotThingClassId, cleaningRobotRemoteStartAllowanceStateStateTypeId);
|
||||
//m_remoteStartAllowanceStateTypeIds.insert(hoodThingClassId, hoodRemoteStartAllowanceStateStateTypeId);
|
||||
|
||||
m_remoteControlActivationStateTypeIds.insert(ovenThingClassId, ovenRemoteControlActivationStateStateTypeId);
|
||||
//m_remoteControlActivationStateTypeIds.insert(fridgeThingClassId, fridgeRemoteControlActivationStateStateTypeId);
|
||||
m_remoteControlActivationStateTypeIds.insert(dryerThingClassId, dryerRemoteControlActivationStateStateTypeId);
|
||||
//m_remoteControlActivationStateTypeIds.insert(coffeMakerThingClassId, coffeMakerRemoteControlActivationStateStateTypeId);
|
||||
m_remoteControlActivationStateTypeIds.insert(dishwasherThingClassId, dishwasherRemoteControlActivationStateStateTypeId);
|
||||
m_remoteControlActivationStateTypeIds.insert(washerThingClassId, washerRemoteControlActivationStateStateTypeId);
|
||||
//m_remoteControlActivationStateTypeIds.insert(cookTopThingClassId, cookTopRemoteControlActivationStateStateTypeId);
|
||||
//m_remoteControlActivationStateTypeIds.insert(cleaningRobotThingClassId, cleaningRobotRemoteControlActivationStateStateTypeId);
|
||||
//m_remoteControlActivationStateTypeIds.insert(hoodThingClassId, hoodRemoteControlActivationStateStateTypeId);
|
||||
|
||||
m_doorStateTypeIds.insert(dishwasherThingClassId, dishwasherDoorStateEventTypeId);
|
||||
m_doorStateTypeIds.insert(washerThingClassId, washerDoorStateEventTypeId);
|
||||
m_doorStateTypeIds.insert(dryerThingClassId, dryerDoorStateEventTypeId);
|
||||
m_doorStateTypeIds.insert(ovenThingClassId, ovenDoorStateEventTypeId);
|
||||
|
||||
m_operationStateTypeIds.insert(ovenThingClassId, ovenOperationStateEventTypeId);
|
||||
//m_operationStateTypeIds.insert(fridgeThingClassId, fridgeOperationStateEventTypeId);
|
||||
m_operationStateTypeIds.insert(dryerThingClassId, dryerOperationStateEventTypeId);
|
||||
m_operationStateTypeIds.insert(coffeMakerThingClassId, coffeMakerOperationStateEventTypeId);
|
||||
m_operationStateTypeIds.insert(dishwasherThingClassId, dishwasherOperationStateEventTypeId);
|
||||
m_operationStateTypeIds.insert(washerThingClassId, washerOperationStateEventTypeId);
|
||||
//m_operationStateTypeIds.insert(cookTopThingClassId, cookTopOperationStateEventTypeId);
|
||||
//m_operationStateTypeIds.insert(cleaningRobotThingClassId, cleaningRobotOperationStateEventTypeId);
|
||||
//m_operationStateTypeIds.insert(hoodThingClassId, hoodOperationStateEventTypeId);
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::startPairing(ThingPairingInfo *info)
|
||||
|
|
@ -147,12 +182,6 @@ void IntegrationPluginHomeConnect::setupThing(ThingSetupInfo *info)
|
|||
//Fresh device setup, has already a fresh access token
|
||||
qCDebug(dcHomeConnect()) << "HomeConnect OAuth setup complete";
|
||||
homeConnect = m_setupHomeConnectConnections.take(thing->id());
|
||||
connect(homeConnect, &HomeConnect::connectionChanged, this, &IntegrationPluginHomeConnect::onConnectionChanged);
|
||||
connect(homeConnect, &HomeConnect::commandExecuted, this, &IntegrationPluginHomeConnect::onRequestExecuted);
|
||||
connect(homeConnect, &HomeConnect::authenticationStatusChanged, this, &IntegrationPluginHomeConnect::onAuthenticationStatusChanged);
|
||||
connect(homeConnect, &HomeConnect::receivedHomeAppliances, this, &IntegrationPluginHomeConnect::onReceivedHomeAppliances);
|
||||
connect(homeConnect, &HomeConnect::receivedStatusList, this, &IntegrationPluginHomeConnect::onReceivedStatusList);
|
||||
//TODO add settings received
|
||||
m_homeConnectConnections.insert(thing, homeConnect);
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
} else {
|
||||
|
|
@ -160,17 +189,20 @@ void IntegrationPluginHomeConnect::setupThing(ThingSetupInfo *info)
|
|||
pluginStorage()->beginGroup(thing->id().toString());
|
||||
QByteArray refreshToken = pluginStorage()->value("refresh_token").toByteArray();
|
||||
pluginStorage()->endGroup();
|
||||
|
||||
homeConnect = new HomeConnect(hardwareManager()->networkManager(), "423713AB3EDA5B44BCE6E7B3546C43DADCB27A156C681E30455250637B2213DB", "AE182EA9F1CB99416DFD62CE61BF6DCDB3BB7D4697B58D4499D3792EC9F7412D", simulationMode, this);
|
||||
connect(homeConnect, &HomeConnect::connectionChanged, this, &IntegrationPluginHomeConnect::onConnectionChanged);
|
||||
connect(homeConnect, &HomeConnect::commandExecuted, this, &IntegrationPluginHomeConnect::onRequestExecuted);
|
||||
connect(homeConnect, &HomeConnect::authenticationStatusChanged, this, &IntegrationPluginHomeConnect::onAuthenticationStatusChanged);
|
||||
connect(homeConnect, &HomeConnect::receivedHomeAppliances, this, &IntegrationPluginHomeConnect::onReceivedHomeAppliances);
|
||||
connect(homeConnect, &HomeConnect::receivedStatusList, this, &IntegrationPluginHomeConnect::onReceivedStatusList);
|
||||
//TODO add settings received
|
||||
homeConnect->getAccessTokenFromRefreshToken(refreshToken);
|
||||
m_asyncSetup.insert(homeConnect, info);
|
||||
}
|
||||
connect(homeConnect, &HomeConnect::connectionChanged, this, &IntegrationPluginHomeConnect::onConnectionChanged);
|
||||
connect(homeConnect, &HomeConnect::commandExecuted, this, &IntegrationPluginHomeConnect::onRequestExecuted);
|
||||
connect(homeConnect, &HomeConnect::authenticationStatusChanged, this, &IntegrationPluginHomeConnect::onAuthenticationStatusChanged);
|
||||
connect(homeConnect, &HomeConnect::receivedHomeAppliances, this, &IntegrationPluginHomeConnect::onReceivedHomeAppliances);
|
||||
connect(homeConnect, &HomeConnect::receivedStatusList, this, &IntegrationPluginHomeConnect::onReceivedStatusList);
|
||||
connect(homeConnect, &HomeConnect::receivedActiveProgram, this, &IntegrationPluginHomeConnect::onReceivedActiveProgram);
|
||||
connect(homeConnect, &HomeConnect::receivedSelectedProgram, this, &IntegrationPluginHomeConnect::onReceivedSelectedProgram);
|
||||
connect(homeConnect, &HomeConnect::receivedSettings, this, &IntegrationPluginHomeConnect::onReceivedSettings);
|
||||
connect(homeConnect, &HomeConnect::receivedEvents, this, &IntegrationPluginHomeConnect::onReceivedEvents);
|
||||
|
||||
} else if ((thing->thingClassId() == dryerThingClassId) ||
|
||||
(thing->thingClassId() == fridgeThingClassId) ||
|
||||
(thing->thingClassId() == washerThingClassId) ||
|
||||
|
|
@ -225,6 +257,12 @@ void IntegrationPluginHomeConnect::postSetupThing(Thing *thing)
|
|||
continue;
|
||||
}
|
||||
homeConnect->getHomeAppliances();
|
||||
Q_FOREACH(Thing *childThing, myThings().filterByParentId(thing->id())) {
|
||||
QString haId = thing->paramValue(m_idParamTypeIds.value(childThing->thingClassId())).toString();
|
||||
homeConnect->getSettings(haId);
|
||||
homeConnect->getProgramsActive(haId);
|
||||
homeConnect->getProgramsSelected(haId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -232,8 +270,10 @@ void IntegrationPluginHomeConnect::postSetupThing(Thing *thing)
|
|||
if (thing->thingClassId() == homeConnectConnectionThingClassId) {
|
||||
HomeConnect *homeConnect = m_homeConnectConnections.value(thing);
|
||||
homeConnect->getHomeAppliances();
|
||||
homeConnect->connectEventStream();
|
||||
thing->setStateValue(homeConnectConnectionConnectedStateTypeId, true);
|
||||
thing->setStateValue(homeConnectConnectionLoggedInStateTypeId, true);
|
||||
//TODO set login username
|
||||
} else if ((thing->thingClassId() == dryerThingClassId) ||
|
||||
(thing->thingClassId() == fridgeThingClassId) ||
|
||||
(thing->thingClassId() == washerThingClassId) ||
|
||||
|
|
@ -242,7 +282,7 @@ void IntegrationPluginHomeConnect::postSetupThing(Thing *thing)
|
|||
(thing->thingClassId() == ovenThingClassId) ||
|
||||
(thing->thingClassId() == hoodThingClassId) ||
|
||||
(thing->thingClassId() == cleaningRobotThingClassId) ||
|
||||
(thing->thingClassId() == cookTopThingClassId)){
|
||||
(thing->thingClassId() == cookTopThingClassId)) {
|
||||
Thing *parentThing = myThings().findById(thing->parentId());
|
||||
if (!parentThing)
|
||||
qCWarning(dcHomeConnect()) << "Could not find parent with Id" << thing->parentId().toString();
|
||||
|
|
@ -253,6 +293,8 @@ void IntegrationPluginHomeConnect::postSetupThing(Thing *thing)
|
|||
} else {
|
||||
homeConnect->getStatus(haId);
|
||||
homeConnect->getSettings(haId);
|
||||
homeConnect->getProgramsActive(haId);
|
||||
homeConnect->getProgramsSelected(haId);
|
||||
}
|
||||
} else {
|
||||
Q_ASSERT_X(false, "postSetupThing", QString("Unhandled thingClassId: %1").arg(thing->thingClassId().toString()).toUtf8());
|
||||
|
|
@ -307,25 +349,43 @@ void IntegrationPluginHomeConnect::thingRemoved(Thing *thing)
|
|||
|
||||
void IntegrationPluginHomeConnect::browseThing(BrowseResult *result)
|
||||
{
|
||||
Q_UNUSED(result)
|
||||
Thing *thing = result->thing();
|
||||
qCDebug(dcHomeConnect()) << "Browse thing called " << thing->name();
|
||||
|
||||
if (thing->thingClassId() == ovenThingClassId) {
|
||||
HomeConnect *homeConnect = m_homeConnectConnections.value(myThings().findById(thing->parentId()));
|
||||
if (!homeConnect)
|
||||
return;
|
||||
QString haid = thing->stateValue(m_idParamTypeIds.value(thing->thingClassId())).toString();
|
||||
homeConnect->getProgramsAvailable(haid);
|
||||
//connect(homeConnect, &HomeConnect::re)
|
||||
}
|
||||
HomeConnect *homeConnect = m_homeConnectConnections.value(myThings().findById(thing->parentId()));
|
||||
if (!homeConnect)
|
||||
return;
|
||||
QString haid = thing->stateValue(m_idParamTypeIds.value(thing->thingClassId())).toString();
|
||||
homeConnect->getProgramsAvailable(haid);
|
||||
connect(homeConnect, &HomeConnect::receivedAvailablePrograms, result, [result, this] (const QString &haId, const QStringList programs) {
|
||||
if(result->thing()->paramValue(m_idParamTypeIds.value(result->thing()->id())).toString() == haId) {
|
||||
Q_FOREACH(QString program, programs) {
|
||||
BrowserItem item;
|
||||
item.setExecutable(true);
|
||||
item.setDisplayName(program);
|
||||
result->addItem(item);
|
||||
}
|
||||
result->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::browserItem(BrowserItemResult *result)
|
||||
{
|
||||
Q_UNUSED(result)
|
||||
Thing *thing = result->thing();
|
||||
qCDebug(dcHomeConnect()) << "Browse item called " << thing->name();
|
||||
|
||||
HomeConnect *homeConnect = m_homeConnectConnections.value(myThings().findById(thing->parentId()));
|
||||
if (!homeConnect)
|
||||
return;
|
||||
QString haid = thing->stateValue(m_idParamTypeIds.value(thing->thingClassId())).toString();
|
||||
homeConnect->getProgramsAvailable(haid);
|
||||
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 (programs.contains(result->item().id()))
|
||||
result->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::executeBrowserItem(BrowserActionInfo *info)
|
||||
|
|
@ -333,6 +393,14 @@ void IntegrationPluginHomeConnect::executeBrowserItem(BrowserActionInfo *info)
|
|||
Q_UNUSED(info)
|
||||
Thing *thing = info->thing();
|
||||
qCDebug(dcHomeConnect()) << "Execute browse item called " << thing->name();
|
||||
|
||||
HomeConnect *homeConnect = m_homeConnectConnections.value(myThings().findById(thing->parentId()));
|
||||
if (!homeConnect)
|
||||
return;
|
||||
QString haid = thing->stateValue(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);
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::onConnectionChanged(bool connected)
|
||||
|
|
@ -389,7 +457,7 @@ void IntegrationPluginHomeConnect::onRequestExecuted(QUuid requestId, bool succe
|
|||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::onReceivedHomeAppliances(QList<HomeConnect::HomeAppliance> appliances)
|
||||
void IntegrationPluginHomeConnect::onReceivedHomeAppliances(const QList<HomeConnect::HomeAppliance> &appliances)
|
||||
{
|
||||
HomeConnect *homeConnectConnection = static_cast<HomeConnect *>(sender());
|
||||
Thing *parentThing = m_homeConnectConnections.key(homeConnectConnection);
|
||||
|
|
@ -399,19 +467,6 @@ void IntegrationPluginHomeConnect::onReceivedHomeAppliances(QList<HomeConnect::H
|
|||
ThingDescriptors desciptors;
|
||||
Q_FOREACH(HomeConnect::HomeAppliance appliance, appliances) {
|
||||
ThingClassId thingClassId;
|
||||
/*Oven,
|
||||
Dishwasher,
|
||||
Washer,
|
||||
Dryer,
|
||||
WasherDryer,
|
||||
FridgeFreezer,
|
||||
Refrigerator,
|
||||
Freezer,
|
||||
WineCooler,
|
||||
CoffeeMaker,
|
||||
Hood,
|
||||
CleaningRobot,
|
||||
CookProcessor*/
|
||||
|
||||
if (appliance.type.contains("Oven", Qt::CaseInsensitive)) {
|
||||
thingClassId = ovenThingClassId;
|
||||
|
|
@ -431,6 +486,17 @@ void IntegrationPluginHomeConnect::onReceivedHomeAppliances(QList<HomeConnect::H
|
|||
thingClassId = coffeMakerThingClassId;
|
||||
} else if (appliance.type.contains("Dryer", Qt::CaseInsensitive)) {
|
||||
thingClassId = dryerThingClassId;
|
||||
} else if (appliance.type.contains("CookTop", Qt::CaseInsensitive)) {
|
||||
thingClassId = cookTopThingClassId;
|
||||
} else if (appliance.type.contains("Hood", Qt::CaseInsensitive)) {
|
||||
thingClassId = hoodThingClassId;
|
||||
} else if (appliance.type.contains("CleaningRobot", Qt::CaseInsensitive)) {
|
||||
thingClassId = cleaningRobotThingClassId;
|
||||
} else if (appliance.type.contains("CookProcessor", Qt::CaseInsensitive)) {
|
||||
thingClassId = cookProcessorThingClassId;
|
||||
} else if (appliance.type.contains("WasherDryer", Qt::CaseInsensitive)) {
|
||||
thingClassId = washerThingClassId;
|
||||
//FIXME add washerdryer thing classid
|
||||
} else {
|
||||
qCWarning(dcHomeConnect()) << "Unknown thing type" << appliance.type;
|
||||
continue;
|
||||
|
|
@ -461,7 +527,9 @@ void IntegrationPluginHomeConnect::onReceivedStatusList(const QString &haId, con
|
|||
return;
|
||||
|
||||
Q_FOREACH(Thing *thing, myThings().filterByParentId(parentThing->id())) {
|
||||
|
||||
if (thing->paramValue(m_idParamTypeIds.value(thing->thingClassId())).toString() == haId) {
|
||||
|
||||
if (statusList.contains("BSH.Common.Status.LocalControlActive")) {
|
||||
if (m_localControlStateTypeIds.contains(thing->thingClassId())) {
|
||||
thing->setStateValue(m_localControlStateTypeIds.value(thing->thingClassId()), statusList.value("BSH.Common.Status.LocalControlActive").toBool());
|
||||
|
|
@ -487,11 +555,187 @@ void IntegrationPluginHomeConnect::onReceivedStatusList(const QString &haId, con
|
|||
thing->setStateValue(m_operationStateTypeIds.value(thing->thingClassId()), statusList.value("BSH.Common.Status.OperationState").toString().split('.').last());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::onReceivedEvents(const QList<HomeConnect::Event> events)
|
||||
void IntegrationPluginHomeConnect::onReceivedEvents(const QList<HomeConnect::Event> &events)
|
||||
{
|
||||
Q_UNUSED(events)
|
||||
Q_FOREACH(HomeConnect::Event event, events) {
|
||||
qCDebug(dcHomeConnect()) << "Received event" << event.key << event.uri << event.name;
|
||||
|
||||
if (event.key == "BSH.Common.Root.SelectedProgram") {
|
||||
|
||||
}
|
||||
if (event.key == "BSH.Common.Root.SelectedProgram") {
|
||||
|
||||
}
|
||||
if (event.key == "BSH.Common.Option.ProgramProgress") {
|
||||
|
||||
}
|
||||
/*
|
||||
* BSH.Common.Root.SelectedProgram
|
||||
* BSH.Common.Root.ActiveProgram
|
||||
* Cooking.Oven.Option.SetpointTemperature
|
||||
* BSH.Common.Option.Duration
|
||||
* Cooking.Oven.Option.FastPreHeat
|
||||
* BSH.Common.Option.StartInRelative
|
||||
* LaundryCare.Washer.Option.Temperature
|
||||
* LaundryCare.Washer.Option.SpinSpeed
|
||||
* LaundryCare.Dryer.Option.DryingTarget
|
||||
* ConsumerProducts.CoffeeMaker.Option.BeanAmount
|
||||
* ConsumerProducts.CoffeeMaker.Option.FillQuantity
|
||||
* ConsumerProducts.CoffeeMaker.Option.CoffeeTemperature
|
||||
* Cooking.Common.Option.Hood.VentingLevel
|
||||
* Cooking.Common.Option.Hood.IntensiveLevel
|
||||
* ConsumerProducts.CleaningRobot.Option.ReferenceMapId
|
||||
* ConsumerProducts.CleaningRobot.Option.CleaningMode
|
||||
* BSH.Common.Option.ElapsedProgramTime
|
||||
* BSH.Common.Option.RemainingProgramTime
|
||||
* BSH.Common.Option.ProgramProgress
|
||||
* ConsumerProducts.CleaningRobot.Option.ProcessPhase
|
||||
* BSH.Common.Setting.PowerState
|
||||
* BSH.Common.Setting.TemperatureUnit
|
||||
* BSH.Common.Setting.LiquidVolumeUnit
|
||||
* Cooking.Common.Setting.Lighting
|
||||
* Cooking.Common.Setting.LightingBrightness
|
||||
* BSH.Common.Setting.AmbientLightEnabled
|
||||
* BSH.Common.Setting.AmbientLightBrightness
|
||||
* BSH.Common.Setting.AmbientLightColor
|
||||
* BSH.Common.Setting.AmbientLightCustomColor
|
||||
* Refrigeration.FridgeFreezer.Setting.SetpointTemperatureFreezer
|
||||
* Refrigeration.FridgeFreezer.Setting.SetpointTemperatureRefrigerator
|
||||
* Refrigeration.Common.Setting.BottleCooler.SetpointTemperature
|
||||
* Refrigeration.Common.Setting.ChillerLeft.SetpointTemperature
|
||||
* Refrigeration.Common.Setting.ChillerCommon.SetpointTemperature
|
||||
Refrigeration.Common.Setting.ChillerRight.SetpointTemperature NOTIFY
|
||||
Refrigeration.Common.Setting.WineCompartment.SetpointTemperature NOTIFY
|
||||
Refrigeration.Common.Setting.WineCompartment2.SetpointTemperature NOTIFY
|
||||
Refrigeration.Common.Setting.WineCompartment3.SetpointTemperature NOTIFY
|
||||
Refrigeration.FridgeFreezer.Setting.SuperModeFreezer NOTIFY
|
||||
Refrigeration.FridgeFreezer.Setting.SuperModeRefrigerator NOTIFY
|
||||
Refrigeration.Common.Setting.EcoMode NOTIFY
|
||||
Refrigeration.Common.Setting.SabbathMode NOTIFY
|
||||
Refrigeration.Common.Setting.VacationMode NOTIFY
|
||||
Refrigeration.Common.Setting.FreshMode NOTIFY
|
||||
ConsumerProducts.CleaningRobot.Setting.CurrentMap NOTIFY
|
||||
ConsumerProducts.CleaningRobot.Setting.NameOfMap1 NOTIFY
|
||||
ConsumerProducts.CleaningRobot.Setting.NameOfMap2 NOTIFY
|
||||
ConsumerProducts.CleaningRobot.Setting.NameOfMap3 NOTIFY
|
||||
ConsumerProducts.CleaningRobot.Setting.NameOfMap4 NOTIFY
|
||||
ConsumerProducts.CleaningRobot.Setting.NameOfMap5 NOTIFY
|
||||
BSH.Common.Status.RemoteControlActive STATUS
|
||||
BSH.Common.Status.RemoteControlStartAllowed STATUS
|
||||
BSH.Common.Status.LocalControlActive STATUS
|
||||
BSH.Common.Status.OperationState STATUS
|
||||
BSH.Common.Status.DoorState STATUS
|
||||
BSH.Common.Status.BatteryLevel STATUS
|
||||
BSH.Common.Status.BatteryChargingState STATUS
|
||||
BSH.Common.Status.ChargingConnection STATUS
|
||||
BSH.Common.Status.Video.CameraState STATUS
|
||||
ConsumerProducts.CleaningRobot.Status.LastSelectedMap STATUS
|
||||
ConsumerProducts.CleaningRobot.Status.DustBoxInserted STATUS
|
||||
ConsumerProducts.CleaningRobot.Status.Lost STATUS
|
||||
ConsumerProducts.CleaningRobot.Status.Lifted STATUS
|
||||
BSH.Common.Event.ProgramAborted
|
||||
BSH.Common.Event.ProgramFinished
|
||||
BSH.Common.Event.AlarmClockElapsed EVENT
|
||||
Cooking.Oven.Event.PreheatFinished EVENT
|
||||
ConsumerProducts.CoffeeMaker.Event.BeanContainerEmpty EVENT
|
||||
ConsumerProducts.CoffeeMaker.Event.WaterTankEmpty EVENT
|
||||
ConsumerProducts.CoffeeMaker.Event.DripTrayFull EVENT
|
||||
Refrigeration.FridgeFreezer.Event.DoorAlarmFreezer EVENT
|
||||
Refrigeration.FridgeFreezer.Event.DoorAlarmRefrigerator EVENT
|
||||
Refrigeration.FridgeFreezer.Event.TemperatureAlarmFreezer EVENT
|
||||
ConsumerProducts.CleaningRobot.Event.EmptyDustBoxAndCleanFilter EVENT
|
||||
ConsumerProducts.CleaningRobot.Event.RobotIsStuck
|
||||
ConsumerProducts.CleaningRobot.Event.DockingStationNotFound
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::onReceivedActiveProgram(const QString &haId, const QString &key, const QHash<QString, QVariant> &options)
|
||||
{
|
||||
HomeConnect *homeConnectConnection = static_cast<HomeConnect *>(sender());
|
||||
Thing *parentThing = m_homeConnectConnections.key(homeConnectConnection);
|
||||
if (!parentThing)
|
||||
return;
|
||||
|
||||
Q_FOREACH(Thing *thing, myThings().filterByParentId(parentThing->id())) {
|
||||
if (thing->paramValue(m_idParamTypeIds.value(thing->thingClassId())).toString() == haId) {
|
||||
qCDebug(dcHomeConnect()) << "Received active program" << thing->name() << key << options;
|
||||
if (thing->thingClassId() == ovenThingClassId) {
|
||||
if (key.contains("Cooking.Oven.Program.HeatingMode")) {
|
||||
thing->setStateValue(ovenActiveProgramStateTypeId, key.split('.').last());
|
||||
thing->setStateValue(ovenTargetTemperatureStateTypeId, options.value("Cooking.Oven.Option.SetpointTemperature").toInt());
|
||||
thing->setStateValue(ovenTargetTemperatureStateTypeId, options.value("BSH.Common.Option.Duration").toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::onReceivedSelectedProgram(const QString &haId, const QString &key, const QHash<QString, QVariant> &options)
|
||||
{
|
||||
HomeConnect *homeConnectConnection = static_cast<HomeConnect *>(sender());
|
||||
Thing *parentThing = m_homeConnectConnections.key(homeConnectConnection);
|
||||
if (!parentThing)
|
||||
return;
|
||||
|
||||
Q_FOREACH(Thing *thing, myThings().filterByParentId(parentThing->id())) {
|
||||
if (thing->paramValue(m_idParamTypeIds.value(thing->thingClassId())).toString() == haId) {
|
||||
qCDebug(dcHomeConnect()) << "Received active program" << thing->name() << key << options;
|
||||
if (thing->thingClassId() == ovenThingClassId) {
|
||||
if (key.contains("Cooking.Oven.Program.HeatingMode")) {
|
||||
thing->setStateValue(ovenSelectedProgramStateTypeId, key.split('.').last());
|
||||
thing->setStateValue(ovenTargetTemperatureStateTypeId, options.value("Cooking.Oven.Option.SetpointTemperature").toInt());
|
||||
thing->setStateValue(ovenTargetTemperatureStateTypeId, options.value("BSH.Common.Option.Duration").toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void IntegrationPluginHomeConnect::onReceivedSettings(const QString &haId, const QHash<QString, QVariant> &settings)
|
||||
{
|
||||
HomeConnect *homeConnectConnection = static_cast<HomeConnect *>(sender());
|
||||
Thing *parentThing = m_homeConnectConnections.key(homeConnectConnection);
|
||||
if (!parentThing)
|
||||
return;
|
||||
|
||||
Q_FOREACH(Thing *thing, myThings().filterByParentId(parentThing->id())) {
|
||||
if (thing->paramValue(m_idParamTypeIds.value(thing->thingClassId())).toString() == haId) {
|
||||
qCDebug(dcHomeConnect()) << "Received setting" << thing->name() << settings;
|
||||
if (settings.contains("BSH.Common.Setting.PowerState")) {
|
||||
//TODO set power state
|
||||
}
|
||||
//BSH.Common.Setting.TemperatureUnit
|
||||
//BSH.Common.Setting.LiquidVolumeUnit
|
||||
//Refrigeration.FridgeFreezer.Setting.SetpointTemperatureRefrigerator
|
||||
//Refrigeration.FridgeFreezer.Setting.SetpointTemperatureFreezer
|
||||
//Refrigeration.Common.Setting.BottleCooler.SetpointTemperature
|
||||
//Refrigeration.Common.Setting.ChillerLeft.SetpointTemperature
|
||||
//Refrigeration.Common.Setting.ChillerCommon.SetpointTemperature
|
||||
//Refrigeration.Common.Setting.ChillerRight.SetpointTemperature
|
||||
//Refrigeration.Common.Setting.WineCompartment.SetpointTemperature
|
||||
//Refrigeration.Common.Setting.WineCompartment2.SetpointTemperature
|
||||
//Refrigeration.Common.Setting.WineCompartment3.SetpointTemperature
|
||||
//Refrigeration.FridgeFreezer.Setting.SuperModeRefrigerator
|
||||
//Refrigeration.FridgeFreezer.Setting.SuperModeFreezer
|
||||
//Refrigeration.Common.Setting.EcoMode
|
||||
//Refrigeration.Common.Setting.SabbathMode
|
||||
//Refrigeration.Common.Setting.VacationMode
|
||||
//Refrigeration.Common.Setting.FreshMode
|
||||
//Cooking.Common.Setting.Lighting
|
||||
//Cooking.Common.Setting.LightingBrightness
|
||||
//BSH.Common.Setting.AmbientLightEnabled
|
||||
//BSH.Common.Setting.AmbientLightBrightness
|
||||
//BSH.Common.Setting.AmbientLightColor
|
||||
//BSH.Common.Setting.AmbientLightCustomColor
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,9 +85,12 @@ private slots:
|
|||
void onConnectionChanged(bool connected);
|
||||
void onAuthenticationStatusChanged(bool authenticated);
|
||||
void onRequestExecuted(QUuid requestId, bool success);
|
||||
void onReceivedHomeAppliances(QList<HomeConnect::HomeAppliance> appliances);
|
||||
void onReceivedHomeAppliances(const QList<HomeConnect::HomeAppliance> &appliances);
|
||||
void onReceivedStatusList(const QString &haId, const QHash<QString, QVariant> &statusList);
|
||||
void onReceivedEvents(const QList<HomeConnect::Event> events);
|
||||
void onReceivedEvents(const QList<HomeConnect::Event> &events);
|
||||
void onReceivedActiveProgram(const QString &haId, const QString &key, const QHash<QString, QVariant> &options);
|
||||
void onReceivedSelectedProgram(const QString &haId, const QString &key, const QHash<QString, QVariant> &options);
|
||||
void onReceivedSettings(const QString &haId, const QHash<QString, QVariant> &settings);
|
||||
};
|
||||
|
||||
#endif // INTEGRATIONPLUGINHOMECONNECT_H
|
||||
|
|
|
|||
|
|
@ -147,6 +147,49 @@
|
|||
"writable": true,
|
||||
"unit": "DegreeCelsius",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"id": "1dcf634c-04c1-4415-9656-06f5b61bde17",
|
||||
"name": "currentTemperature",
|
||||
"displayName": "Current temperature",
|
||||
"displayNameEvent": "Current temperature changed",
|
||||
"defaultValue": 0,
|
||||
"unit": "DegreeCelsius",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"id": "3527a28d-e4df-481b-a8b6-88717b77c7a6",
|
||||
"name": "duration",
|
||||
"displayName": "Duration",
|
||||
"displayNameEvent": "Duration changed",
|
||||
"defaultValue": 0,
|
||||
"unit": "Seconds",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"id": "85a333dc-0e0b-454c-9c9a-d14dd6484275",
|
||||
"name": "progress",
|
||||
"displayName": "Progress",
|
||||
"displayNameEvent": "Progress changed",
|
||||
"defaultValue": 0,
|
||||
"unit": "Percentage",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"id": "2e6f27bb-371a-44a4-b057-51f765bdeb86",
|
||||
"name": "selectedProgram",
|
||||
"displayName": "Selected program",
|
||||
"displayNameEvent": "Selected program changed",
|
||||
"defaultValue": "None",
|
||||
"type": "QString"
|
||||
},
|
||||
{
|
||||
"id": "474d9ca0-6842-4a1b-9655-e147df923459",
|
||||
"name": "activeProgram",
|
||||
"displayName": "Active program",
|
||||
"displayNameEvent": "Active program changed",
|
||||
"defaultValue": "None",
|
||||
"type": "QString"
|
||||
}
|
||||
],
|
||||
"actionTypes": [
|
||||
|
|
@ -407,7 +450,7 @@
|
|||
{
|
||||
"id": "6cbf309d-bde8-4e6e-ad6d-b85c8fc1843f",
|
||||
"name": "fridge",
|
||||
"displayName": "Fridge",
|
||||
"displayName": "Fridge Freezer",
|
||||
"interfaces": ["connectable"],
|
||||
"createMethods": ["auto"],
|
||||
"paramTypes": [
|
||||
|
|
@ -440,6 +483,54 @@
|
|||
"Open",
|
||||
"Closed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "bc13977e-0ea1-4804-af00-311ae62c6c06",
|
||||
"name": "fridgeTemperature",
|
||||
"displayName": "Fridge temperature",
|
||||
"displayNameEvent": "Fridge temperature changed",
|
||||
"defaultValue": 0,
|
||||
"type": "int",
|
||||
"minValue": 2,
|
||||
"maxValue": 8,
|
||||
"unit": "DegreeCelsius"
|
||||
},
|
||||
{
|
||||
"id": "5a1a8665-835b-4909-8f79-42874c5c4643",
|
||||
"name": "fridgeTemperatureSetting",
|
||||
"displayName": "Fridge temperature setting",
|
||||
"displayNameEvent": "Fridge temperature setting changed",
|
||||
"displayNameAction": "Set fridge temperature setting",
|
||||
"defaultValue": 0,
|
||||
"type": "int",
|
||||
"minValue": 2,
|
||||
"maxValue": 8,
|
||||
"writable": true,
|
||||
"unit": "DegreeCelsius"
|
||||
},
|
||||
{
|
||||
"id": "523adac4-a98a-49b5-96d4-d506831aeab7",
|
||||
"name": "freezerTemperature",
|
||||
"displayName": "Freezer temperature",
|
||||
"displayNameEvent": "Freezer temperature changed",
|
||||
"defaultValue": -18,
|
||||
"type": "int",
|
||||
"minValue": -24,
|
||||
"maxValue": -16,
|
||||
"unit": "DegreeCelsius"
|
||||
},
|
||||
{
|
||||
"id": "081ceedc-7c09-4cd9-8015-13a59ce653bf",
|
||||
"name": "freezerTemperatureSetting",
|
||||
"displayName": "Freezer temperature setting",
|
||||
"displayNameEvent": "Freezer temperature setting changed",
|
||||
"displayNameAction": "Set freezer temperature setting",
|
||||
"defaultValue": -18,
|
||||
"type": "int",
|
||||
"minValue": -24,
|
||||
"maxValue": -16,
|
||||
"writable": true,
|
||||
"unit": "DegreeCelsius"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue