diff --git a/plugins/deviceplugins/philipshue/light.cpp b/plugins/deviceplugins/philipshue/light.cpp index d2ac711c..b6d913b8 100644 --- a/plugins/deviceplugins/philipshue/light.cpp +++ b/plugins/deviceplugins/philipshue/light.cpp @@ -179,27 +179,6 @@ void Light::setColor(const QColor &color) quint16 hue = color.hue() * 65535 / 360; quint8 sat = color.saturation(); -// // Transform from RGB to XYZ -// QGenericMatrix<3, 3, qreal> rgb2xyzMatrix; -// rgb2xyzMatrix(0, 0) = 0.412453; rgb2xyzMatrix(0, 1) = 0.357580; rgb2xyzMatrix(0, 2) = 0.180423; -// rgb2xyzMatrix(1, 0) = 0.212671; rgb2xyzMatrix(1, 1) = 0.715160; rgb2xyzMatrix(1, 2) = 0.072169; -// rgb2xyzMatrix(2, 0) = 0.019334; rgb2xyzMatrix(2, 1) = 0.119193; rgb2xyzMatrix(2, 2) = 0.950227; - -// QGenericMatrix<1, 3, qreal> rgbMatrix; -// rgbMatrix(0, 0) = 1.0 * color.red() / 255; -// rgbMatrix(1, 0) = 1.0 * color.green() / 255; -// rgbMatrix(2, 0) = 1.0 * color.blue() / 255; - -// QGenericMatrix<1, 3, qreal> xyzMatrix = rgb2xyzMatrix * rgbMatrix; - -// // transform from XYZ to CIELUV u' and v' -// qreal u = 4*xyzMatrix(0, 0) / (xyzMatrix(0, 0) + 15*xyzMatrix(1, 0) + 3*xyzMatrix(2, 0)); -// qreal v = 9*xyzMatrix(1, 0) / (xyzMatrix(0, 0) + 15*xyzMatrix(1, 0) + 3*xyzMatrix(2, 0)); - - // Transform from CIELUV to (x,y) -// qreal x = 27*u / (18*u - 48*v + 36); -// qreal y = 12*v / (18*u - 48*v + 36); - qDebug() << "setting color" << color; if (m_busyStateChangeId == -1) { QVariantMap params; @@ -210,11 +189,6 @@ void Light::setColor(const QColor &color) // Lets just assume it always succeeds m_sat = sat; -// QVariantList xyList; -// xyList << x << y; -// params.insert("xy", xyList); - - params.insert("on", true); m_busyStateChangeId = m_bridge->put(m_ip, m_username, "lights/" + QString::number(m_id) + "/state", params, this, "setStateFinished"); } else { @@ -222,8 +196,6 @@ void Light::setColor(const QColor &color) m_hueDirty = true; m_dirtySat = sat; m_satDirty = true; -// m_xyDirty = true; -// m_dirtyXy = QPointF(x, y); } } @@ -341,7 +313,7 @@ void Light::responseReceived(int id, const QVariant &response) m_reachable = stateMap.value("reachable").toBool(); emit stateChanged(); -// qDebug() << "got light response" << m_modelId << m_type << m_swversion << m_on << m_bri << m_reachable; + qDebug() << "got light response" << m_modelId << m_type << m_swversion << m_on << m_bri << m_reachable; } void Light::setDescriptionFinished(int id, const QVariant &response) diff --git a/plugins/deviceplugins/wemo/devicepluginwemo.cpp b/plugins/deviceplugins/wemo/devicepluginwemo.cpp index 7057942c..c954984b 100644 --- a/plugins/deviceplugins/wemo/devicepluginwemo.cpp +++ b/plugins/deviceplugins/wemo/devicepluginwemo.cpp @@ -84,20 +84,14 @@ DeviceManager::DeviceError DevicePluginWemo::discoverDevices(const DeviceClassId DeviceManager::DeviceSetupStatus DevicePluginWemo::setupDevice(Device *device) { - if (device->deviceClassId() == wemoSwitchDeviceClassId) { - foreach (Device *d, myDevices()) { - if (d->paramValue("serial number").toString() == device->paramValue("serial number").toString()) { - qWarning() << "WeMo Switch " << device->paramValue("serial number").toString() << " allready added..."; - return DeviceManager::DeviceSetupStatusFailure; - } - } - - device->setName("WeMo Switch (" + device->paramValue("serial number").toString() + ")"); - - refresh(device); - return DeviceManager::DeviceSetupStatusSuccess; + if (device->deviceClassId() != wemoSwitchDeviceClassId) { + return DeviceManager::DeviceSetupStatusFailure; } - return DeviceManager::DeviceSetupStatusFailure; + + device->setName("WeMo Switch (" + device->paramValue("serial number").toString() + ")"); + + refresh(device); + return DeviceManager::DeviceSetupStatusSuccess; } DeviceManager::HardwareResources DevicePluginWemo::requiredHardware() const @@ -126,11 +120,6 @@ DeviceManager::DeviceError DevicePluginWemo::executeAction(Device *device, const } } - // Rediscover - if (action.actionTypeId() == rediscoverActionTypeId) { - upnpDiscover("upnp:rootdevice"); - return DeviceManager::DeviceErrorNoError; - } return DeviceManager::DeviceErrorActionTypeNotFound; } @@ -197,16 +186,14 @@ void DevicePluginWemo::upnpDiscoveryFinished(const QList & QList deviceDescriptors; foreach (UpnpDeviceDescriptor upnpDeviceDescriptor, upnpDeviceDescriptorList) { if (upnpDeviceDescriptor.friendlyName() == "WeMo Switch") { - if (!verifyExistingDevices(upnpDeviceDescriptor)) { - DeviceDescriptor descriptor(wemoSwitchDeviceClassId, "WemoSwitch", upnpDeviceDescriptor.serialNumber()); - ParamList params; - params.append(Param("name", upnpDeviceDescriptor.friendlyName())); - params.append(Param("host address", upnpDeviceDescriptor.hostAddress().toString())); - params.append(Param("port", upnpDeviceDescriptor.port())); - params.append(Param("serial number", upnpDeviceDescriptor.serialNumber())); - descriptor.setParams(params); - deviceDescriptors.append(descriptor); - } + DeviceDescriptor descriptor(wemoSwitchDeviceClassId, "WemoSwitch", upnpDeviceDescriptor.serialNumber()); + ParamList params; + params.append(Param("name", upnpDeviceDescriptor.friendlyName())); + params.append(Param("host address", upnpDeviceDescriptor.hostAddress().toString())); + params.append(Param("port", upnpDeviceDescriptor.port())); + params.append(Param("serial number", upnpDeviceDescriptor.serialNumber())); + descriptor.setParams(params); + deviceDescriptors.append(descriptor); } } emit devicesDiscovered(wemoSwitchDeviceClassId, deviceDescriptors); @@ -217,30 +204,6 @@ void DevicePluginWemo::upnpNotifyReceived(const QByteArray ¬ifyData) Q_UNUSED(notifyData); } -bool DevicePluginWemo::verifyExistingDevices(UpnpDeviceDescriptor deviceDescriptor) -{ - foreach (Device* device, myDevices()) { - // check if we allready have added this Wemo device and verify the params - if (device->paramValue("serial number").toString() == deviceDescriptor.serialNumber()) { - qDebug() << "verify wemo paramters... of" << deviceDescriptor.serialNumber(); - // now check if ip or port changed - bool somethingChanged = false; - if (device->paramValue("host address").toString() != deviceDescriptor.hostAddress().toString()) { - device->setParamValue("host address", deviceDescriptor.hostAddress().toString()); - somethingChanged = true; - } - if(device->paramValue("port").toInt() != deviceDescriptor.port()){ - device->setParamValue("port", deviceDescriptor.port()); - somethingChanged = true; - } - if (somethingChanged) { - refresh(device); - } - return true; - } - } - return false; -} void DevicePluginWemo::refresh(Device *device) { @@ -277,6 +240,7 @@ bool DevicePluginWemo::setPower(Device *device, const bool &power, const ActionI return true; } + void DevicePluginWemo::processRefreshData(const QByteArray &data, Device *device) { if (data.contains("0")) { diff --git a/plugins/deviceplugins/wemo/devicepluginwemo.h b/plugins/deviceplugins/wemo/devicepluginwemo.h index fe3a1211..3b582f3b 100644 --- a/plugins/deviceplugins/wemo/devicepluginwemo.h +++ b/plugins/deviceplugins/wemo/devicepluginwemo.h @@ -49,7 +49,6 @@ private: QHash m_refreshReplies; QHash m_setPowerReplies; QHash m_runningActionExecutions; - bool verifyExistingDevices(UpnpDeviceDescriptor deviceDescriptor); void refresh(Device* device); bool setPower(Device *device, const bool &power, const ActionId &actionId); diff --git a/plugins/deviceplugins/wemo/devicepluginwemo.json b/plugins/deviceplugins/wemo/devicepluginwemo.json index 57145247..6d0c742c 100644 --- a/plugins/deviceplugins/wemo/devicepluginwemo.json +++ b/plugins/deviceplugins/wemo/devicepluginwemo.json @@ -49,13 +49,6 @@ "type": "bool", "defaultValue": false } - ], - "actionTypes": [ - { - "id": "269cf3b8-d4dd-42e9-8309-6cb3ca8842df", - "idName": "rediscover", - "name": "rediscover" - } ] } ]