mirror of
https://github.com/nymea/nymea-plugins.git
synced 2026-08-05 03:33:51 +02:00
moved set name function
This commit is contained in:
parent
f3e003eae2
commit
480caee01f
@ -197,6 +197,41 @@ void BridgeConnection::setFlash(const QString &uuid, const QString &mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void BridgeConnection::setLightName(const QString &uuid, const QString &name)
|
||||||
|
{
|
||||||
|
HueLight *light = m_lights.value(uuid);
|
||||||
|
|
||||||
|
QVariantMap requestMap;
|
||||||
|
requestMap.insert("name", name);
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromVariant(requestMap);
|
||||||
|
|
||||||
|
QNetworkRequest request(QUrl("http://" + light->hostAddress().toString() + "/api/" + light->apiKey() +
|
||||||
|
"/lights/" + QString::number(light->id())));
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
|
|
||||||
|
QNetworkReply *reply = m_hardwareManager->networkManager()->put(request,jsonDoc.toJson());
|
||||||
|
connect(reply, &QNetworkReply::finished, this, &BridgeConnection::networkManagerReplyReady);
|
||||||
|
//m_setNameRequests.insert(reply, device);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BridgeConnection::setRemoteName(const QString &uuid, const QString &name)
|
||||||
|
{
|
||||||
|
HueRemote *remote = m_remotes.balue(uuid);
|
||||||
|
|
||||||
|
QVariantMap requestMap;
|
||||||
|
requestMap.insert("name", device->name());
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromVariant(requestMap);
|
||||||
|
|
||||||
|
QNetworkRequest request(QUrl("http://" + remote->hostAddress().toString() + "/api/" + remote->apiKey() +
|
||||||
|
"/sensors/" + QString::number(remote->id())));
|
||||||
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
|
|
||||||
|
QNetworkReply *reply = m_hardwareManager->networkManager()->put(request,jsonDoc.toJson());
|
||||||
|
connect(reply, &QNetworkReply::finished, this, &BridgeConnection::networkManagerReplyReady);
|
||||||
|
//m_setNameRequests.insert(reply, device);
|
||||||
|
}
|
||||||
|
|
||||||
void BridgeConnection::processLightRefreshResponse(QString uuid, const QByteArray &data)
|
void BridgeConnection::processLightRefreshResponse(QString uuid, const QByteArray &data)
|
||||||
{
|
{
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
|
|||||||
@ -60,8 +60,8 @@ public:
|
|||||||
void setFlash(const QString &uuid, const QString &flashMode);
|
void setFlash(const QString &uuid, const QString &flashMode);
|
||||||
void setTemperature(const QString &uuid, quint16 temperature);
|
void setTemperature(const QString &uuid, quint16 temperature);
|
||||||
|
|
||||||
void setLightName();
|
void setLightName(const QString &uuid, const QString &name);
|
||||||
void setRemoteName();
|
void setRemoteName(const QString &uuid, const QString &name);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void lightStateChanged();
|
void lightStateChanged();
|
||||||
|
|||||||
@ -770,39 +770,6 @@ void DevicePluginPhilipsHue::onMotionSensorLightIntensityChanged(double lightInt
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DevicePluginPhilipsHue::setLightName(Device *device)
|
|
||||||
{
|
|
||||||
HueLight *light = m_lights.key(device);
|
|
||||||
|
|
||||||
QVariantMap requestMap;
|
|
||||||
requestMap.insert("name", device->name());
|
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromVariant(requestMap);
|
|
||||||
|
|
||||||
QNetworkRequest request(QUrl("http://" + light->hostAddress().toString() + "/api/" + light->apiKey() +
|
|
||||||
"/lights/" + QString::number(light->id())));
|
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
||||||
|
|
||||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request,jsonDoc.toJson());
|
|
||||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
|
||||||
m_setNameRequests.insert(reply, device);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginPhilipsHue::setRemoteName(Device *device)
|
|
||||||
{
|
|
||||||
HueRemote *remote = m_remotes.key(device);
|
|
||||||
|
|
||||||
QVariantMap requestMap;
|
|
||||||
requestMap.insert("name", device->name());
|
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromVariant(requestMap);
|
|
||||||
|
|
||||||
QNetworkRequest request(QUrl("http://" + remote->hostAddress().toString() + "/api/" + remote->apiKey() +
|
|
||||||
"/sensors/" + QString::number(remote->id())));
|
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
||||||
|
|
||||||
QNetworkReply *reply = hardwareManager()->networkManager()->put(request,jsonDoc.toJson());
|
|
||||||
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
|
|
||||||
m_setNameRequests.insert(reply, device);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginPhilipsHue::processBridgeLightDiscoveryResponse(Device *device, const QByteArray &data)
|
void DevicePluginPhilipsHue::processBridgeLightDiscoveryResponse(Device *device, const QByteArray &data)
|
||||||
{
|
{
|
||||||
@ -1056,7 +1023,6 @@ void DevicePluginPhilipsHue::processBridgeSensorDiscoveryResponse(Device *device
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DevicePluginPhilipsHue::processPairingResponse(PairingInfo *pairingInfo, const QByteArray &data)
|
void DevicePluginPhilipsHue::processPairingResponse(PairingInfo *pairingInfo, const QByteArray &data)
|
||||||
{
|
{
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
@ -1284,25 +1250,5 @@ bool DevicePluginPhilipsHue::sensorAlreadyAdded(const QString &uuid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DevicePluginPhilipsHue::brightnessToPercentage(int brightness)
|
|
||||||
{
|
|
||||||
return qRound((100.0 * brightness) / 255.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int DevicePluginPhilipsHue::percentageToBrightness(int percentage)
|
|
||||||
{
|
|
||||||
return qRound((255.0 * percentage) / 100.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginPhilipsHue::abortRequests(QHash<QNetworkReply *, Device *> requestList, Device *device)
|
|
||||||
{
|
|
||||||
foreach (QNetworkReply* reply, requestList.keys()) {
|
|
||||||
if (requestList.value(reply) == device) {
|
|
||||||
reply->abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user