From dab02323a58ced70365b1bee9f4350280a1668bc Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 8 Oct 2018 18:36:47 +0200 Subject: [PATCH] update all plugins accordng to same named branch in core --- avahimonitor/devicepluginavahimonitor.cpp | 8 +- awattar/devicepluginawattar.cpp | 18 +- .../deviceplugincommandlauncher.cpp | 6 +- datetime/deviceplugindatetime.cpp | 44 +- denon/deviceplugindenon.cpp | 16 +- dweetio/deviceplugindweetio.cpp | 16 +- elgato/devicepluginelgato.cpp | 28 +- elro/devicepluginelro.cpp | 26 +- eq-3/deviceplugineq-3.cpp | 64 +-- flowercare/devicepluginflowercare.cpp | 10 +- gpio/deviceplugingpio.cpp | 44 +- httpcommander/devicepluginhttpcommander.cpp | 22 +- intertechno/devicepluginintertechno.cpp | 10 +- keba/devicepluginkeba.cpp | 18 +- kodi/devicepluginkodi.cpp | 26 +- leynew/devicepluginleynew.cpp | 8 +- lgsmarttv/devicepluginlgsmarttv.cpp | 48 +-- .../devicepluginmailnotification.cpp | 40 +- netatmo/devicepluginnetatmo.cpp | 28 +- .../devicepluginnetworkdetector.cpp | 12 +- nymea-plugins.pro | 6 +- openweathermap/devicepluginopenweathermap.cpp | 10 +- orderbutton/devicepluginorderbutton.cpp | 32 +- osdomotics/devicepluginosdomotics.cpp | 30 +- philipshue/devicepluginphilipshue.cpp | 385 +++++++++--------- philipshue/devicepluginphilipshue.json | 30 +- plantcare/devicepluginplantcare.cpp | 40 +- remotessh/devicepluginremotessh.cpp | 12 +- senic/devicepluginsenic.cpp | 30 +- simulation/devicepluginsimulation.cpp | 40 +- snapd/devicepluginsnapd.cpp | 34 +- tcpcommander/deviceplugintcpcommander.cpp | 28 +- udpcommander/devicepluginudpcommander.cpp | 12 +- unitec/devicepluginunitec.cpp | 24 +- wakeonlan/devicepluginwakeonlan.cpp | 2 +- wemo/devicepluginwemo.cpp | 14 +- ws2812/devicepluginws2812.cpp | 108 ++--- 37 files changed, 662 insertions(+), 667 deletions(-) diff --git a/avahimonitor/devicepluginavahimonitor.cpp b/avahimonitor/devicepluginavahimonitor.cpp index b4574808..46c64a1b 100644 --- a/avahimonitor/devicepluginavahimonitor.cpp +++ b/avahimonitor/devicepluginavahimonitor.cpp @@ -79,8 +79,8 @@ DeviceManager::DeviceError DevicePluginAvahiMonitor::discoverDevices(const Devic foreach (const AvahiServiceEntry &service, hardwareManager()->avahiBrowser()->serviceEntries()) { DeviceDescriptor deviceDescriptor(avahiDeviceClassId, service.name(), service.hostAddress().toString()); ParamList params; - params.append(Param(avahiServiceParamTypeId, service.name())); - params.append(Param(avahiHostNameParamTypeId, service.hostName())); + params.append(Param(avahiDeviceServiceParamTypeId, service.name())); + params.append(Param(avahiDeviceHostNameParamTypeId, service.hostName())); deviceDescriptor.setParams(params); deviceDescriptors.append(deviceDescriptor); } @@ -93,7 +93,7 @@ DeviceManager::DeviceError DevicePluginAvahiMonitor::discoverDevices(const Devic void DevicePluginAvahiMonitor::onServiceEntryAdded(const AvahiServiceEntry &serviceEntry) { foreach (Device *device, myDevices()) { - if (device->paramValue(avahiServiceParamTypeId).toString() == serviceEntry.name()) { + if (device->paramValue(avahiDeviceServiceParamTypeId).toString() == serviceEntry.name()) { device->setStateValue(avahiOnlineStateTypeId, true); } } @@ -102,7 +102,7 @@ void DevicePluginAvahiMonitor::onServiceEntryAdded(const AvahiServiceEntry &serv void DevicePluginAvahiMonitor::onServiceEntryRemoved(const AvahiServiceEntry &serviceEntry) { foreach (Device *device, myDevices()) { - if (device->paramValue(avahiServiceParamTypeId).toString() == serviceEntry.name()) { + if (device->paramValue(avahiDeviceServiceParamTypeId).toString() == serviceEntry.name()) { device->setStateValue(avahiOnlineStateTypeId, false); } } diff --git a/awattar/devicepluginawattar.cpp b/awattar/devicepluginawattar.cpp index 96ed5627..9aca0d02 100644 --- a/awattar/devicepluginawattar.cpp +++ b/awattar/devicepluginawattar.cpp @@ -100,8 +100,8 @@ DeviceManager::DeviceSetupStatus DevicePluginAwattar::setupDevice(Device *device qCDebug(dcAwattar) << "Setup device" << device->name() << device->params(); - m_token = device->paramValue(awattarTokenParamTypeId).toString(); - m_userUuid = device->paramValue(awattarUserUuidParamTypeId).toString(); + m_token = device->paramValue(awattarDeviceTokenParamTypeId).toString(); + m_userUuid = device->paramValue(awattarDeviceUserUuidParamTypeId).toString(); m_device = device; if (m_token.isEmpty() || m_userUuid.isEmpty()) { @@ -124,7 +124,7 @@ void DevicePluginAwattar::deviceRemoved(Device *device) Q_UNUSED(device) qDeleteAll(m_heatPumps); m_heatPumps.clear(); - m_device = 0; + m_device = nullptr; } DeviceManager::DeviceError DevicePluginAwattar::executeAction(Device *device, const Action &action) @@ -133,9 +133,9 @@ DeviceManager::DeviceError DevicePluginAwattar::executeAction(Device *device, co return DeviceManager::DeviceErrorHardwareNotAvailable; if (action.actionTypeId() == awattarSgSyncModeActionTypeId) { - qCDebug(dcAwattar) << "Set sg sync mode to" << action.param(awattarSgSyncModeActionParamTypeId).value(); - device->setStateValue(awattarSgSyncModeStateTypeId, action.param(awattarSgSyncModeActionParamTypeId).value()); - if (action.param(awattarSgSyncModeActionParamTypeId).value() == "auto") + qCDebug(dcAwattar) << "Set sg sync mode to" << action.param(awattarSgSyncModeActionSgSyncModeParamTypeId).value(); + device->setStateValue(awattarSgSyncModeStateTypeId, action.param(awattarSgSyncModeActionSgSyncModeParamTypeId).value()); + if (action.param(awattarSgSyncModeActionSgSyncModeParamTypeId).value() == "auto") setSgMode(m_autoSgMode); return DeviceManager::DeviceErrorNoError; @@ -146,7 +146,7 @@ DeviceManager::DeviceError DevicePluginAwattar::executeAction(Device *device, co } device->setStateValue(awattarSgSyncModeStateTypeId, "manual"); - QString sgModeString = action.param(awattarSgModeParamTypeId).value().toString(); + QString sgModeString = action.param(awattarSetSgModeActionSgModeParamTypeId).value().toString(); qCDebug(dcAwattar) << "Set manual SG mode to:" << sgModeString; if(sgModeString == "1 - Off") { @@ -198,10 +198,10 @@ void DevicePluginAwattar::updateData() void DevicePluginAwattar::searchHeatPumps() { - QHostAddress rplAddress = QHostAddress(configuration().paramValue(awattarRplParamTypeId).toString()); + QHostAddress rplAddress = QHostAddress(configuration().paramValue(awattarPluginRplParamTypeId).toString()); if (rplAddress.isNull()) { - qCWarning(dcAwattar) << "Invalid RPL address" << configuration().paramValue(awattarRplParamTypeId).toString(); + qCWarning(dcAwattar) << "Invalid RPL address" << configuration().paramValue(awattarPluginRplParamTypeId).toString(); return; } diff --git a/commandlauncher/deviceplugincommandlauncher.cpp b/commandlauncher/deviceplugincommandlauncher.cpp index 3ab244d2..100d96ae 100644 --- a/commandlauncher/deviceplugincommandlauncher.cpp +++ b/commandlauncher/deviceplugincommandlauncher.cpp @@ -117,7 +117,7 @@ DeviceManager::DeviceSetupStatus DevicePluginCommandLauncher::setupDevice(Device // Script if(device->deviceClassId() == scriptDeviceClassId){ - QStringList scriptArguments = device->paramValue(scriptScriptParamTypeId).toString().split(QRegExp("[ \r\n][ \r\n]*")); + QStringList scriptArguments = device->paramValue(scriptDeviceScriptParamTypeId).toString().split(QRegExp("[ \r\n][ \r\n]*")); // check if script exists and if it is executable QFileInfo fileInfo(scriptArguments.first()); if (!fileInfo.exists()) { @@ -156,7 +156,7 @@ DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *de m_applications.insert(process, device); m_startingApplications.insert(process, action.id()); - process->start("/bin/bash", QStringList() << "-c" << device->paramValue(applicationCommandParamTypeId).toString()); + process->start("/bin/bash", QStringList() << "-c" << device->paramValue(applicationDeviceCommandParamTypeId).toString()); return DeviceManager::DeviceErrorAsync; } @@ -191,7 +191,7 @@ DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *de m_scripts.insert(process, device); m_startingScripts.insert(process, action.id()); - process->start("/bin/bash", QStringList() << device->paramValue(scriptScriptParamTypeId).toString()); + process->start("/bin/bash", QStringList() << device->paramValue(scriptDeviceScriptParamTypeId).toString()); return DeviceManager::DeviceErrorAsync; } diff --git a/datetime/deviceplugindatetime.cpp b/datetime/deviceplugindatetime.cpp index 49a64115..59bad2f8 100644 --- a/datetime/deviceplugindatetime.cpp +++ b/datetime/deviceplugindatetime.cpp @@ -103,8 +103,8 @@ #include DevicePluginDateTime::DevicePluginDateTime() : - m_timer(0), - m_todayDevice(0), + m_timer(nullptr), + m_todayDevice(nullptr), m_timeZone(QTimeZone(QTimeZone::systemTimeZoneId())), m_dusk(QDateTime()), m_sunrise(QDateTime()), @@ -142,17 +142,17 @@ DeviceManager::DeviceSetupStatus DevicePluginDateTime::setupDevice(Device *devic if (device->deviceClassId() == alarmDeviceClassId) { Alarm *alarm = new Alarm(this); alarm->setName(device->name()); - alarm->setMonday(device->paramValue(alarmMondayParamTypeId).toBool()); - alarm->setTuesday(device->paramValue(alarmTuesdayParamTypeId).toBool()); - alarm->setWednesday(device->paramValue(alarmWednesdayParamTypeId).toBool()); - alarm->setThursday(device->paramValue(alarmThursdayParamTypeId).toBool()); - alarm->setFriday(device->paramValue(alarmFridayParamTypeId).toBool()); - alarm->setSaturday(device->paramValue(alarmSaturdayParamTypeId).toBool()); - alarm->setSunday(device->paramValue(alarmSundayParamTypeId).toBool()); - alarm->setMinutes(device->paramValue(alarmMinutesParamTypeId).toInt()); - alarm->setHours(device->paramValue(alarmHoursParamTypeId).toInt()); - alarm->setTimeType(device->paramValue(alarmTimeTypeParamTypeId).toString()); - alarm->setOffset(device->paramValue(alarmOffsetParamTypeId).toInt()); + alarm->setMonday(device->paramValue(alarmDeviceMondayParamTypeId).toBool()); + alarm->setTuesday(device->paramValue(alarmDeviceTuesdayParamTypeId).toBool()); + alarm->setWednesday(device->paramValue(alarmDeviceWednesdayParamTypeId).toBool()); + alarm->setThursday(device->paramValue(alarmDeviceThursdayParamTypeId).toBool()); + alarm->setFriday(device->paramValue(alarmDeviceFridayParamTypeId).toBool()); + alarm->setSaturday(device->paramValue(alarmDeviceSaturdayParamTypeId).toBool()); + alarm->setSunday(device->paramValue(alarmDeviceSundayParamTypeId).toBool()); + alarm->setMinutes(device->paramValue(alarmDeviceMinutesParamTypeId).toInt()); + alarm->setHours(device->paramValue(alarmDeviceHoursParamTypeId).toInt()); + alarm->setTimeType(device->paramValue(alarmDeviceTimeTypeParamTypeId).toString()); + alarm->setOffset(device->paramValue(alarmDeviceOffsetParamTypeId).toInt()); alarm->setDusk(m_dusk); alarm->setSunrise(m_sunrise); alarm->setNoon(m_noon); @@ -166,10 +166,10 @@ DeviceManager::DeviceSetupStatus DevicePluginDateTime::setupDevice(Device *devic if (device->deviceClassId() == countdownDeviceClassId) { Countdown *countdown = new Countdown(device->name(), - QTime(device->paramValue(countdownHoursParamTypeId).toInt(), - device->paramValue(countdownMinutesParamTypeId).toInt(), - device->paramValue(countdownSecondsParamTypeId).toInt()), - device->paramValue(countdownRepeatingParamTypeId).toBool()); + QTime(device->paramValue(countdownDeviceHoursParamTypeId).toInt(), + device->paramValue(countdownDeviceMinutesParamTypeId).toInt(), + device->paramValue(countdownDeviceSecondsParamTypeId).toInt()), + device->paramValue(countdownDeviceRepeatingParamTypeId).toBool()); connect(countdown, &Countdown::countdownTimeout, this, &DevicePluginDateTime::onCountdownTimeout); connect(countdown, &Countdown::runningStateChanged, this, &DevicePluginDateTime::onCountdownRunningChanged); @@ -203,7 +203,7 @@ void DevicePluginDateTime::deviceRemoved(Device *device) // date if (device->deviceClassId() == todayDeviceClassId) { - m_todayDevice = 0; + m_todayDevice = nullptr; } // alarm @@ -254,7 +254,7 @@ void DevicePluginDateTime::startMonitoringAutoDevices() void DevicePluginDateTime::searchGeoLocation() { - if (m_todayDevice == 0) + if (!m_todayDevice) return; QNetworkRequest request; @@ -454,7 +454,7 @@ void DevicePluginDateTime::onDayChanged(const QDateTime &dateTime) { qCDebug(dcDateTime) << "day changed" << dateTime.toString(); - if (m_todayDevice == 0) + if (!m_todayDevice) return; m_todayDevice->setStateValue(todayDayStateTypeId, dateTime.date().day()); @@ -482,7 +482,7 @@ void DevicePluginDateTime::updateTimes() } // date - if (m_todayDevice == 0) + if (!m_todayDevice) return; if (m_dusk.isValid()) { @@ -515,7 +515,7 @@ void DevicePluginDateTime::updateTimes() void DevicePluginDateTime::validateTimeTypes(const QDateTime &dateTime) { - if (m_todayDevice == 0) + if (!m_todayDevice) return; if (dateTime == m_dusk) { diff --git a/denon/deviceplugindenon.cpp b/denon/deviceplugindenon.cpp index 8c945c56..4001c7e6 100644 --- a/denon/deviceplugindenon.cpp +++ b/denon/deviceplugindenon.cpp @@ -64,7 +64,7 @@ void DevicePluginDenon::init() DeviceManager::DeviceSetupStatus DevicePluginDenon::setupDevice(Device *device) { - qCDebug(dcDenon) << "Setup Denon device" << device->paramValue(AVRX1000IpParamTypeId).toString(); + qCDebug(dcDenon) << "Setup Denon device" << device->paramValue(AVRX1000DeviceIpParamTypeId).toString(); // Check if we already have a denon device if (!myDevices().isEmpty()) { @@ -72,9 +72,9 @@ DeviceManager::DeviceSetupStatus DevicePluginDenon::setupDevice(Device *device) return DeviceManager::DeviceSetupStatusFailure; } - QHostAddress address(device->paramValue(AVRX1000IpParamTypeId).toString()); + QHostAddress address(device->paramValue(AVRX1000DeviceIpParamTypeId).toString()); if (address.isNull()) { - qCWarning(dcDenon) << "Could not parse ip address" << device->paramValue(AVRX1000IpParamTypeId).toString(); + qCWarning(dcDenon) << "Could not parse ip address" << device->paramValue(AVRX1000DeviceIpParamTypeId).toString(); return DeviceManager::DeviceSetupStatusFailure; } @@ -116,9 +116,9 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons // Print information that we are executing now the update action qCDebug(dcDenon) << "set power action" << action.id(); - qCDebug(dcDenon) << "power: " << action.param(AVRX1000PowerActionParamTypeId).value().Bool; + qCDebug(dcDenon) << "power: " << action.param(AVRX1000PowerActionPowerParamTypeId).value().Bool; - if (action.param(AVRX1000PowerActionParamTypeId).value().toBool() == true){ + if (action.param(AVRX1000PowerActionPowerParamTypeId).value().toBool() == true){ QByteArray cmd = "PWON\r"; qCDebug(dcDenon) << "Execute power: " << action.id() << cmd; m_denonConnection->sendData(cmd); @@ -132,7 +132,7 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons } else if (action.actionTypeId() == AVRX1000VolumeActionTypeId) { - QByteArray vol = action.param(AVRX1000VolumeActionParamTypeId).value().toByteArray(); + QByteArray vol = action.param(AVRX1000VolumeActionVolumeParamTypeId).value().toByteArray(); QByteArray cmd = "MV" + vol + "\r"; qCDebug(dcDenon) << "Execute volume" << action.id() << cmd; @@ -143,7 +143,7 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons } else if (action.actionTypeId() == AVRX1000ChannelActionTypeId) { qCDebug(dcDenon) << "Execute update action" << action.id(); - QByteArray channel = action.param(AVRX1000ChannelActionParamTypeId).value().toByteArray(); + QByteArray channel = action.param(AVRX1000ChannelActionChannelParamTypeId).value().toByteArray(); QByteArray cmd = "SI" + channel + "\r"; qCDebug(dcDenon) << "Change to channel:" << cmd; @@ -204,7 +204,7 @@ void DevicePluginDenon::onDataReceived(const QByteArray &data) } if (data.contains("SI")) { - QString cmd = NULL; + QString cmd; if (data.contains("TUNER")) { cmd = "TUNER"; } else if (data.contains("DVD")) { diff --git a/dweetio/deviceplugindweetio.cpp b/dweetio/deviceplugindweetio.cpp index 4f01476d..f90ffdc5 100644 --- a/dweetio/deviceplugindweetio.cpp +++ b/dweetio/deviceplugindweetio.cpp @@ -54,7 +54,7 @@ DeviceManager::DeviceSetupStatus DevicePluginDweetio::setupDevice(Device *device if (device->deviceClassId() == postDeviceClassId) { - QString thing = device->paramValue(postThingParamTypeId).toString(); + QString thing = device->paramValue(postDeviceThingParamTypeId).toString(); if (thing.isEmpty()){ qDebug(dcDweetio) << "No thing name given, creating one"; thing = QUuid::createUuid().toString(); @@ -101,7 +101,7 @@ DeviceManager::DeviceError DevicePluginDweetio::executeAction(Device *device, co if (action.actionTypeId() == postContentDataActionTypeId) { - QString content = action.param(postContentDataAreaParamTypeId).value().toString(); + QString content = action.param(postContentDataActionContentDataAreaParamTypeId).value().toString(); postContent(content, device, action); return DeviceManager::DeviceErrorAsync; @@ -113,13 +113,13 @@ DeviceManager::DeviceError DevicePluginDweetio::executeAction(Device *device, co void DevicePluginDweetio::postContent(const QString &content, Device *device, const Action &action) { - QUrl url = QString("https://dweet.io:443/dweet/for/") + device->paramValue(postThingParamTypeId).toString(); + QUrl url = QString("https://dweet.io:443/dweet/for/") + device->paramValue(postDeviceThingParamTypeId).toString(); QNetworkRequest request(url); request.setRawHeader("Content-Type", QString("application/json").toLocal8Bit()); request.setRawHeader("Accept", QString("application/json").toLocal8Bit()); request.setSslConfiguration(QSslConfiguration::defaultConfiguration()); - QString key = device->paramValue(postKeyParamTypeId).toString(); + QString key = device->paramValue(postDeviceKeyParamTypeId).toString(); if (!(key.isEmpty()) || !(key == "none")) { QUrlQuery query; query.addQueryItem("key", key); @@ -127,7 +127,7 @@ void DevicePluginDweetio::postContent(const QString &content, Device *device, co } QVariantMap contentMap; - contentMap.insert(device->paramValue(postContentNameParamTypeId).toString(), content); + contentMap.insert(device->paramValue(postDeviceContentNameParamTypeId).toString(), content); QByteArray data = QJsonDocument::fromVariant(contentMap).toJson(QJsonDocument::Compact); qDebug(dcDweetio) << "Dweet: " << data << "Url: " << url; @@ -155,7 +155,7 @@ void DevicePluginDweetio::processGetReply(const QVariantMap &data, Device *devic { QVariantList withList = data.value("with").toList(); QVariantMap contentMap = withList.first().toMap().value("content").toMap(); - QString content = contentMap.value(device->paramValue(getContentNameParamTypeId).toString()).toString(); + QString content = contentMap.value(device->paramValue(getDeviceContentNameParamTypeId).toString()).toString(); device->setStateValue(getContentStateTypeId, content); qDebug(dcDweetio) << "Data: " << data << "Device: " << device->name(); @@ -236,13 +236,13 @@ void DevicePluginDweetio::getRequest(Device *device) { qCDebug(dcDweetio()) << "Refresh data for" << device->name(); - QUrl url = QString("https://dweet.io:443/get/latest/dweet/for/") + device->paramValue(postThingParamTypeId).toString(); + QUrl url = QString("https://dweet.io:443/get/latest/dweet/for/") + device->paramValue(postDeviceThingParamTypeId).toString(); QNetworkRequest request(url); request.setRawHeader("Content-Type", QString("application/json").toLocal8Bit()); request.setRawHeader("Accept", QString("application/json").toLocal8Bit()); request.setSslConfiguration(QSslConfiguration::defaultConfiguration()); - QString key = device->paramValue(getKeyParamTypeId).toString(); + QString key = device->paramValue(getDeviceKeyParamTypeId).toString(); if (!(key.isEmpty()) || !(key == "none")) { QUrlQuery query; query.addQueryItem("key", key); diff --git a/elgato/devicepluginelgato.cpp b/elgato/devicepluginelgato.cpp index 6db65743..559a0903 100644 --- a/elgato/devicepluginelgato.cpp +++ b/elgato/devicepluginelgato.cpp @@ -444,8 +444,8 @@ DeviceManager::DeviceSetupStatus DevicePluginElgato::setupDevice(Device *device) qCDebug(dcElgato()) << "Setup device" << device->name() << device->params(); if (device->deviceClassId() == aveaDeviceClassId) { - QBluetoothAddress address = QBluetoothAddress(device->paramValue(aveaMacAddressParamTypeId).toString()); - QString name = device->paramValue(aveaNameParamTypeId).toString(); + QBluetoothAddress address = QBluetoothAddress(device->paramValue(aveaDeviceMacAddressParamTypeId).toString()); + QString name = device->paramValue(aveaDeviceNameParamTypeId).toString(); QBluetoothDeviceInfo deviceInfo = QBluetoothDeviceInfo(address, name, 0); BluetoothLowEnergyDevice *bluetoothDevice = hardwareManager()->bluetoothLowEnergyManager()->registerDevice(deviceInfo, QLowEnergyController::PublicAddress); @@ -478,28 +478,28 @@ DeviceManager::DeviceError DevicePluginElgato::executeAction(Device *device, con AveaBulb *bulb = m_bulbs.value(device); if (action.actionTypeId() == aveaPowerActionTypeId) { - bool power = action.param(aveaPowerActionParamTypeId).value().toBool(); + bool power = action.param(aveaPowerActionPowerParamTypeId).value().toBool(); device->setStateValue(aveaPowerStateTypeId, power); if (!bulb->setPower(power)) return DeviceManager::DeviceErrorHardwareNotAvailable; return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == aveaBrightnessActionTypeId) { - int percentage = action.param(aveaBrightnessActionParamTypeId).value().toInt(); + int percentage = action.param(aveaBrightnessActionBrightnessParamTypeId).value().toInt(); if (!bulb->setBrightness(percentage)) return DeviceManager::DeviceErrorHardwareNotAvailable; device->setStateValue(aveaBrightnessStateTypeId, percentage); return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == aveaColorActionTypeId) { - QColor color = action.param(aveaColorActionParamTypeId).value().value(); + QColor color = action.param(aveaColorActionColorParamTypeId).value().value(); if (!bulb->setColor(color)) return DeviceManager::DeviceErrorHardwareNotAvailable; device->setStateValue(aveaColorStateTypeId, color); return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == aveaColorTemperatureActionTypeId) { - int ctValue = action.param(aveaColorTemperatureActionParamTypeId).value().toInt(); + int ctValue = action.param(aveaColorTemperatureActionColorTemperatureParamTypeId).value().toInt(); // normalize from 0 to 347 instead of 153 to 500 int ct = ctValue - 153; // for blue: lower half fades blue from 255 to 0 @@ -520,31 +520,31 @@ DeviceManager::DeviceError DevicePluginElgato::executeAction(Device *device, con device->setStateValue(aveaColorTemperatureStateTypeId, ctValue); return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == aveaWhiteActionTypeId) { - int whiteValue = action.param(aveaWhiteActionParamTypeId).value().toInt(); + int whiteValue = action.param(aveaWhiteActionWhiteParamTypeId).value().toInt(); if (!bulb->setWhite(whiteValue)) return DeviceManager::DeviceErrorHardwareNotAvailable; return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == aveaGreenActionTypeId) { - int greenValue = action.param(aveaGreenActionParamTypeId).value().toInt(); + int greenValue = action.param(aveaGreenActionGreenParamTypeId).value().toInt(); if (!bulb->setGreen(greenValue)) return DeviceManager::DeviceErrorHardwareNotAvailable; return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == aveaRedActionTypeId) { - int redValue = action.param(aveaRedActionParamTypeId).value().toInt(); + int redValue = action.param(aveaRedActionRedParamTypeId).value().toInt(); if (!bulb->setRed(redValue)) return DeviceManager::DeviceErrorHardwareNotAvailable; return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == aveaBlueActionTypeId) { - int blueValue = action.param(aveaBlueActionParamTypeId).value().toInt(); + int blueValue = action.param(aveaBlueActionBlueParamTypeId).value().toInt(); if (!bulb->setBlue(blueValue)) return DeviceManager::DeviceErrorHardwareNotAvailable; return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == aveaFadeActionTypeId) { - int fadeValue = action.param(aveaFadeActionParamTypeId).value().toInt(); + int fadeValue = action.param(aveaFadeActionFadeParamTypeId).value().toInt(); device->setStateValue(aveaFadeStateTypeId, fadeValue); if (!bulb->setFade(fadeValue)) return DeviceManager::DeviceErrorHardwareNotAvailable; @@ -571,7 +571,7 @@ void DevicePluginElgato::deviceRemoved(Device *device) bool DevicePluginElgato::verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo) { foreach (Device *device, myDevices()) { - if (device->paramValue(aveaMacAddressParamTypeId).toString() == deviceInfo.address().toString()) + if (device->paramValue(aveaDeviceMacAddressParamTypeId).toString() == deviceInfo.address().toString()) return true; } @@ -603,8 +603,8 @@ void DevicePluginElgato::onBluetoothDiscoveryFinished() if (!verifyExistingDevices(deviceInfo)) { DeviceDescriptor descriptor(aveaDeviceClassId, "Avea", deviceInfo.address().toString()); ParamList params; - params.append(Param(aveaNameParamTypeId, deviceInfo.name())); - params.append(Param(aveaMacAddressParamTypeId, deviceInfo.address().toString())); + params.append(Param(aveaDeviceNameParamTypeId, deviceInfo.name())); + params.append(Param(aveaDeviceMacAddressParamTypeId, deviceInfo.address().toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } diff --git a/elro/devicepluginelro.cpp b/elro/devicepluginelro.cpp index c6ab7a0c..74ad964c 100644 --- a/elro/devicepluginelro.cpp +++ b/elro/devicepluginelro.cpp @@ -66,61 +66,61 @@ DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const // create the bincode // channels - if (device->paramValue(elroSocketChan1ParamTypeId).toBool()) { + if (device->paramValue(elroSocketDeviceChan1ParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(elroSocketChan2ParamTypeId).toBool()) { + if (device->paramValue(elroSocketDeviceChan2ParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(elroSocketChan3ParamTypeId).toBool()) { + if (device->paramValue(elroSocketDeviceChan3ParamTypeId).toBool()) { binCode.append("00"); }else{ binCode.append("01"); } - if(device->paramValue(elroSocketChan4ParamTypeId).toBool()){ + if(device->paramValue(elroSocketDeviceChan4ParamTypeId).toBool()){ binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(elroSocketChan5ParamTypeId).toBool()) { + if (device->paramValue(elroSocketDeviceChan5ParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } // Buttons - if (device->paramValue(elroSocketAParamTypeId).toBool()) { + if (device->paramValue(elroSocketDeviceAParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(elroSocketBParamTypeId).toBool()) { + if (device->paramValue(elroSocketDeviceBParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(elroSocketCParamTypeId).toBool()) { + if (device->paramValue(elroSocketDeviceCParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(elroSocketDParamTypeId).toBool()) { + if (device->paramValue(elroSocketDeviceDParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(elroSocketEParamTypeId).toBool()) { + if (device->paramValue(elroSocketDeviceEParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } // Power - if (action.param(elroSocketPowerParamTypeId).value().toBool()) { + if (action.param(elroSocketPowerActionPowerParamTypeId).value().toBool()) { binCode.append("0001"); } else { binCode.append("0100"); @@ -146,9 +146,9 @@ DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const // send data to hardware resource if (hardwareManager()->radio433()->sendData(delay, rawData, 10)) { - qCDebug(dcElro) << "Transmitted" << pluginName() << device->name() << "power: " << action.param(elroSocketPowerParamTypeId).value().toBool(); + qCDebug(dcElro) << "Transmitted" << pluginName() << device->name() << "power: " << action.param(elroSocketPowerActionPowerParamTypeId).value().toBool(); } else { - qCWarning(dcElro) << "Could not transmitt" << pluginName() << device->name() << "power: " << action.param(elroSocketPowerParamTypeId).value().toBool(); + qCWarning(dcElro) << "Could not transmitt" << pluginName() << device->name() << "power: " << action.param(elroSocketPowerActionPowerParamTypeId).value().toBool(); return DeviceManager::DeviceErrorHardwareNotAvailable; } diff --git a/eq-3/deviceplugineq-3.cpp b/eq-3/deviceplugineq-3.cpp index d3526f04..3a11faf0 100644 --- a/eq-3/deviceplugineq-3.cpp +++ b/eq-3/deviceplugineq-3.cpp @@ -111,13 +111,13 @@ DeviceManager::DeviceSetupStatus DevicePluginEQ3::setupDevice(Device *device) if(device->deviceClassId() == cubeDeviceClassId){ foreach (MaxCube *cube, m_cubes.keys()) { - if(cube->serialNumber() == device->paramValue(cubeSerialParamTypeId).toString()){ + if(cube->serialNumber() == device->paramValue(cubeDeviceSerialParamTypeId).toString()){ qCDebug(dcEQ3) << cube->serialNumber() << " already exists..."; return DeviceManager::DeviceSetupStatusFailure; } } - MaxCube *cube = new MaxCube(this,device->paramValue(cubeSerialParamTypeId).toString(),QHostAddress(device->paramValue(cubeHostParamTypeId).toString()),device->paramValue(cubePortParamTypeId).toInt()); + MaxCube *cube = new MaxCube(this,device->paramValue(cubeDeviceSerialParamTypeId).toString(),QHostAddress(device->paramValue(cubeDeviceHostParamTypeId).toString()),device->paramValue(cubeDevicePortParamTypeId).toInt()); m_cubes.insert(cube,device); connect(cube,SIGNAL(cubeConnectionStatusChanged(bool)),this,SLOT(cubeConnectionStatusChanged(bool))); @@ -133,7 +133,7 @@ DeviceManager::DeviceSetupStatus DevicePluginEQ3::setupDevice(Device *device) return DeviceManager::DeviceSetupStatusAsync; } if(device->deviceClassId() == wallThermostateDeviceClassId){ - device->setName("Max! Wall Thermostat (" + device->paramValue(wallThermostateSerialParamTypeId).toString() + ")"); + device->setName("Max! Wall Thermostat (" + device->paramValue(wallThermostateDeviceSerialParamTypeId).toString() + ")"); } return DeviceManager::DeviceSetupStatusSuccess; @@ -156,13 +156,13 @@ DeviceManager::DeviceError DevicePluginEQ3::executeAction(Device *device, const { if(device->deviceClassId() == wallThermostateDeviceClassId){ foreach (MaxCube *cube, m_cubes.keys()){ - if(cube->serialNumber() == device->paramValue(wallThermostateParentParamTypeId).toString()){ + if(cube->serialNumber() == device->paramValue(wallThermostateDeviceParentParamTypeId).toString()){ - QByteArray rfAddress = device->paramValue(wallThermostateRfParamTypeId).toByteArray(); - int roomId = device->paramValue(wallThermostateRoomParamTypeId).toInt(); + QByteArray rfAddress = device->paramValue(wallThermostateDeviceRfParamTypeId).toByteArray(); + int roomId = device->paramValue(wallThermostateDeviceRoomParamTypeId).toInt(); if (action.actionTypeId() == wallThermostateDesiredTemperatureActionTypeId){ - cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(wallThermostateDesiredTemperatureActionParamTypeId).value().toDouble(), action.id()); + cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(wallThermostateDesiredTemperatureActionDesiredTemperatureParamTypeId).value().toDouble(), action.id()); } else if (action.actionTypeId() == wallThermostateSetAutoModeActionTypeId){ cube->setDeviceAutoMode(rfAddress, roomId, action.id()); } else if (action.actionTypeId() == wallThermostateSetManualModeActionTypeId){ @@ -170,20 +170,20 @@ DeviceManager::DeviceError DevicePluginEQ3::executeAction(Device *device, const } else if (action.actionTypeId() == wallThermostateSetEcoModeActionTypeId){ cube->setDeviceEcoMode(rfAddress, roomId, action.id()); } else if (action.actionTypeId() == wallThermostateDisplayCurrentTempActionTypeId){ - cube->displayCurrentTemperature(rfAddress, roomId, action.param(wallThermostateDisplayParamTypeId).value().toBool(), action.id()); + cube->displayCurrentTemperature(rfAddress, roomId, action.param(wallThermostateDisplayCurrentTempActionDisplayParamTypeId).value().toBool(), action.id()); } return DeviceManager::DeviceErrorAsync; } } } else if (device->deviceClassId() == radiatorThermostateDeviceClassId){ foreach (MaxCube *cube, m_cubes.keys()){ - if(cube->serialNumber() == device->paramValue(radiatorThermostateParentParamTypeId).toString()){ + if(cube->serialNumber() == device->paramValue(radiatorThermostateDeviceParentParamTypeId).toString()){ - QByteArray rfAddress = device->paramValue(radiatorThermostateRfParamTypeId).toByteArray(); - int roomId = device->paramValue(radiatorThermostateRoomParamTypeId).toInt(); + QByteArray rfAddress = device->paramValue(radiatorThermostateDeviceRfParamTypeId).toByteArray(); + int roomId = device->paramValue(radiatorThermostateDeviceRoomParamTypeId).toInt(); if (action.actionTypeId() == radiatorThermostateDesiredTemperatureActionTypeId){ - cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(radiatorThermostateDesiredTemperatureActionParamTypeId).value().toDouble(), action.id()); + cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(radiatorThermostateDesiredTemperatureActionDesiredTemperatureParamTypeId).value().toDouble(), action.id()); } else if (action.actionTypeId() == radiatorThermostateSetAutoModeActionTypeId){ cube->setDeviceAutoMode(rfAddress, roomId, action.id()); } else if (action.actionTypeId() == radiatorThermostateSetManualModeActionTypeId){ @@ -236,13 +236,13 @@ void DevicePluginEQ3::discoveryDone(const QList &cubeList) foreach (MaxCube *cube, cubeList) { DeviceDescriptor descriptor(cubeDeviceClassId, "Max! Cube LAN Gateway",cube->serialNumber()); ParamList params; - Param hostParam(cubeHostParamTypeId, cube->hostAddress().toString()); + Param hostParam(cubeDeviceHostParamTypeId, cube->hostAddress().toString()); params.append(hostParam); - Param portParam(cubePortParamTypeId, cube->port()); + Param portParam(cubeDevicePortParamTypeId, cube->port()); params.append(portParam); - Param firmwareParam(cubeFirmwareParamTypeId, cube->firmware()); + Param firmwareParam(cubeDeviceFirmwareParamTypeId, cube->firmware()); params.append(firmwareParam); - Param serialNumberParam(cubeSerialParamTypeId, cube->serialNumber()); + Param serialNumberParam(cubeDeviceSerialParamTypeId, cube->serialNumber()); params.append(serialNumberParam); descriptor.setParams(params); @@ -269,7 +269,7 @@ void DevicePluginEQ3::wallThermostatFound() foreach (WallThermostat *wallThermostat, cube->wallThermostatList()) { bool allreadyAdded = false; foreach (Device *device, deviceManager()->findConfiguredDevices(wallThermostateDeviceClassId)){ - if(wallThermostat->serialNumber() == device->paramValue(wallThermostateSerialParamTypeId).toString()){ + if(wallThermostat->serialNumber() == device->paramValue(wallThermostateDeviceSerialParamTypeId).toString()){ allreadyAdded = true; break; } @@ -277,12 +277,12 @@ void DevicePluginEQ3::wallThermostatFound() if(!allreadyAdded){ DeviceDescriptor descriptor(wallThermostateDeviceClassId, wallThermostat->serialNumber()); ParamList params; - params.append(Param(wallThermostateNameParamTypeId, wallThermostat->deviceName())); - params.append(Param(wallThermostateParentParamTypeId, cube->serialNumber())); - params.append(Param(wallThermostateSerialParamTypeId, wallThermostat->serialNumber())); - params.append(Param(wallThermostateRfParamTypeId, wallThermostat->rfAddress())); - params.append(Param(wallThermostateRoomParamTypeId, wallThermostat->roomId())); - params.append(Param(wallThermostateRoomNameParamTypeId, wallThermostat->roomName())); + params.append(Param(wallThermostateDeviceNameParamTypeId, wallThermostat->deviceName())); + params.append(Param(wallThermostateDeviceParentParamTypeId, cube->serialNumber())); + params.append(Param(wallThermostateDeviceSerialParamTypeId, wallThermostat->serialNumber())); + params.append(Param(wallThermostateDeviceRfParamTypeId, wallThermostat->rfAddress())); + params.append(Param(wallThermostateDeviceRoomParamTypeId, wallThermostat->roomId())); + params.append(Param(wallThermostateDeviceRoomNameParamTypeId, wallThermostat->roomName())); descriptor.setParams(params); descriptorList.append(descriptor); } @@ -303,7 +303,7 @@ void DevicePluginEQ3::radiatorThermostatFound() foreach (RadiatorThermostat *radiatorThermostat, cube->radiatorThermostatList()) { bool allreadyAdded = false; foreach (Device *device, deviceManager()->findConfiguredDevices(radiatorThermostateDeviceClassId)){ - if(radiatorThermostat->serialNumber() == device->paramValue(radiatorThermostateSerialParamTypeId).toString()){ + if(radiatorThermostat->serialNumber() == device->paramValue(radiatorThermostateDeviceSerialParamTypeId).toString()){ allreadyAdded = true; break; } @@ -311,12 +311,12 @@ void DevicePluginEQ3::radiatorThermostatFound() if(!allreadyAdded){ DeviceDescriptor descriptor(radiatorThermostateDeviceClassId, radiatorThermostat->serialNumber()); ParamList params; - params.append(Param(radiatorThermostateNameParamTypeId, radiatorThermostat->deviceName())); - params.append(Param(radiatorThermostateParentParamTypeId, cube->serialNumber())); - params.append(Param(radiatorThermostateSerialParamTypeId, radiatorThermostat->serialNumber())); - params.append(Param(radiatorThermostateRfParamTypeId, radiatorThermostat->rfAddress())); - params.append(Param(radiatorThermostateRoomParamTypeId, radiatorThermostat->roomId())); - params.append(Param(radiatorThermostateRoomNameParamTypeId, radiatorThermostat->roomName())); + params.append(Param(radiatorThermostateDeviceNameParamTypeId, radiatorThermostat->deviceName())); + params.append(Param(radiatorThermostateDeviceParentParamTypeId, cube->serialNumber())); + params.append(Param(radiatorThermostateDeviceSerialParamTypeId, radiatorThermostat->serialNumber())); + params.append(Param(radiatorThermostateDeviceRfParamTypeId, radiatorThermostat->rfAddress())); + params.append(Param(radiatorThermostateDeviceRoomParamTypeId, radiatorThermostat->roomId())); + params.append(Param(radiatorThermostateDeviceRoomNameParamTypeId, radiatorThermostat->roomName())); descriptor.setParams(params); descriptorList.append(descriptor); } @@ -344,7 +344,7 @@ void DevicePluginEQ3::wallThermostatDataUpdated() foreach (WallThermostat *wallThermostat, cube->wallThermostatList()) { foreach (Device *device, deviceManager()->findConfiguredDevices(wallThermostateDeviceClassId)){ - if(device->paramValue(wallThermostateSerialParamTypeId).toString() == wallThermostat->serialNumber()){ + if(device->paramValue(wallThermostateDeviceSerialParamTypeId).toString() == wallThermostat->serialNumber()){ device->setStateValue(wallThermostateComfortTempStateTypeId, wallThermostat->comfortTemp()); device->setStateValue(wallThermostateEcoTempStateTypeId, wallThermostat->ecoTemp()); device->setStateValue(wallThermostateMaxSetpointTempStateTypeId, wallThermostat->maxSetPointTemp()); @@ -371,7 +371,7 @@ void DevicePluginEQ3::radiatorThermostatDataUpdated() foreach (RadiatorThermostat *radiatorThermostat, cube->radiatorThermostatList()) { foreach (Device *device, deviceManager()->findConfiguredDevices(radiatorThermostateDeviceClassId)){ - if(device->paramValue(radiatorThermostateSerialParamTypeId).toString() == radiatorThermostat->serialNumber()){ + if(device->paramValue(radiatorThermostateDeviceSerialParamTypeId).toString() == radiatorThermostat->serialNumber()){ device->setStateValue(radiatorThermostateComfortTempStateTypeId, radiatorThermostat->comfortTemp()); device->setStateValue(radiatorThermostateMaxSetpointTempStateTypeId, radiatorThermostat->maxSetPointTemp()); device->setStateValue(radiatorThermostateMinSetpointTempStateTypeId, radiatorThermostat->minSetPointTemp()); diff --git a/flowercare/devicepluginflowercare.cpp b/flowercare/devicepluginflowercare.cpp index 67ea02e5..95a83fac 100644 --- a/flowercare/devicepluginflowercare.cpp +++ b/flowercare/devicepluginflowercare.cpp @@ -73,8 +73,8 @@ DeviceManager::DeviceSetupStatus DevicePluginFlowercare::setupDevice(Device *dev qCDebug(dcFlowerCare) << "Setting up Flower care" << device->name() << device->params(); if (device->deviceClassId() == flowerCareDeviceClassId) { - QBluetoothAddress address = QBluetoothAddress(device->paramValue(flowerCareMacParamTypeId).toString()); - QString name = device->paramValue(flowerCareNameParamTypeId).toString(); + QBluetoothAddress address = QBluetoothAddress(device->paramValue(flowerCareDeviceMacParamTypeId).toString()); + QString name = device->paramValue(flowerCareDeviceNameParamTypeId).toString(); QBluetoothDeviceInfo deviceInfo = QBluetoothDeviceInfo(address, name, 0); BluetoothLowEnergyDevice *bluetoothDevice = hardwareManager()->bluetoothLowEnergyManager()->registerDevice(deviceInfo, QLowEnergyController::PublicAddress); @@ -125,7 +125,7 @@ DeviceManager::DeviceError DevicePluginFlowercare::executeAction(Device *device, bool DevicePluginFlowercare::verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo) { foreach (Device *device, m_list.keys()) { - if (device->paramValue(flowerCareMacParamTypeId).toString() == deviceInfo.address().toString()) + if (device->paramValue(flowerCareDeviceMacParamTypeId).toString() == deviceInfo.address().toString()) return true; } @@ -169,8 +169,8 @@ void DevicePluginFlowercare::onBluetoothDiscoveryFinished() if (!verifyExistingDevices(deviceInfo)) { DeviceDescriptor descriptor(flowerCareDeviceClassId, "Flower Care", deviceInfo.address().toString()); ParamList params; - params.append(Param(flowerCareNameParamTypeId, deviceInfo.name())); - params.append(Param(flowerCareMacParamTypeId, deviceInfo.address().toString())); + params.append(Param(flowerCareDeviceNameParamTypeId, deviceInfo.name())); + params.append(Param(flowerCareDeviceMacParamTypeId, deviceInfo.address().toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } diff --git a/gpio/deviceplugingpio.cpp b/gpio/deviceplugingpio.cpp index e2a21255..93d9f8b5 100644 --- a/gpio/deviceplugingpio.cpp +++ b/gpio/deviceplugingpio.cpp @@ -72,10 +72,10 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device) // Create and configure gpio int gpioId = -1; if (device->deviceClassId() == gpioOutputRpiDeviceClassId) - gpioId = device->paramValue(gpioOutputRpiGpioParamTypeId).toInt(); + gpioId = device->paramValue(gpioOutputRpiDeviceGpioParamTypeId).toInt(); if (device->deviceClassId() == gpioOutputBbbDeviceClassId) - gpioId = device->paramValue(gpioOutputBbbGpioParamTypeId).toInt(); + gpioId = device->paramValue(gpioOutputBbbDeviceGpioParamTypeId).toInt(); Gpio *gpio = new Gpio(gpioId, this); @@ -109,10 +109,10 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device) int gpioId = -1; if (device->deviceClassId() == gpioInputRpiDeviceClassId) - gpioId = device->paramValue(gpioInputRpiGpioParamTypeId).toInt(); + gpioId = device->paramValue(gpioInputRpiDeviceGpioParamTypeId).toInt(); if (device->deviceClassId() == gpioInputBbbDeviceClassId) - gpioId = device->paramValue(gpioInputBbbGpioParamTypeId).toInt(); + gpioId = device->paramValue(gpioInputBbbDeviceGpioParamTypeId).toInt(); GpioMonitor *monior = new GpioMonitor(gpioId, this); @@ -175,13 +175,13 @@ DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId DeviceDescriptor descriptor(deviceClassId, QString("GPIO %1").arg(gpioDescriptor.gpio()), description); ParamList parameters; if (deviceClass.id() == gpioOutputRpiDeviceClassId) { - parameters.append(Param(gpioOutputRpiGpioParamTypeId, gpioDescriptor.gpio())); - parameters.append(Param(gpioOutputRpiPinParamTypeId, gpioDescriptor.pin())); - parameters.append(Param(gpioOutputRpiDescriptionParamTypeId, gpioDescriptor.description())); + parameters.append(Param(gpioOutputRpiDeviceGpioParamTypeId, gpioDescriptor.gpio())); + parameters.append(Param(gpioOutputRpiDevicePinParamTypeId, gpioDescriptor.pin())); + parameters.append(Param(gpioOutputRpiDeviceDescriptionParamTypeId, gpioDescriptor.description())); } else if (deviceClass.id() == gpioInputRpiDeviceClassId) { - parameters.append(Param(gpioInputRpiGpioParamTypeId, gpioDescriptor.gpio())); - parameters.append(Param(gpioInputRpiPinParamTypeId, gpioDescriptor.pin())); - parameters.append(Param(gpioInputRpiDescriptionParamTypeId, gpioDescriptor.description())); + parameters.append(Param(gpioInputRpiDeviceGpioParamTypeId, gpioDescriptor.gpio())); + parameters.append(Param(gpioInputRpiDevicePinParamTypeId, gpioDescriptor.pin())); + parameters.append(Param(gpioInputRpiDeviceDescriptionParamTypeId, gpioDescriptor.description())); } descriptor.setParams(parameters); @@ -218,13 +218,13 @@ DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId DeviceDescriptor descriptor(deviceClassId, QString("GPIO %1").arg(gpioDescriptor.gpio()), description); ParamList parameters; if (deviceClass.id() == gpioOutputBbbDeviceClassId) { - parameters.append(Param(gpioOutputBbbGpioParamTypeId, gpioDescriptor.gpio())); - parameters.append(Param(gpioOutputBbbPinParamTypeId, gpioDescriptor.pin())); - parameters.append(Param(gpioOutputBbbDescriptionParamTypeId, gpioDescriptor.description())); + parameters.append(Param(gpioOutputBbbDeviceGpioParamTypeId, gpioDescriptor.gpio())); + parameters.append(Param(gpioOutputBbbDevicePinParamTypeId, gpioDescriptor.pin())); + parameters.append(Param(gpioOutputBbbDeviceDescriptionParamTypeId, gpioDescriptor.description())); } else if (deviceClass.id() == gpioInputBbbDeviceClassId) { - parameters.append(Param(gpioInputBbbGpioParamTypeId, gpioDescriptor.gpio())); - parameters.append(Param(gpioInputBbbPinParamTypeId, gpioDescriptor.pin())); - parameters.append(Param(gpioInputBbbDescriptionParamTypeId, gpioDescriptor.description())); + parameters.append(Param(gpioInputBbbDeviceGpioParamTypeId, gpioDescriptor.gpio())); + parameters.append(Param(gpioInputBbbDevicePinParamTypeId, gpioDescriptor.pin())); + parameters.append(Param(gpioInputBbbDeviceDescriptionParamTypeId, gpioDescriptor.description())); } descriptor.setParams(parameters); @@ -282,10 +282,10 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const // Find the gpio in the corresponding hash if (deviceClass.vendorId() == raspberryPiVendorId) - gpio = m_raspberryPiGpios.value(device->paramValue(gpioOutputRpiGpioParamTypeId).toInt()); + gpio = m_raspberryPiGpios.value(device->paramValue(gpioOutputRpiDeviceGpioParamTypeId).toInt()); if (deviceClass.vendorId() == beagleboneBlackVendorId) - gpio = m_beagleboneBlackGpios.value(device->paramValue(gpioOutputBbbGpioParamTypeId).toInt()); + gpio = m_beagleboneBlackGpios.value(device->paramValue(gpioOutputBbbDeviceGpioParamTypeId).toInt()); // Check if gpio was found if (!gpio) { @@ -297,7 +297,7 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const if (deviceClass.vendorId() == raspberryPiVendorId) { if (action.actionTypeId() == gpioOutputRpiPowerValueActionTypeId) { bool success = false; - if (action.param(gpioOutputRpiPowerValueActionParamTypeId).value().toBool()) { + if (action.param(gpioOutputRpiPowerValueActionPowerValueParamTypeId).value().toBool()) { success = gpio->setValue(Gpio::ValueHigh); } else { success = gpio->setValue(Gpio::ValueLow); @@ -309,14 +309,14 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const } // Set the current state - device->setStateValue(gpioOutputRpiPowerValueStateTypeId, action.param(gpioOutputRpiPowerValueActionParamTypeId).value()); + device->setStateValue(gpioOutputRpiPowerValueStateTypeId, action.param(gpioOutputRpiPowerValueActionPowerValueParamTypeId).value()); return DeviceManager::DeviceErrorNoError; } } else if (deviceClass.vendorId() == beagleboneBlackVendorId) { if (action.actionTypeId() == gpioOutputBbbPowerValueActionTypeId) { bool success = false; - if (action.param(gpioOutputBbbPowerValueActionParamTypeId).value().toBool()) { + if (action.param(gpioOutputBbbPowerValueActionPowerValueParamTypeId).value().toBool()) { success = gpio->setValue(Gpio::ValueHigh); } else { success = gpio->setValue(Gpio::ValueLow); @@ -328,7 +328,7 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const } // Set the current state - device->setStateValue(gpioOutputBbbPowerValueStateTypeId, action.param(gpioOutputBbbPowerValueActionParamTypeId).value()); + device->setStateValue(gpioOutputBbbPowerValueStateTypeId, action.param(gpioOutputBbbPowerValueActionPowerValueParamTypeId).value()); return DeviceManager::DeviceErrorNoError; } diff --git a/httpcommander/devicepluginhttpcommander.cpp b/httpcommander/devicepluginhttpcommander.cpp index cd5327a9..b9dc81b2 100644 --- a/httpcommander/devicepluginhttpcommander.cpp +++ b/httpcommander/devicepluginhttpcommander.cpp @@ -47,7 +47,7 @@ DeviceManager::DeviceSetupStatus DevicePluginHttpCommander::setupDevice(Device * // Get if (device->deviceClassId() == httpGetCommanderDeviceClassId) { - QUrl url = device->paramValue(httpGetCommanderUrlParamTypeId).toUrl(); + QUrl url = device->paramValue(httpGetCommanderDeviceUrlParamTypeId).toUrl(); if (!url.isValid()) { qDebug(dcHttpCommander()) << "Given URL is not valid"; return DeviceManager::DeviceSetupStatusFailure; @@ -58,7 +58,7 @@ DeviceManager::DeviceSetupStatus DevicePluginHttpCommander::setupDevice(Device * // Put if (device->deviceClassId() == httpPutCommanderDeviceClassId) { - QUrl url = device->paramValue(httpPutCommanderUrlParamTypeId).toUrl(); + QUrl url = device->paramValue(httpPutCommanderDeviceUrlParamTypeId).toUrl(); if (!url.isValid()) { qDebug(dcHttpCommander()) << "Given URL is not valid"; return DeviceManager::DeviceSetupStatusFailure; @@ -69,7 +69,7 @@ DeviceManager::DeviceSetupStatus DevicePluginHttpCommander::setupDevice(Device * // Post if (device->deviceClassId() == httpPostCommanderDeviceClassId) { - QUrl url = device->paramValue(httpPostCommanderUrlParamTypeId).toUrl(); + QUrl url = device->paramValue(httpPostCommanderDeviceUrlParamTypeId).toUrl(); if (!url.isValid()) { qDebug(dcHttpCommander()) << "Given URL is not valid"; return DeviceManager::DeviceSetupStatusFailure; @@ -105,9 +105,9 @@ DeviceManager::DeviceError DevicePluginHttpCommander::executeAction(Device *devi if (device->deviceClassId() == httpPostCommanderDeviceClassId) { if (action.actionTypeId() == httpPostCommanderPostActionTypeId) { - QUrl url = device->paramValue(httpPostCommanderUrlParamTypeId).toUrl(); - url.setPort(device->paramValue(httpPostCommanderPortParamTypeId).toInt()); - QByteArray payload = action.param(httpPostCommanderDataParamTypeId).value().toByteArray(); + QUrl url = device->paramValue(httpPostCommanderDeviceUrlParamTypeId).toUrl(); + url.setPort(device->paramValue(httpPostCommanderDevicePortParamTypeId).toInt()); + QByteArray payload = action.param(httpPostCommanderPostActionDataParamTypeId).value().toByteArray(); QNetworkReply *reply = hardwareManager()->networkManager()->post(QNetworkRequest(url), payload); connect(reply, &QNetworkReply::finished, this, &DevicePluginHttpCommander::onPostRequestFinished); @@ -125,9 +125,9 @@ DeviceManager::DeviceError DevicePluginHttpCommander::executeAction(Device *devi // check if this is the "press" action if (action.actionTypeId() == httpPutCommanderPutActionTypeId) { - QUrl url = device->paramValue(httpPutCommanderUrlParamTypeId).toUrl(); - url.setPort(device->paramValue(httpPutCommanderPortParamTypeId).toInt()); - QByteArray payload = action.param(httpPutCommanderDataParamTypeId).value().toByteArray(); + QUrl url = device->paramValue(httpPutCommanderDeviceUrlParamTypeId).toUrl(); + url.setPort(device->paramValue(httpPutCommanderDevicePortParamTypeId).toInt()); + QByteArray payload = action.param(httpPutCommanderPutActionDataParamTypeId).value().toByteArray(); QNetworkReply *reply = hardwareManager()->networkManager()->put(QNetworkRequest(url), payload); connect(reply, &QNetworkReply::finished, this, &DevicePluginHttpCommander::onPutRequestFinished); @@ -141,8 +141,8 @@ DeviceManager::DeviceError DevicePluginHttpCommander::executeAction(Device *devi void DevicePluginHttpCommander::makeGetCall(Device *device) { - QUrl url = device->paramValue(httpGetCommanderUrlParamTypeId).toUrl(); - url.setPort(device->paramValue(httpGetCommanderPortParamTypeId).toInt()); + QUrl url = device->paramValue(httpGetCommanderDeviceUrlParamTypeId).toUrl(); + url.setPort(device->paramValue(httpGetCommanderDevicePortParamTypeId).toInt()); QNetworkRequest request; request.setUrl(url); request.setRawHeader("User-Agent", "guhIO 1.0"); diff --git a/intertechno/devicepluginintertechno.cpp b/intertechno/devicepluginintertechno.cpp index dd76536a..95703dce 100644 --- a/intertechno/devicepluginintertechno.cpp +++ b/intertechno/devicepluginintertechno.cpp @@ -64,7 +64,7 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device QList rawData; QByteArray binCode; - QString familyCode = device->paramValue(switchFamilyCodeParamTypeId).toString(); + QString familyCode = device->paramValue(switchDeviceFamilyCodeParamTypeId).toString(); // ======================================= // generate bin from family code @@ -102,7 +102,7 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device binCode.append("01010101"); } - QString buttonCode = device->paramValue(switchButtonCodeParamTypeId).toString(); + QString buttonCode = device->paramValue(switchDeviceButtonCodeParamTypeId).toString(); // ======================================= // generate bin from button code @@ -150,7 +150,7 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device // ======================================= // add power nibble - if (action.param(switchPowerParamTypeId).value().toBool()) { + if (action.param(switchSetPowerActionPowerParamTypeId).value().toBool()) { binCode.append("0101"); } else { binCode.append("0100"); @@ -177,9 +177,9 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device // ======================================= // send data to hardware resource if (hardwareManager()->radio433()->sendData(delay, rawData, 10)) { - qCDebug(dcIntertechno) << "transmitted" << pluginName() << device->name() << "power: " << action.param(switchPowerParamTypeId).value().toBool(); + qCDebug(dcIntertechno) << "transmitted" << pluginName() << device->name() << "power: " << action.param(switchSetPowerActionPowerParamTypeId).value().toBool(); } else { - qCWarning(dcIntertechno) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(switchPowerParamTypeId).value().toBool(); + qCWarning(dcIntertechno) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(switchSetPowerActionPowerParamTypeId).value().toBool(); return DeviceManager::DeviceErrorHardwareNotAvailable; } return DeviceManager::DeviceErrorNoError; diff --git a/keba/devicepluginkeba.cpp b/keba/devicepluginkeba.cpp index f1073c15..98a3862b 100644 --- a/keba/devicepluginkeba.cpp +++ b/keba/devicepluginkeba.cpp @@ -59,7 +59,7 @@ DeviceManager::DeviceSetupStatus DevicePluginKeba::setupDevice(Device *device) qCDebug(dcKebaKeContact()) << "Create keba socket"; } - QHostAddress address = QHostAddress(device->paramValue(wallboxIpParamTypeId).toString()); + QHostAddress address = QHostAddress(device->paramValue(wallboxDeviceIpParamTypeId).toString()); //Check if the IP is empty if (address.isNull()) { @@ -81,7 +81,7 @@ void DevicePluginKeba::postSetupDevice(Device *device) qCDebug(dcKebaKeContact()) << "Post setup" << device->name(); QByteArray datagram; datagram.append("report 2"); - m_kebaSocket->writeDatagram(datagram.data(), datagram.size(), QHostAddress(device->paramValue(wallboxIpParamTypeId).toString()), 7090); + m_kebaSocket->writeDatagram(datagram.data(), datagram.size(), QHostAddress(device->paramValue(wallboxDeviceIpParamTypeId).toString()), 7090); } void DevicePluginKeba::deviceRemoved(Device *device) @@ -120,24 +120,24 @@ DeviceManager::DeviceError DevicePluginKeba::executeAction(Device *device, const if(action.actionTypeId() == wallboxMaxCurrentActionTypeId){ // Print information that we are executing now the update action - qCDebug(dcKebaKeContact()) << "Update max current to : " << action.param(wallboxMaxCurrentActionParamTypeId).value().toString(); + qCDebug(dcKebaKeContact()) << "Update max current to : " << action.param(wallboxMaxCurrentActionMaxCurrentParamTypeId).value().toString(); QByteArray datagram; - datagram.append("curr " + QVariant(action.param(wallboxMaxCurrentActionParamTypeId).value().toInt()*1000).toString()); + datagram.append("curr " + QVariant(action.param(wallboxMaxCurrentActionMaxCurrentParamTypeId).value().toInt()*1000).toString()); qCDebug(dcKebaKeContact()) << "Datagram : " << datagram; - m_kebaSocket->writeDatagram(datagram.data(),datagram.size(), QHostAddress(device->paramValue(wallboxIpParamTypeId).toString()) , 7090); + m_kebaSocket->writeDatagram(datagram.data(),datagram.size(), QHostAddress(device->paramValue(wallboxDeviceIpParamTypeId).toString()) , 7090); } else if(action.actionTypeId() == wallboxOutEnableActionTypeId){ // Print information that we are executing now the update action - qCDebug(dcKebaKeContact()) << "output enable : " << action.param(wallboxOutEnableActionParamTypeId).value().toString(); + qCDebug(dcKebaKeContact()) << "output enable : " << action.param(wallboxOutEnableActionOutEnableParamTypeId).value().toString(); QByteArray datagram; - if(action.param(wallboxOutEnableActionParamTypeId).value().toBool()){ + if(action.param(wallboxOutEnableActionOutEnableParamTypeId).value().toBool()){ datagram.append("ena 1"); } else{ datagram.append("ena 0"); } qCDebug(dcKebaKeContact()) << "Datagram : " << datagram; - m_kebaSocket->writeDatagram(datagram.data(),datagram.size(), QHostAddress(device->paramValue(wallboxIpParamTypeId).toString()) , 7090); + m_kebaSocket->writeDatagram(datagram.data(),datagram.size(), QHostAddress(device->paramValue(wallboxDeviceIpParamTypeId).toString()) , 7090); } return DeviceManager::DeviceErrorNoError; @@ -230,7 +230,7 @@ void DevicePluginKeba::readPendingDatagrams() QByteArray datagram; datagram.append("report 3"); qCDebug(dcKebaKeContact()) << "datagram : " << datagram; - socket->writeDatagram(datagram.data(),datagram.size(), QHostAddress(m_kebaDevices.value(sender)->paramValue(wallboxIpParamTypeId).toString()) , 7090); + socket->writeDatagram(datagram.data(),datagram.size(), QHostAddress(m_kebaDevices.value(sender)->paramValue(wallboxDeviceIpParamTypeId).toString()) , 7090); } else if(data.value("ID").toString() == "3"){ //power of current charging session diff --git a/kodi/devicepluginkodi.cpp b/kodi/devicepluginkodi.cpp index c519a525..2067e688 100644 --- a/kodi/devicepluginkodi.cpp +++ b/kodi/devicepluginkodi.cpp @@ -96,8 +96,8 @@ void DevicePluginKodi::init() DeviceManager::DeviceSetupStatus DevicePluginKodi::setupDevice(Device *device) { - qCDebug(dcKodi) << "Setup Kodi device" << device->paramValue(kodiIpParamTypeId).toString(); - Kodi *kodi= new Kodi(QHostAddress(device->paramValue(kodiIpParamTypeId).toString()), 9090, this); + qCDebug(dcKodi) << "Setup Kodi device" << device->paramValue(kodiDeviceIpParamTypeId).toString(); + Kodi *kodi= new Kodi(QHostAddress(device->paramValue(kodiDeviceIpParamTypeId).toString()), 9090, this); connect(kodi, &Kodi::connectionStatusChanged, this, &DevicePluginKodi::onConnectionChanged); connect(kodi, &Kodi::stateChanged, this, &DevicePluginKodi::onStateChanged); @@ -145,25 +145,25 @@ DeviceManager::DeviceError DevicePluginKodi::executeAction(Device *device, const } if (action.actionTypeId() == kodiShowNotificationActionTypeId) { - kodi->showNotification(action.param(kodiMessageParamTypeId).value().toString(), 8000, action.param(kodiTypeParamTypeId).value().toString(), action.id()); + kodi->showNotification(action.param(kodiShowNotificationActionMessageParamTypeId).value().toString(), 8000, action.param(kodiShowNotificationActionTypeParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; } else if (action.actionTypeId() == kodiVolumeActionTypeId) { - kodi->setVolume(action.param(kodiVolumeActionParamTypeId).value().toInt(), action.id()); + kodi->setVolume(action.param(kodiVolumeActionVolumeParamTypeId).value().toInt(), action.id()); return DeviceManager::DeviceErrorAsync; } else if (action.actionTypeId() == kodiMuteActionTypeId) { - kodi->setMuted(action.param(kodiMuteActionParamTypeId).value().toBool(), action.id()); + kodi->setMuted(action.param(kodiMuteActionMuteParamTypeId).value().toBool(), action.id()); return DeviceManager::DeviceErrorAsync; } else if (action.actionTypeId() == kodiPressButtonActionTypeId) { - kodi->pressButton(action.param(kodiButtonParamTypeId).value().toString(), action.id()); + kodi->pressButton(action.param(kodiPressButtonActionButtonParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; } else if (action.actionTypeId() == kodiSystemActionTypeId) { - kodi->systemCommand(action.param(kodiSystemCommandParamTypeId).value().toString(), action.id()); + kodi->systemCommand(action.param(kodiSystemActionSystemCommandParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; } else if (action.actionTypeId() == kodiVideoLibraryActionTypeId) { - kodi->videoLibrary(action.param(kodiVideoCommandParamTypeId).value().toString(), action.id()); + kodi->videoLibrary(action.param(kodiVideoLibraryActionVideoCommandParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; } else if (action.actionTypeId() == kodiAudioLibraryActionTypeId) { - kodi->audioLibrary(action.param(kodiAudioCommandParamTypeId).value().toString(), action.id()); + kodi->audioLibrary(action.param(kodiAudioLibraryActionAudioCommandParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; } else if(action.actionTypeId() == kodiSkipBackActionTypeId) { kodi->pressButton("skipprevious", action.id()); @@ -220,7 +220,7 @@ void DevicePluginKodi::onUpnpDiscoveryFinished() // check if we already found the kodi on this ip bool alreadyAdded = false; foreach (const DeviceDescriptor dDescriptor, deviceDescriptors) { - if (dDescriptor.params().paramValue(kodiIpParamTypeId).toString() == upnpDescriptor.hostAddress().toString()) { + if (dDescriptor.params().paramValue(kodiDeviceIpParamTypeId).toString() == upnpDescriptor.hostAddress().toString()) { alreadyAdded = true; break; } @@ -231,9 +231,9 @@ void DevicePluginKodi::onUpnpDiscoveryFinished() qCDebug(dcKodi) << upnpDescriptor; DeviceDescriptor deviceDescriptor(kodiDeviceClassId, "Kodi - Media Center", upnpDescriptor.hostAddress().toString()); ParamList params; - params.append(Param(kodiNameParamTypeId, upnpDescriptor.friendlyName())); - params.append(Param(kodiIpParamTypeId, upnpDescriptor.hostAddress().toString())); - params.append(Param(kodiPortParamTypeId, 9090)); + params.append(Param(kodiDeviceNameParamTypeId, upnpDescriptor.friendlyName())); + params.append(Param(kodiDeviceIpParamTypeId, upnpDescriptor.hostAddress().toString())); + params.append(Param(kodiDevicePortParamTypeId, 9090)); deviceDescriptor.setParams(params); deviceDescriptors.append(deviceDescriptor); } diff --git a/leynew/devicepluginleynew.cpp b/leynew/devicepluginleynew.cpp index f0658a9f..b3f89008 100644 --- a/leynew/devicepluginleynew.cpp +++ b/leynew/devicepluginleynew.cpp @@ -82,14 +82,14 @@ DeviceManager::DeviceError DevicePluginLeynew::executeAction(Device *device, con // TODO: find out how the id will be calculated to bin code or make it discoverable // ======================================= // bincode depending on the id - if (device->paramValue(rfControllerIdParamTypeId) == "0115"){ + if (device->paramValue(rfControllerDeviceIdParamTypeId) == "0115"){ binCode.append("001101000001"); - } else if (device->paramValue(rfControllerIdParamTypeId) == "0014") { + } else if (device->paramValue(rfControllerDeviceIdParamTypeId) == "0014") { binCode.append("110000010101"); - } else if (device->paramValue(rfControllerIdParamTypeId) == "0008") { + } else if (device->paramValue(rfControllerDeviceIdParamTypeId) == "0008") { binCode.append("111101010101"); } else { - qCWarning(dcLeynew) << "Could not get id of device: invalid parameter" << device->paramValue(rfControllerIdParamTypeId); + qCWarning(dcLeynew) << "Could not get id of device: invalid parameter" << device->paramValue(rfControllerDeviceIdParamTypeId); return DeviceManager::DeviceErrorInvalidParameter; } diff --git a/lgsmarttv/devicepluginlgsmarttv.cpp b/lgsmarttv/devicepluginlgsmarttv.cpp index 64be07b4..58cfe484 100644 --- a/lgsmarttv/devicepluginlgsmarttv.cpp +++ b/lgsmarttv/devicepluginlgsmarttv.cpp @@ -83,25 +83,25 @@ DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::setupDevice(Device *devi return DeviceManager::DeviceSetupStatusFailure; } - TvDevice *tvDevice = new TvDevice(QHostAddress(device->paramValue(lgSmartTvHostAddressParamTypeId).toString()), - device->paramValue(lgSmartTvPortParamTypeId).toInt(), this); - tvDevice->setUuid(device->paramValue(lgSmartTvUuidParamTypeId).toString()); + TvDevice *tvDevice = new TvDevice(QHostAddress(device->paramValue(lgSmartTvDeviceHostAddressParamTypeId).toString()), + device->paramValue(lgSmartTvDevicePortParamTypeId).toInt(), this); + tvDevice->setUuid(device->paramValue(lgSmartTvDeviceUuidParamTypeId).toString()); // if the key is missing, this setup call comes from a pairing procedure - if (device->paramValue(lgSmartTvKeyParamTypeId) == QString()) { + if (device->paramValue(lgSmartTvDeviceKeyParamTypeId) == QString()) { // check if we know the key from the pairing procedure - if (!m_tvKeys.contains(device->paramValue(lgSmartTvUuidParamTypeId).toString())) { + if (!m_tvKeys.contains(device->paramValue(lgSmartTvDeviceUuidParamTypeId).toString())) { qCWarning(dcLgSmartTv) << "could not find any pairing key"; return DeviceManager::DeviceSetupStatusFailure; } // use the key from the pairing procedure - QString key = m_tvKeys.value(device->paramValue(lgSmartTvUuidParamTypeId).toString()); + QString key = m_tvKeys.value(device->paramValue(lgSmartTvDeviceUuidParamTypeId).toString()); tvDevice->setKey(key); - device->setParamValue(lgSmartTvKeyParamTypeId, key); + device->setParamValue(lgSmartTvDeviceKeyParamTypeId, key); } else { // add the key for editing - if (!m_tvKeys.contains(device->paramValue(lgSmartTvUuidParamTypeId).toString())) { + if (!m_tvKeys.contains(device->paramValue(lgSmartTvDeviceUuidParamTypeId).toString())) { m_tvKeys.insert(tvDevice->uuid(), tvDevice->key()); } } @@ -236,8 +236,8 @@ DeviceManager::DeviceError DevicePluginLgSmartTv::displayPin(const PairingTransa { Q_UNUSED(pairingTransactionId) - QHostAddress host = QHostAddress(deviceDescriptor.params().paramValue(lgSmartTvHostAddressParamTypeId).toString()); - int port = deviceDescriptor.params().paramValue(lgSmartTvPortParamTypeId).toInt(); + QHostAddress host = QHostAddress(deviceDescriptor.params().paramValue(lgSmartTvDeviceHostAddressParamTypeId).toString()); + int port = deviceDescriptor.params().paramValue(lgSmartTvDevicePortParamTypeId).toInt(); QPair request = TvDevice::createDisplayKeyRequest(host, port); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); @@ -250,23 +250,23 @@ DeviceManager::DeviceSetupStatus DevicePluginLgSmartTv::confirmPairing(const Pai { Q_UNUSED(deviceClassId) - QHostAddress host = QHostAddress(params.paramValue(lgSmartTvHostAddressParamTypeId).toString()); - int port = params.paramValue(lgSmartTvPortParamTypeId).toInt(); + QHostAddress host = QHostAddress(params.paramValue(lgSmartTvDeviceHostAddressParamTypeId).toString()); + int port = params.paramValue(lgSmartTvDevicePortParamTypeId).toInt(); QPair request = TvDevice::createPairingRequest(host, port, secret); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_setupPairingTv.insert(reply, pairingTransactionId); - m_tvKeys.insert(params.paramValue(lgSmartTvUuidParamTypeId).toString(), secret); + m_tvKeys.insert(params.paramValue(lgSmartTvDeviceUuidParamTypeId).toString(), secret); return DeviceManager::DeviceSetupStatusAsync; } void DevicePluginLgSmartTv::pairTvDevice(Device *device, const bool &setup) { - QHostAddress host = QHostAddress(device->paramValue(lgSmartTvHostAddressParamTypeId).toString()); - int port = device->paramValue(lgSmartTvPortParamTypeId).toInt(); - QString key = device->paramValue(lgSmartTvKeyParamTypeId).toString(); + QHostAddress host = QHostAddress(device->paramValue(lgSmartTvDeviceHostAddressParamTypeId).toString()); + int port = device->paramValue(lgSmartTvDevicePortParamTypeId).toInt(); + QString key = device->paramValue(lgSmartTvDeviceKeyParamTypeId).toString(); QPair request = TvDevice::createPairingRequest(host, port, key); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); @@ -280,8 +280,8 @@ void DevicePluginLgSmartTv::pairTvDevice(Device *device, const bool &setup) void DevicePluginLgSmartTv::unpairTvDevice(Device *device) { - QHostAddress host = QHostAddress(device->paramValue(lgSmartTvHostAddressParamTypeId).toString()); - int port = device->paramValue(lgSmartTvPortParamTypeId).toInt(); + QHostAddress host = QHostAddress(device->paramValue(lgSmartTvDeviceHostAddressParamTypeId).toString()); + int port = device->paramValue(lgSmartTvDevicePortParamTypeId).toInt(); QPair request = TvDevice::createEndPairingRequest(host, port); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); @@ -332,12 +332,12 @@ void DevicePluginLgSmartTv::onUpnpDiscoveryFinished() qCDebug(dcLgSmartTv) << upnpDeviceDescriptor; DeviceDescriptor descriptor(lgSmartTvDeviceClassId, "Lg Smart Tv", upnpDeviceDescriptor.modelName()); ParamList params; - params.append(Param(lgSmartTvNameParamTypeId, upnpDeviceDescriptor.friendlyName())); - params.append(Param(lgSmartTvUuidParamTypeId, upnpDeviceDescriptor.uuid())); - params.append(Param(lgSmartTvModelParamTypeId, upnpDeviceDescriptor.modelName())); - params.append(Param(lgSmartTvHostAddressParamTypeId, upnpDeviceDescriptor.hostAddress().toString())); - params.append(Param(lgSmartTvPortParamTypeId, upnpDeviceDescriptor.port())); - params.append(Param(lgSmartTvKeyParamTypeId, QString())); + params.append(Param(lgSmartTvDeviceNameParamTypeId, upnpDeviceDescriptor.friendlyName())); + params.append(Param(lgSmartTvDeviceUuidParamTypeId, upnpDeviceDescriptor.uuid())); + params.append(Param(lgSmartTvDeviceModelParamTypeId, upnpDeviceDescriptor.modelName())); + params.append(Param(lgSmartTvDeviceHostAddressParamTypeId, upnpDeviceDescriptor.hostAddress().toString())); + params.append(Param(lgSmartTvDevicePortParamTypeId, upnpDeviceDescriptor.port())); + params.append(Param(lgSmartTvDeviceKeyParamTypeId, QString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } diff --git a/mailnotification/devicepluginmailnotification.cpp b/mailnotification/devicepluginmailnotification.cpp index 48bf5ccf..f526a274 100644 --- a/mailnotification/devicepluginmailnotification.cpp +++ b/mailnotification/devicepluginmailnotification.cpp @@ -85,13 +85,13 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic SmtpClient *smtpClient = new SmtpClient(this); smtpClient->setHost("smtp.gmail.com"); smtpClient->setPort(465); - smtpClient->setUser(device->paramValue(googleMailUserParamTypeId).toString()); + smtpClient->setUser(device->paramValue(googleMailDeviceUserParamTypeId).toString()); // TODO: use cryptography to save password not as plain text - smtpClient->setPassword(device->paramValue(googleMailPasswordParamTypeId).toString()); + smtpClient->setPassword(device->paramValue(googleMailDevicePasswordParamTypeId).toString()); smtpClient->setAuthMethod(SmtpClient::AuthMethodLogin); smtpClient->setEncryptionType(SmtpClient::EncryptionTypeSSL); - smtpClient->setSender(device->paramValue(googleMailUserParamTypeId).toString()); - smtpClient->setRecipient(device->paramValue(googleMailRecipientParamTypeId).toString()); + smtpClient->setSender(device->paramValue(googleMailDeviceUserParamTypeId).toString()); + smtpClient->setRecipient(device->paramValue(googleMailDeviceRecipientParamTypeId).toString()); connect(smtpClient, &SmtpClient::testLoginFinished, this, &DevicePluginMailNotification::testLoginFinished); connect(smtpClient, &SmtpClient::sendMailFinished, this, &DevicePluginMailNotification::sendMailFinished); @@ -106,13 +106,13 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic SmtpClient *smtpClient = new SmtpClient(this); smtpClient->setHost("smtp.mail.yahoo.com"); smtpClient->setPort(465); - smtpClient->setUser(device->paramValue(yahooMailUserParamTypeId).toString()); + smtpClient->setUser(device->paramValue(yahooMailDeviceUserParamTypeId).toString()); // TODO: use cryptography to save password not as plain text - smtpClient->setPassword(device->paramValue(yahooMailPasswordParamTypeId).toString()); + smtpClient->setPassword(device->paramValue(yahooMailDevicePasswordParamTypeId).toString()); smtpClient->setAuthMethod(SmtpClient::AuthMethodLogin); smtpClient->setEncryptionType(SmtpClient::EncryptionTypeSSL); - smtpClient->setSender(device->paramValue(yahooMailUserParamTypeId).toString()); - smtpClient->setRecipient(device->paramValue(yahooMailRecipientParamTypeId).toString()); + smtpClient->setSender(device->paramValue(yahooMailDeviceUserParamTypeId).toString()); + smtpClient->setRecipient(device->paramValue(yahooMailDeviceRecipientParamTypeId).toString()); connect(smtpClient, &SmtpClient::testLoginFinished, this, &DevicePluginMailNotification::testLoginFinished); connect(smtpClient, &SmtpClient::sendMailFinished, this, &DevicePluginMailNotification::sendMailFinished); @@ -125,33 +125,33 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic // Custom mail if(device->deviceClassId() == customMailDeviceClassId) { SmtpClient *smtpClient = new SmtpClient(this); - smtpClient->setHost(device->paramValue(customMailSmtpParamTypeId).toString()); - smtpClient->setPort(device->paramValue(customMailPortParamTypeId).toInt()); - smtpClient->setUser(device->paramValue(customMailCustomUserParamTypeId).toString()); + smtpClient->setHost(device->paramValue(customMailDeviceSmtpParamTypeId).toString()); + smtpClient->setPort(device->paramValue(customMailDevicePortParamTypeId).toInt()); + smtpClient->setUser(device->paramValue(customMailDeviceCustomUserParamTypeId).toString()); // TODO: use cryptography to save password not as plain text - smtpClient->setPassword(device->paramValue(customMailCustomPasswordParamTypeId).toString()); + smtpClient->setPassword(device->paramValue(customMailDeviceCustomPasswordParamTypeId).toString()); - if(device->paramValue(customMailAuthenticationParamTypeId).toString() == "PLAIN") { + if(device->paramValue(customMailDeviceAuthenticationParamTypeId).toString() == "PLAIN") { smtpClient->setAuthMethod(SmtpClient::AuthMethodPlain); - } else if(device->paramValue(customMailAuthenticationParamTypeId).toString() == "LOGIN") { + } else if(device->paramValue(customMailDeviceAuthenticationParamTypeId).toString() == "LOGIN") { smtpClient->setAuthMethod(SmtpClient::AuthMethodLogin); } else { return DeviceManager::DeviceSetupStatusFailure; } - if(device->paramValue(customMailEncryptionParamTypeId).toString() == "NONE") { + if(device->paramValue(customMailDeviceEncryptionParamTypeId).toString() == "NONE") { smtpClient->setEncryptionType(SmtpClient::EncryptionTypeNone); - } else if(device->paramValue(customMailEncryptionParamTypeId).toString() == "SSL") { + } else if(device->paramValue(customMailDeviceEncryptionParamTypeId).toString() == "SSL") { smtpClient->setEncryptionType(SmtpClient::EncryptionTypeSSL); - } else if(device->paramValue(customMailEncryptionParamTypeId).toString() == "TLS") { + } else if(device->paramValue(customMailDeviceEncryptionParamTypeId).toString() == "TLS") { smtpClient->setEncryptionType(SmtpClient::EncryptionTypeTLS); } else { return DeviceManager::DeviceSetupStatusFailure; } - smtpClient->setRecipient(device->paramValue(customMailCustomRecipientParamTypeId).toString()); - smtpClient->setSender(device->paramValue(customMailCustomSenderParamTypeId).toString()); + smtpClient->setRecipient(device->paramValue(customMailDeviceCustomRecipientParamTypeId).toString()); + smtpClient->setSender(device->paramValue(customMailDeviceCustomSenderParamTypeId).toString()); connect(smtpClient, &SmtpClient::testLoginFinished, this, &DevicePluginMailNotification::testLoginFinished); connect(smtpClient, &SmtpClient::sendMailFinished, this, &DevicePluginMailNotification::sendMailFinished); @@ -168,7 +168,7 @@ DeviceManager::DeviceError DevicePluginMailNotification::executeAction(Device *d { if(action.actionTypeId() == googleMailSendMailActionTypeId) { SmtpClient *smtpClient = m_clients.key(device); - smtpClient->sendMail(action.param(googleMailSubjectParamTypeId).value().toString(), action.param(googleMailBodyParamTypeId).value().toString(), action.id()); + smtpClient->sendMail(action.param(googleMailSendMailActionSubjectParamTypeId).value().toString(), action.param(googleMailSendMailActionBodyParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; } return DeviceManager::DeviceErrorActionTypeNotFound; diff --git a/netatmo/devicepluginnetatmo.cpp b/netatmo/devicepluginnetatmo.cpp index a44364b9..7993f25a 100644 --- a/netatmo/devicepluginnetatmo.cpp +++ b/netatmo/devicepluginnetatmo.cpp @@ -71,8 +71,8 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device OAuth2 *authentication = new OAuth2("561c015d49c75f0d1cce6e13", "GuvKkdtu7JQlPD47qTTepRR9hQ0CUPAj4Tae3Ohcq", this); authentication->setUrl(QUrl("https://api.netatmo.net/oauth2/token")); - authentication->setUsername(device->paramValue(connectionUsernameParamTypeId).toString()); - authentication->setPassword(device->paramValue(connectionPasswordParamTypeId).toString()); + authentication->setUsername(device->paramValue(connectionDeviceUsernameParamTypeId).toString()); + authentication->setPassword(device->paramValue(connectionDevicePasswordParamTypeId).toString()); authentication->setScope("read_station read_thermostat write_thermostat"); m_authentications.insert(authentication, device); @@ -84,8 +84,8 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device } else if (device->deviceClassId() == indoorDeviceClassId) { qCDebug(dcNetatmo) << "Setup netatmo indoor base station" << device->params(); - NetatmoBaseStation *indoor = new NetatmoBaseStation(device->paramValue(indoorNameParamTypeId).toString(), - device->paramValue(indoorMacParamTypeId).toString(), + NetatmoBaseStation *indoor = new NetatmoBaseStation(device->paramValue(indoorDeviceNameParamTypeId).toString(), + device->paramValue(indoorDeviceMacParamTypeId).toString(), this); m_indoorDevices.insert(indoor, device); @@ -94,9 +94,9 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device return DeviceManager::DeviceSetupStatusSuccess; } else if (device->deviceClassId() == outdoorDeviceClassId) { qCDebug(dcNetatmo) << "Setup netatmo outdoor module" << device->params(); - NetatmoOutdoorModule *outdoor = new NetatmoOutdoorModule(device->paramValue(outdoorNameParamTypeId).toString(), - device->paramValue(outdoorMacParamTypeId).toString(), - device->paramValue(outdoorBaseStationParamTypeId).toString(), + NetatmoOutdoorModule *outdoor = new NetatmoOutdoorModule(device->paramValue(outdoorDeviceNameParamTypeId).toString(), + device->paramValue(outdoorDeviceMacParamTypeId).toString(), + device->paramValue(outdoorDeviceBaseStationParamTypeId).toString(), this); m_outdoorDevices.insert(outdoor, device); @@ -163,8 +163,8 @@ void DevicePluginNetatmo::processRefreshData(const QVariantMap &data, const QStr if (!indoorDevice) { DeviceDescriptor descriptor(indoorDeviceClassId, "Indoor Station", deviceMap.value("station_name").toString(), connectionId); ParamList params; - params.append(Param(indoorNameParamTypeId, deviceMap.value("station_name").toString())); - params.append(Param(indoorMacParamTypeId, deviceMap.value("_id").toString())); + params.append(Param(indoorDeviceNameParamTypeId, deviceMap.value("station_name").toString())); + params.append(Param(indoorDeviceMacParamTypeId, deviceMap.value("_id").toString())); descriptor.setParams(params); emit autoDevicesAppeared(indoorDeviceClassId, QList() << descriptor); } else { @@ -189,9 +189,9 @@ void DevicePluginNetatmo::processRefreshData(const QVariantMap &data, const QStr if (!outdoorDevice) { DeviceDescriptor descriptor(outdoorDeviceClassId, "Outdoor Module", moduleMap.value("module_name").toString(), connectionId); ParamList params; - params.append(Param(outdoorNameParamTypeId, moduleMap.value("module_name").toString())); - params.append(Param(outdoorMacParamTypeId, moduleMap.value("_id").toString())); - params.append(Param(outdoorBaseStationParamTypeId, moduleMap.value("main_device").toString())); + params.append(Param(outdoorDeviceNameParamTypeId, moduleMap.value("module_name").toString())); + params.append(Param(outdoorDeviceMacParamTypeId, moduleMap.value("_id").toString())); + params.append(Param(outdoorDeviceBaseStationParamTypeId, moduleMap.value("main_device").toString())); descriptor.setParams(params); emit autoDevicesAppeared(outdoorDeviceClassId, QList() << descriptor); } else { @@ -209,7 +209,7 @@ Device *DevicePluginNetatmo::findIndoorDevice(const QString &macAddress) { foreach (Device *device, myDevices()) { if (device->deviceClassId() == indoorDeviceClassId) { - if (device->paramValue(indoorMacParamTypeId).toString() == macAddress) { + if (device->paramValue(indoorDeviceMacParamTypeId).toString() == macAddress) { return device; } } @@ -221,7 +221,7 @@ Device *DevicePluginNetatmo::findOutdoorDevice(const QString &macAddress) { foreach (Device *device, myDevices()) { if (device->deviceClassId() == outdoorDeviceClassId) { - if (device->paramValue(outdoorMacParamTypeId).toString() == macAddress) { + if (device->paramValue(outdoorDeviceMacParamTypeId).toString() == macAddress) { return device; } } diff --git a/networkdetector/devicepluginnetworkdetector.cpp b/networkdetector/devicepluginnetworkdetector.cpp index c27a8d4d..9d0bd811 100644 --- a/networkdetector/devicepluginnetworkdetector.cpp +++ b/networkdetector/devicepluginnetworkdetector.cpp @@ -77,7 +77,7 @@ void DevicePluginNetworkDetector::init() DeviceManager::DeviceSetupStatus DevicePluginNetworkDetector::setupDevice(Device *device) { qCDebug(dcNetworkDetector()) << "Setup" << device->name() << device->params(); - DeviceMonitor *monitor = new DeviceMonitor(device->paramValue(networkDeviceMacAddressParamTypeId).toString(), device->paramValue(networkDeviceAddressParamTypeId).toString(), this); + DeviceMonitor *monitor = new DeviceMonitor(device->paramValue(networkDeviceDeviceMacAddressParamTypeId).toString(), device->paramValue(networkDeviceDeviceAddressParamTypeId).toString(), this); connect(monitor, &DeviceMonitor::reachableChanged, this, &DevicePluginNetworkDetector::deviceReachableChanged); connect(monitor, &DeviceMonitor::addressChanged, this, &DevicePluginNetworkDetector::deviceAddressChanged); m_monitors.insert(monitor, device); @@ -125,8 +125,8 @@ void DevicePluginNetworkDetector::discoveryFinished(const QList &hosts) DeviceDescriptor descriptor(networkDeviceDeviceClassId, (host.hostName().isEmpty() ? host.address() : host.hostName() + "(" + host.address() + ")"), host.macAddress()); ParamList paramList; - Param macAddress(networkDeviceMacAddressParamTypeId, host.macAddress()); - Param address(networkDeviceAddressParamTypeId, host.address()); + Param macAddress(networkDeviceDeviceMacAddressParamTypeId, host.macAddress()); + Param address(networkDeviceDeviceAddressParamTypeId, host.address()); paramList.append(macAddress); paramList.append(address); descriptor.setParams(paramList); @@ -142,7 +142,7 @@ void DevicePluginNetworkDetector::deviceReachableChanged(bool reachable) DeviceMonitor *monitor = static_cast(sender()); Device *device = m_monitors.value(monitor); if (device->stateValue(networkDeviceConnectedStateTypeId).toBool() != reachable) { - qCDebug(dcNetworkDetector()) << "Device" << device->paramValue(networkDeviceMacAddressParamTypeId).toString() << "reachable changed" << reachable; + qCDebug(dcNetworkDetector()) << "Device" << device->paramValue(networkDeviceDeviceMacAddressParamTypeId).toString() << "reachable changed" << reachable; device->setStateValue(networkDeviceConnectedStateTypeId, reachable); } } @@ -151,7 +151,7 @@ void DevicePluginNetworkDetector::deviceAddressChanged(const QString &address) { DeviceMonitor *monitor = static_cast(sender()); Device *device = m_monitors.value(monitor); - if (device->paramValue(networkDeviceAddressParamTypeId).toString() != address) { - device->setParamValue(networkDeviceAddressParamTypeId.toString(), address); + if (device->paramValue(networkDeviceDeviceAddressParamTypeId).toString() != address) { + device->setParamValue(networkDeviceDeviceAddressParamTypeId.toString(), address); } } diff --git a/nymea-plugins.pro b/nymea-plugins.pro index bd9fb34e..6c5b071f 100644 --- a/nymea-plugins.pro +++ b/nymea-plugins.pro @@ -36,7 +36,7 @@ PLUGIN_DIRS = \ simulation \ keba \ remotessh \ - dweetio \ + dweetio \ flowercare \ CONFIG+=all @@ -61,6 +61,10 @@ for (entry, PLUGIN_DIRS):lrelease.commands += lrelease $$files($$PWD/$${entry}/t for (entry, PLUGIN_DIRS):lrelease.commands += rsync -a $$PWD/$${entry}/translations/*.qm $$OUT_PWD/translations/; QMAKE_EXTRA_TARGETS += lrelease +# For Qt-Creator's code model: Add CPATH to INCLUDEPATH explicitly +INCLUDEPATH += $$(CPATH) +message(" cpath is $$(CPATH)") + # Verify if building only a selection of plugins contains(CONFIG, selection) { CONFIG-=all diff --git a/openweathermap/devicepluginopenweathermap.cpp b/openweathermap/devicepluginopenweathermap.cpp index 699a047b..77a13e66 100644 --- a/openweathermap/devicepluginopenweathermap.cpp +++ b/openweathermap/devicepluginopenweathermap.cpp @@ -84,7 +84,7 @@ DeviceManager::DeviceError DevicePluginOpenweathermap::discoverDevices(const Dev return DeviceManager::DeviceErrorDeviceClassNotFound; } - QString location = params.paramValue(openweathermapLocationParamTypeId).toString(); + QString location = params.paramValue(openweathermapDiscoveryLocationParamTypeId).toString(); // if we have an empty search string, perform an autodetection of the location with the WAN ip... if (location.isEmpty()){ @@ -161,7 +161,7 @@ void DevicePluginOpenweathermap::update(Device *device) qCDebug(dcOpenWeatherMap()) << "Refresh data for" << device->name(); QUrl url("http://api.openweathermap.org/data/2.5/weather"); QUrlQuery query; - query.addQueryItem("id", device->paramValue(openweathermapIdParamTypeId).toString()); + query.addQueryItem("id", device->paramValue(openweathermapDeviceIdParamTypeId).toString()); query.addQueryItem("mode", "json"); query.addQueryItem("units", "metric"); query.addQueryItem("appid", m_apiKey); @@ -315,11 +315,11 @@ void DevicePluginOpenweathermap::processSearchResults(const QList & foreach (QVariantMap elemant, cityList) { DeviceDescriptor descriptor(openweathermapDeviceClassId, elemant.value("name").toString(), elemant.value("country").toString()); ParamList params; - Param nameParam(openweathermapNameParamTypeId, elemant.value("name")); + Param nameParam(openweathermapDeviceNameParamTypeId, elemant.value("name")); params.append(nameParam); - Param countryParam(openweathermapCountryParamTypeId, elemant.value("country")); + Param countryParam(openweathermapDeviceCountryParamTypeId, elemant.value("country")); params.append(countryParam); - Param idParam(openweathermapIdParamTypeId, elemant.value("id")); + Param idParam(openweathermapDeviceIdParamTypeId, elemant.value("id")); params.append(idParam); descriptor.setParams(params); retList.append(descriptor); diff --git a/orderbutton/devicepluginorderbutton.cpp b/orderbutton/devicepluginorderbutton.cpp index 622c3ef9..6192ee97 100644 --- a/orderbutton/devicepluginorderbutton.cpp +++ b/orderbutton/devicepluginorderbutton.cpp @@ -65,7 +65,7 @@ DeviceManager::DeviceSetupStatus DevicePluginOrderButton::setupDevice(Device *de qCDebug(dcOrderButton) << "Setup Plant Care" << device->name() << device->params(); // Check if device already added with this address - if (deviceAlreadyAdded(QHostAddress(device->paramValue(orderbuttonHostParamTypeId).toString()))) { + if (deviceAlreadyAdded(QHostAddress(device->paramValue(orderbuttonDeviceHostParamTypeId).toString()))) { qCWarning(dcOrderButton) << "Device with this address already added."; return DeviceManager::DeviceSetupStatusFailure; } @@ -95,7 +95,7 @@ DeviceManager::DeviceError DevicePluginOrderButton::discoverDevices(const Device Q_UNUSED(params) // Perform a HTTP GET on the RPL router address - QHostAddress address(configuration().paramValue(orderButtonRplParamTypeId).toString()); + QHostAddress address(configuration().paramValue(orderButtonPluginRplParamTypeId).toString()); qCDebug(dcOrderButton) << "Scan for new nodes on RPL" << address.toString(); QUrl url; @@ -131,7 +131,7 @@ DeviceManager::DeviceError DevicePluginOrderButton::executeAction(Device *device if (action.actionTypeId() == orderbuttonResetActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonDeviceHostParamTypeId).toString()); url.setPath("/s/count"); CoapReply *reply = m_coap->post(CoapRequest(url), QByteArray("count=0")); @@ -147,11 +147,11 @@ DeviceManager::DeviceError DevicePluginOrderButton::executeAction(Device *device return DeviceManager::DeviceErrorAsync; } else if(action.actionTypeId() == orderbuttonLedActionTypeId) { - bool led = action.param(orderbuttonLedActionParamTypeId).value().toBool(); + bool led = action.param(orderbuttonLedActionLedParamTypeId).value().toBool(); QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonDeviceHostParamTypeId).toString()); url.setPath("/a/led"); QByteArray payload = QString("mode=%1").arg(QString::number((int)led)).toUtf8(); @@ -175,7 +175,7 @@ void DevicePluginOrderButton::pingDevice(Device *device) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonDeviceHostParamTypeId).toString()); m_pingReplies.insert(m_coap->ping(CoapRequest(url)), device); } @@ -184,7 +184,7 @@ void DevicePluginOrderButton::updateBattery(Device *device) qCDebug(dcOrderButton) << "Update" << device->name() << "battery value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonDeviceHostParamTypeId).toString()); url.setPath("/s/battery"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -201,7 +201,7 @@ void DevicePluginOrderButton::updateCount(Device *device) qCDebug(dcOrderButton) << "Update" << device->name() << "count value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonDeviceHostParamTypeId).toString()); url.setPath("/s/count"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -219,7 +219,7 @@ void DevicePluginOrderButton::updateButton(Device *device) qCDebug(dcOrderButton) << "Update" << device->name() << "button value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonDeviceHostParamTypeId).toString()); url.setPath("/s/button"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -238,7 +238,7 @@ void DevicePluginOrderButton::updateLed(Device *device) qCDebug(dcOrderButton) << "Update" << device->name() << "led value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonDeviceHostParamTypeId).toString()); url.setPath("/a/led"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -256,7 +256,7 @@ void DevicePluginOrderButton::enableNotifications(Device *device) qCDebug(dcOrderButton) << "Enable" << device->name() << "notifications"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonDeviceHostParamTypeId).toString()); url.setPath("/s/button"); m_enableNotification.insert(m_coap->enableResourceNotifications(CoapRequest(url)), device); @@ -298,7 +298,7 @@ bool DevicePluginOrderButton::deviceAlreadyAdded(const QHostAddress &address) { // Check if we already have a device with the given address foreach (Device *device, myDevices()) { - if (device->paramValue(orderbuttonHostParamTypeId).toString() == address.toString()) { + if (device->paramValue(orderbuttonDeviceHostParamTypeId).toString() == address.toString()) { return true; } } @@ -309,11 +309,11 @@ Device *DevicePluginOrderButton::findDevice(const QHostAddress &address) { // Return the device pointer with the given address (otherwise 0) foreach (Device *device, myDevices()) { - if (device->paramValue(orderbuttonHostParamTypeId).toString() == address.toString()) { + if (device->paramValue(orderbuttonDeviceHostParamTypeId).toString() == address.toString()) { return device; } } - return NULL; + return nullptr; } void DevicePluginOrderButton::onPluginTimer() @@ -358,7 +358,7 @@ void DevicePluginOrderButton::onNetworkReplyFinished() // Create a deviceDescriptor for each found address DeviceDescriptor descriptor(deviceClassId, "Order Button", address.toString()); ParamList params; - params.append(Param(orderbuttonHostParamTypeId, address.toString())); + params.append(Param(orderbuttonDeviceHostParamTypeId, address.toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -466,7 +466,7 @@ void DevicePluginOrderButton::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(orderbuttonLedStateTypeId, action.param(orderbuttonLedActionParamTypeId).value().toBool()); + device->setStateValue(orderbuttonLedStateTypeId, action.param(orderbuttonLedActionLedParamTypeId).value().toBool()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); diff --git a/osdomotics/devicepluginosdomotics.cpp b/osdomotics/devicepluginosdomotics.cpp index 9bdb0460..8d8b75d2 100644 --- a/osdomotics/devicepluginosdomotics.cpp +++ b/osdomotics/devicepluginosdomotics.cpp @@ -70,11 +70,11 @@ void DevicePluginOsdomotics::init() DeviceManager::DeviceSetupStatus DevicePluginOsdomotics::setupDevice(Device *device) { if (device->deviceClassId() == rplRouterDeviceClassId) { - qCDebug(dcOsdomotics) << "Setup RPL router" << device->paramValue(rplRouterRplHostParamTypeId).toString(); - QHostAddress address(device->paramValue(rplRouterRplHostParamTypeId).toString()); + qCDebug(dcOsdomotics) << "Setup RPL router" << device->paramValue(rplRouterDeviceRplHostParamTypeId).toString(); + QHostAddress address(device->paramValue(rplRouterDeviceRplHostParamTypeId).toString()); if (address.isNull()) { - qCWarning(dcOsdomotics) << "Got invalid address" << device->paramValue(rplRouterRplHostParamTypeId).toString(); + qCWarning(dcOsdomotics) << "Got invalid address" << device->paramValue(rplRouterDeviceRplHostParamTypeId).toString(); return DeviceManager::DeviceSetupStatusFailure; } @@ -88,8 +88,8 @@ DeviceManager::DeviceSetupStatus DevicePluginOsdomotics::setupDevice(Device *dev return DeviceManager::DeviceSetupStatusAsync; } else if (device->deviceClassId() == merkurNodeDeviceClassId) { - qCDebug(dcOsdomotics) << "Setup Merkur node" << device->paramValue(merkurNodeHostParamTypeId).toString(); - device->setParentId(DeviceId(device->paramValue(merkurNodeRouterParamTypeId).toString())); + qCDebug(dcOsdomotics) << "Setup Merkur node" << device->paramValue(merkurNodeDeviceHostParamTypeId).toString(); + device->setParentId(DeviceId(device->paramValue(merkurNodeDeviceRouterParamTypeId).toString())); return DeviceManager::DeviceSetupStatusSuccess; } return DeviceManager::DeviceSetupStatusFailure; @@ -111,7 +111,7 @@ DeviceManager::DeviceError DevicePluginOsdomotics::executeAction(Device *device, if (action.actionTypeId() == merkurNodeToggleLedActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(merkurNodeHostParamTypeId).toString()); + url.setHost(device->paramValue(merkurNodeDeviceHostParamTypeId).toString()); url.setPath("/actuators/toggle"); qCDebug(dcOsdomotics) << "Toggle light"; @@ -137,7 +137,7 @@ DeviceManager::DeviceError DevicePluginOsdomotics::executeAction(Device *device, void DevicePluginOsdomotics::scanNodes(Device *device) { - QHostAddress address(device->paramValue(merkurNodeHostParamTypeId).toString()); + QHostAddress address(device->paramValue(merkurNodeDeviceHostParamTypeId).toString()); qCDebug(dcOsdomotics) << "Scan for new nodes" << address.toString(); QUrl url; @@ -163,7 +163,7 @@ void DevicePluginOsdomotics::parseNodes(Device *device, const QByteArray &data) // check if we already have found this node foreach (Device *device, myDevices()) { - if (device->paramValue(merkurNodeHostParamTypeId).toString() == nodeAddress.toString()) { + if (device->paramValue(merkurNodeDeviceHostParamTypeId).toString() == nodeAddress.toString()) { return; } } @@ -192,11 +192,11 @@ void DevicePluginOsdomotics::parseNodes(Device *device, const QByteArray &data) void DevicePluginOsdomotics::updateNode(Device *device) { - qCDebug(dcOsdomotics) << "Update node" << device->paramValue(merkurNodeHostParamTypeId).toString() << "battery value"; + qCDebug(dcOsdomotics) << "Update node" << device->paramValue(merkurNodeDeviceHostParamTypeId).toString() << "battery value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(merkurNodeHostParamTypeId).toString()); + url.setHost(device->paramValue(merkurNodeDeviceHostParamTypeId).toString()); url.setPath("/sensors/battery"); CoapReply *reply = m_coap->get(CoapRequest(url)); @@ -213,11 +213,11 @@ void DevicePluginOsdomotics::updateNode(Device *device) Device *DevicePluginOsdomotics::findDevice(const QHostAddress &address) { foreach (Device *device, myDevices()) { - if (device->paramValue(merkurNodeHostParamTypeId).toString() == address.toString()) { + if (device->paramValue(merkurNodeDeviceHostParamTypeId).toString() == address.toString()) { return device; } } - return 0; + return nullptr; } void DevicePluginOsdomotics::onPluginTimer() @@ -285,9 +285,9 @@ void DevicePluginOsdomotics::coapReplyFinished(CoapReply *reply) DeviceDescriptor descriptor(merkurNodeDeviceClassId, "Merkur Node", reply->request().url().host()); ParamList params; - params.append(Param(merkurNodeNameParamTypeId, "Merkur Node")); - params.append(Param(merkurNodeHostParamTypeId, reply->request().url().host())); - params.append(Param(merkurNodeRouterParamTypeId, device->id())); + params.append(Param(merkurNodeDeviceNameParamTypeId, "Merkur Node")); + params.append(Param(merkurNodeDeviceHostParamTypeId, reply->request().url().host())); + params.append(Param(merkurNodeDeviceRouterParamTypeId, device->id())); descriptor.setParams(params); emit autoDevicesAppeared(merkurNodeDeviceClassId, QList() << descriptor); diff --git a/philipshue/devicepluginphilipshue.cpp b/philipshue/devicepluginphilipshue.cpp index 61b942c6..38214a07 100644 --- a/philipshue/devicepluginphilipshue.cpp +++ b/philipshue/devicepluginphilipshue.cpp @@ -111,20 +111,20 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::discoverDevices(const DeviceC DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *device) { // hue bridge - if (device->deviceClassId() == hueBridgeDeviceClassId) { + if (device->deviceClassId() == bridgeDeviceClassId) { // unconfigured bridges (from pairing) foreach (HueBridge *b, m_unconfiguredBridges) { - if (b->hostAddress().toString() == device->paramValue(hueBridgeBridgeHostParamTypeId).toString()) { + if (b->hostAddress().toString() == device->paramValue(bridgeDeviceHostParamTypeId).toString()) { m_unconfiguredBridges.removeAll(b); qCDebug(dcPhilipsHue) << "Setup unconfigured Hue Bridge" << b->name(); // set data which was not known during discovery - device->setParamValue(hueBridgeBridgeNameParamTypeId, b->name()); - device->setParamValue(hueBridgeBridgeApiKeyParamTypeId, b->apiKey()); - device->setParamValue(hueBridgeBridgeZigbeeChannelParamTypeId, b->zigbeeChannel()); - device->setParamValue(hueBridgeBridgeIdParamTypeId, b->id()); - device->setParamValue(hueBridgeBridgeMacParamTypeId, b->macAddress()); + device->setParamValue(bridgeDeviceNameParamTypeId, b->name()); + device->setParamValue(bridgeDeviceApiKeyParamTypeId, b->apiKey()); + device->setParamValue(bridgeDeviceZigbeeChannelParamTypeId, b->zigbeeChannel()); + device->setParamValue(bridgeDeviceIdParamTypeId, b->id()); + device->setParamValue(bridgeDeviceMacParamTypeId, b->macAddress()); m_bridges.insert(b, device); - device->setStateValue(hueBridgeConnectedStateTypeId, true); + device->setStateValue(bridgeConnectedStateTypeId, true); discoverBridgeDevices(b); return DeviceManager::DeviceSetupStatusSuccess; } @@ -134,12 +134,12 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev qCDebug(dcPhilipsHue) << "Setup Hue Bridge" << device->params(); HueBridge *bridge = new HueBridge(this); - bridge->setId(device->paramValue(hueBridgeBridgeIdParamTypeId).toString()); - bridge->setApiKey(device->paramValue(hueBridgeBridgeApiKeyParamTypeId).toString()); - bridge->setHostAddress(QHostAddress(device->paramValue(hueBridgeBridgeHostParamTypeId).toString())); - bridge->setName(device->paramValue(hueBridgeBridgeNameParamTypeId).toString()); - bridge->setMacAddress(device->paramValue(hueBridgeBridgeMacParamTypeId).toString()); - bridge->setZigbeeChannel(device->paramValue(hueBridgeBridgeZigbeeChannelParamTypeId).toInt()); + bridge->setId(device->paramValue(bridgeDeviceIdParamTypeId).toString()); + bridge->setApiKey(device->paramValue(bridgeDeviceApiKeyParamTypeId).toString()); + bridge->setHostAddress(QHostAddress(device->paramValue(bridgeDeviceHostParamTypeId).toString())); + bridge->setName(device->paramValue(bridgeDeviceNameParamTypeId).toString()); + bridge->setMacAddress(device->paramValue(bridgeDeviceMacParamTypeId).toString()); + bridge->setZigbeeChannel(device->paramValue(bridgeDeviceZigbeeChannelParamTypeId).toInt()); m_bridges.insert(bridge, device); discoverBridgeDevices(bridge); @@ -147,18 +147,18 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev } // hue color light - if (device->deviceClassId() == hueLightDeviceClassId) { + if (device->deviceClassId() == lightDeviceClassId) { qCDebug(dcPhilipsHue) << "Setup Hue color light" << device->params(); HueBridge *bridge = m_bridges.key(myDevices().findById(device->parentId())); HueLight *hueLight = new HueLight(this); hueLight->setHostAddress(bridge->hostAddress()); hueLight->setApiKey(bridge->apiKey()); - hueLight->setId(device->paramValue(hueLightLightIdParamTypeId).toInt()); - hueLight->setName(device->paramValue(hueLightNameParamTypeId).toString()); - hueLight->setModelId(device->paramValue(hueLightModelIdParamTypeId).toString()); - hueLight->setUuid(device->paramValue(hueLightUuidParamTypeId).toString()); - hueLight->setType(device->paramValue(hueLightTypeParamTypeId).toString()); + hueLight->setId(device->paramValue(lightDeviceLightIdParamTypeId).toInt()); + hueLight->setName(device->paramValue(lightDeviceNameParamTypeId).toString()); + hueLight->setModelId(device->paramValue(lightDeviceModelIdParamTypeId).toString()); + hueLight->setUuid(device->paramValue(lightDeviceUuidParamTypeId).toString()); + hueLight->setType(device->paramValue(lightDeviceTypeParamTypeId).toString()); connect(hueLight, &HueLight::stateChanged, this, &DevicePluginPhilipsHue::lightStateChanged); m_lights.insert(hueLight, device); @@ -166,24 +166,24 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev device->setName(hueLight->name()); refreshLight(device); - setLightName(device, device->paramValue(hueLightNameParamTypeId).toString()); + setLightName(device, device->paramValue(lightDeviceNameParamTypeId).toString()); return DeviceManager::DeviceSetupStatusSuccess; } // hue white light - if (device->deviceClassId() == hueWhiteLightDeviceClassId) { + if (device->deviceClassId() == whiteLightDeviceClassId) { qCDebug(dcPhilipsHue) << "Setup Hue white light" << device->params(); HueBridge *bridge = m_bridges.key(myDevices().findById(device->parentId())); HueLight *hueLight = new HueLight(this); hueLight->setHostAddress(bridge->hostAddress()); hueLight->setApiKey(bridge->apiKey()); - hueLight->setId(device->paramValue(hueWhiteLightLightIdParamTypeId).toInt()); - hueLight->setName(device->paramValue(hueWhiteLightNameParamTypeId).toString()); - hueLight->setModelId(device->paramValue(hueWhiteLightModelIdParamTypeId).toString()); - hueLight->setUuid(device->paramValue(hueWhiteLightUuidParamTypeId).toString()); - hueLight->setType(device->paramValue(hueWhiteLightTypeParamTypeId).toString()); + hueLight->setId(device->paramValue(whiteLightDeviceLightIdParamTypeId).toInt()); + hueLight->setName(device->paramValue(whiteLightDeviceNameParamTypeId).toString()); + hueLight->setModelId(device->paramValue(whiteLightDeviceModelIdParamTypeId).toString()); + hueLight->setUuid(device->paramValue(whiteLightDeviceUuidParamTypeId).toString()); + hueLight->setType(device->paramValue(whiteLightDeviceTypeParamTypeId).toString()); connect(hueLight, &HueLight::stateChanged, this, &DevicePluginPhilipsHue::lightStateChanged); @@ -192,23 +192,23 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev m_lights.insert(hueLight, device); refreshLight(device); - setLightName(device, device->paramValue(hueWhiteLightNameParamTypeId).toString()); + setLightName(device, device->paramValue(whiteLightDeviceNameParamTypeId).toString()); return DeviceManager::DeviceSetupStatusSuccess; } // hue remote - if (device->deviceClassId() == hueRemoteDeviceClassId) { + if (device->deviceClassId() == remoteDeviceClassId) { qCDebug(dcPhilipsHue) << "Setup Hue remote" << device->params() << device->deviceClassId(); HueBridge *bridge = m_bridges.key(myDevices().findById(device->parentId())); HueRemote *hueRemote = new HueRemote(this); hueRemote->setHostAddress(bridge->hostAddress()); hueRemote->setApiKey(bridge->apiKey()); - hueRemote->setId(device->paramValue(hueRemoteSensorIdParamTypeId).toInt()); - hueRemote->setName(device->paramValue(hueRemoteNameParamTypeId).toString()); - hueRemote->setModelId(device->paramValue(hueRemoteModelIdParamTypeId).toString()); - hueRemote->setType(device->paramValue(hueRemoteTypeParamTypeId).toString()); - hueRemote->setUuid(device->paramValue(hueRemoteUuidParamTypeId).toString()); + hueRemote->setId(device->paramValue(remoteDeviceSensorIdParamTypeId).toInt()); + hueRemote->setName(device->paramValue(remoteDeviceNameParamTypeId).toString()); + hueRemote->setModelId(device->paramValue(remoteDeviceModelIdParamTypeId).toString()); + hueRemote->setType(device->paramValue(remoteDeviceTypeParamTypeId).toString()); + hueRemote->setUuid(device->paramValue(remoteDeviceUuidParamTypeId).toString()); device->setName(hueRemote->name()); @@ -220,11 +220,11 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev } // hue tap - if (device->deviceClassId() == hueTapDeviceClassId) { + if (device->deviceClassId() == tapDeviceClassId) { HueRemote *hueTap = new HueRemote(this); hueTap->setName(device->name()); - hueTap->setId(device->paramValue(hueTapSensorIdParamTypeId).toInt()); - hueTap->setModelId(device->paramValue(hueTapModelIdParamTypeId).toString()); + hueTap->setId(device->paramValue(tapDeviceSensorIdParamTypeId).toInt()); + hueTap->setModelId(device->paramValue(tapDeviceModelIdParamTypeId).toString()); connect(hueTap, &HueRemote::stateChanged, this, &DevicePluginPhilipsHue::remoteStateChanged); connect(hueTap, &HueRemote::buttonPressed, this, &DevicePluginPhilipsHue::onRemoteButtonEvent); @@ -249,19 +249,19 @@ void DevicePluginPhilipsHue::deviceRemoved(Device *device) abortRequests(m_bridgeSensorsDiscoveryRequests, device); abortRequests(m_bridgeSearchDevicesRequests, device); - if (device->deviceClassId() == hueBridgeDeviceClassId) { + if (device->deviceClassId() == bridgeDeviceClassId) { HueBridge *bridge = m_bridges.key(device); m_bridges.remove(bridge); bridge->deleteLater(); } - if (device->deviceClassId() == hueLightDeviceClassId || device->deviceClassId() == hueWhiteLightDeviceClassId) { + if (device->deviceClassId() == lightDeviceClassId || device->deviceClassId() == whiteLightDeviceClassId) { HueLight *light = m_lights.key(device); m_lights.remove(light); light->deleteLater(); } - if (device->deviceClassId() == hueRemoteDeviceClassId || device->deviceClassId() == hueTapDeviceClassId) { + if (device->deviceClassId() == remoteDeviceClassId || device->deviceClassId() == tapDeviceClassId) { HueRemote *remote = m_remotes.key(device); m_remotes.remove(remote); remote->deleteLater(); @@ -272,12 +272,12 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::confirmPairing(const Pa { Q_UNUSED(secret) - if (deviceClassId != hueBridgeDeviceClassId) + if (deviceClassId != bridgeDeviceClassId) return DeviceManager::DeviceSetupStatusFailure; PairingInfo *pairingInfo = new PairingInfo(this); pairingInfo->setPairingTransactionId(pairingTransactionId); - pairingInfo->setHost(QHostAddress(params.paramValue(hueBridgeBridgeHostParamTypeId).toString())); + pairingInfo->setHost(QHostAddress(params.paramValue(bridgeDeviceHostParamTypeId).toString())); QVariantMap deviceTypeParam; deviceTypeParam.insert("devicetype", "nymea"); @@ -377,7 +377,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady() // check HTTP status code if (status != 200 || reply->error() != QNetworkReply::NoError) { - if (device->stateValue(hueBridgeConnectedStateTypeId).toBool()) { + if (device->stateValue(bridgeConnectedStateTypeId).toBool()) { qCWarning(dcPhilipsHue) << "Refresh Hue Bridge request error:" << status << reply->errorString(); bridgeReachableChanged(device, false); } @@ -403,7 +403,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady() // check HTTP status code if (status != 200 || reply->error() != QNetworkReply::NoError) { - if (device->stateValue(hueLightConnectedStateTypeId).toBool()) { + if (device->stateValue(lightConnectedStateTypeId).toBool()) { qCWarning(dcPhilipsHue) << "Refresh Hue lights request error:" << status << reply->errorString(); bridgeReachableChanged(device, false); } @@ -417,7 +417,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady() // check HTTP status code if (status != 200 || reply->error() != QNetworkReply::NoError) { - if (device->stateValue(hueRemoteConnectedStateTypeId).toBool() || device->stateValue(hueTapConnectedStateTypeId).toBool()) { + if (device->stateValue(remoteConnectedStateTypeId).toBool() || device->stateValue(tapConnectedStateTypeId).toBool()) { qCWarning(dcPhilipsHue) << "Refresh Hue sensors request error:" << status << reply->errorString(); bridgeReachableChanged(device, false); } @@ -461,7 +461,7 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, qCDebug(dcPhilipsHue) << "Execute action" << action.actionTypeId() << action.params(); // color light - if (device->deviceClassId() == hueLightDeviceClassId) { + if (device->deviceClassId() == lightDeviceClassId) { HueLight *light = m_lights.key(device); if (!light->reachable()) { @@ -469,38 +469,38 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, return DeviceManager::DeviceErrorHardwareNotAvailable; } - if (action.actionTypeId() == hueLightPowerActionTypeId) { - QPair request = light->createSetPowerRequest(action.param(hueLightPowerActionParamTypeId).value().toBool()); + if (action.actionTypeId() == lightPowerActionTypeId) { + QPair request = light->createSetPowerRequest(action.param(lightPowerActionPowerParamTypeId).value().toBool()); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply, QPair(device, action.id())); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == hueLightColorActionTypeId) { - QPair request = light->createSetColorRequest(action.param(hueLightColorActionParamTypeId).value().value()); + } else if (action.actionTypeId() == lightColorActionTypeId) { + QPair request = light->createSetColorRequest(action.param(lightColorActionColorParamTypeId).value().value()); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply,QPair(device, action.id())); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == hueLightBrightnessActionTypeId) { - QPair request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueLightBrightnessActionParamTypeId).value().toInt())); + } else if (action.actionTypeId() == lightBrightnessActionTypeId) { + QPair request = light->createSetBrightnessRequest(percentageToBrightness(action.param(lightBrightnessActionBrightnessParamTypeId).value().toInt())); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply, QPair(device, action.id())); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == hueLightHueEffectActionTypeId) { - QPair request = light->createSetEffectRequest(action.param(hueLightHueEffectActionParamTypeId).value().toString()); + } else if (action.actionTypeId() == lightEffectActionTypeId) { + QPair request = light->createSetEffectRequest(action.param(lightEffectActionEffectParamTypeId).value().toString()); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply, QPair(device, action.id())); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == hueLightHueAlertActionTypeId) { - QPair request = light->createFlashRequest(action.param(hueLightAlertParamTypeId).value().toString()); + } else if (action.actionTypeId() == lightAlertActionTypeId) { + QPair request = light->createFlashRequest(action.param(lightAlertActionAlertParamTypeId).value().toString()); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply, QPair(device, action.id())); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == hueLightColorTemperatureActionTypeId) { - QPair request = light->createSetTemperatureRequest(action.param(hueLightColorTemperatureActionParamTypeId).value().toInt()); + } else if (action.actionTypeId() == lightColorTemperatureActionTypeId) { + QPair request = light->createSetTemperatureRequest(action.param(lightColorTemperatureActionColorTemperatureParamTypeId).value().toInt()); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply, QPair(device, action.id())); @@ -510,7 +510,7 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, } // white light - if (device->deviceClassId() == hueWhiteLightDeviceClassId) { + if (device->deviceClassId() == whiteLightDeviceClassId) { HueLight *light = m_lights.key(device); if (!light->reachable()) { @@ -518,20 +518,20 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, return DeviceManager::DeviceErrorHardwareNotAvailable; } - if (action.actionTypeId() == hueWhiteLightPowerActionTypeId) { - QPair request = light->createSetPowerRequest(action.param(hueWhiteLightPowerActionParamTypeId).value().toBool()); + if (action.actionTypeId() == whiteLightPowerActionTypeId) { + QPair request = light->createSetPowerRequest(action.param(whiteLightPowerActionPowerParamTypeId).value().toBool()); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply, QPair(device, action.id())); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == hueWhiteLightBrightnessActionTypeId) { - QPair request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueWhiteLightBrightnessActionParamTypeId).value().toInt())); + } else if (action.actionTypeId() == whiteLightBrightnessActionTypeId) { + QPair request = light->createSetBrightnessRequest(percentageToBrightness(action.param(whiteLightBrightnessActionBrightnessParamTypeId).value().toInt())); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply, QPair(device, action.id())); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == hueWhiteLightHueAlertActionTypeId) { - QPair request = light->createFlashRequest(action.param(hueWhiteLightAlertParamTypeId).value().toString()); + } else if (action.actionTypeId() == whiteLightAlertActionTypeId) { + QPair request = light->createFlashRequest(action.param(whiteLightAlertActionAlertParamTypeId).value().toString()); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply, QPair(device, action.id())); @@ -540,23 +540,23 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, return DeviceManager::DeviceErrorActionTypeNotFound; } - if (device->deviceClassId() == hueBridgeDeviceClassId) { + if (device->deviceClassId() == bridgeDeviceClassId) { HueBridge *bridge = m_bridges.key(device); - if (!device->stateValue(hueBridgeConnectedStateTypeId).toBool()) { + if (!device->stateValue(bridgeConnectedStateTypeId).toBool()) { qCWarning(dcPhilipsHue) << "Bridge" << bridge->hostAddress().toString() << "not reachable"; return DeviceManager::DeviceErrorHardwareNotAvailable; } - if (action.actionTypeId() == hueBridgeSearchNewDevicesActionTypeId) { + if (action.actionTypeId() == bridgeSearchNewDevicesActionTypeId) { searchNewDevices(bridge); return DeviceManager::DeviceErrorNoError; - } else if (action.actionTypeId() == hueBridgeCheckForUpdatesActionTypeId) { + } else if (action.actionTypeId() == bridgeCheckForUpdatesActionTypeId) { QPair request = bridge->createCheckUpdatesRequest(); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); m_asyncActions.insert(reply, QPair(device, action.id())); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == hueBridgeUpgradeActionTypeId) { + } else if (action.actionTypeId() == bridgeUpgradeActionTypeId) { QPair request = bridge->createUpgradeRequest(); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); @@ -578,17 +578,17 @@ void DevicePluginPhilipsHue::lightStateChanged() return; } - if (device->deviceClassId() == hueLightDeviceClassId) { - device->setStateValue(hueLightConnectedStateTypeId, light->reachable()); - device->setStateValue(hueLightColorStateTypeId, QVariant::fromValue(light->color())); - device->setStateValue(hueLightPowerStateTypeId, light->power()); - device->setStateValue(hueLightBrightnessStateTypeId, brightnessToPercentage(light->brightness())); - device->setStateValue(hueLightColorTemperatureStateTypeId, light->ct()); - device->setStateValue(hueLightHueEffectStateTypeId, light->effect()); - } else if (device->deviceClassId() == hueWhiteLightDeviceClassId) { - device->setStateValue(hueWhiteLightConnectedStateTypeId, light->reachable()); - device->setStateValue(hueWhiteLightPowerStateTypeId, light->power()); - device->setStateValue(hueWhiteLightBrightnessStateTypeId, brightnessToPercentage(light->brightness())); + if (device->deviceClassId() == lightDeviceClassId) { + device->setStateValue(lightConnectedStateTypeId, light->reachable()); + device->setStateValue(lightColorStateTypeId, QVariant::fromValue(light->color())); + device->setStateValue(lightPowerStateTypeId, light->power()); + device->setStateValue(lightBrightnessStateTypeId, brightnessToPercentage(light->brightness())); + device->setStateValue(lightColorTemperatureStateTypeId, light->ct()); + device->setStateValue(lightEffectStateTypeId, light->effect()); + } else if (device->deviceClassId() == whiteLightDeviceClassId) { + device->setStateValue(whiteLightConnectedStateTypeId, light->reachable()); + device->setStateValue(whiteLightPowerStateTypeId, light->power()); + device->setStateValue(whiteLightBrightnessStateTypeId, brightnessToPercentage(light->brightness())); } } @@ -601,85 +601,78 @@ void DevicePluginPhilipsHue::remoteStateChanged() qCWarning(dcPhilipsHue) << "Could not find device for remote" << remote->name(); return; } - if (device->deviceClassId() == hueTapDeviceClassId) { - device->setStateValue(hueTapConnectedStateTypeId, remote->reachable()); + if (device->deviceClassId() == tapDeviceClassId) { + device->setStateValue(tapConnectedStateTypeId, remote->reachable()); } else { - device->setStateValue(hueRemoteConnectedStateTypeId, remote->reachable()); - device->setStateValue(hueRemoteBatteryLevelStateTypeId, remote->battery()); - device->setStateValue(hueRemoteBatteryCriticalStateTypeId, remote->battery() < 5); + device->setStateValue(remoteConnectedStateTypeId, remote->reachable()); + device->setStateValue(remoteBatteryLevelStateTypeId, remote->battery()); + device->setStateValue(remoteBatteryCriticalStateTypeId, remote->battery() < 5); } } void DevicePluginPhilipsHue::onRemoteButtonEvent(const int &buttonCode) { HueRemote *remote = static_cast(sender()); - Device *device = m_remotes.value(remote); EventTypeId id; Param param; - if (device->deviceClassId() == hueRemoteDeviceClassId) { - param = Param(hueRemoteButtonNameParamTypeId); - } else if (device->deviceClassId() == hueTapDeviceClassId) { - param = Param(hueTapButtonNameParamTypeId); - } // TODO: Legacy events should be removed eventually switch (buttonCode) { case HueRemote::OnPressed: - emitEvent(Event(hueRemoteOnPressedEventTypeId, m_remotes.value(remote)->id())); - param.setValue("ON"); - id = hueRemotePressedEventTypeId; + param = Param(remotePressedEventButtonNameParamTypeId, "ON"); + id = remotePressedEventTypeId; break; case HueRemote::OnLongPressed: - emitEvent(Event(hueRemoteOnLongPressedEventTypeId, m_remotes.value(remote)->id())); - param.setValue("ON"); - id = hueRemoteLongPressedEventTypeId; + emitEvent(Event(remoteOnLongPressedEventTypeId, m_remotes.value(remote)->id())); + param = Param(remoteLongPressedEventButtonNameParamTypeId, "ON"); + id = remoteLongPressedEventTypeId; break; case HueRemote::DimUpPressed: - emitEvent(Event(hueRemoteDimUpPressedEventTypeId, m_remotes.value(remote)->id())); - param.setValue("DIM UP"); - id = hueRemotePressedEventTypeId; + emitEvent(Event(remoteDimUpPressedEventTypeId, m_remotes.value(remote)->id())); + param = Param(remotePressedEventButtonNameParamTypeId, "DIM UP"); + id = remotePressedEventTypeId; break; case HueRemote::DimUpLongPressed: - emitEvent(Event(hueRemoteDimUpLongPressedEventTypeId, m_remotes.value(remote)->id())); - param.setValue("DIM UP"); - id = hueRemoteLongPressedEventTypeId; + emitEvent(Event(remoteDimUpLongPressedEventTypeId, m_remotes.value(remote)->id())); + param = Param(remoteLongPressedEventButtonNameParamTypeId, "DIM UP"); + id = remoteLongPressedEventTypeId; break; case HueRemote::DimDownPressed: - emitEvent(Event(hueRemoteDimDownPressedEventTypeId, m_remotes.value(remote)->id())); - param.setValue("DIM DOWN"); - id = hueRemotePressedEventTypeId; + emitEvent(Event(remoteDimDownPressedEventTypeId, m_remotes.value(remote)->id())); + param = Param(remotePressedEventButtonNameParamTypeId, "DIM DOWN"); + id = remotePressedEventTypeId; break; case HueRemote::DimDownLongPressed: - emitEvent(Event(hueRemoteDimDownLongPressedEventTypeId, m_remotes.value(remote)->id())); - param.setValue("DIM DOWN"); - id = hueRemoteLongPressedEventTypeId; + emitEvent(Event(remoteDimDownLongPressedEventTypeId, m_remotes.value(remote)->id())); + param = Param(remoteLongPressedEventButtonNameParamTypeId, "DIM DOWN"); + id = remoteLongPressedEventTypeId; break; case HueRemote::OffPressed: - emitEvent(Event(hueRemoteOffPressedEventTypeId, m_remotes.value(remote)->id())); - param.setValue("OFF"); - id = hueRemotePressedEventTypeId; + emitEvent(Event(remoteOffPressedEventTypeId, m_remotes.value(remote)->id())); + param = Param(remotePressedEventButtonNameParamTypeId, "OFF"); + id = remotePressedEventTypeId; break; case HueRemote::OffLongPressed: - emitEvent(Event(hueRemoteOffLongPressedEventTypeId, m_remotes.value(remote)->id())); - param.setValue("OFF"); - id = hueRemoteLongPressedEventTypeId; + emitEvent(Event(remoteOffLongPressedEventTypeId, m_remotes.value(remote)->id())); + param = Param(remoteLongPressedEventButtonNameParamTypeId, "OFF"); + id = remoteLongPressedEventTypeId; break; case HueRemote::TapButton1Pressed: - param.setValue("•"); - id = hueTapPressedEventTypeId; + param = Param(tapPressedEventButtonNameParamTypeId, "•"); + id = tapPressedEventTypeId; break; case HueRemote::TapButton2Pressed: - param.setValue("••"); - id = hueTapPressedEventTypeId; + param = Param(tapPressedEventButtonNameParamTypeId, "••"); + id = tapPressedEventTypeId; break; case HueRemote::TapButton3Pressed: - param.setValue("•••"); - id = hueTapPressedEventTypeId; + param = Param(tapPressedEventButtonNameParamTypeId, "•••"); + id = tapPressedEventTypeId; break; case HueRemote::TapButton4Pressed: - param.setValue("•••••"); - id = hueTapPressedEventTypeId; + param = Param(tapPressedEventButtonNameParamTypeId, "•••••"); + id = tapPressedEventTypeId; break; default: break; @@ -708,20 +701,20 @@ void DevicePluginPhilipsHue::onUpnpDiscoveryFinished() QList deviceDescriptors; foreach (const UpnpDeviceDescriptor &upnpDevice, reply->deviceDescriptors()) { if (upnpDevice.modelDescription().contains("Philips")) { - DeviceDescriptor descriptor(hueBridgeDeviceClassId, "Philips Hue Bridge", upnpDevice.hostAddress().toString()); + DeviceDescriptor descriptor(bridgeDeviceClassId, "Philips Hue Bridge", upnpDevice.hostAddress().toString()); ParamList params; - params.append(Param(hueBridgeBridgeNameParamTypeId, upnpDevice.friendlyName())); - params.append(Param(hueBridgeBridgeHostParamTypeId, upnpDevice.hostAddress().toString())); - params.append(Param(hueBridgeBridgeApiKeyParamTypeId, QString())); - params.append(Param(hueBridgeBridgeMacParamTypeId, QString())); - params.append(Param(hueBridgeBridgeIdParamTypeId, upnpDevice.serialNumber().toLower())); - params.append(Param(hueBridgeBridgeZigbeeChannelParamTypeId, -1)); + params.append(Param(bridgeDeviceNameParamTypeId, upnpDevice.friendlyName())); + params.append(Param(bridgeDeviceHostParamTypeId, upnpDevice.hostAddress().toString())); + params.append(Param(bridgeDeviceApiKeyParamTypeId, QString())); + params.append(Param(bridgeDeviceMacParamTypeId, QString())); + params.append(Param(bridgeDeviceIdParamTypeId, upnpDevice.serialNumber().toLower())); + params.append(Param(bridgeDeviceZigbeeChannelParamTypeId, -1)); descriptor.setParams(params); deviceDescriptors.append(descriptor); } } - emit devicesDiscovered(hueBridgeDeviceClassId, deviceDescriptors); + emit devicesDiscovered(bridgeDeviceClassId, deviceDescriptors); } void DevicePluginPhilipsHue::refreshLight(Device *device) @@ -831,19 +824,19 @@ void DevicePluginPhilipsHue::processNUpnpResponse(const QByteArray &data) QList deviceDescriptors; foreach (const QVariant &bridgeVariant, bridgeList) { QVariantMap bridgeMap = bridgeVariant.toMap(); - DeviceDescriptor descriptor(hueBridgeDeviceClassId, "Philips Hue Bridge", bridgeMap.value("internalipaddress").toString()); + DeviceDescriptor descriptor(bridgeDeviceClassId, "Philips Hue Bridge", bridgeMap.value("internalipaddress").toString()); ParamList params; - params.append(Param(hueBridgeBridgeNameParamTypeId, "Philips hue")); - params.append(Param(hueBridgeBridgeHostParamTypeId, bridgeMap.value("internalipaddress").toString())); - params.append(Param(hueBridgeBridgeApiKeyParamTypeId, QString())); - params.append(Param(hueBridgeBridgeMacParamTypeId, QString())); - params.append(Param(hueBridgeBridgeIdParamTypeId, bridgeMap.value("internalipaddress").toString().toLower())); - params.append(Param(hueBridgeBridgeZigbeeChannelParamTypeId, -1)); + params.append(Param(bridgeDeviceNameParamTypeId, "Philips hue")); + params.append(Param(bridgeDeviceHostParamTypeId, bridgeMap.value("internalipaddress").toString())); + params.append(Param(bridgeDeviceApiKeyParamTypeId, QString())); + params.append(Param(bridgeDeviceMacParamTypeId, QString())); + params.append(Param(bridgeDeviceIdParamTypeId, bridgeMap.value("internalipaddress").toString().toLower())); + params.append(Param(bridgeDeviceZigbeeChannelParamTypeId, -1)); descriptor.setParams(params); deviceDescriptors.append(descriptor); } qCDebug(dcPhilipsHue) << "N-UPNP discover finished. Found" << deviceDescriptors.count() << "devices."; - emit devicesDiscovered(hueBridgeDeviceClassId, deviceDescriptors); + emit devicesDiscovered(bridgeDeviceClassId, deviceDescriptors); } void DevicePluginPhilipsHue::processBridgeLightDiscoveryResponse(Device *device, const QByteArray &data) @@ -883,26 +876,26 @@ void DevicePluginPhilipsHue::processBridgeLightDiscoveryResponse(Device *device, // check if this is a white light if (model == "LWB004" || model == "LWB006" || model == "LWB007") { - DeviceDescriptor descriptor(hueWhiteLightDeviceClassId, "Philips Hue White Light", lightMap.value("name").toString(), device->id()); + DeviceDescriptor descriptor(whiteLightDeviceClassId, "Philips Hue White Light", lightMap.value("name").toString(), device->id()); ParamList params; - params.append(Param(hueWhiteLightNameParamTypeId, lightMap.value("name").toString())); - params.append(Param(hueWhiteLightModelIdParamTypeId, model)); - params.append(Param(hueWhiteLightTypeParamTypeId, lightMap.value("type").toString())); - params.append(Param(hueWhiteLightUuidParamTypeId, uuid)); - params.append(Param(hueWhiteLightLightIdParamTypeId, lightId)); + params.append(Param(whiteLightDeviceNameParamTypeId, lightMap.value("name").toString())); + params.append(Param(whiteLightDeviceModelIdParamTypeId, model)); + params.append(Param(whiteLightDeviceTypeParamTypeId, lightMap.value("type").toString())); + params.append(Param(whiteLightDeviceUuidParamTypeId, uuid)); + params.append(Param(whiteLightDeviceLightIdParamTypeId, lightId)); descriptor.setParams(params); whiteLightDescriptors.append(descriptor); qCDebug(dcPhilipsHue) << "Found new white light" << lightMap.value("name").toString() << model; } else { - DeviceDescriptor descriptor(hueLightDeviceClassId, "Philips Hue Light", lightMap.value("name").toString(), device->id()); + DeviceDescriptor descriptor(lightDeviceClassId, "Philips Hue Light", lightMap.value("name").toString(), device->id()); ParamList params; - params.append(Param(hueLightNameParamTypeId, lightMap.value("name").toString())); - params.append(Param(hueLightModelIdParamTypeId, model)); - params.append(Param(hueLightTypeParamTypeId, lightMap.value("type").toString())); - params.append(Param(hueLightUuidParamTypeId, uuid)); - params.append(Param(hueLightLightIdParamTypeId, lightId)); + params.append(Param(lightDeviceNameParamTypeId, lightMap.value("name").toString())); + params.append(Param(lightDeviceModelIdParamTypeId, model)); + params.append(Param(lightDeviceTypeParamTypeId, lightMap.value("type").toString())); + params.append(Param(lightDeviceUuidParamTypeId, uuid)); + params.append(Param(lightDeviceLightIdParamTypeId, lightId)); descriptor.setParams(params); lightDescriptors.append(descriptor); qCDebug(dcPhilipsHue) << "Found new color light" << lightMap.value("name").toString() << model; @@ -910,10 +903,10 @@ void DevicePluginPhilipsHue::processBridgeLightDiscoveryResponse(Device *device, } if (!lightDescriptors.isEmpty()) - emit autoDevicesAppeared(hueLightDeviceClassId, lightDescriptors); + emit autoDevicesAppeared(lightDeviceClassId, lightDescriptors); if (!whiteLightDescriptors.isEmpty()) - emit autoDevicesAppeared(hueWhiteLightDeviceClassId, whiteLightDescriptors); + emit autoDevicesAppeared(whiteLightDeviceClassId, whiteLightDescriptors); } void DevicePluginPhilipsHue::processBridgeSensorDiscoveryResponse(Device *device, const QByteArray &data) @@ -949,25 +942,25 @@ void DevicePluginPhilipsHue::processBridgeSensorDiscoveryResponse(Device *device continue; if (model == "RWL021" || model == "RWL020") { - DeviceDescriptor descriptor(hueRemoteDeviceClassId, "Philips Hue Remote", sensorMap.value("name").toString(), device->id()); + DeviceDescriptor descriptor(remoteDeviceClassId, "Philips Hue Remote", sensorMap.value("name").toString(), device->id()); ParamList params; - params.append(Param(hueRemoteNameParamTypeId, sensorMap.value("name").toString())); - params.append(Param(hueRemoteModelIdParamTypeId, model)); - params.append(Param(hueRemoteTypeParamTypeId, sensorMap.value("type").toString())); - params.append(Param(hueRemoteUuidParamTypeId, uuid)); - params.append(Param(hueRemoteSensorIdParamTypeId, sensorId)); + params.append(Param(remoteDeviceNameParamTypeId, sensorMap.value("name").toString())); + params.append(Param(remoteDeviceModelIdParamTypeId, model)); + params.append(Param(remoteDeviceTypeParamTypeId, sensorMap.value("type").toString())); + params.append(Param(remoteDeviceUuidParamTypeId, uuid)); + params.append(Param(remoteDeviceSensorIdParamTypeId, sensorId)); descriptor.setParams(params); - emit autoDevicesAppeared(hueRemoteDeviceClassId, {descriptor}); + emit autoDevicesAppeared(remoteDeviceClassId, {descriptor}); qCDebug(dcPhilipsHue) << "Found new remote" << sensorMap.value("name").toString() << model; } else if (model == "ZGPSWITCH") { - DeviceDescriptor descriptor(hueTapDeviceClassId, "Hue Tap", sensorMap.value("name").toString(), device->id()); + DeviceDescriptor descriptor(tapDeviceClassId, "Hue Tap", sensorMap.value("name").toString(), device->id()); ParamList params; - params.append(Param(hueTapUuidParamTypeId, uuid)); - params.append(Param(hueTapModelIdParamTypeId, model)); - params.append(Param(hueTapSensorIdParamTypeId, sensorId)); + params.append(Param(tapDeviceUuidParamTypeId, uuid)); + params.append(Param(tapDeviceModelIdParamTypeId, model)); + params.append(Param(tapDeviceSensorIdParamTypeId, sensorId)); descriptor.setParams(params); - emit autoDevicesAppeared(hueTapDeviceClassId, {descriptor}); - qCDebug(dcPhilipsHue()) << "Found hue tap:" << sensorMap << hueTapDeviceClassId; + emit autoDevicesAppeared(tapDeviceClassId, {descriptor}); + qCDebug(dcPhilipsHue()) << "Found hue tap:" << sensorMap << tapDeviceClassId; } else { qCDebug(dcPhilipsHue()) << "Found unknown sensor:" << model; } @@ -1020,22 +1013,22 @@ void DevicePluginPhilipsHue::processBridgeRefreshResponse(Device *device, const // mark bridge as reachable bridgeReachableChanged(device, true); - device->setStateValue(hueBridgeApiVersionStateTypeId, configMap.value("apiversion").toString()); - device->setStateValue(hueBridgeSoftwareVersionStateTypeId, configMap.value("swversion").toString()); + device->setStateValue(bridgeApiVersionStateTypeId, configMap.value("apiversion").toString()); + device->setStateValue(bridgeSoftwareVersionStateTypeId, configMap.value("swversion").toString()); int updateStatus = configMap.value("swupdate").toMap().value("updatestate").toInt(); switch (updateStatus) { case 0: - device->setStateValue(hueBridgeUpdateStatusStateTypeId, "Up to date"); + device->setStateValue(bridgeUpdateStatusStateTypeId, "Up to date"); break; case 1: - device->setStateValue(hueBridgeUpdateStatusStateTypeId, "Downloading updates"); + device->setStateValue(bridgeUpdateStatusStateTypeId, "Downloading updates"); break; case 2: - device->setStateValue(hueBridgeUpdateStatusStateTypeId, "Updates ready to install"); + device->setStateValue(bridgeUpdateStatusStateTypeId, "Updates ready to install"); break; case 3: - device->setStateValue(hueBridgeUpdateStatusStateTypeId, "Installing updates"); + device->setStateValue(bridgeUpdateStatusStateTypeId, "Installing updates"); break; default: break; @@ -1130,7 +1123,7 @@ void DevicePluginPhilipsHue::processSetNameResponse(Device *device, const QByteA //emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess); - if (device->deviceClassId() == hueLightDeviceClassId || device->deviceClassId() == hueWhiteLightDeviceClassId) + if (device->deviceClassId() == lightDeviceClassId || device->deviceClassId() == whiteLightDeviceClassId) refreshLight(device); } @@ -1249,7 +1242,7 @@ void DevicePluginPhilipsHue::processActionResponse(Device *device, const ActionI return; } - if (device->deviceClassId() != hueBridgeDeviceClassId) + if (device->deviceClassId() != bridgeDeviceClassId) m_lights.key(device)->processActionResponse(jsonDoc.toVariant().toList()); emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorNoError); @@ -1258,19 +1251,19 @@ void DevicePluginPhilipsHue::processActionResponse(Device *device, const ActionI void DevicePluginPhilipsHue::bridgeReachableChanged(Device *device, const bool &reachable) { if (reachable) { - device->setStateValue(hueBridgeConnectedStateTypeId, true); + device->setStateValue(bridgeConnectedStateTypeId, true); } else { // mark bridge and corresponding hue devices unreachable - if (device->deviceClassId() == hueBridgeDeviceClassId) { - device->setStateValue(hueBridgeConnectedStateTypeId, false); + if (device->deviceClassId() == bridgeDeviceClassId) { + device->setStateValue(bridgeConnectedStateTypeId, false); foreach (HueLight *light, m_lights.keys()) { if (m_lights.value(light)->parentId() == device->id()) { light->setReachable(false); - if (m_lights.value(light)->deviceClassId() == hueLightDeviceClassId) { - m_lights.value(light)->setStateValue(hueLightConnectedStateTypeId, false); - } else if (m_lights.value(light)->deviceClassId() == hueWhiteLightDeviceClassId) { - m_lights.value(light)->setStateValue(hueWhiteLightConnectedStateTypeId, false); + if (m_lights.value(light)->deviceClassId() == lightDeviceClassId) { + m_lights.value(light)->setStateValue(lightConnectedStateTypeId, false); + } else if (m_lights.value(light)->deviceClassId() == whiteLightDeviceClassId) { + m_lights.value(light)->setStateValue(whiteLightConnectedStateTypeId, false); } } } @@ -1278,10 +1271,10 @@ void DevicePluginPhilipsHue::bridgeReachableChanged(Device *device, const bool & foreach (HueRemote *remote, m_remotes.keys()) { if (m_remotes.value(remote)->parentId() == device->id()) { remote->setReachable(false); - if (m_remotes.value(remote)->deviceClassId() == hueRemoteDeviceClassId) { - m_remotes.value(remote)->setStateValue(hueRemoteConnectedStateTypeId, false); - } else if (m_remotes.value(remote)->deviceClassId() == hueTapDeviceClassId) { - m_remotes.value(remote)->setStateValue(hueTapConnectedStateTypeId, false); + if (m_remotes.value(remote)->deviceClassId() == remoteDeviceClassId) { + m_remotes.value(remote)->setStateValue(remoteConnectedStateTypeId, false); + } else if (m_remotes.value(remote)->deviceClassId() == tapDeviceClassId) { + m_remotes.value(remote)->setStateValue(tapConnectedStateTypeId, false); } } } @@ -1293,8 +1286,8 @@ void DevicePluginPhilipsHue::bridgeReachableChanged(Device *device, const bool & bool DevicePluginPhilipsHue::bridgeAlreadyAdded(const QString &id) { foreach (Device *device, myDevices()) { - if (device->deviceClassId() == hueBridgeDeviceClassId) { - if (device->paramValue(hueBridgeBridgeIdParamTypeId).toString() == id) { + if (device->deviceClassId() == bridgeDeviceClassId) { + if (device->paramValue(bridgeDeviceIdParamTypeId).toString() == id) { return true; } } @@ -1305,12 +1298,12 @@ bool DevicePluginPhilipsHue::bridgeAlreadyAdded(const QString &id) bool DevicePluginPhilipsHue::lightAlreadyAdded(const QString &uuid) { foreach (Device *device, myDevices()) { - if (device->deviceClassId() == hueLightDeviceClassId) { - if (device->paramValue(hueLightUuidParamTypeId).toString() == uuid) { + if (device->deviceClassId() == lightDeviceClassId) { + if (device->paramValue(lightDeviceUuidParamTypeId).toString() == uuid) { return true; } - } else if (device->deviceClassId() == hueWhiteLightDeviceClassId) { - if (device->paramValue(hueWhiteLightUuidParamTypeId).toString() == uuid) { + } else if (device->deviceClassId() == whiteLightDeviceClassId) { + if (device->paramValue(whiteLightDeviceUuidParamTypeId).toString() == uuid) { return true; } } @@ -1321,13 +1314,13 @@ bool DevicePluginPhilipsHue::lightAlreadyAdded(const QString &uuid) bool DevicePluginPhilipsHue::sensorAlreadyAdded(const QString &uuid) { foreach (Device *device, myDevices()) { - if (device->deviceClassId() == hueRemoteDeviceClassId) { - if (device->paramValue(hueRemoteUuidParamTypeId).toString() == uuid) { + if (device->deviceClassId() == remoteDeviceClassId) { + if (device->paramValue(remoteDeviceUuidParamTypeId).toString() == uuid) { return true; } } - if (device->deviceClassId() == hueTapDeviceClassId) { - if (device->paramValue(hueTapUuidParamTypeId).toString() == uuid) { + if (device->deviceClassId() == tapDeviceClassId) { + if (device->paramValue(tapDeviceUuidParamTypeId).toString() == uuid) { return true; } } diff --git a/philipshue/devicepluginphilipshue.json b/philipshue/devicepluginphilipshue.json index f5947307..5f47a15e 100644 --- a/philipshue/devicepluginphilipshue.json +++ b/philipshue/devicepluginphilipshue.json @@ -10,7 +10,7 @@ "deviceClasses": [ { "id": "642aa4c7-19aa-45ed-ba06-aa1ae6c9edf7", - "name": "hueBridge", + "name": "bridge", "displayName": "Hue gateway", "deviceIcon": "Gateway", "interfaces": ["gateway", "connectable"], @@ -26,14 +26,14 @@ "paramTypes": [ { "id": "275b76f2-0174-4f26-b3ec-5f108baf8bdd", - "name": "bridgeName", + "name": "name", "displayName": "name", "type" : "QString", "inputType": "TextLine" }, { "id": "8bf5776a-d5a6-4600-8b27-481f0d803a8f", - "name": "bridgeApiKey", + "name": "apiKey", "displayName": "api key", "type" : "QString", "inputType": "TextLine", @@ -41,7 +41,7 @@ }, { "id": "1845975b-1184-4440-bc0d-73d53a9f683c", - "name": "bridgeHost", + "name": "host", "displayName": "host address", "type" : "QString", "inputType": "IPv4Address", @@ -49,7 +49,7 @@ }, { "id": "2c67203d-a308-45ec-9a08-fc4183c06ff8", - "name": "bridgeMac", + "name": "mac", "displayName": "mac address", "type" : "QString", "inputType": "MacAddress", @@ -57,21 +57,21 @@ }, { "id": "a496feb0-3b7b-46cb-a63a-e063447d6b1d", - "name": "bridgeId", + "name": "id", "displayName": "id", "type" : "QString", "readOnly": true }, { "id": "ea228c4d-975c-4b43-9445-7c9a907c29d6", - "name": "bridgeSoftware", + "name": "softwareVersion", "displayName": "software version", "type" : "QString", "readOnly": true }, { "id": "53170394-956c-4511-b3a8-2c8a502ef1ed", - "name": "bridgeZigbeeChannel", + "name": "zigbeeChannel", "displayName": "zigbee channel", "type" : "int", "readOnly": true @@ -142,7 +142,7 @@ }, { "id": "0edba26c-96ab-44fb-a6a2-c0574d19630e", - "name": "hueLight", + "name": "light", "displayName": "Hue Light", "deviceIcon": "LightBulb", "interfaces": ["colorlight", "connectable"], @@ -256,7 +256,7 @@ }, { "id": "0b7cdd8d-4db8-4183-abe2-f3c01d1c9afc", - "name": "hueEffect", + "name": "effect", "displayName": "effect", "displayNameEvent": "effect changed", "displayNameAction": "Set effect", @@ -274,7 +274,7 @@ "actionTypes": [ { "id": "d25dcfbc-d28c-4905-80e3-300ffb1248f5", - "name": "hueAlert", + "name": "alert", "displayName": "flash", "paramTypes": [ { @@ -293,7 +293,7 @@ }, { "id": "4fa568ef-7a3a-422b-b0c0-206d37cb4eed", - "name": "hueWhiteLight", + "name": "whiteLight", "displayName": "Hue White Light", "deviceIcon": "LightBulb", "interfaces": ["dimmablelight", "connectable"], @@ -381,7 +381,7 @@ "actionTypes": [ { "id": "d25dcfbc-d28c-4905-80e3-300ffb1248f5", - "name": "hueAlert", + "name": "alert", "displayName": "flash", "paramTypes": [ { @@ -400,7 +400,7 @@ }, { "id": "bb482d39-67ef-46dc-88e9-7b181d642b28", - "name": "hueRemote", + "name": "remote", "displayName": "Hue Remote", "deviceIcon": "Switch", "interfaces": ["longpressmultibutton", "batterylevel", "connectable"], @@ -549,7 +549,7 @@ }, { "id": "2b8c1fb8-67ee-42e9-947b-16e0a09f0d4e", - "name": "hueTap", + "name": "tap", "displayName": "Hue Tap", "deviceIcon": "Switch", "interfaces": ["simplemultibutton", "connectable"], diff --git a/plantcare/devicepluginplantcare.cpp b/plantcare/devicepluginplantcare.cpp index 20f09481..0dfcdafe 100644 --- a/plantcare/devicepluginplantcare.cpp +++ b/plantcare/devicepluginplantcare.cpp @@ -66,7 +66,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPlantCare::setupDevice(Device *devi qCDebug(dcPlantCare) << "Setup Plant Care" << device->name() << device->params(); // Check if device already added with this address - if (deviceAlreadyAdded(QHostAddress(device->paramValue(plantCareHostParamTypeId).toString()))) { + if (deviceAlreadyAdded(QHostAddress(device->paramValue(plantCareDeviceHostParamTypeId).toString()))) { qCWarning(dcPlantCare) << "Device with this address already added."; return DeviceManager::DeviceSetupStatusFailure; } @@ -102,7 +102,7 @@ DeviceManager::DeviceError DevicePluginPlantCare::discoverDevices(const DeviceCl Q_UNUSED(params) // Perform a HTTP GET on the RPL router address - QHostAddress address(configuration().paramValue(plantCareRplParamTypeId).toString()); + QHostAddress address(configuration().paramValue(plantCarePluginRplParamTypeId).toString()); qCDebug(dcPlantCare) << "Scan for new nodes on RPL" << address.toString(); QUrl url; @@ -132,7 +132,7 @@ DeviceManager::DeviceError DevicePluginPlantCare::executeAction(Device *device, if (action.actionTypeId() == plantCareToggleLedActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); url.setPath("/a/toggle"); CoapReply *reply = m_coap->post(CoapRequest(url)); @@ -148,11 +148,11 @@ DeviceManager::DeviceError DevicePluginPlantCare::executeAction(Device *device, return DeviceManager::DeviceErrorAsync; } else if(action.actionTypeId() == plantCareLedPowerActionTypeId) { - int power = action.param(plantCareLedPowerActionParamTypeId).value().toInt(); + int power = action.param(plantCareLedPowerActionLedPowerParamTypeId).value().toInt(); QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); url.setPath("/a/light"); QByteArray payload = QString("pwm=%1").arg(QString::number(power)).toUtf8(); @@ -170,11 +170,11 @@ DeviceManager::DeviceError DevicePluginPlantCare::executeAction(Device *device, return DeviceManager::DeviceErrorAsync; } else if(action.actionTypeId() == plantCareWaterPumpActionTypeId) { - bool pump = action.param(plantCareWaterPumpActionParamTypeId).value().toBool(); + bool pump = action.param(plantCareWaterPumpActionWaterPumpParamTypeId).value().toBool(); QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); url.setPath("/a/pump"); QByteArray payload = QString("mode=%1").arg(QString::number((int)pump)).toUtf8(); @@ -198,7 +198,7 @@ void DevicePluginPlantCare::pingDevice(Device *device) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); m_pingReplies.insert(m_coap->ping(CoapRequest(url)), device); } @@ -207,7 +207,7 @@ void DevicePluginPlantCare::updateBattery(Device *device) qCDebug(dcPlantCare) << "Update" << device->name() << "battery value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); url.setPath("/s/battery"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -224,7 +224,7 @@ void DevicePluginPlantCare::updateMoisture(Device *device) qCDebug(dcPlantCare) << "Update" << device->name() << "moisture value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); url.setPath("/s/moisture"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -242,7 +242,7 @@ void DevicePluginPlantCare::updateWater(Device *device) qCDebug(dcPlantCare) << "Update" << device->name() << "water value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); url.setPath("/s/water"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -260,7 +260,7 @@ void DevicePluginPlantCare::updateBrightness(Device *device) qCDebug(dcPlantCare) << "Update" << device->name() << "brightness value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); url.setPath("/a/light"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -278,7 +278,7 @@ void DevicePluginPlantCare::updatePump(Device *device) qCDebug(dcPlantCare) << "Update" << device->name() << "pump value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); url.setPath("/a/pump"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -296,7 +296,7 @@ void DevicePluginPlantCare::enableNotifications(Device *device) qCDebug(dcPlantCare) << "Enable" << device->name() << "notifications"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareDeviceHostParamTypeId).toString()); url.setPath("/s/water"); m_enableNotification.insert(m_coap->enableResourceNotifications(CoapRequest(url)), device); @@ -342,7 +342,7 @@ bool DevicePluginPlantCare::deviceAlreadyAdded(const QHostAddress &address) { // Check if we already have a device with the given address foreach (Device *device, myDevices()) { - if (device->paramValue(plantCareHostParamTypeId).toString() == address.toString()) { + if (device->paramValue(plantCareDeviceHostParamTypeId).toString() == address.toString()) { return true; } } @@ -353,11 +353,11 @@ Device *DevicePluginPlantCare::findDevice(const QHostAddress &address) { // Return the device pointer with the given address (otherwise 0) foreach (Device *device, myDevices()) { - if (device->paramValue(plantCareHostParamTypeId).toString() == address.toString()) { + if (device->paramValue(plantCareDeviceHostParamTypeId).toString() == address.toString()) { return device; } } - return NULL; + return nullptr; } void DevicePluginPlantCare::onPluginTimer() @@ -402,7 +402,7 @@ void DevicePluginPlantCare::onNetworkReplyFinished() // Create a deviceDescriptor for each found address DeviceDescriptor descriptor(deviceClassId, "Plant Care", address.toString()); ParamList params; - params.append(Param(plantCareHostParamTypeId, address.toString())); + params.append(Param(plantCareDeviceHostParamTypeId, address.toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -517,7 +517,7 @@ void DevicePluginPlantCare::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(plantCareLedPowerStateTypeId, action.param(plantCareLedPowerActionParamTypeId).value().toBool()); + device->setStateValue(plantCareLedPowerStateTypeId, action.param(plantCareLedPowerActionLedPowerParamTypeId).value().toBool()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -543,7 +543,7 @@ void DevicePluginPlantCare::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(plantCareWaterPumpStateTypeId, action.param(plantCareWaterPumpActionParamTypeId).value().toBool()); + device->setStateValue(plantCareWaterPumpStateTypeId, action.param(plantCareWaterPumpActionWaterPumpParamTypeId).value().toBool()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); diff --git a/remotessh/devicepluginremotessh.cpp b/remotessh/devicepluginremotessh.cpp index f7bcd370..5dd6b2f2 100644 --- a/remotessh/devicepluginremotessh.cpp +++ b/remotessh/devicepluginremotessh.cpp @@ -55,7 +55,7 @@ DeviceManager::DeviceError DevicePluginRemoteSsh::executeAction(Device *device, if (action.actionTypeId() == reverseSshConnectedActionTypeId) { - if (action.param(reverseSshConnectedActionParamTypeId).value().toBool() == true) { + if (action.param(reverseSshConnectedActionConnectedParamTypeId).value().toBool() == true) { QProcess *process = startReverseSSHProcess(device); m_reverseSSHProcess.insert(process, device); m_startingProcess.insert(process, action.id()); @@ -115,11 +115,11 @@ QProcess * DevicePluginRemoteSsh::startReverseSSHProcess(Device *device) connect(process, &QProcess::readyRead, this, &DevicePluginRemoteSsh::processReadyRead); QStringList arguments; - int localPort = device->paramValue(reverseSshLocalPortParamTypeId).toInt(); - int remotePort = device->paramValue(reverseSshRemotePortParamTypeId).toInt(); - QString user = device->paramValue(reverseSshUserParamTypeId).toString(); - QString password = device->paramValue(reverseSshPasswordParamTypeId).toString(); - QString address = device->paramValue(reverseSshAddressParamTypeId).toString(); + int localPort = device->paramValue(reverseSshDeviceLocalPortParamTypeId).toInt(); + int remotePort = device->paramValue(reverseSshDeviceRemotePortParamTypeId).toInt(); + QString user = device->paramValue(reverseSshDeviceUserParamTypeId).toString(); + QString password = device->paramValue(reverseSshDevicePasswordParamTypeId).toString(); + QString address = device->paramValue(reverseSshDeviceAddressParamTypeId).toString(); arguments << "-p" << password; arguments << "ssh" << "-o StrictHostKeyChecking=no" << "-oUserKnownHostsFile=/dev/null"; diff --git a/senic/devicepluginsenic.cpp b/senic/devicepluginsenic.cpp index e06c0aaf..2ab1b7b4 100644 --- a/senic/devicepluginsenic.cpp +++ b/senic/devicepluginsenic.cpp @@ -77,8 +77,8 @@ DeviceManager::DeviceSetupStatus DevicePluginSenic::setupDevice(Device *device) { qCDebug(dcSenic()) << "Setup device" << device->name() << device->params(); - QString name = device->paramValue(nuimoNameParamTypeId).toString(); - QBluetoothAddress address = QBluetoothAddress(device->paramValue(nuimoMacParamTypeId).toString()); + QString name = device->paramValue(nuimoDeviceNameParamTypeId).toString(); + QBluetoothAddress address = QBluetoothAddress(device->paramValue(nuimoDeviceMacParamTypeId).toString()); QBluetoothDeviceInfo deviceInfo = QBluetoothDeviceInfo(address, name, 0); BluetoothLowEnergyDevice *bluetoothDevice = hardwareManager()->bluetoothLowEnergyManager()->registerDevice(deviceInfo, QLowEnergyController::RandomAddress); @@ -107,23 +107,23 @@ DeviceManager::DeviceError DevicePluginSenic::executeAction(Device *device, cons if (action.actionTypeId() == nuimoShowLogoActionTypeId) { - if (action.param(nuimoLogoParamTypeId).value().toString() == "Up") + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Up") nuimo->showImage(Nuimo::MatrixTypeUp); - if (action.param(nuimoLogoParamTypeId).value().toString() == "Down") + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Down") nuimo->showImage(Nuimo::MatrixTypeDown); - if (action.param(nuimoLogoParamTypeId).value().toString() == "Left") + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Left") nuimo->showImage(Nuimo::MatrixTypeLeft); - if (action.param(nuimoLogoParamTypeId).value().toString() == "Right") + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Right") nuimo->showImage(Nuimo::MatrixTypeRight); - if (action.param(nuimoLogoParamTypeId).value().toString() == "Play") + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Play") nuimo->showImage(Nuimo::MatrixTypePlay); - if (action.param(nuimoLogoParamTypeId).value().toString() == "Pause") + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Pause") nuimo->showImage(Nuimo::MatrixTypePause); - if (action.param(nuimoLogoParamTypeId).value().toString() == "Stop") + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Stop") nuimo->showImage(Nuimo::MatrixTypeStop); - if (action.param(nuimoLogoParamTypeId).value().toString() == "Music") + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Music") nuimo->showImage(Nuimo::MatrixTypeStop); - if (action.param(nuimoLogoParamTypeId).value().toString() == "Heart") + if (action.param(nuimoShowLogoActionLogoParamTypeId).value().toString() == "Heart") nuimo->showImage(Nuimo::MatrixTypeHeart); return DeviceManager::DeviceErrorNoError; @@ -145,7 +145,7 @@ void DevicePluginSenic::deviceRemoved(Device *device) bool DevicePluginSenic::verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo) { foreach (Device *device, myDevices()) { - if (device->paramValue(nuimoMacParamTypeId).toString() == deviceInfo.address().toString()) + if (device->paramValue(nuimoDeviceMacParamTypeId).toString() == deviceInfo.address().toString()) return true; } @@ -178,8 +178,8 @@ void DevicePluginSenic::onBluetoothDiscoveryFinished() if (!verifyExistingDevices(deviceInfo)) { DeviceDescriptor descriptor(nuimoDeviceClassId, "Nuimo", deviceInfo.address().toString()); ParamList params; - params.append(Param(nuimoNameParamTypeId, deviceInfo.name())); - params.append(Param(nuimoMacParamTypeId, deviceInfo.address().toString())); + params.append(Param(nuimoDeviceNameParamTypeId, deviceInfo.name())); + params.append(Param(nuimoDeviceMacParamTypeId, deviceInfo.address().toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -221,8 +221,6 @@ void DevicePluginSenic::onSwipeDetected(const Nuimo::SwipeDirection &direction) case Nuimo::SwipeDirectionDown: emitEvent(Event(nuimoSwipeDownEventTypeId, device->id())); break; - default: - break; } } diff --git a/simulation/devicepluginsimulation.cpp b/simulation/devicepluginsimulation.cpp index a8be2601..51f79878 100644 --- a/simulation/devicepluginsimulation.cpp +++ b/simulation/devicepluginsimulation.cpp @@ -97,7 +97,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, if (action.actionTypeId() == alternativeButtonPowerActionTypeId) { // get the param value - Param powerParam = action.param(alternativeButtonPowerActionParamTypeId); + Param powerParam = action.param(alternativeButtonPowerActionPowerParamTypeId); bool power = powerParam.value().toBool(); qCDebug(dcSimulation()) << "Set power" << power << "for button" << device->name(); @@ -116,7 +116,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, if (action.actionTypeId() == heatingPowerActionTypeId) { // get the param value - Param powerParam = action.param(heatingPowerActionParamTypeId); + Param powerParam = action.param(heatingPowerActionPowerParamTypeId); bool power = powerParam.value().toBool(); qCDebug(dcSimulation()) << "Set power" << power << "for heating device" << device->name(); device->setStateValue(heatingPowerStateTypeId, power); @@ -125,7 +125,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, } else if (action.actionTypeId() == heatingTargetTemperatureActionTypeId) { // get the param value - Param temperatureParam = action.param(heatingTargetTemperatureActionParamTypeId); + Param temperatureParam = action.param(heatingTargetTemperatureActionTargetTemperatureParamTypeId); int temperature = temperatureParam.value().toInt(); qCDebug(dcSimulation()) << "Set target temperature" << temperature << "for heating device" << device->name(); @@ -140,7 +140,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, if (action.actionTypeId() == evChargerPowerActionTypeId){ // get the param value - Param powerParam = action.param(evChargerPowerActionParamTypeId); + Param powerParam = action.param(evChargerPowerActionPowerParamTypeId); bool power = powerParam.value().toBool(); qCDebug(dcSimulation()) << "Set power" << power << "for heating device" << device->name(); @@ -150,7 +150,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, } else if(action.actionTypeId() == evChargerCurrentActionTypeId){ // get the param value - Param currentParam = action.param(evChargerCurrentActionParamTypeId); + Param currentParam = action.param(evChargerCurrentActionCurrentParamTypeId); int current = currentParam.value().toInt(); qCDebug(dcSimulation()) << "Set current" << current << "for EV Charger device" << device->name(); device->setStateValue(evChargerCurrentStateTypeId, current); @@ -163,7 +163,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, if(action.actionTypeId() == socketPowerActionTypeId){ // get the param value - Param powerParam = action.param(socketPowerActionParamTypeId); + Param powerParam = action.param(socketPowerActionPowerParamTypeId); bool power = powerParam.value().toBool(); // Set the "power" state qCDebug(dcSimulation()) << "Set power" << power << "for socket device" << device->name(); @@ -176,25 +176,25 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, if(device->deviceClassId() == colorBulbDeviceClassId){ if(action.actionTypeId() == colorBulbBrightnessActionTypeId){ - int brightness = action.param(colorBulbBrightnessActionParamTypeId).value().toInt(); + int brightness = action.param(colorBulbBrightnessActionBrightnessParamTypeId).value().toInt(); qCDebug(dcSimulation()) << "Set brightness" << brightness << "for color bulb device" << device->name(); device->setStateValue(colorBulbBrightnessStateTypeId, brightness); return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == colorBulbColorTemperatureActionTypeId){ - int temperature = action.param(colorBulbColorTemperatureActionParamTypeId).value().toInt(); + int temperature = action.param(colorBulbColorTemperatureActionColorTemperatureParamTypeId).value().toInt(); qCDebug(dcSimulation()) << "Set color temperature" << temperature << "for color bulb device" << device->name(); device->setStateValue(colorBulbColorTemperatureStateTypeId, temperature); return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == colorBulbColorActionTypeId) { - QColor color = action.param(colorBulbColorActionParamTypeId).value().value(); + QColor color = action.param(colorBulbColorActionColorParamTypeId).value().value(); qCDebug(dcSimulation()) << "Set color" << color << "for color bulb device" << device->name(); device->setStateValue(colorBulbColorStateTypeId, color); return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == colorBulbPowerActionTypeId) { - bool power = action.param(colorBulbPowerActionParamTypeId).value().toBool(); + bool power = action.param(colorBulbPowerActionPowerParamTypeId).value().toBool(); qCDebug(dcSimulation()) << "Set power" << power << "for color bulb device" << device->name(); device->setStateValue(colorBulbPowerStateTypeId, power); return DeviceManager::DeviceErrorNoError; @@ -206,17 +206,17 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, if (device->deviceClassId() == heatingRodDeviceClassId) { if (action.actionTypeId() == heatingRodPowerActionTypeId) { - bool power = action.param(heatingRodPowerActionParamTypeId).value().toBool(); + bool power = action.param(heatingRodPowerActionPowerParamTypeId).value().toBool(); qCDebug(dcSimulation()) << "Set power" << power << "for heating rod device" << device->name(); device->setStateValue(heatingRodPowerStateTypeId, power); return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == heatingRodWaterTemperatureActionTypeId) { - int temperature = action.param(heatingRodWaterTemperatureActionParamTypeId).value().toInt(); + int temperature = action.param(heatingRodWaterTemperatureActionWaterTemperatureParamTypeId).value().toInt(); qCDebug(dcSimulation()) << "Set water temperature" << temperature << "for heating rod device" << device->name(); device->setStateValue(heatingRodWaterTemperatureStateTypeId, temperature); return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == heatingRodMaxPowerActionTypeId) { - double maxPower = action.param(heatingRodMaxPowerActionParamTypeId).value().toDouble(); + double maxPower = action.param(heatingRodMaxPowerActionMaxPowerParamTypeId).value().toDouble(); qCDebug(dcSimulation()) << "Set max power" << maxPower << "for heating rod device" << device->name(); device->setStateValue(heatingRodMaxPowerStateTypeId, maxPower); return DeviceManager::DeviceErrorNoError; @@ -227,7 +227,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, if (device->deviceClassId() == batteryDeviceClassId) { if (action.actionTypeId() == batteryMaxChargingActionTypeId) { - int maxCharging = action.param(batteryMaxChargingActionParamTypeId).value().toInt(); + int maxCharging = action.param(batteryMaxChargingActionMaxChargingParamTypeId).value().toInt(); device->setStateValue(batteryMaxChargingStateTypeId, maxCharging); qCDebug(dcSimulation()) << "Set max charging power" << maxCharging << "for battery device" << device->name(); device->setStateValue(batteryChargingStateTypeId, maxCharging); @@ -238,7 +238,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, if (device->deviceClassId() == waterValveDeviceClassId) { if (action.actionTypeId() == waterValvePowerActionTypeId) { - bool power = action.param(waterValvePowerActionParamTypeId).value().toBool(); + bool power = action.param(waterValvePowerActionPowerParamTypeId).value().toBool(); device->setStateValue(waterValvePowerStateTypeId, power); return DeviceManager::DeviceErrorNoError; } @@ -286,7 +286,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == garageGatePowerActionTypeId) { - bool power = action.param(garageGatePowerActionParamTypeId).value().toBool(); + bool power = action.param(garageGatePowerActionPowerParamTypeId).value().toBool(); device->setStateValue(garageGatePowerStateTypeId, power); return DeviceManager::DeviceErrorNoError; } @@ -314,8 +314,8 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == rollerShutterPercentageActionTypeId) { - qCDebug(dcSimulation()) << "Setting awning to" << action.param(rollerShutterPercentageActionParamTypeId); - m_simulationTimers.value(device)->setProperty("targetValue", action.param(rollerShutterPercentageActionParamTypeId).value()); + qCDebug(dcSimulation()) << "Setting awning to" << action.param(rollerShutterPercentageActionPercentageParamTypeId); + m_simulationTimers.value(device)->setProperty("targetValue", action.param(rollerShutterPercentageActionPercentageParamTypeId).value()); m_simulationTimers.value(device)->start(500); device->setStateValue(rollerShutterMovingStateTypeId, true); return DeviceManager::DeviceErrorNoError; @@ -344,8 +344,8 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device, return DeviceManager::DeviceErrorNoError; } if (action.actionTypeId() == extendedAwningPercentageActionTypeId) { - qCDebug(dcSimulation()) << "Setting awning to" << action.param(extendedAwningPercentageActionParamTypeId); - m_simulationTimers.value(device)->setProperty("targetValue", action.param(extendedAwningPercentageActionParamTypeId).value()); + qCDebug(dcSimulation()) << "Setting awning to" << action.param(extendedAwningPercentageActionPercentageParamTypeId); + m_simulationTimers.value(device)->setProperty("targetValue", action.param(extendedAwningPercentageActionPercentageParamTypeId).value()); m_simulationTimers.value(device)->start(500); device->setStateValue(extendedAwningMovingStateTypeId, true); return DeviceManager::DeviceErrorNoError; diff --git a/snapd/devicepluginsnapd.cpp b/snapd/devicepluginsnapd.cpp index 02264432..c2a557d7 100644 --- a/snapd/devicepluginsnapd.cpp +++ b/snapd/devicepluginsnapd.cpp @@ -39,8 +39,8 @@ DevicePluginSnapd::~DevicePluginSnapd() void DevicePluginSnapd::init() { // Initialize plugin configurations - m_advancedMode = configValue(snapdAdvancedModeParamTypeId).toBool(); - m_refreshTime = configValue(snapdRefreshScheduleParamTypeId).toInt(); + m_advancedMode = configValue(snapdPluginAdvancedModeParamTypeId).toBool(); + m_refreshTime = configValue(snapdPluginRefreshScheduleParamTypeId).toInt(); connect(this, &DevicePluginSnapd::configValueChanged, this, &DevicePluginSnapd::onPluginConfigurationChanged); // Refresh timer for snapd checks @@ -114,12 +114,12 @@ DeviceManager::DeviceSetupStatus DevicePluginSnapd::setupDevice(Device *device) } m_snapdControl = new SnapdControl(device, this); - m_snapdControl->setPreferredRefreshTime(configValue(snapdRefreshScheduleParamTypeId).toInt()); + m_snapdControl->setPreferredRefreshTime(configValue(snapdPluginRefreshScheduleParamTypeId).toInt()); connect(m_snapdControl, &SnapdControl::snapListUpdated, this, &DevicePluginSnapd::onSnapListUpdated); } else if (device->deviceClassId() == snapDeviceClassId) { - device->setName(QString("%1").arg(device->paramValue(snapNameParamTypeId).toString())); - m_snapDevices.insert(device->paramValue(snapIdParamTypeId).toString(), device); + device->setName(QString("%1").arg(device->paramValue(snapDeviceNameParamTypeId).toString())); + m_snapDevices.insert(device->paramValue(snapDeviceIdParamTypeId).toString(), device); } return DeviceManager::DeviceSetupStatusSuccess; @@ -162,11 +162,11 @@ DeviceManager::DeviceError DevicePluginSnapd::executeAction(Device *device, cons } if (action.actionTypeId() == snapChannelActionTypeId) { - QString snapName = device->paramValue(snapNameParamTypeId).toString(); - m_snapdControl->changeSnapChannel(snapName, action.param(snapChannelActionParamTypeId).value().toString()); + QString snapName = device->paramValue(snapDeviceNameParamTypeId).toString(); + m_snapdControl->changeSnapChannel(snapName, action.param(snapChannelActionChannelParamTypeId).value().toString()); return DeviceManager::DeviceErrorNoError; } else if (action.actionTypeId() == snapRevertActionTypeId) { - QString snapName = device->paramValue(snapNameParamTypeId).toString(); + QString snapName = device->paramValue(snapDeviceNameParamTypeId).toString(); m_snapdControl->snapRevert(snapName); return DeviceManager::DeviceErrorNoError; } @@ -182,7 +182,7 @@ void DevicePluginSnapd::onPluginConfigurationChanged(const ParamTypeId ¶mTyp qCDebug(dcSnapd()) << "Plugin configuration changed"; // Check advanced mode - if (paramTypeId == snapdAdvancedModeParamTypeId) { + if (paramTypeId == snapdPluginAdvancedModeParamTypeId) { qCDebug(dcSnapd()) << "Advanced mode" << (value.toBool() ? "enabled." : "disabled."); m_advancedMode = value.toBool(); @@ -190,7 +190,7 @@ void DevicePluginSnapd::onPluginConfigurationChanged(const ParamTypeId ¶mTyp if (!m_advancedMode) { foreach (const QString deviceSnapId, m_snapDevices.keys()) { Device *device = m_snapDevices.take(deviceSnapId); - qCDebug(dcSnapd()) << "Remove device for snap" << device->paramValue(snapNameParamTypeId).toString(); + qCDebug(dcSnapd()) << "Remove device for snap" << device->paramValue(snapDeviceNameParamTypeId).toString(); emit autoDeviceDisappeared(device->id()); } } else { @@ -202,7 +202,7 @@ void DevicePluginSnapd::onPluginConfigurationChanged(const ParamTypeId ¶mTyp } // Check refresh schedule - if (paramTypeId == snapdRefreshScheduleParamTypeId) { + if (paramTypeId == snapdPluginRefreshScheduleParamTypeId) { if (!m_snapdControl) return; @@ -247,11 +247,11 @@ void DevicePluginSnapd::onSnapListUpdated(const QVariantList &snapList) if (!m_snapDevices.contains(snapMap.value("id").toString())) { DeviceDescriptor descriptor(snapDeviceClassId, QString("Snap %1").arg(snapMap.value("name").toString())); ParamList params; - params.append(Param(snapNameParamTypeId, snapMap.value("name"))); - params.append(Param(snapIdParamTypeId, snapMap.value("id"))); - params.append(Param(snapSummaryParamTypeId, snapMap.value("summary"))); - params.append(Param(snapDescriptionParamTypeId, snapMap.value("description"))); - params.append(Param(snapDeveloperParamTypeId, snapMap.value("developer"))); + params.append(Param(snapDeviceNameParamTypeId, snapMap.value("name"))); + params.append(Param(snapDeviceIdParamTypeId, snapMap.value("id"))); + params.append(Param(snapDeviceSummaryParamTypeId, snapMap.value("summary"))); + params.append(Param(snapDeviceDescriptionParamTypeId, snapMap.value("description"))); + params.append(Param(snapDeviceDeveloperParamTypeId, snapMap.value("developer"))); descriptor.setParams(params); emit autoDevicesAppeared(snapDeviceClassId, QList() << descriptor); @@ -273,7 +273,7 @@ void DevicePluginSnapd::onSnapListUpdated(const QVariantList &snapList) foreach (const QString deviceSnapId, m_snapDevices.keys()) { if (!snapIdList.contains(deviceSnapId)) { Device *device = m_snapDevices.take(deviceSnapId); - qCDebug(dcSnapd()) << "The snap" << device->paramValue(snapNameParamTypeId).toString() << "is not installed any more."; + qCDebug(dcSnapd()) << "The snap" << device->paramValue(snapDeviceNameParamTypeId).toString() << "is not installed any more."; emit autoDeviceDisappeared(device->id()); } } diff --git a/tcpcommander/deviceplugintcpcommander.cpp b/tcpcommander/deviceplugintcpcommander.cpp index 52bfef1c..648c208f 100644 --- a/tcpcommander/deviceplugintcpcommander.cpp +++ b/tcpcommander/deviceplugintcpcommander.cpp @@ -38,7 +38,7 @@ DeviceManager::DeviceSetupStatus DevicePluginTcpCommander::setupDevice(Device *d } if (device->deviceClassId() == tcpInputDeviceClassId) { - int port = device->paramValue(tcpInputPortParamTypeId).toInt(); + int port = device->paramValue(tcpInputDevicePortParamTypeId).toInt(); TcpServer *tcpServer = new TcpServer(port, this); if (tcpServer->isValid()) { @@ -60,8 +60,8 @@ DeviceManager::DeviceError DevicePluginTcpCommander::executeAction(Device *devic if (device->deviceClassId() == tcpOutputDeviceClassId) { if (action.actionTypeId() == tcpOutputOutputDataActionTypeId) { - int port = device->paramValue(tcpOutputPortParamTypeId).toInt(); - QHostAddress address= QHostAddress(device->paramValue(tcpOutputIpv4addressParamTypeId).toString()); + int port = device->paramValue(tcpOutputDevicePortParamTypeId).toInt(); + QHostAddress address= QHostAddress(device->paramValue(tcpOutputDeviceIpv4addressParamTypeId).toString()); QTcpSocket *tcpSocket = m_tcpSockets.key(device); tcpSocket->connectToHost(address, port); return DeviceManager::DeviceErrorNoError; @@ -98,7 +98,7 @@ void DevicePluginTcpCommander::onTcpSocketConnected() qDebug(dcTCPCommander()) << device->name() << "Setup finished" ; emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess); } else { - QByteArray data = device->paramValue(tcpOutputOutputDataAreaParamTypeId).toByteArray(); + QByteArray data = device->paramValue(tcpOutputOutputDataActionOutputDataAreaParamTypeId).toByteArray(); tcpSocket->write(data); } device->setStateValue(tcpOutputConnectedStateTypeId, true); @@ -166,28 +166,28 @@ void DevicePluginTcpCommander::onTcpServerTextMessageReceived(QByteArray data) qDebug(dcTCPCommander()) << device->name() << "Message received" << data; device->setStateValue(tcpInputDataReceivedStateTypeId, data); - if (device->paramValue(tcpInputComparisionParamTypeId).toString() == "Is exactly") { + if (device->paramValue(tcpInputDeviceComparisionParamTypeId).toString() == "Is exactly") { qDebug(dcTCPCommander()) << "is exactly"; - if (data == device->paramValue(tcpInputInputDataParamTypeId)) { + if (data == device->paramValue(tcpInputDeviceInputDataParamTypeId)) { qDebug(dcTCPCommander()) << "comparison successful"; emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); } - } else if (device->paramValue(tcpInputComparisionParamTypeId).toString() == "Contains") { - if (data.contains(device->paramValue(tcpInputInputDataParamTypeId).toByteArray())) { + } else if (device->paramValue(tcpInputDeviceComparisionParamTypeId).toString() == "Contains") { + if (data.contains(device->paramValue(tcpInputDeviceInputDataParamTypeId).toByteArray())) { emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); } - } else if (device->paramValue(tcpInputComparisionParamTypeId) == "Contains not") { - if (!data.contains(device->paramValue(tcpInputInputDataParamTypeId).toByteArray())) + } else if (device->paramValue(tcpInputDeviceComparisionParamTypeId) == "Contains not") { + if (!data.contains(device->paramValue(tcpInputDeviceInputDataParamTypeId).toByteArray())) emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); - } else if (device->paramValue(tcpInputComparisionParamTypeId) == "Starts with") { - if (data.startsWith(device->paramValue(tcpInputInputDataParamTypeId).toByteArray())) + } else if (device->paramValue(tcpInputDeviceComparisionParamTypeId) == "Starts with") { + if (data.startsWith(device->paramValue(tcpInputDeviceInputDataParamTypeId).toByteArray())) emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); - } else if (device->paramValue(tcpInputComparisionParamTypeId) == "Ends with") { - if (data.endsWith(device->paramValue(tcpInputInputDataParamTypeId).toByteArray())) + } else if (device->paramValue(tcpInputDeviceComparisionParamTypeId) == "Ends with") { + if (data.endsWith(device->paramValue(tcpInputDeviceInputDataParamTypeId).toByteArray())) emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); } } diff --git a/udpcommander/devicepluginudpcommander.cpp b/udpcommander/devicepluginudpcommander.cpp index bf92c4a0..4888c894 100644 --- a/udpcommander/devicepluginudpcommander.cpp +++ b/udpcommander/devicepluginudpcommander.cpp @@ -74,7 +74,7 @@ DeviceManager::DeviceSetupStatus DevicePluginUdpCommander::setupDevice(Device *d if (device->deviceClassId() == udpReceiverDeviceClassId) { QUdpSocket *udpSocket = new QUdpSocket(this); - int port = device->paramValue(udpReceiverPortParamTypeId).toInt(); + int port = device->paramValue(udpReceiverDevicePortParamTypeId).toInt(); if (!udpSocket->bind(QHostAddress::Any, port, QUdpSocket::ShareAddress)) { qCWarning(dcUdpCommander()) << device->name() << "cannot bind to port" << port; delete udpSocket; @@ -101,9 +101,9 @@ DeviceManager::DeviceError DevicePluginUdpCommander::executeAction(Device *devic if (device->deviceClassId() == udpCommanderDeviceClassId) { if (action.actionTypeId() == udpCommanderTriggerActionTypeId) { QUdpSocket *udpSocket = m_commanderList.key(device); - int port = device->paramValue(udpCommanderPortParamTypeId).toInt(); - QHostAddress address = QHostAddress(device->paramValue(udpCommanderAddressParamTypeId).toString()); - QByteArray data = action.param(udpCommanderDataParamTypeId).value().toByteArray(); + int port = device->paramValue(udpCommanderDevicePortParamTypeId).toInt(); + QHostAddress address = QHostAddress(device->paramValue(udpCommanderDeviceAddressParamTypeId).toString()); + QByteArray data = action.param(udpCommanderTriggerActionDataParamTypeId).value().toByteArray(); qDebug(dcUdpCommander()) << "Send UDP datagram:" << data << "address:" << address.toIPv4Address() << "port:" << port; udpSocket->writeDatagram(data, address, port); @@ -143,7 +143,7 @@ void DevicePluginUdpCommander::readPendingDatagrams() QByteArray datagram; QHostAddress sender; - quint16 senderPort; + quint16 senderPort = 0; while (socket->hasPendingDatagrams()) { datagram.resize(socket->pendingDatagramSize()); @@ -153,7 +153,7 @@ void DevicePluginUdpCommander::readPendingDatagrams() qCDebug(dcUdpCommander()) << device->name() << "got command from" << sender.toString() << senderPort; Event ev = Event(udpReceiverTriggeredEventTypeId, device->id()); ParamList params; - params.append(Param(udpReceiverDataParamTypeId, datagram)); + params.append(Param(udpReceiverTriggeredEventDataParamTypeId, datagram)); ev.setParams(params); emit emitEvent(ev); diff --git a/unitec/devicepluginunitec.cpp b/unitec/devicepluginunitec.cpp index 109c4ffc..6310cf1f 100644 --- a/unitec/devicepluginunitec.cpp +++ b/unitec/devicepluginunitec.cpp @@ -66,8 +66,8 @@ DeviceManager::DeviceSetupStatus DevicePluginUnitec::setupDevice(Device *device) } foreach (Device* d, myDevices()) { - if (d->paramValue(switchChannelParamTypeId).toString() == device->paramValue(switchChannelParamTypeId).toString()) { - qCWarning(dcUnitec) << "Unitec switch with channel " << device->paramValue(switchChannelParamTypeId).toString() << "already added."; + if (d->paramValue(switchDeviceChannelParamTypeId).toString() == device->paramValue(switchDeviceChannelParamTypeId).toString()) { + qCWarning(dcUnitec) << "Unitec switch with channel " << device->paramValue(switchDeviceChannelParamTypeId).toString() << "already added."; return DeviceManager::DeviceSetupStatusFailure; } } @@ -88,21 +88,21 @@ DeviceManager::DeviceError DevicePluginUnitec::executeAction(Device *device, con } // Bin codes for buttons - if (device->paramValue(switchChannelParamTypeId).toString() == "A" && action.param(switchPowerParamTypeId).value().toBool() == true) { + if (device->paramValue(switchDeviceChannelParamTypeId).toString() == "A" && action.param(switchPowerActionPowerParamTypeId).value().toBool() == true) { binCode.append("111011000100111010111111"); - } else if (device->paramValue(switchChannelParamTypeId).toString() == "A" && action.param(switchPowerParamTypeId).value().toBool() == false) { + } else if (device->paramValue(switchDeviceChannelParamTypeId).toString() == "A" && action.param(switchPowerActionPowerParamTypeId).value().toBool() == false) { binCode.append("111001100110100001011111"); - } else if (device->paramValue(switchChannelParamTypeId).toString() == "B" && action.param(switchPowerParamTypeId).value().toBool() == true) { + } else if (device->paramValue(switchDeviceChannelParamTypeId).toString() == "B" && action.param(switchPowerActionPowerParamTypeId).value().toBool() == true) { binCode.append("111011000100111010111011"); - } else if (device->paramValue(switchChannelParamTypeId).toString() == "B" && action.param(switchPowerParamTypeId).value().toBool() == false) { + } else if (device->paramValue(switchDeviceChannelParamTypeId).toString() == "B" && action.param(switchPowerActionPowerParamTypeId).value().toBool() == false) { binCode.append("111000111001100111101011"); - } else if (device->paramValue(switchChannelParamTypeId).toString() == "C" && action.param(switchPowerParamTypeId).value().toBool() == true) { + } else if (device->paramValue(switchDeviceChannelParamTypeId).toString() == "C" && action.param(switchPowerActionPowerParamTypeId).value().toBool() == true) { binCode.append("111000000011011111000011"); - } else if (device->paramValue(switchChannelParamTypeId).toString() == "C" && action.param(switchPowerParamTypeId).value().toBool() == false) { + } else if (device->paramValue(switchDeviceChannelParamTypeId).toString() == "C" && action.param(switchPowerActionPowerParamTypeId).value().toBool() == false) { binCode.append("111001100110100001010011"); - } else if (device->paramValue(switchChannelParamTypeId).toString() == "D" && action.param(switchPowerParamTypeId).value().toBool() == true) { + } else if (device->paramValue(switchDeviceChannelParamTypeId).toString() == "D" && action.param(switchPowerActionPowerParamTypeId).value().toBool() == true) { binCode.append("111001100110100001011101"); - } else if (device->paramValue(switchChannelParamTypeId).toString() == "D" && action.param(switchPowerParamTypeId).value().toBool() == false) { + } else if (device->paramValue(switchDeviceChannelParamTypeId).toString() == "D" && action.param(switchPowerActionPowerParamTypeId).value().toBool() == false) { binCode.append("111000000011011111001101"); } @@ -128,9 +128,9 @@ DeviceManager::DeviceError DevicePluginUnitec::executeAction(Device *device, con // ======================================= // send data to hardware resource if(hardwareManager()->radio433()->sendData(delay, rawData, 10)){ - qCDebug(dcUnitec) << "transmitted" << pluginName() << device->name() << "power: " << action.param(switchPowerParamTypeId).value().toBool(); + qCDebug(dcUnitec) << "transmitted" << pluginName() << device->name() << "power: " << action.param(switchPowerActionPowerParamTypeId).value().toBool(); }else{ - qCWarning(dcUnitec) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(switchPowerParamTypeId).value().toBool(); + qCWarning(dcUnitec) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(switchPowerActionPowerParamTypeId).value().toBool(); return DeviceManager::DeviceErrorHardwareNotAvailable; } diff --git a/wakeonlan/devicepluginwakeonlan.cpp b/wakeonlan/devicepluginwakeonlan.cpp index 8c151319..bffc1b38 100644 --- a/wakeonlan/devicepluginwakeonlan.cpp +++ b/wakeonlan/devicepluginwakeonlan.cpp @@ -62,7 +62,7 @@ DeviceManager::DeviceError DevicePluginWakeOnLan::executeAction(Device *device, { if(action.actionTypeId() == wolWolActionTypeId){ qCDebug(dcWakeOnLan) << "Wake up" << device->name(); - wakeup(device->paramValue(wolMacParamTypeId).toString()); + wakeup(device->paramValue(wolDeviceMacParamTypeId).toString()); } return DeviceManager::DeviceErrorNoError; } diff --git a/wemo/devicepluginwemo.cpp b/wemo/devicepluginwemo.cpp index a4fbaf5a..69ea1f44 100644 --- a/wemo/devicepluginwemo.cpp +++ b/wemo/devicepluginwemo.cpp @@ -106,7 +106,7 @@ DeviceManager::DeviceError DevicePluginWemo::executeAction(Device *device, const // Check if wemo device is reachable if (device->stateValue(wemoSwitchReachableStateTypeId).toBool()) { // setPower returns false, if the curent powerState is already the new powerState - if (setPower(device, action.param(wemoSwitchPowerActionParamTypeId).value().toBool(), action.id())) { + if (setPower(device, action.param(wemoSwitchPowerActionPowerParamTypeId).value().toBool(), action.id())) { return DeviceManager::DeviceErrorAsync; } else { return DeviceManager::DeviceErrorNoError; @@ -143,7 +143,7 @@ void DevicePluginWemo::refresh(Device *device) QByteArray getBinarayStateMessage("1"); QNetworkRequest request; - request.setUrl(QUrl("http://" + device->paramValue(wemoSwitchHostParamTypeId).toString() + ":" + device->paramValue(wemoSwitchPortParamTypeId).toString() + "/upnp/control/basicevent1")); + request.setUrl(QUrl("http://" + device->paramValue(wemoSwitchDeviceHostParamTypeId).toString() + ":" + device->paramValue(wemoSwitchDevicePortParamTypeId).toString() + "/upnp/control/basicevent1")); request.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("text/xml; charset=\"utf-8\"")); request.setHeader(QNetworkRequest::UserAgentHeader,QVariant("nymea")); request.setRawHeader("SOAPACTION", "\"urn:Belkin:service:basicevent:1#GetBinaryState\""); @@ -163,7 +163,7 @@ bool DevicePluginWemo::setPower(Device *device, const bool &power, const ActionI QByteArray setPowerMessage("" + QByteArray::number((int)power) + ""); QNetworkRequest request; - request.setUrl(QUrl("http://" + device->paramValue(wemoSwitchHostParamTypeId).toString() + ":" + device->paramValue(wemoSwitchPortParamTypeId).toString() + "/upnp/control/basicevent1")); + request.setUrl(QUrl("http://" + device->paramValue(wemoSwitchDeviceHostParamTypeId).toString() + ":" + device->paramValue(wemoSwitchDevicePortParamTypeId).toString() + "/upnp/control/basicevent1")); request.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("text/xml; charset=\"utf-8\"")); request.setHeader(QNetworkRequest::UserAgentHeader,QVariant("nymea")); request.setRawHeader("SOAPACTION", "\"urn:Belkin:service:basicevent:1#SetBinaryState\""); @@ -249,10 +249,10 @@ void DevicePluginWemo::onUpnpDiscoveryFinished() if (upnpDeviceDescriptor.friendlyName() == "WeMo Switch") { DeviceDescriptor descriptor(wemoSwitchDeviceClassId, "WeMo Switch", upnpDeviceDescriptor.serialNumber()); ParamList params; - params.append(Param(wemoSwitchNameParamTypeId, upnpDeviceDescriptor.friendlyName())); - params.append(Param(wemoSwitchHostParamTypeId, upnpDeviceDescriptor.hostAddress().toString())); - params.append(Param(wemoSwitchPortParamTypeId, upnpDeviceDescriptor.port())); - params.append(Param(wemoSwitchSerialParamTypeId, upnpDeviceDescriptor.serialNumber())); + params.append(Param(wemoSwitchDeviceNameParamTypeId, upnpDeviceDescriptor.friendlyName())); + params.append(Param(wemoSwitchDeviceHostParamTypeId, upnpDeviceDescriptor.hostAddress().toString())); + params.append(Param(wemoSwitchDevicePortParamTypeId, upnpDeviceDescriptor.port())); + params.append(Param(wemoSwitchDeviceSerialParamTypeId, upnpDeviceDescriptor.serialNumber())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } diff --git a/ws2812/devicepluginws2812.cpp b/ws2812/devicepluginws2812.cpp index 6974281a..69fc3b9f 100644 --- a/ws2812/devicepluginws2812.cpp +++ b/ws2812/devicepluginws2812.cpp @@ -71,7 +71,7 @@ DeviceManager::DeviceSetupStatus DevicePluginWs2812::setupDevice(Device *device) qCDebug(dcWs2812) << "Setup Plant Care" << device->name() << device->params(); // Check if device already added with this address - if (deviceAlreadyAdded(QHostAddress(device->paramValue(ws2812HostParamTypeId).toString()))) { + if (deviceAlreadyAdded(QHostAddress(device->paramValue(ws2812DeviceHostParamTypeId).toString()))) { qCWarning(dcWs2812) << "Device with this address already added."; return DeviceManager::DeviceSetupStatusFailure; } @@ -101,7 +101,7 @@ DeviceManager::DeviceError DevicePluginWs2812::discoverDevices(const DeviceClass Q_UNUSED(params) // Perform a HTTP GET on the RPL router address - QHostAddress address(configuration().paramValue(ws2812RplParamTypeId).toString()); + QHostAddress address(configuration().paramValue(ws2812PluginRplParamTypeId).toString()); qCDebug(dcWs2812) << "Scan for new nodes on RPL" << address.toString(); QUrl url; @@ -137,10 +137,10 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/a/color"); - QColor newColor = action.param(ws2812EffectModeActionParamTypeId).value().value().toRgb(); + QColor newColor = action.param(ws2812EffectColorActionEffectColorParamTypeId).value().value().toRgb(); QByteArray message = "color=" + newColor.name().remove("#").toUtf8(); qCDebug(dcWs2812) << "Sending" << url.toString() << message; @@ -161,10 +161,10 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/a/speed"); - int speed = action.param(ws2812SpeedActionParamTypeId).value().toInt(); + int speed = action.param(ws2812SpeedActionSpeedParamTypeId).value().toInt(); qCDebug(dcWs2812) << "Set Speed:" << speed; @@ -186,11 +186,11 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con } else if(action.actionTypeId() == ws2812BrightnessActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/a/brightness"); - int brightness = action.param(ws2812BrightnessActionParamTypeId).value().toInt(); + int brightness = action.param(ws2812BrightnessActionBrightnessParamTypeId).value().toInt(); qCDebug(dcWs2812) << "Set brightness:" << brightness; @@ -213,14 +213,14 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/p/maxpix"); //QColor color = action.param("color").value().value().toHsv(); //QColor newColor = QColor::fromHsv(color.hue(), color.saturation(), 100 * light->brightness() / 255.0); //QByteArray message = "color=" + newColor.toRgb().name().remove("#").toUtf8(); - int max = action.param(ws2812MaxPixActionParamTypeId).value().toInt(); + int max = action.param(ws2812MaxPixActionMaxPixParamTypeId).value().toInt(); qCDebug(dcWs2812) << "Max Pix" << max; @@ -246,12 +246,12 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con int effectmode = 0; - QString effectModeString = action.param(ws2812EffectModeActionParamTypeId).value().toString(); + QString effectModeString = action.param(ws2812EffectModeActionEffectModeParamTypeId).value().toString(); QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/a/effect"); qCDebug(dcWs2812) << "Set effect mode to:" << effectModeString; @@ -299,7 +299,7 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/a/tcolor"); @@ -311,11 +311,11 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con */ if(action.actionTypeId() == ws2812Tcolor1ActionTypeId) { - tColor1 = action.param(ws2812Tcolor1ActionParamTypeId).value().value().toRgb(); + tColor1 = action.param(ws2812Tcolor1ActionTcolor1ParamTypeId).value().value().toRgb(); } else if(action.actionTypeId() == ws2812Tcolor2ActionTypeId){ - tColor2 = action.param(ws2812Tcolor2ActionParamTypeId).value().value().toRgb(); + tColor2 = action.param(ws2812Tcolor2ActionTcolor2ParamTypeId).value().value().toRgb(); } else if(action.actionTypeId() == ws2812Tcolor3ActionTypeId){ - tColor3 = action.param(ws2812Tcolor3ActionParamTypeId).value().value().toRgb(); + tColor3 = action.param(ws2812Tcolor3ActionTcolor3ParamTypeId).value().value().toRgb(); } QByteArray message = "color=" + tColor1.name().remove("#").toUtf8() + tColor2.name().remove("#").toUtf8() + tColor3.name().remove("#").toUtf8(); @@ -340,7 +340,7 @@ void DevicePluginWs2812::pingDevice(Device *device) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); m_pingReplies.insert(m_coap->ping(CoapRequest(url)), device); } @@ -349,7 +349,7 @@ void DevicePluginWs2812::updateBattery(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "battery value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/s/battery"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -368,7 +368,7 @@ void DevicePluginWs2812::updateColor(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "color value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/a/color"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -385,7 +385,7 @@ void DevicePluginWs2812::updateTricolore(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "tricolore value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/a/tcolor"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -404,7 +404,7 @@ void DevicePluginWs2812::updateEffect(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "effect mode"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/a/effect"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -422,7 +422,7 @@ void DevicePluginWs2812::updateMaxPix(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "max pix"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/p/maxpix"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -441,7 +441,7 @@ void DevicePluginWs2812::enableNotifications(Device *device) qCDebug(dcWs2812) << "Enable" << device->name() << "notifications"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812DeviceHostParamTypeId).toString()); url.setPath("/s/battery"); @@ -494,7 +494,7 @@ bool DevicePluginWs2812::deviceAlreadyAdded(const QHostAddress &address) { // Check if we already have a device with the given address foreach (Device *device, myDevices()) { - if (device->paramValue(ws2812HostParamTypeId).toString() == address.toString()) { + if (device->paramValue(ws2812DeviceHostParamTypeId).toString() == address.toString()) { return true; } } @@ -505,11 +505,11 @@ Device *DevicePluginWs2812::findDevice(const QHostAddress &address) { // Return the device pointer with the given address (otherwise 0) foreach (Device *device, myDevices()) { - if (device->paramValue(ws2812HostParamTypeId).toString() == address.toString()) { + if (device->paramValue(ws2812DeviceHostParamTypeId).toString() == address.toString()) { return device; } } - return NULL; + return nullptr; } void DevicePluginWs2812::onPluginTimer() @@ -554,7 +554,7 @@ void DevicePluginWs2812::onNetworkReplyFinished() // Create a deviceDescriptor for each found address DeviceDescriptor descriptor(deviceClassId, "ws2812", address.toString()); ParamList params; - params.append(Param(ws2812HostParamTypeId, address.toString())); + params.append(Param(ws2812DeviceHostParamTypeId, address.toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -616,37 +616,37 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) switch (effectmode) { case 0: - effectModeString == "Off"; + effectModeString = "Off"; break; case 1: - effectModeString == "Color On"; + effectModeString = "Color On"; break; case 2: - effectModeString == "Color Wave"; + effectModeString = "Color Wave"; break; case 3: - effectModeString == "Color Fade"; + effectModeString = "Color Fade"; break; case 4: - effectModeString == "Color Flash"; + effectModeString = "Color Flash"; break; case 5: - effectModeString == "Rainbow Wave"; + effectModeString = "Rainbow Wave"; break; case 6: - effectModeString == "Rainbow Flash"; + effectModeString = "Rainbow Flash"; break; case 7: - effectModeString == "Knight Rider"; + effectModeString = "Knight Rider"; break; case 8: - effectModeString == "Fire"; + effectModeString = "Fire"; break; case 9: - effectModeString == "Tricolore"; + effectModeString = "Tricolore"; break; default: - effectModeString == "Off"; + effectModeString = "Off"; } device->setStateValue(ws2812EffectModeStateTypeId, effectModeString); }else if (urlPath == "/a/brightness") { @@ -704,7 +704,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareFailure); return; } - QString tcolor = action.param(ws2812EffectColorActionParamTypeId).value().toByteArray(); + QString tcolor = action.param(ws2812EffectColorActionEffectColorParamTypeId).value().toByteArray(); // Update the state here, so we don't have to wait for the notification device->setStateValue(ws2812Tcolor1StateTypeId, tcolor.left(6)); @@ -736,7 +736,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(ws2812EffectColorStateTypeId, action.param(ws2812EffectColorActionParamTypeId).value().toInt()); + device->setStateValue(ws2812EffectColorStateTypeId, action.param(ws2812EffectColorActionEffectColorParamTypeId).value().toInt()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -762,7 +762,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(ws2812BrightnessStateTypeId, action.param(ws2812BrightnessActionParamTypeId).value().toInt()); + device->setStateValue(ws2812BrightnessStateTypeId, action.param(ws2812BrightnessActionBrightnessParamTypeId).value().toInt()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -788,7 +788,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(ws2812SpeedStateTypeId, action.param(ws2812SpeedActionParamTypeId).value().toInt()); + device->setStateValue(ws2812SpeedStateTypeId, action.param(ws2812SpeedActionSpeedParamTypeId).value().toInt()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -814,7 +814,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(ws2812MaxPixStateTypeId, action.param(ws2812MaxPixActionParamTypeId).value().toInt()); + device->setStateValue(ws2812MaxPixStateTypeId, action.param(ws2812MaxPixActionMaxPixParamTypeId).value().toInt()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -864,37 +864,37 @@ void DevicePluginWs2812::onNotificationReceived(const CoapObserveResource &resou switch (effectmode) { case 0: - effectModeString == "Off"; + effectModeString = "Off"; break; case 1: - effectModeString == "Color On"; + effectModeString = "Color On"; break; case 2: - effectModeString == "Color Wave"; + effectModeString = "Color Wave"; break; case 3: - effectModeString == "Color Fade"; + effectModeString = "Color Fade"; break; case 4: - effectModeString == "Color Flash"; + effectModeString = "Color Flash"; break; case 5: - effectModeString == "Rainbow Wave"; + effectModeString = "Rainbow Wave"; break; case 6: - effectModeString == "Rainbow Flash"; + effectModeString = "Rainbow Flash"; break; case 7: - effectModeString == "Knight Rider"; + effectModeString = "Knight Rider"; break; case 8: - effectModeString == "Fire"; + effectModeString = "Fire"; break; case 9: - effectModeString == "Tricolore"; + effectModeString = "Tricolore"; break; default: - effectModeString == "Off"; + effectModeString = "Off"; }