fixed color temperture conversion
This commit is contained in:
parent
a642f25988
commit
38e0791ffa
@ -428,9 +428,11 @@ void DevicePluginNanoleaf::onColorTemperatureReceived(int kelvin)
|
|||||||
Device *device = myDevices().findById(m_nanoleafConnections.key(nanoleaf));
|
Device *device = myDevices().findById(m_nanoleafConnections.key(nanoleaf));
|
||||||
if (!device)
|
if (!device)
|
||||||
return;
|
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
|
//NOTE: this is just a rough estimation of the mired value
|
||||||
int mired = static_cast<int>(kelvin/11.12); //FIXME
|
//Mired: 153 - 500
|
||||||
|
//Kelvin: 1200-6500
|
||||||
|
int mired = static_cast<int>(653-(kelvin/13));
|
||||||
device->setStateValue(lightPanelsColorTemperatureStateTypeId, mired);
|
device->setStateValue(lightPanelsColorTemperatureStateTypeId, mired);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -636,7 +636,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();
|
//qDebug(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();
|
||||||
@ -653,8 +653,8 @@ QUuid Nanoleaf::setSaturation(int percentage)
|
|||||||
|
|
||||||
QUuid Nanoleaf::setMired(int mired)
|
QUuid Nanoleaf::setMired(int mired)
|
||||||
{
|
{
|
||||||
//NOTE: this is just a rough estimation
|
//NOTE: this is just a rough conversion between mired and kelvin
|
||||||
int kelvin = static_cast<int>(mired * 11.12);
|
int kelvin = static_cast<int>((653-mired) * 13);
|
||||||
QUuid requestId = setKelvin(kelvin);
|
QUuid requestId = setKelvin(kelvin);
|
||||||
return requestId;
|
return requestId;
|
||||||
}
|
}
|
||||||
@ -678,7 +678,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();
|
qDebug(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();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user