diff --git a/nanoleaf/devicepluginnanoleaf.cpp b/nanoleaf/devicepluginnanoleaf.cpp index bd68ef87..727d859c 100644 --- a/nanoleaf/devicepluginnanoleaf.cpp +++ b/nanoleaf/devicepluginnanoleaf.cpp @@ -428,9 +428,11 @@ void DevicePluginNanoleaf::onColorTemperatureReceived(int kelvin) Device *device = myDevices().findById(m_nanoleafConnections.key(nanoleaf)); if (!device) return; - //qCDebug(dcNanoleaf()) << "Color temperature received" << kelvin; + qCDebug(dcNanoleaf()) << "Color temperature received, Kelvin:" << kelvin << "Mired:" << (653-(kelvin/13)); //NOTE: this is just a rough estimation of the mired value - int mired = static_cast(kelvin/11.12); //FIXME + //Mired: 153 - 500 + //Kelvin: 1200-6500 + int mired = static_cast(653-(kelvin/13)); device->setStateValue(lightPanelsColorTemperatureStateTypeId, mired); } diff --git a/nanoleaf/nanoleaf.cpp b/nanoleaf/nanoleaf.cpp index 3cc4648e..28f1d149 100644 --- a/nanoleaf/nanoleaf.cpp +++ b/nanoleaf/nanoleaf.cpp @@ -636,7 +636,7 @@ QUuid Nanoleaf::setSaturation(int percentage) request.setUrl(url); request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json"); QNetworkReply *reply = m_networkManager->put(request, body.toJson()); - qDebug(dcNanoleaf()) << "Sending request" << request.url() << body.toJson(); + //qDebug(dcNanoleaf()) << "Sending request" << request.url() << body.toJson(); connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] { reply->deleteLater(); int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); @@ -653,8 +653,8 @@ QUuid Nanoleaf::setSaturation(int percentage) QUuid Nanoleaf::setMired(int mired) { - //NOTE: this is just a rough estimation - int kelvin = static_cast(mired * 11.12); + //NOTE: this is just a rough conversion between mired and kelvin + int kelvin = static_cast((653-mired) * 13); QUuid requestId = setKelvin(kelvin); return requestId; } @@ -678,7 +678,7 @@ QUuid Nanoleaf::setKelvin(int kelvin) request.setUrl(url); request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader, "application/json"); QNetworkReply *reply = m_networkManager->put(request, body.toJson()); - qDebug(dcNanoleaf()) << "Sending request" << request.url(); + qDebug(dcNanoleaf()) << "Sending request" << request.url() << body.toJson(); connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] { reply->deleteLater(); int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();