nanoleaf: Add Qt6 support
This commit is contained in:
parent
47d8cb8a7b
commit
2b3d60071e
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,8 +31,8 @@
|
|||||||
#include "integrationpluginnanoleaf.h"
|
#include "integrationpluginnanoleaf.h"
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
|
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
#include <network/zeroconf/zeroconfservicebrowser.h>
|
||||||
#include "platform/platformzeroconfcontroller.h"
|
#include <platform/platformzeroconfcontroller.h>
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -60,9 +60,8 @@ void IntegrationPluginNanoleaf::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
QString model = entry.txt("md");
|
QString model = entry.txt("md");
|
||||||
QString firmwareVersion = entry.txt("srcvers");
|
QString firmwareVersion = entry.txt("srcvers");
|
||||||
|
|
||||||
if (serialNumbers.contains(serialNo)) {
|
if (serialNumbers.contains(serialNo))
|
||||||
continue; //To avoid duplicated devices
|
continue; //To avoid duplicated devices
|
||||||
}
|
|
||||||
|
|
||||||
Thing *existingThing = myThings().findByParams(ParamList() << Param(lightPanelsThingSerialNoParamTypeId, serialNo));
|
Thing *existingThing = myThings().findByParams(ParamList() << Param(lightPanelsThingSerialNoParamTypeId, serialNo));
|
||||||
if (existingThing) {
|
if (existingThing) {
|
||||||
@ -199,29 +198,29 @@ void IntegrationPluginNanoleaf::executeAction(ThingActionInfo *info)
|
|||||||
if (action.actionTypeId() == lightPanelsPowerActionTypeId) {
|
if (action.actionTypeId() == lightPanelsPowerActionTypeId) {
|
||||||
bool power = action.param(lightPanelsPowerActionPowerParamTypeId).value().toBool();
|
bool power = action.param(lightPanelsPowerActionPowerParamTypeId).value().toBool();
|
||||||
QUuid requestId = nanoleaf->setPower(power);
|
QUuid requestId = nanoleaf->setPower(power);
|
||||||
connect(info, &ThingActionInfo::aborted,[requestId, this](){m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [requestId, this](){ m_asyncActions.remove(requestId); });
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
|
|
||||||
} else if (action.actionTypeId() == lightPanelsBrightnessActionTypeId) {
|
} else if (action.actionTypeId() == lightPanelsBrightnessActionTypeId) {
|
||||||
int brightness = action.param(lightPanelsBrightnessActionBrightnessParamTypeId).value().toInt();
|
int brightness = action.param(lightPanelsBrightnessActionBrightnessParamTypeId).value().toInt();
|
||||||
QUuid requestId = nanoleaf->setBrightness(brightness);
|
QUuid requestId = nanoleaf->setBrightness(brightness);
|
||||||
connect(info, &ThingActionInfo::aborted,[requestId, this](){m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [requestId, this](){ m_asyncActions.remove(requestId); });
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
|
|
||||||
} else if (action.actionTypeId() == lightPanelsColorActionTypeId) {
|
} else if (action.actionTypeId() == lightPanelsColorActionTypeId) {
|
||||||
QColor color(action.param(lightPanelsColorActionColorParamTypeId).value().toString());
|
QColor color(action.param(lightPanelsColorActionColorParamTypeId).value().toString());
|
||||||
QUuid requestId = nanoleaf->setColor(color);
|
QUuid requestId = nanoleaf->setColor(color);
|
||||||
connect(info, &ThingActionInfo::aborted,[requestId, this](){m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [requestId, this](){ m_asyncActions.remove(requestId); });
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
|
|
||||||
} else if (action.actionTypeId() == lightPanelsColorTemperatureActionTypeId) {
|
} else if (action.actionTypeId() == lightPanelsColorTemperatureActionTypeId) {
|
||||||
int colorTemperature = action.param(lightPanelsColorTemperatureActionColorTemperatureParamTypeId).value().toInt();
|
int colorTemperature = action.param(lightPanelsColorTemperatureActionColorTemperatureParamTypeId).value().toInt();
|
||||||
QUuid requestId = nanoleaf->setMired(colorTemperature);
|
QUuid requestId = nanoleaf->setMired(colorTemperature);
|
||||||
connect(info, &ThingActionInfo::aborted,[requestId, this](){m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [requestId, this](){ m_asyncActions.remove(requestId); });
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
} else if (action.actionTypeId() == lightPanelsAlertActionTypeId) {
|
} else if (action.actionTypeId() == lightPanelsAlertActionTypeId) {
|
||||||
QUuid requestId = nanoleaf->identify();
|
QUuid requestId = nanoleaf->identify();
|
||||||
connect(info, &ThingActionInfo::aborted,[requestId, this](){m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [requestId, this](){ m_asyncActions.remove(requestId); });
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,12 +31,12 @@
|
|||||||
#ifndef INTEGRATIONPLUGINNANOLEAF_H
|
#ifndef INTEGRATIONPLUGINNANOLEAF_H
|
||||||
#define INTEGRATIONPLUGINNANOLEAF_H
|
#define INTEGRATIONPLUGINNANOLEAF_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
#include "nanoleaf.h"
|
#include <plugintimer.h>
|
||||||
|
#include <network/networkaccessmanager.h>
|
||||||
|
#include <network/zeroconf/zeroconfservicebrowser.h>
|
||||||
|
|
||||||
#include "plugintimer.h"
|
#include "nanoleaf.h"
|
||||||
#include "network/networkaccessmanager.h"
|
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
|
||||||
|
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
ZeroConfServiceBrowser *m_zeroconfBrowser = nullptr;
|
ZeroConfServiceBrowser *m_zeroconfBrowser = nullptr;
|
||||||
PluginTimer *m_pluginTimer = nullptr;
|
PluginTimer *m_pluginTimer = nullptr;
|
||||||
QHash<ThingId, Nanoleaf*> m_nanoleafConnections;
|
QHash<ThingId, Nanoleaf *> m_nanoleafConnections;
|
||||||
QHash<ThingId, Nanoleaf*> m_unfinishedNanoleafConnections;
|
QHash<ThingId, Nanoleaf *> m_unfinishedNanoleafConnections;
|
||||||
QHash<QUuid, ThingActionInfo *> m_asyncActions;
|
QHash<QUuid, ThingActionInfo *> m_asyncActions;
|
||||||
QHash<Nanoleaf *, ThingPairingInfo *> m_unfinishedPairing;
|
QHash<Nanoleaf *, ThingPairingInfo *> m_unfinishedPairing;
|
||||||
QHash<Nanoleaf *, ThingSetupInfo *> m_asyncDeviceSetup;
|
QHash<Nanoleaf *, ThingSetupInfo *> m_asyncDeviceSetup;
|
||||||
|
|||||||
@ -87,7 +87,7 @@ void Nanoleaf::addUser()
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply *reply = m_networkManager->post(request, "");
|
QNetworkReply *reply = m_networkManager->post(request, "");
|
||||||
//qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
//qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -108,7 +108,7 @@ void Nanoleaf::addUser()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_authToken = data.toVariant().toMap().value("auth_token").toString();
|
m_authToken = data.toVariant().toMap().value("auth_token").toString();
|
||||||
@ -129,7 +129,7 @@ void Nanoleaf::deleteUser()
|
|||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
QNetworkReply *reply = m_networkManager->deleteResource(request);
|
QNetworkReply *reply = m_networkManager->deleteResource(request);
|
||||||
//qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
//qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -153,7 +153,7 @@ void Nanoleaf::getControllerInfo()
|
|||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
QNetworkReply *reply = m_networkManager->get(request);
|
QNetworkReply *reply = m_networkManager->get(request);
|
||||||
//qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
//qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -166,7 +166,7 @@ void Nanoleaf::getControllerInfo()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit connectionChanged(true);
|
emit connectionChanged(true);
|
||||||
@ -241,7 +241,7 @@ void Nanoleaf::getPower()
|
|||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
QNetworkReply *reply = m_networkManager->get(request);
|
QNetworkReply *reply = m_networkManager->get(request);
|
||||||
//qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
//qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -254,7 +254,7 @@ void Nanoleaf::getPower()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool power = data.toVariant().toMap().value("value").toBool();
|
bool power = data.toVariant().toMap().value("value").toBool();
|
||||||
@ -274,7 +274,7 @@ void Nanoleaf::getHue()
|
|||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
QNetworkReply *reply = m_networkManager->get(request);
|
QNetworkReply *reply = m_networkManager->get(request);
|
||||||
//qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
//qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -286,7 +286,7 @@ void Nanoleaf::getHue()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int hue = data.toVariant().toMap().value("value").toBool();
|
int hue = data.toVariant().toMap().value("value").toBool();
|
||||||
@ -317,7 +317,7 @@ void Nanoleaf::getBrightness()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int brightness = data.toVariant().toMap().value("value").toInt();
|
int brightness = data.toVariant().toMap().value("value").toInt();
|
||||||
@ -348,7 +348,7 @@ void Nanoleaf::getSaturation()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int brightness = data.toVariant().toMap().value("value").toInt();
|
int brightness = data.toVariant().toMap().value("value").toInt();
|
||||||
@ -380,7 +380,7 @@ void Nanoleaf::getColorTemperature()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int kelvin = data.toVariant().toMap().value("value").toInt();
|
int kelvin = data.toVariant().toMap().value("value").toInt();
|
||||||
@ -412,7 +412,7 @@ void Nanoleaf::getColorMode()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit connectionChanged(true);
|
emit connectionChanged(true);
|
||||||
@ -443,11 +443,11 @@ void Nanoleaf::registerForEvents()
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
QNetworkReply *reply = m_networkManager->get(request);
|
QNetworkReply *reply = m_networkManager->get(request);
|
||||||
|
|
||||||
connect(reply, &QNetworkReply::readyRead, this, [reply, this] {
|
connect(reply, &QNetworkReply::readyRead, this, [reply] {
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qCDebug(dcNanoleaf()) << "On event stream" << data.toJson();
|
qCDebug(dcNanoleaf()) << "On event stream" << data.toJson();
|
||||||
@ -464,7 +464,7 @@ void Nanoleaf::registerForEvents()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qCDebug(dcNanoleaf()) << "Event received" << data.toJson();
|
qCDebug(dcNanoleaf()) << "Event received" << data.toJson();
|
||||||
@ -528,7 +528,7 @@ QUuid Nanoleaf::setPower(bool power)
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
||||||
//qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
//qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -570,7 +570,7 @@ QUuid Nanoleaf::setHue(int hue)
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
||||||
//qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
//qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -604,7 +604,7 @@ QUuid Nanoleaf::setBrightness(int percentage)
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
||||||
//qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
//qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -638,7 +638,7 @@ QUuid Nanoleaf::setSaturation(int percentage)
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
||||||
//qDebug(dcNanoleaf()) << "Sending request" << request.url() << body.toJson();
|
//qCDebug(dcNanoleaf()) << "Sending request" << request.url() << body.toJson();
|
||||||
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -680,7 +680,7 @@ QUuid Nanoleaf::setKelvin(int kelvin)
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
||||||
qDebug(dcNanoleaf()) << "Sending request" << request.url() << body.toJson();
|
qCDebug(dcNanoleaf()) << "Sending request" << request.url() << body.toJson();
|
||||||
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -718,7 +718,7 @@ void Nanoleaf::getEffects()
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
QJsonDocument data = QJsonDocument::fromJson(reply->readAll(), &error);
|
||||||
if (error.error != QJsonParseError::NoError) {
|
if (error.error != QJsonParseError::NoError) {
|
||||||
qDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
qCDebug(dcNanoleaf()) << "Recieved invalide JSON object";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QStringList effects;
|
QStringList effects;
|
||||||
@ -774,7 +774,7 @@ QUuid Nanoleaf::setEffect(const QString &effect)
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
QNetworkReply *reply = m_networkManager->put(request, body.toJson());
|
||||||
qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
@ -802,7 +802,7 @@ QUuid Nanoleaf::identify()
|
|||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json");
|
||||||
QNetworkReply *reply = m_networkManager->put(request, "");
|
QNetworkReply *reply = m_networkManager->put(request, "");
|
||||||
qDebug(dcNanoleaf()) << "Sending request" << request.url();
|
qCDebug(dcNanoleaf()) << "Sending request" << request.url();
|
||||||
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -37,8 +37,8 @@
|
|||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
#include "network/networkaccessmanager.h"
|
#include <network/networkaccessmanager.h>
|
||||||
#include "integrations/thing.h"
|
#include <integrations/thing.h>
|
||||||
|
|
||||||
class Nanoleaf : public QObject
|
class Nanoleaf : public QObject
|
||||||
{
|
{
|
||||||
@ -119,11 +119,11 @@ signals:
|
|||||||
void authenticationStatusChanged(bool authenticated);
|
void authenticationStatusChanged(bool authenticated);
|
||||||
void requestExecuted(QUuid requestId, bool success);
|
void requestExecuted(QUuid requestId, bool success);
|
||||||
|
|
||||||
void controllerInfoReceived(const ControllerInfo &controllerInfo);
|
void controllerInfoReceived(const Nanoleaf::ControllerInfo &controllerInfo);
|
||||||
void authTokenRecieved(const QString &token);
|
void authTokenRecieved(const QString &token);
|
||||||
void powerReceived(bool power);
|
void powerReceived(bool power);
|
||||||
void brightnessReceived(int percentage);
|
void brightnessReceived(int percentage);
|
||||||
void colorModeReceived(ColorMode colorMode);
|
void colorModeReceived(Nanoleaf::ColorMode colorMode);
|
||||||
void hueReceived(int hue);
|
void hueReceived(int hue);
|
||||||
void saturationReceived(int percentage);
|
void saturationReceived(int percentage);
|
||||||
void effectListReceived(const QStringList &effects);
|
void effectListReceived(const QStringList &effects);
|
||||||
@ -132,7 +132,7 @@ signals:
|
|||||||
void selectedEffectReceived(const QString &effect);
|
void selectedEffectReceived(const QString &effect);
|
||||||
|
|
||||||
//Only supported by Canvas
|
//Only supported by Canvas
|
||||||
void touchEventReceived(GestureID gesture);
|
void touchEventReceived(Nanoleaf::GestureID gesture);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NANOLEAF_H
|
#endif // NANOLEAF_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user