mirror of https://github.com/nymea/nymea.git
fix tune plugin and some hue modifications
parent
4e09d25296
commit
f2baa2659b
|
|
@ -187,6 +187,7 @@ void Device::setStateValue(const StateTypeId &stateTypeId, const QVariant &value
|
|||
for (int i = 0; i < m_states.count(); ++i) {
|
||||
if (m_states.at(i).stateTypeId() == stateTypeId) {
|
||||
if (m_states.at(i).value() == value) {
|
||||
//qDebug() << name() << m_states.at(i).value() << "-----> value unchanged";
|
||||
return;
|
||||
}
|
||||
State newState(stateTypeId, m_id);
|
||||
|
|
|
|||
|
|
@ -106,8 +106,6 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::discoverDevices(const DeviceC
|
|||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *device)
|
||||
{
|
||||
qDebug() << "setupDevice" << device->params();
|
||||
|
||||
Light *light = nullptr;
|
||||
|
||||
// Lets see if this a a newly added device... In which case its hue id number is not set, well, -1...
|
||||
|
|
@ -283,11 +281,6 @@ void DevicePluginPhilipsHue::getLightsFinished(int id, const QVariant ¶ms)
|
|||
}
|
||||
|
||||
emit pairingFinished(pairingInfo.pairingTransactionId, DeviceManager::DeviceSetupStatusSuccess);
|
||||
|
||||
// If we have more than one device on that bridge, tell DeviceManager that there are more.
|
||||
if (params.toMap().count() > 1) {
|
||||
// emit autoDevicesAppeared();
|
||||
}
|
||||
}
|
||||
|
||||
void DevicePluginPhilipsHue::getFinished(int id, const QVariant ¶ms)
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ void HueBridgeConnection::slotCreateUserFinished()
|
|||
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||
|
||||
qDebug() << jsonDoc.toJson();
|
||||
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
QVariantMap params;
|
||||
QVariantMap errorMap;
|
||||
|
|
@ -119,6 +122,7 @@ void HueBridgeConnection::slotGetFinished()
|
|||
|
||||
QJsonParseError error;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||
|
||||
if (error.error != QJsonParseError::NoError) {
|
||||
QVariantMap params;
|
||||
QVariantMap errorMap;
|
||||
|
|
@ -128,6 +132,10 @@ void HueBridgeConnection::slotGetFinished()
|
|||
return;
|
||||
}
|
||||
|
||||
if (jsonDoc.toJson().contains("error")){
|
||||
qDebug() << jsonDoc.toJson();
|
||||
}
|
||||
|
||||
QVariant response = jsonDoc.toVariant();
|
||||
emit getFinished(c.id, response.toMap());
|
||||
if (c.obj) {
|
||||
|
|
|
|||
|
|
@ -132,8 +132,13 @@ void Light::setBri(quint8 bri)
|
|||
qDebug() << "setting brightness to" << bri << m_busyStateChangeId;
|
||||
if (m_busyStateChangeId == -1) {
|
||||
QVariantMap params;
|
||||
params.insert("bri", bri);
|
||||
params.insert("on", true);
|
||||
if (bri == 0) {
|
||||
params.insert("bri", bri);
|
||||
params.insert("on", false);
|
||||
} else {
|
||||
params.insert("bri", bri);
|
||||
params.insert("on", true);
|
||||
}
|
||||
m_busyStateChangeId = m_bridge->put(m_ip, m_username, "lights/" + QString::number(m_id) + "/state", params, this, "setStateFinished");
|
||||
} else {
|
||||
m_dirtyBri = bri;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ void DevicePluginTune::tuneAutodetected()
|
|||
QList<DeviceDescriptor> descriptorList;
|
||||
DeviceDescriptor descriptor(tuneDeviceClassId);
|
||||
ParamList params;
|
||||
params.append(Param("name", "Wohnzimmer"));
|
||||
params.append(Param("name", "Living room"));
|
||||
descriptor.setParams(params);
|
||||
descriptorList.append(descriptor);
|
||||
metaObject()->invokeMethod(this, "autoDevicesAppeared", Qt::QueuedConnection, Q_ARG(DeviceClassId, tuneDeviceClassId), Q_ARG(QList<DeviceDescriptor>, descriptorList));
|
||||
|
|
@ -151,9 +151,11 @@ void DevicePluginTune::tuneConnectionStatusChanged(const bool &connected)
|
|||
void DevicePluginTune::updateMood(const QVariantMap &message)
|
||||
{
|
||||
QVariantMap mood = message.value("mood").toMap();
|
||||
qDebug () << QJsonDocument::fromVariant(message).toJson();
|
||||
Device *device = deviceManager()->findConfiguredDevice(DeviceId(mood.value("deviceId").toString()));
|
||||
if (device) {
|
||||
QVariantMap states = mood.value("states").toMap();
|
||||
//qDebug() << "======>" << device->name() << states.value("active").toBool() << states.value("value").toInt();
|
||||
device->setStateValue(activeStateTypeId, states.value("active").toBool());
|
||||
device->setStateValue(valueStateTypeId, states.value("value").toInt());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ JsonRpcServer::JsonRpcServer(QObject *parent) :
|
|||
|
||||
connect(m_manager, &TuneManager::tuneConnectionStatusChanged, this, &JsonRpcServer::connectionStatusChanged);
|
||||
connect(m_manager, &TuneManager::dataReady, this, &JsonRpcServer::processData);
|
||||
|
||||
}
|
||||
|
||||
void JsonRpcServer::start()
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QJsonDocument>
|
||||
#include <QTimer>
|
||||
|
||||
#include "tunemanager.h"
|
||||
#include "plugin/device.h"
|
||||
|
|
|
|||
|
|
@ -100,14 +100,14 @@ bool TuneManager::start()
|
|||
delete m_server;
|
||||
return false;
|
||||
}
|
||||
qDebug() << " --> Tune server started" << localhost << m_port;
|
||||
qDebug() << "--> Tune server started" << localhost << m_port;
|
||||
connect(m_server, &QTcpServer::newConnection, this, &TuneManager::tuneConnected);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TuneManager::stop()
|
||||
{
|
||||
qDebug() << " --> close Tune server" << m_server->serverAddress().toString();
|
||||
qDebug() << "--> close Tune server" << m_server->serverAddress().toString();
|
||||
m_server->close();
|
||||
delete m_server;
|
||||
m_server = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue