diff --git a/avahimonitor/devicepluginavahimonitor.cpp b/avahimonitor/devicepluginavahimonitor.cpp index d81dc4c5..9749d78f 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(serviceParamTypeId, service.name())); - params.append(Param(hostNameParamTypeId, service.hostName())); + params.append(Param(avahiServiceParamTypeId, service.name())); + params.append(Param(avahiHostNameParamTypeId, service.hostName())); deviceDescriptor.setParams(params); deviceDescriptors.append(deviceDescriptor); } @@ -93,8 +93,8 @@ DeviceManager::DeviceError DevicePluginAvahiMonitor::discoverDevices(const Devic void DevicePluginAvahiMonitor::onServiceEntryAdded(const AvahiServiceEntry &serviceEntry) { foreach (Device *device, myDevices()) { - if (device->paramValue(serviceParamTypeId).toString() == serviceEntry.name()) { - device->setStateValue(onlineStateTypeId, true); + if (device->paramValue(avahiServiceParamTypeId).toString() == serviceEntry.name()) { + device->setStateValue(avahiOnlineStateTypeId, true); } } } @@ -102,8 +102,8 @@ void DevicePluginAvahiMonitor::onServiceEntryAdded(const AvahiServiceEntry &serv void DevicePluginAvahiMonitor::onServiceEntryRemoved(const AvahiServiceEntry &serviceEntry) { foreach (Device *device, myDevices()) { - if (device->paramValue(serviceParamTypeId).toString() == serviceEntry.name()) { - device->setStateValue(onlineStateTypeId, false); + if (device->paramValue(avahiServiceParamTypeId).toString() == serviceEntry.name()) { + device->setStateValue(avahiOnlineStateTypeId, false); } } } diff --git a/awattar/devicepluginawattar.cpp b/awattar/devicepluginawattar.cpp index 71cb67f8..a93553c5 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(tokenParamTypeId).toString(); - m_userUuid = device->paramValue(userUuidParamTypeId).toString(); + m_token = device->paramValue(awattarTokenParamTypeId).toString(); + m_userUuid = device->paramValue(awattarUserUuidParamTypeId).toString(); m_device = device; if (m_token.isEmpty() || m_userUuid.isEmpty()) { @@ -132,21 +132,21 @@ DeviceManager::DeviceError DevicePluginAwattar::executeAction(Device *device, co if (m_device.isNull() || m_device != device) return DeviceManager::DeviceErrorHardwareNotAvailable; - if (action.actionTypeId() == sgSyncModeActionTypeId) { - qCDebug(dcAwattar) << "Set sg sync mode to" << action.param(sgSyncModeStateParamTypeId).value(); - device->setStateValue(sgSyncModeStateTypeId, action.param(sgSyncModeStateParamTypeId).value()); - if (action.param(sgSyncModeStateParamTypeId).value() == "auto") + if (action.actionTypeId() == awattarSgSyncModeActionTypeId) { + qCDebug(dcAwattar) << "Set sg sync mode to" << action.param(awattarSgSyncModeStateParamTypeId).value(); + device->setStateValue(awattarSgSyncModeStateTypeId, action.param(awattarSgSyncModeStateParamTypeId).value()); + if (action.param(awattarSgSyncModeStateParamTypeId).value() == "auto") setSgMode(m_autoSgMode); return DeviceManager::DeviceErrorNoError; - } else if (action.actionTypeId() == setSgModeActionTypeId) { - if (!device->stateValue(reachableStateTypeId).toBool()) { + } else if (action.actionTypeId() == awattarSetSgModeActionTypeId) { + if (!device->stateValue(awattarReachableStateTypeId).toBool()) { qCWarning(dcAwattar) << "Could not set SG mode. The pump is not reachable"; return DeviceManager::DeviceErrorHardwareNotAvailable; } - device->setStateValue(sgSyncModeStateTypeId, "manual"); - QString sgModeString = action.param(sgModeParamTypeId).value().toString(); + device->setStateValue(awattarSgSyncModeStateTypeId, "manual"); + QString sgModeString = action.param(awattarSgModeParamTypeId).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(rplParamTypeId).toString()); + QHostAddress rplAddress = QHostAddress(configuration().paramValue(awattarRplParamTypeId).toString()); if (rplAddress.isNull()) { - qCWarning(dcAwattar) << "Invalid RPL address" << configuration().paramValue(rplParamTypeId).toString(); + qCWarning(dcAwattar) << "Invalid RPL address" << configuration().paramValue(awattarRplParamTypeId).toString(); return; } @@ -256,8 +256,8 @@ void DevicePluginAwattar::processPriceData(const QVariantMap &data) if (price < minPrice) minPrice = price; - m_device->setStateValue(currentMarketPriceStateTypeId, currentPrice / 10.0); - m_device->setStateValue(validUntilStateTypeId, endTime.toLocalTime().toTime_t()); + m_device->setStateValue(awattarCurrentMarketPriceStateTypeId, currentPrice / 10.0); + m_device->setStateValue(awattarValidUntilStateTypeId, endTime.toLocalTime().toTime_t()); } } @@ -270,10 +270,10 @@ void DevicePluginAwattar::processPriceData(const QVariantMap &data) deviation = qRound(-100 * (averagePrice - currentPrice) / (maxPrice - averagePrice)); } - m_device->setStateValue(averagePriceStateTypeId, averagePrice / 10.0); - m_device->setStateValue(lowestPriceStateTypeId, minPrice / 10.0); - m_device->setStateValue(highestPriceStateTypeId, maxPrice / 10.0); - m_device->setStateValue(averageDeviationStateTypeId, deviation); + m_device->setStateValue(awattarAveragePriceStateTypeId, averagePrice / 10.0); + m_device->setStateValue(awattarLowestPriceStateTypeId, minPrice / 10.0); + m_device->setStateValue(awattarHighestPriceStateTypeId, maxPrice / 10.0); + m_device->setStateValue(awattarAverageDeviationStateTypeId, deviation); } void DevicePluginAwattar::processUserData(const QVariantMap &data) @@ -301,7 +301,7 @@ void DevicePluginAwattar::processUserData(const QVariantMap &data) m_autoSgMode = sgMode; // sync the sg mode to each pump available - if (m_device->stateValue(sgSyncModeStateTypeId).toString() == "auto") { + if (m_device->stateValue(awattarSgSyncModeStateTypeId).toString() == "auto") { setSgMode(m_autoSgMode); } else { setSgMode(m_manualSgMode); @@ -340,19 +340,19 @@ void DevicePluginAwattar::setSgMode(const int &sgMode) switch (sgMode) { case 1: - m_device->setStateValue(sgModeStateTypeId, "1 - Off"); + m_device->setStateValue(awattarSgModeStateTypeId, "1 - Off"); break; case 2: - m_device->setStateValue(sgModeStateTypeId, "2 - Normal"); + m_device->setStateValue(awattarSgModeStateTypeId, "2 - Normal"); break; case 3: - m_device->setStateValue(sgModeStateTypeId, "3 - High Temperature"); + m_device->setStateValue(awattarSgModeStateTypeId, "3 - High Temperature"); break; case 4: - m_device->setStateValue(sgModeStateTypeId, "4 - On"); + m_device->setStateValue(awattarSgModeStateTypeId, "4 - On"); break; default: - m_device->setStateValue(sgModeStateTypeId, "0 - Invalid"); + m_device->setStateValue(awattarSgModeStateTypeId, "0 - Invalid"); return; } @@ -369,7 +369,7 @@ void DevicePluginAwattar::setOnlineStatus(const bool &online) if (m_device.isNull()) return; - m_device->setStateValue(onlineStateTypeId, online); + m_device->setStateValue(awattarOnlineStateTypeId, online); } bool DevicePluginAwattar::heatPumpExists(const QHostAddress &pumpAddress) @@ -481,6 +481,6 @@ void DevicePluginAwattar::onHeatPumpReachableChanged() } if (m_device) - m_device->setStateValue(reachableStateTypeId, reachable); + m_device->setStateValue(awattarReachableStateTypeId, reachable); } diff --git a/awattar/devicepluginawattar.json b/awattar/devicepluginawattar.json index 9e86fbb5..b03b39d4 100644 --- a/awattar/devicepluginawattar.json +++ b/awattar/devicepluginawattar.json @@ -1,6 +1,6 @@ { "displayName": "aWATTar", - "name": "Awattar", + "name": "awattar", "id": "9c261c33-d44e-461e-8ec1-68803cb73f12", "paramTypes": [ { diff --git a/commandlauncher/deviceplugincommandlauncher.cpp b/commandlauncher/deviceplugincommandlauncher.cpp index 9a29d809..7e12d1dd 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(scriptParamTypeId).toString().split(QRegExp("[ \r\n][ \r\n]*")); + QStringList scriptArguments = device->paramValue(scriptScriptParamTypeId).toString().split(QRegExp("[ \r\n][ \r\n]*")); // check if script exists and if it is executable QFileInfo fileInfo(scriptArguments.first()); if (!fileInfo.exists()) { @@ -143,7 +143,7 @@ DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *de // Application if (device->deviceClassId() == applicationDeviceClassId ) { // execute application... - if (action.actionTypeId() == executeActionTypeId) { + if (action.actionTypeId() == applicationExecuteActionTypeId) { // check if we already have started the application if (m_applications.values().contains(device)) { if (m_applications.key(device)->state() == QProcess::Running) { @@ -156,12 +156,12 @@ 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(commandParamTypeId).toString()); + process->start("/bin/bash", QStringList() << "-c" << device->paramValue(applicationCommandParamTypeId).toString()); return DeviceManager::DeviceErrorAsync; } // kill application... - if (action.actionTypeId() == killActionTypeId) { + if (action.actionTypeId() == applicationKillActionTypeId) { // check if the application is running... if (!m_applications.values().contains(device)) { return DeviceManager::DeviceErrorNoError; @@ -178,7 +178,7 @@ DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *de // Script if (device->deviceClassId() == scriptDeviceClassId ) { // execute script... - if (action.actionTypeId() == executeActionTypeId) { + if (action.actionTypeId() == scriptExecuteActionTypeId) { // check if we already have started the script if (m_scripts.values().contains(device)) { if (m_scripts.key(device)->state() == QProcess::Running) { @@ -191,12 +191,12 @@ DeviceManager::DeviceError DevicePluginCommandLauncher::executeAction(Device *de m_scripts.insert(process, device); m_startingScripts.insert(process, action.id()); - process->start("/bin/bash", QStringList() << device->paramValue(scriptParamTypeId).toString()); + process->start("/bin/bash", QStringList() << device->paramValue(scriptScriptParamTypeId).toString()); return DeviceManager::DeviceErrorAsync; } // kill script... - if (action.actionTypeId() == killActionTypeId) { + if (action.actionTypeId() == scriptKillActionTypeId) { // check if the script is running... if (!m_scripts.values().contains(device)) { return DeviceManager::DeviceErrorNoError; @@ -253,12 +253,12 @@ void DevicePluginCommandLauncher::scriptStateChanged(QProcess::ProcessState stat switch (state) { case QProcess::Running: - device->setStateValue(runningStateTypeId, true); + device->setStateValue(scriptRunningStateTypeId, true); emit actionExecutionFinished(m_startingScripts.value(process), DeviceManager::DeviceErrorNoError); m_startingScripts.remove(process); break; case QProcess::NotRunning: - device->setStateValue(runningStateTypeId, false); + device->setStateValue(scriptRunningStateTypeId, false); if (m_killingScripts.contains(process)) { emit actionExecutionFinished(m_killingScripts.value(process), DeviceManager::DeviceErrorNoError); m_killingScripts.remove(process); @@ -277,7 +277,7 @@ void DevicePluginCommandLauncher::scriptFinished(int exitCode, QProcess::ExitSta QProcess *process = static_cast(sender()); Device *device = m_scripts.value(process); - device->setStateValue(runningStateTypeId, false); + device->setStateValue(scriptRunningStateTypeId, false); m_scripts.remove(process); process->deleteLater(); @@ -290,12 +290,12 @@ void DevicePluginCommandLauncher::applicationStateChanged(QProcess::ProcessState switch (state) { case QProcess::Running: - device->setStateValue(runningStateTypeId, true); + device->setStateValue(applicationRunningStateTypeId, true); emit actionExecutionFinished(m_startingApplications.value(process), DeviceManager::DeviceErrorNoError); m_startingApplications.remove(process); break; case QProcess::NotRunning: - device->setStateValue(runningStateTypeId, false); + device->setStateValue(applicationRunningStateTypeId, false); if (m_killingApplications.contains(process)) { emit actionExecutionFinished(m_killingApplications.value(process), DeviceManager::DeviceErrorNoError); m_killingApplications.remove(process); @@ -314,7 +314,7 @@ void DevicePluginCommandLauncher::applicationFinished(int exitCode, QProcess::Ex QProcess *process = static_cast(sender()); Device *device = m_applications.value(process); - device->setStateValue(runningStateTypeId, false); + device->setStateValue(applicationRunningStateTypeId, false); m_applications.remove(process); process->deleteLater(); diff --git a/conrad/devicepluginconrad.cpp b/conrad/devicepluginconrad.cpp index f691ead1..18964992 100644 --- a/conrad/devicepluginconrad.cpp +++ b/conrad/devicepluginconrad.cpp @@ -77,11 +77,11 @@ DeviceManager::DeviceError DevicePluginConrad::executeAction(Device *device, con int repetitions = 10; - if (action.actionTypeId() == upActionTypeId) { + if (action.actionTypeId() == conradShutterUpActionTypeId) { binCode = "10101000"; - } else if (action.actionTypeId() == downActionTypeId) { + } else if (action.actionTypeId() == conradShutterDownActionTypeId) { binCode = "10100000"; - } else if (action.actionTypeId() == syncActionTypeId) { + } else if (action.actionTypeId() == conradShutterSyncActionTypeId) { binCode = "10100000"; repetitions = 20; } else { diff --git a/datetime/deviceplugindatetime.cpp b/datetime/deviceplugindatetime.cpp index 3e986b9c..ebadb979 100644 --- a/datetime/deviceplugindatetime.cpp +++ b/datetime/deviceplugindatetime.cpp @@ -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(mondayParamTypeId).toBool()); - alarm->setTuesday(device->paramValue(tuesdayParamTypeId).toBool()); - alarm->setWednesday(device->paramValue(wednesdayParamTypeId).toBool()); - alarm->setThursday(device->paramValue(thursdayParamTypeId).toBool()); - alarm->setFriday(device->paramValue(fridayParamTypeId).toBool()); - alarm->setSaturday(device->paramValue(saturdayParamTypeId).toBool()); - alarm->setSunday(device->paramValue(sundayParamTypeId).toBool()); - alarm->setMinutes(device->paramValue(minutesParamTypeId).toInt()); - alarm->setHours(device->paramValue(hoursParamTypeId).toInt()); - alarm->setTimeType(device->paramValue(timeTypeParamTypeId).toString()); - alarm->setOffset(device->paramValue(offsetParamTypeId).toInt()); + 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->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(hoursParamTypeId).toInt(), - device->paramValue(minutesParamTypeId).toInt(), - device->paramValue(secondsParamTypeId).toInt()), - device->paramValue(repeatingParamTypeId).toBool()); + QTime(device->paramValue(countdownHoursParamTypeId).toInt(), + device->paramValue(countdownMinutesParamTypeId).toInt(), + device->paramValue(countdownSecondsParamTypeId).toInt()), + device->paramValue(countdownRepeatingParamTypeId).toBool()); connect(countdown, &Countdown::countdownTimeout, this, &DevicePluginDateTime::onCountdownTimeout); connect(countdown, &Countdown::runningStateChanged, this, &DevicePluginDateTime::onCountdownRunningChanged); @@ -225,13 +225,13 @@ DeviceManager::DeviceError DevicePluginDateTime::executeAction(Device *device, c { if (device->deviceClassId() == countdownDeviceClassId) { Countdown *countdown = m_countdowns.value(device); - if (action.actionTypeId() == startActionTypeId) { + if (action.actionTypeId() == countdownStartActionTypeId) { countdown->start(); return DeviceManager::DeviceErrorNoError; - } else if (action.actionTypeId() == restartActionTypeId) { + } else if (action.actionTypeId() == countdownRestartActionTypeId) { countdown->restart(); return DeviceManager::DeviceErrorNoError; - } else if (action.actionTypeId() == stopActionTypeId) { + } else if (action.actionTypeId() == countdownStopActionTypeId) { countdown->stop(); return DeviceManager::DeviceErrorNoError; } @@ -286,9 +286,9 @@ void DevicePluginDateTime::processGeoLocationData(const QByteArray &data) // check timezone QString timeZone = response.value("timezone").toString(); - m_todayDevice->setStateValue(timeZoneStateTypeId, timeZone); - m_todayDevice->setStateValue(cityStateTypeId, response.value("city").toString()); - m_todayDevice->setStateValue(countryStateTypeId, response.value("country").toString()); + m_todayDevice->setStateValue(todayTimeZoneStateTypeId, timeZone); + m_todayDevice->setStateValue(todayCityStateTypeId, response.value("city").toString()); + m_todayDevice->setStateValue(todayCountryStateTypeId, response.value("country").toString()); qCDebug(dcDateTime) << "---------------------------------------------"; qCDebug(dcDateTime) << "autodetected location for" << response.value("query").toString(); @@ -392,7 +392,7 @@ void DevicePluginDateTime::onAlarm() Alarm *alarm = static_cast(sender()); Device *device = m_alarms.key(alarm); - emit emitEvent(Event(alarmEventTypeId, device->id())); + emit emitEvent(Event(alarmAlarmEventTypeId, device->id())); } void DevicePluginDateTime::onCountdownTimeout() @@ -400,7 +400,7 @@ void DevicePluginDateTime::onCountdownTimeout() Countdown *countdown = static_cast(sender()); Device *device = m_countdowns.key(countdown); - emit emitEvent(Event(timeoutEventTypeId, device->id())); + emit emitEvent(Event(countdownTimeoutEventTypeId, device->id())); } void DevicePluginDateTime::onCountdownRunningChanged(const bool &running) @@ -408,7 +408,7 @@ void DevicePluginDateTime::onCountdownRunningChanged(const bool &running) Countdown *countdown = static_cast(sender()); Device *device = m_countdowns.key(countdown); - device->setStateValue(runningStateTypeId, running); + device->setStateValue(countdownRunningStateTypeId, running); } void DevicePluginDateTime::onSecondChanged() @@ -457,16 +457,16 @@ void DevicePluginDateTime::onDayChanged(const QDateTime &dateTime) if (m_todayDevice == 0) return; - m_todayDevice->setStateValue(dayStateTypeId, dateTime.date().day()); - m_todayDevice->setStateValue(monthStateTypeId, dateTime.date().month()); - m_todayDevice->setStateValue(yearStateTypeId, dateTime.date().year()); - m_todayDevice->setStateValue(weekdayStateTypeId, dateTime.date().dayOfWeek()); - m_todayDevice->setStateValue(weekdayNameStateTypeId, dateTime.date().longDayName(dateTime.date().dayOfWeek())); - m_todayDevice->setStateValue(monthNameStateTypeId, dateTime.date().longMonthName(dateTime.date().month())); + m_todayDevice->setStateValue(todayDayStateTypeId, dateTime.date().day()); + m_todayDevice->setStateValue(todayMonthStateTypeId, dateTime.date().month()); + m_todayDevice->setStateValue(todayYearStateTypeId, dateTime.date().year()); + m_todayDevice->setStateValue(todayWeekdayStateTypeId, dateTime.date().dayOfWeek()); + m_todayDevice->setStateValue(todayWeekdayNameStateTypeId, dateTime.date().longDayName(dateTime.date().dayOfWeek())); + m_todayDevice->setStateValue(todayMonthNameStateTypeId, dateTime.date().longMonthName(dateTime.date().month())); if(dateTime.date().dayOfWeek() == 6 || dateTime.date().dayOfWeek() == 7){ - m_todayDevice->setStateValue(weekendStateTypeId, true); + m_todayDevice->setStateValue(todayWeekendStateTypeId, true); }else{ - m_todayDevice->setStateValue(weekendStateTypeId, false); + m_todayDevice->setStateValue(todayWeekendStateTypeId, false); } } @@ -486,29 +486,29 @@ void DevicePluginDateTime::updateTimes() return; if (m_dusk.isValid()) { - m_todayDevice->setStateValue(duskStateTypeId, m_dusk.toTime_t()); + m_todayDevice->setStateValue(todayDuskStateTypeId, m_dusk.toTime_t()); } else { - m_todayDevice->setStateValue(duskStateTypeId, 0); + m_todayDevice->setStateValue(todayDuskStateTypeId, 0); } if (m_dusk.isValid()) { - m_todayDevice->setStateValue(sunriseStateTypeId, m_sunrise.toTime_t()); + m_todayDevice->setStateValue(todaySunriseStateTypeId, m_sunrise.toTime_t()); } else { - m_todayDevice->setStateValue(sunriseStateTypeId, 0); + m_todayDevice->setStateValue(todaySunriseStateTypeId, 0); } if (m_dusk.isValid()) { - m_todayDevice->setStateValue(noonStateTypeId, m_noon.toTime_t()); + m_todayDevice->setStateValue(todayNoonStateTypeId, m_noon.toTime_t()); } else { - m_todayDevice->setStateValue(noonStateTypeId, 0); + m_todayDevice->setStateValue(todayNoonStateTypeId, 0); } if (m_dusk.isValid()) { - m_todayDevice->setStateValue(sunsetStateTypeId, m_sunset.toTime_t()); + m_todayDevice->setStateValue(todaySunsetStateTypeId, m_sunset.toTime_t()); } else { - m_todayDevice->setStateValue(sunsetStateTypeId, 0); + m_todayDevice->setStateValue(todaySunsetStateTypeId, 0); } if (m_dusk.isValid()) { - m_todayDevice->setStateValue(dawnStateTypeId, m_dawn.toTime_t()); + m_todayDevice->setStateValue(todayDawnStateTypeId, m_dawn.toTime_t()); } else { - m_todayDevice->setStateValue(dawnStateTypeId, 0); + m_todayDevice->setStateValue(todayDawnStateTypeId, 0); } } @@ -519,15 +519,15 @@ void DevicePluginDateTime::validateTimeTypes(const QDateTime &dateTime) return; if (dateTime == m_dusk) { - emit emitEvent(Event(duskEventTypeId, m_todayDevice->id())); + emit emitEvent(Event(todayDuskEventTypeId, m_todayDevice->id())); } else if (dateTime == m_sunrise) { - emit emitEvent(Event(sunriseEventTypeId, m_todayDevice->id())); + emit emitEvent(Event(todaySunriseEventTypeId, m_todayDevice->id())); } else if (dateTime == m_noon) { - emit emitEvent(Event(noonEventTypeId, m_todayDevice->id())); + emit emitEvent(Event(todayNoonEventTypeId, m_todayDevice->id())); } else if (dateTime == m_dawn) { - emit emitEvent(Event(dawnEventTypeId, m_todayDevice->id())); + emit emitEvent(Event(todayDawnEventTypeId, m_todayDevice->id())); } else if (dateTime == m_sunset) { - emit emitEvent(Event(sunsetEventTypeId, m_todayDevice->id())); + emit emitEvent(Event(todaySunsetEventTypeId, m_todayDevice->id())); } foreach (Alarm *alarm, m_alarms.values()) { diff --git a/denon/deviceplugindenon.cpp b/denon/deviceplugindenon.cpp index edb69d22..20227aeb 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(ipParamTypeId).toString(); + qCDebug(dcDenon) << "Setup Denon device" << device->paramValue(AVRX1000IpParamTypeId).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(ipParamTypeId).toString()); + QHostAddress address(device->paramValue(AVRX1000IpParamTypeId).toString()); if (address.isNull()) { - qCWarning(dcDenon) << "Could not parse ip address" << device->paramValue(ipParamTypeId).toString(); + qCWarning(dcDenon) << "Could not parse ip address" << device->paramValue(AVRX1000IpParamTypeId).toString(); return DeviceManager::DeviceSetupStatusFailure; } @@ -112,13 +112,13 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons return DeviceManager::DeviceErrorHardwareNotAvailable; // check if the requested action is our "update" action ... - if (action.actionTypeId() == powerActionTypeId) { + if (action.actionTypeId() == AVRX1000PowerActionTypeId) { // Print information that we are executing now the update action qCDebug(dcDenon) << "set power action" << action.id(); - qCDebug(dcDenon) << "power: " << action.param(powerStateParamTypeId).value().Bool; + qCDebug(dcDenon) << "power: " << action.param(AVRX1000PowerStateParamTypeId).value().Bool; - if (action.param(powerStateParamTypeId).value().toBool() == true){ + if (action.param(AVRX1000PowerStateParamTypeId).value().toBool() == true){ QByteArray cmd = "PWON\r"; qCDebug(dcDenon) << "Execute power: " << action.id() << cmd; m_denonConnection->sendData(cmd); @@ -130,9 +130,9 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons return DeviceManager::DeviceErrorNoError; - } else if (action.actionTypeId() == volumeActionTypeId) { + } else if (action.actionTypeId() == AVRX1000VolumeActionTypeId) { - QByteArray vol = action.param(volumeStateParamTypeId).value().toByteArray(); + QByteArray vol = action.param(AVRX1000VolumeStateParamTypeId).value().toByteArray(); QByteArray cmd = "MV" + vol + "\r"; qCDebug(dcDenon) << "Execute volume" << action.id() << cmd; @@ -140,10 +140,10 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons return DeviceManager::DeviceErrorNoError; - } else if (action.actionTypeId() == channelActionTypeId) { + } else if (action.actionTypeId() == AVRX1000ChannelActionTypeId) { qCDebug(dcDenon) << "Execute update action" << action.id(); - QByteArray channel = action.param(channelStateParamTypeId).value().toByteArray(); + QByteArray channel = action.param(AVRX1000ChannelStateParamTypeId).value().toByteArray(); QByteArray cmd = "SI" + channel + "\r"; qCDebug(dcDenon) << "Change to channel:" << cmd; @@ -184,7 +184,7 @@ void DevicePluginDenon::onConnectionChanged() } // Set connection status - m_device->setStateValue(connectedStateTypeId, m_denonConnection->connected()); + m_device->setStateValue(AVRX1000ConnectedStateTypeId, m_denonConnection->connected()); } void DevicePluginDenon::onDataReceived(const QByteArray &data) @@ -200,7 +200,7 @@ void DevicePluginDenon::onDataReceived(const QByteArray &data) int vol = data.mid(index+2, 2).toInt(); qCDebug(dcDenon) << "Update volume:" << vol; - m_device->setStateValue(volumeStateTypeId, vol); + m_device->setStateValue(AVRX1000VolumeStateTypeId, vol); } if (data.contains("SI")) { @@ -248,15 +248,15 @@ void DevicePluginDenon::onDataReceived(const QByteArray &data) } qCDebug(dcDenon) << "Update channel:" << cmd; - m_device->setStateValue(channelStateTypeId, cmd); + m_device->setStateValue(AVRX1000ChannelStateTypeId, cmd); } if (data.contains("PWON")) { qCDebug(dcDenon) << "Update power on"; - m_device->setStateValue(powerStateTypeId, true); + m_device->setStateValue(AVRX1000PowerStateTypeId, true); } else if (data.contains("PWSTANDBY")) { qCDebug(dcDenon) << "Update power off"; - m_device->setStateValue(powerStateTypeId, false); + m_device->setStateValue(AVRX1000PowerStateTypeId, false); } } diff --git a/elgato/aveabulb.cpp b/elgato/aveabulb.cpp index 06f203c9..e9fb0cf1 100644 --- a/elgato/aveabulb.cpp +++ b/elgato/aveabulb.cpp @@ -60,7 +60,7 @@ bool AveaBulb::setColor(const QColor &color) void AveaBulb::onConnectedChanged(const bool &connected) { qCDebug(dcElgato()) << "Bulb" << m_bluetoothDevice->name() << m_bluetoothDevice->address().toString() << (connected ? "connected" : "disconnected"); - m_device->setStateValue(connectedStateTypeId, connected); + m_device->setStateValue(aveaConnectedStateTypeId, connected); if (!connected) { // Clean up services diff --git a/elgato/devicepluginelgato.cpp b/elgato/devicepluginelgato.cpp index b21f3140..d21060ce 100644 --- a/elgato/devicepluginelgato.cpp +++ b/elgato/devicepluginelgato.cpp @@ -431,8 +431,8 @@ DeviceManager::DeviceSetupStatus DevicePluginElgato::setupDevice(Device *device) qCDebug(dcElgato()) << "Setup device" << device->name() << device->params(); if (device->deviceClassId() == aveaDeviceClassId) { - QBluetoothAddress address = QBluetoothAddress(device->paramValue(macAddressParamTypeId).toString()); - QString name = device->paramValue(nameParamTypeId).toString(); + QBluetoothAddress address = QBluetoothAddress(device->paramValue(aveaMacAddressParamTypeId).toString()); + QString name = device->paramValue(aveaNameParamTypeId).toString(); QBluetoothDeviceInfo deviceInfo = QBluetoothDeviceInfo(address, name, 0); BluetoothLowEnergyDevice *bluetoothDevice = hardwareManager()->bluetoothLowEnergyManager()->registerDevice(deviceInfo, QLowEnergyController::PublicAddress); @@ -469,7 +469,6 @@ DeviceManager::DeviceError DevicePluginElgato::executeAction(Device *device, con return DeviceManager::DeviceErrorDeviceClassNotFound; } - void DevicePluginElgato::deviceRemoved(Device *device) { if (!m_bulbs.keys().contains(device)) @@ -484,7 +483,7 @@ void DevicePluginElgato::deviceRemoved(Device *device) bool DevicePluginElgato::verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo) { foreach (Device *device, myDevices()) { - if (device->paramValue(macAddressParamTypeId).toString() == deviceInfo.address().toString()) + if (device->paramValue(aveaMacAddressParamTypeId).toString() == deviceInfo.address().toString()) return true; } @@ -507,8 +506,8 @@ void DevicePluginElgato::onBluetoothDiscoveryFinished() if (!verifyExistingDevices(deviceInfo)) { DeviceDescriptor descriptor(aveaDeviceClassId, "Avea", deviceInfo.address().toString()); ParamList params; - params.append(Param(nameParamTypeId, deviceInfo.name())); - params.append(Param(macAddressParamTypeId, deviceInfo.address().toString())); + params.append(Param(aveaNameParamTypeId, deviceInfo.name())); + params.append(Param(aveaMacAddressParamTypeId, deviceInfo.address().toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } diff --git a/elro/devicepluginelro.cpp b/elro/devicepluginelro.cpp index 79064a65..8c4792cb 100644 --- a/elro/devicepluginelro.cpp +++ b/elro/devicepluginelro.cpp @@ -58,7 +58,7 @@ DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const if (!hardwareManager()->radio433()->available()) return DeviceManager::DeviceErrorHardwareNotAvailable; - if (action.actionTypeId() != powerActionTypeId) + if (action.actionTypeId() != elroSocketPowerActionTypeId) return DeviceManager::DeviceErrorActionTypeNotFound; QList rawData; @@ -66,61 +66,61 @@ DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const // create the bincode // channels - if (device->paramValue(chan1ParamTypeId).toBool()) { + if (device->paramValue(elroSocketChan1ParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(chan2ParamTypeId).toBool()) { + if (device->paramValue(elroSocketChan2ParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(chan3ParamTypeId).toBool()) { + if (device->paramValue(elroSocketChan3ParamTypeId).toBool()) { binCode.append("00"); }else{ binCode.append("01"); } - if(device->paramValue(chan4ParamTypeId).toBool()){ + if(device->paramValue(elroSocketChan4ParamTypeId).toBool()){ binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(chan5ParamTypeId).toBool()) { + if (device->paramValue(elroSocketChan5ParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } // Buttons - if (device->paramValue(aParamTypeId).toBool()) { + if (device->paramValue(elroSocketAParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(bParamTypeId).toBool()) { + if (device->paramValue(elroSocketBParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(cParamTypeId).toBool()) { + if (device->paramValue(elroSocketCParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(dParamTypeId).toBool()) { + if (device->paramValue(elroSocketDParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } - if (device->paramValue(eParamTypeId).toBool()) { + if (device->paramValue(elroSocketEParamTypeId).toBool()) { binCode.append("00"); } else { binCode.append("01"); } // Power - if (action.param(powerParamTypeId).value().toBool()) { + if (action.param(elroSocketPowerParamTypeId).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(powerParamTypeId).value().toBool(); + qCDebug(dcElro) << "Transmitted" << pluginName() << device->name() << "power: " << action.param(elroSocketPowerParamTypeId).value().toBool(); } else { - qCWarning(dcElro) << "Could not transmitt" << pluginName() << device->name() << "power: " << action.param(powerParamTypeId).value().toBool(); + qCWarning(dcElro) << "Could not transmitt" << pluginName() << device->name() << "power: " << action.param(elroSocketPowerParamTypeId).value().toBool(); return DeviceManager::DeviceErrorHardwareNotAvailable; } diff --git a/eq-3/deviceplugineq-3.cpp b/eq-3/deviceplugineq-3.cpp index 467bb111..0b9fb1c2 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(serialParamTypeId).toString()){ + if(cube->serialNumber() == device->paramValue(cubeSerialParamTypeId).toString()){ qCDebug(dcEQ3) << cube->serialNumber() << " already exists..."; return DeviceManager::DeviceSetupStatusFailure; } } - MaxCube *cube = new MaxCube(this,device->paramValue(serialParamTypeId).toString(),QHostAddress(device->paramValue(hostParamTypeId).toString()),device->paramValue(portParamTypeId).toInt()); + MaxCube *cube = new MaxCube(this,device->paramValue(cubeSerialParamTypeId).toString(),QHostAddress(device->paramValue(cubeHostParamTypeId).toString()),device->paramValue(cubePortParamTypeId).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(serialParamTypeId).toString() + ")"); + device->setName("Max! Wall Thermostat (" + device->paramValue(wallThermostateSerialParamTypeId).toString() + ")"); } return DeviceManager::DeviceSetupStatusSuccess; @@ -154,23 +154,42 @@ void DevicePluginEQ3::deviceRemoved(Device *device) DeviceManager::DeviceError DevicePluginEQ3::executeAction(Device *device, const Action &action) { - if(device->deviceClassId() == wallThermostateDeviceClassId || device->deviceClassId() == radiatorThermostateDeviceClassId){ + if(device->deviceClassId() == wallThermostateDeviceClassId){ foreach (MaxCube *cube, m_cubes.keys()){ - if(cube->serialNumber() == device->paramValue(parentParamTypeId).toString()){ + if(cube->serialNumber() == device->paramValue(wallThermostateParentParamTypeId).toString()){ - QByteArray rfAddress = device->paramValue(rfParamTypeId).toByteArray(); - int roomId = device->paramValue(roomParamTypeId).toInt(); + QByteArray rfAddress = device->paramValue(wallThermostateRfParamTypeId).toByteArray(); + int roomId = device->paramValue(wallThermostateRoomParamTypeId).toInt(); - if (action.actionTypeId() == desiredTemperatureActionTypeId){ - cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(desiredTemperatureStateParamTypeId).value().toDouble(), action.id()); - } else if (action.actionTypeId() == setAutoModeActionTypeId){ + if (action.actionTypeId() == wallThermostateDesiredTemperatureActionTypeId){ + cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(wallThermostateDesiredTemperatureStateParamTypeId).value().toDouble(), action.id()); + } else if (action.actionTypeId() == wallThermostateSetAutoModeActionTypeId){ cube->setDeviceAutoMode(rfAddress, roomId, action.id()); - } else if (action.actionTypeId() == setManualModeActionTypeId){ + } else if (action.actionTypeId() == wallThermostateSetManualModeActionTypeId){ cube->setDeviceManuelMode(rfAddress, roomId, action.id()); - } else if (action.actionTypeId() == setEcoModeActionTypeId){ + } 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()); + } + return DeviceManager::DeviceErrorAsync; + } + } + } else if (device->deviceClassId() == radiatorThermostateDeviceClassId){ + foreach (MaxCube *cube, m_cubes.keys()){ + if(cube->serialNumber() == device->paramValue(radiatorThermostateParentParamTypeId).toString()){ + + QByteArray rfAddress = device->paramValue(radiatorThermostateRfParamTypeId).toByteArray(); + int roomId = device->paramValue(radiatorThermostateRoomParamTypeId).toInt(); + + if (action.actionTypeId() == radiatorThermostateDesiredTemperatureActionTypeId){ + cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(radiatorThermostateDesiredTemperatureStateParamTypeId).value().toDouble(), action.id()); + } else if (action.actionTypeId() == radiatorThermostateSetAutoModeActionTypeId){ + cube->setDeviceAutoMode(rfAddress, roomId, action.id()); + } else if (action.actionTypeId() == radiatorThermostateSetManualModeActionTypeId){ + cube->setDeviceManuelMode(rfAddress, roomId, action.id()); + } else if (action.actionTypeId() == radiatorThermostateSetEcoModeActionTypeId){ cube->setDeviceEcoMode(rfAddress, roomId, action.id()); - } else if (action.actionTypeId() == displayCurrentTempActionTypeId){ - cube->displayCurrentTemperature(rfAddress, roomId, action.param(displayParamTypeId).value().toBool(), action.id()); } return DeviceManager::DeviceErrorAsync; } @@ -197,7 +216,7 @@ void DevicePluginEQ3::cubeConnectionStatusChanged(const bool &connected) if (m_cubes.contains(cube)) { device = m_cubes.value(cube); device->setName("Max! Cube " + cube->serialNumber()); - device->setStateValue(connectionStateTypeId,true); + device->setStateValue(cubeConnectionStateTypeId,true); emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess); } }else{ @@ -205,7 +224,7 @@ void DevicePluginEQ3::cubeConnectionStatusChanged(const bool &connected) Device *device; if (m_cubes.contains(cube)){ device = m_cubes.value(cube); - device->setStateValue(connectionStateTypeId,false); + device->setStateValue(cubeConnectionStateTypeId,false); emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusFailure); } } @@ -217,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(hostParamTypeId, cube->hostAddress().toString()); + Param hostParam(cubeHostParamTypeId, cube->hostAddress().toString()); params.append(hostParam); - Param portParam(portParamTypeId, cube->port()); + Param portParam(cubePortParamTypeId, cube->port()); params.append(portParam); - Param firmwareParam(firmwareParamTypeId, cube->firmware()); + Param firmwareParam(cubeFirmwareParamTypeId, cube->firmware()); params.append(firmwareParam); - Param serialNumberParam(serialParamTypeId, cube->serialNumber()); + Param serialNumberParam(cubeSerialParamTypeId, cube->serialNumber()); params.append(serialNumberParam); descriptor.setParams(params); @@ -250,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(serialParamTypeId).toString()){ + if(wallThermostat->serialNumber() == device->paramValue(wallThermostateSerialParamTypeId).toString()){ allreadyAdded = true; break; } @@ -258,12 +277,12 @@ void DevicePluginEQ3::wallThermostatFound() if(!allreadyAdded){ DeviceDescriptor descriptor(wallThermostateDeviceClassId, wallThermostat->serialNumber()); ParamList params; - params.append(Param(nameParamTypeId, wallThermostat->deviceName())); - params.append(Param(parentParamTypeId, cube->serialNumber())); - params.append(Param(serialParamTypeId, wallThermostat->serialNumber())); - params.append(Param(rfParamTypeId, wallThermostat->rfAddress())); - params.append(Param(roomParamTypeId, wallThermostat->roomId())); - params.append(Param(roomNameParamTypeId, wallThermostat->roomName())); + 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())); descriptor.setParams(params); descriptorList.append(descriptor); } @@ -284,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(serialParamTypeId).toString()){ + if(radiatorThermostat->serialNumber() == device->paramValue(radiatorThermostateSerialParamTypeId).toString()){ allreadyAdded = true; break; } @@ -292,12 +311,12 @@ void DevicePluginEQ3::radiatorThermostatFound() if(!allreadyAdded){ DeviceDescriptor descriptor(radiatorThermostateDeviceClassId, radiatorThermostat->serialNumber()); ParamList params; - params.append(Param(nameParamTypeId, radiatorThermostat->deviceName())); - params.append(Param(parentParamTypeId, cube->serialNumber())); - params.append(Param(serialParamTypeId, radiatorThermostat->serialNumber())); - params.append(Param(rfParamTypeId, radiatorThermostat->rfAddress())); - params.append(Param(roomParamTypeId, radiatorThermostat->roomId())); - params.append(Param(roomNameParamTypeId, radiatorThermostat->roomName())); + 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())); descriptor.setParams(params); descriptorList.append(descriptor); } @@ -314,7 +333,7 @@ void DevicePluginEQ3::updateCubeConfig() Device *device; if (m_cubes.contains(cube)) { device = m_cubes.value(cube); - device->setStateValue(portalEnabledStateTypeId,cube->portalEnabeld()); + device->setStateValue(cubePortalEnabledStateTypeId,cube->portalEnabeld()); return; } } @@ -325,22 +344,22 @@ void DevicePluginEQ3::wallThermostatDataUpdated() foreach (WallThermostat *wallThermostat, cube->wallThermostatList()) { foreach (Device *device, deviceManager()->findConfiguredDevices(wallThermostateDeviceClassId)){ - if(device->paramValue(serialParamTypeId).toString() == wallThermostat->serialNumber()){ - device->setStateValue(comfortTempStateTypeId, wallThermostat->comfortTemp()); - device->setStateValue(ecoTempStateTypeId, wallThermostat->ecoTemp()); - device->setStateValue(maxSetpointTempStateTypeId, wallThermostat->maxSetPointTemp()); - device->setStateValue(minSetpointTempStateTypeId, wallThermostat->minSetPointTemp()); - device->setStateValue(errorOccurredStateTypeId, wallThermostat->errorOccured()); - device->setStateValue(initializedStateTypeId, wallThermostat->initialized()); - device->setStateValue(batteryLowStateTypeId, wallThermostat->batteryLow()); - device->setStateValue(linkStatusOKStateTypeId, wallThermostat->linkStatusOK()); - device->setStateValue(panelLockedStateTypeId, wallThermostat->panelLocked()); - device->setStateValue(gatewayKnownStateTypeId, wallThermostat->gatewayKnown()); - device->setStateValue(dtsActiveStateTypeId, wallThermostat->dtsActive()); - device->setStateValue(deviceModeStateTypeId, wallThermostat->deviceMode()); - device->setStateValue(deviceModeStringStateTypeId, wallThermostat->deviceModeString()); - device->setStateValue(desiredTemperatureStateTypeId, wallThermostat->setpointTemperature()); - device->setStateValue(currentTemperatureStateTypeId, wallThermostat->currentTemperature()); + if(device->paramValue(wallThermostateSerialParamTypeId).toString() == wallThermostat->serialNumber()){ + device->setStateValue(wallThermostateComfortTempStateTypeId, wallThermostat->comfortTemp()); + device->setStateValue(wallThermostateEcoTempStateTypeId, wallThermostat->ecoTemp()); + device->setStateValue(wallThermostateMaxSetpointTempStateTypeId, wallThermostat->maxSetPointTemp()); + device->setStateValue(wallThermostateMinSetpointTempStateTypeId, wallThermostat->minSetPointTemp()); + device->setStateValue(wallThermostateErrorOccurredStateTypeId, wallThermostat->errorOccured()); + device->setStateValue(wallThermostateInitializedStateTypeId, wallThermostat->initialized()); + device->setStateValue(wallThermostateBatteryLowStateTypeId, wallThermostat->batteryLow()); + device->setStateValue(wallThermostateLinkStatusOKStateTypeId, wallThermostat->linkStatusOK()); + device->setStateValue(wallThermostatePanelLockedStateTypeId, wallThermostat->panelLocked()); + device->setStateValue(wallThermostateGatewayKnownStateTypeId, wallThermostat->gatewayKnown()); + device->setStateValue(wallThermostateDtsActiveStateTypeId, wallThermostat->dtsActive()); + device->setStateValue(wallThermostateDeviceModeStateTypeId, wallThermostat->deviceMode()); + device->setStateValue(wallThermostateDeviceModeStringStateTypeId, wallThermostat->deviceModeString()); + device->setStateValue(wallThermostateDesiredTemperatureStateTypeId, wallThermostat->setpointTemperature()); + device->setStateValue(wallThermostateCurrentTemperatureStateTypeId, wallThermostat->currentTemperature()); } } } @@ -352,30 +371,28 @@ void DevicePluginEQ3::radiatorThermostatDataUpdated() foreach (RadiatorThermostat *radiatorThermostat, cube->radiatorThermostatList()) { foreach (Device *device, deviceManager()->findConfiguredDevices(radiatorThermostateDeviceClassId)){ - if(device->paramValue(serialParamTypeId).toString() == radiatorThermostat->serialNumber()){ - device->setStateValue(comfortTempStateTypeId, radiatorThermostat->comfortTemp()); - device->setStateValue(ecoTempStateTypeId, radiatorThermostat->ecoTemp()); - device->setStateValue(maxSetpointTempStateTypeId, radiatorThermostat->maxSetPointTemp()); - device->setStateValue(minSetpointTempStateTypeId, radiatorThermostat->minSetPointTemp()); - device->setStateValue(errorOccurredStateTypeId, radiatorThermostat->errorOccured()); - device->setStateValue(initializedStateTypeId, radiatorThermostat->initialized()); - device->setStateValue(batteryLowStateTypeId, radiatorThermostat->batteryLow()); - device->setStateValue(linkStatusOKStateTypeId, radiatorThermostat->linkStatusOK()); - device->setStateValue(panelLockedStateTypeId, radiatorThermostat->panelLocked()); - device->setStateValue(gatewayKnownStateTypeId, radiatorThermostat->gatewayKnown()); - device->setStateValue(dtsActiveStateTypeId, radiatorThermostat->dtsActive()); - device->setStateValue(deviceModeStateTypeId, radiatorThermostat->deviceMode()); - device->setStateValue(deviceModeStringStateTypeId, radiatorThermostat->deviceModeString()); - device->setStateValue(desiredTemperatureStateTypeId, radiatorThermostat->setpointTemperature()); - device->setStateValue(offsetTempStateTypeId, radiatorThermostat->offsetTemp()); - device->setStateValue(windowOpenDurationStateTypeId, radiatorThermostat->windowOpenDuration()); - device->setStateValue(boostValveValueStateTypeId, radiatorThermostat->boostValveValue()); - device->setStateValue(boostDurationStateTypeId, radiatorThermostat->boostDuration()); - device->setStateValue(discalcWeekDayStateTypeId, radiatorThermostat->discalcingWeekDay()); - device->setStateValue(discalcTimeStateTypeId, radiatorThermostat->discalcingTime().toString("HH:mm")); - device->setStateValue(valveMaximumSettingsStateTypeId, radiatorThermostat->valveMaximumSettings()); - device->setStateValue(valveOffsetStateTypeId, radiatorThermostat->valveOffset()); - device->setStateValue(valvePositionStateTypeId, radiatorThermostat->valvePosition()); + if(device->paramValue(radiatorThermostateSerialParamTypeId).toString() == radiatorThermostat->serialNumber()){ + device->setStateValue(radiatorThermostateComfortTempStateTypeId, radiatorThermostat->comfortTemp()); + device->setStateValue(radiatorThermostateMaxSetpointTempStateTypeId, radiatorThermostat->maxSetPointTemp()); + device->setStateValue(radiatorThermostateMinSetpointTempStateTypeId, radiatorThermostat->minSetPointTemp()); + device->setStateValue(radiatorThermostateErrorOccurredStateTypeId, radiatorThermostat->errorOccured()); + device->setStateValue(radiatorThermostateInitializedStateTypeId, radiatorThermostat->initialized()); + device->setStateValue(radiatorThermostateBatteryLowStateTypeId, radiatorThermostat->batteryLow()); + device->setStateValue(radiatorThermostatePanelLockedStateTypeId, radiatorThermostat->panelLocked()); + device->setStateValue(radiatorThermostateGatewayKnownStateTypeId, radiatorThermostat->gatewayKnown()); + device->setStateValue(radiatorThermostateDtsActiveStateTypeId, radiatorThermostat->dtsActive()); + device->setStateValue(radiatorThermostateDeviceModeStateTypeId, radiatorThermostat->deviceMode()); + device->setStateValue(radiatorThermostateDeviceModeStringStateTypeId, radiatorThermostat->deviceModeString()); + device->setStateValue(radiatorThermostateDesiredTemperatureStateTypeId, radiatorThermostat->setpointTemperature()); + device->setStateValue(radiatorThermostateOffsetTempStateTypeId, radiatorThermostat->offsetTemp()); + device->setStateValue(radiatorThermostateWindowOpenDurationStateTypeId, radiatorThermostat->windowOpenDuration()); + device->setStateValue(radiatorThermostateBoostValveValueStateTypeId, radiatorThermostat->boostValveValue()); + device->setStateValue(radiatorThermostateBoostDurationStateTypeId, radiatorThermostat->boostDuration()); + device->setStateValue(radiatorThermostateDiscalcWeekDayStateTypeId, radiatorThermostat->discalcingWeekDay()); + device->setStateValue(radiatorThermostateDiscalcTimeStateTypeId, radiatorThermostat->discalcingTime().toString("HH:mm")); + device->setStateValue(radiatorThermostateValveMaximumSettingsStateTypeId, radiatorThermostat->valveMaximumSettings()); + device->setStateValue(radiatorThermostateValveOffsetStateTypeId, radiatorThermostat->valveOffset()); + device->setStateValue(radiatorThermostateValvePositionStateTypeId, radiatorThermostat->valvePosition()); } } } diff --git a/genericelements/deviceplugingenericelements.cpp b/genericelements/deviceplugingenericelements.cpp index 7357a37e..4a0feaf6 100644 --- a/genericelements/deviceplugingenericelements.cpp +++ b/genericelements/deviceplugingenericelements.cpp @@ -83,16 +83,16 @@ DeviceManager::DeviceError DevicePluginGenericElements::executeAction(Device *de { // Toggle Button if (device->deviceClassId() == toggleButtonDeviceClassId ) { - if (action.actionTypeId() == stateActionTypeId) { - device->setStateValue(stateStateTypeId, !device->stateValue(stateStateTypeId).toBool()); + if (action.actionTypeId() == toggleButtonStateActionTypeId) { + device->setStateValue(toggleButtonStateStateTypeId, !device->stateValue(toggleButtonStateStateTypeId).toBool()); return DeviceManager::DeviceErrorNoError; } return DeviceManager::DeviceErrorActionTypeNotFound; } // Button if (device->deviceClassId() == buttonDeviceClassId ) { - if (action.actionTypeId() == buttonPressActionTypeId) { - emit emitEvent(Event(buttonPressedEventTypeId, device->id())); + if (action.actionTypeId() == buttonButtonPressActionTypeId) { + emit emitEvent(Event(buttonButtonPressedEventTypeId, device->id())); return DeviceManager::DeviceErrorNoError; } return DeviceManager::DeviceErrorActionTypeNotFound; diff --git a/genericelements/deviceplugingenericelements.json b/genericelements/deviceplugingenericelements.json index b9e10870..9d638484 100644 --- a/genericelements/deviceplugingenericelements.json +++ b/genericelements/deviceplugingenericelements.json @@ -74,24 +74,24 @@ "actionTypes": [ { "id": "892596d2-0863-4807-97da-469b9f7003f2", - "name": "onOffButtonOn", + "name": "on", "displayName": "press ON" }, { "id": "a8d64050-0b58-4ccf-b052-77ce2b7368ad", - "name": "onOffButtonOff", + "name": "off", "displayName": "press OFF" } ], "eventTypes": [ { "id": "4eeba6a2-e4c7-4a2e-8360-2797d98114e6", - "name": "onOffButtonOn", + "name": "on", "displayName": "ON pressed" }, { "id": "b636c5f3-2eb0-4682-96d4-88a4aa9d2c12", - "name": "onOffButtonOff", + "name": "off", "displayName": "OFF pressed" } ] diff --git a/gpio/deviceplugingpio.cpp b/gpio/deviceplugingpio.cpp index beb471cd..c5760678 100644 --- a/gpio/deviceplugingpio.cpp +++ b/gpio/deviceplugingpio.cpp @@ -70,7 +70,14 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device) // GPIO Switch if (device->deviceClassId() == gpioSwitchRpiDeviceClassId || device->deviceClassId() == gpioSwitchBbbDeviceClassId) { // Create and configure gpio - Gpio *gpio = new Gpio(device->paramValue(gpioParamTypeId).toInt(), this); + int gpioId = -1; + if (device->deviceClassId() == gpioSwitchRpiDeviceClassId) + gpioId = device->paramValue(gpioSwitchRpiGpioParamTypeId).toInt(); + + if (device->deviceClassId() == gpioSwitchBbbDeviceClassId) + gpioId = device->paramValue(gpioSwitchBbbGpioParamTypeId).toInt(); + + Gpio *gpio = new Gpio(gpioId, this); if (!gpio->exportGpio()) { qCWarning(dcGpioController()) << "Could not export gpio for device" << device->name(); @@ -99,7 +106,15 @@ DeviceManager::DeviceSetupStatus DevicePluginGpio::setupDevice(Device *device) } if (device->deviceClassId() == gpioButtonRpiDeviceClassId || device->deviceClassId() == gpioButtonBbbDeviceClassId) { - GpioMonitor *monior = new GpioMonitor(device->paramValue(gpioParamTypeId).toInt(), this); + + int gpioId = -1; + if (device->deviceClassId() == gpioButtonRpiDeviceClassId) + gpioId = device->paramValue(gpioButtonRpiGpioParamTypeId).toInt(); + + if (device->deviceClassId() == gpioButtonBbbDeviceClassId) + gpioId = device->paramValue(gpioButtonBbbGpioParamTypeId).toInt(); + + GpioMonitor *monior = new GpioMonitor(gpioId, this); if (!monior->enable()) { qCWarning(dcGpioController()) << "Could not enable gpio monitor for device" << device->name(); @@ -159,9 +174,15 @@ DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId DeviceDescriptor descriptor(deviceClassId, QString("GPIO %1").arg(gpioDescriptor.gpio()), description); ParamList parameters; - parameters.append(Param(gpioParamTypeId, gpioDescriptor.gpio())); - parameters.append(Param(pinParamTypeId, gpioDescriptor.pin())); - parameters.append(Param(descriptionParamTypeId, gpioDescriptor.description())); + if (deviceClass.id() == gpioSwitchRpiDeviceClassId) { + parameters.append(Param(gpioSwitchRpiGpioParamTypeId, gpioDescriptor.gpio())); + parameters.append(Param(gpioSwitchRpiPinParamTypeId, gpioDescriptor.pin())); + parameters.append(Param(gpioSwitchRpiDescriptionParamTypeId, gpioDescriptor.description())); + } else if (deviceClass.id() == gpioButtonRpiDeviceClassId) { + parameters.append(Param(gpioButtonRpiGpioParamTypeId, gpioDescriptor.gpio())); + parameters.append(Param(gpioButtonRpiPinParamTypeId, gpioDescriptor.pin())); + parameters.append(Param(gpioButtonRpiDescriptionParamTypeId, gpioDescriptor.description())); + } descriptor.setParams(parameters); deviceDescriptors.append(descriptor); @@ -196,9 +217,15 @@ DeviceManager::DeviceError DevicePluginGpio::discoverDevices(const DeviceClassId DeviceDescriptor descriptor(deviceClassId, QString("GPIO %1").arg(gpioDescriptor.gpio()), description); ParamList parameters; - parameters.append(Param(gpioParamTypeId, gpioDescriptor.gpio())); - parameters.append(Param(pinParamTypeId, gpioDescriptor.pin())); - parameters.append(Param(descriptionParamTypeId, gpioDescriptor.description())); + if (deviceClass.id() == gpioSwitchBbbDeviceClassId) { + parameters.append(Param(gpioSwitchBbbGpioParamTypeId, gpioDescriptor.gpio())); + parameters.append(Param(gpioSwitchBbbPinParamTypeId, gpioDescriptor.pin())); + parameters.append(Param(gpioSwitchBbbDescriptionParamTypeId, gpioDescriptor.description())); + } else if (deviceClass.id() == gpioButtonBbbDeviceClassId) { + parameters.append(Param(gpioButtonBbbGpioParamTypeId, gpioDescriptor.gpio())); + parameters.append(Param(gpioButtonBbbPinParamTypeId, gpioDescriptor.pin())); + parameters.append(Param(gpioButtonBbbDescriptionParamTypeId, gpioDescriptor.description())); + } descriptor.setParams(parameters); deviceDescriptors.append(descriptor); @@ -255,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(gpioParamTypeId).toInt()); + gpio = m_raspberryPiGpios.value(device->paramValue(gpioSwitchRpiGpioParamTypeId).toInt()); if (deviceClass.vendorId() == beagleboneBlackVendorId) - gpio = m_beagleboneBlackGpios.value(device->paramValue(gpioParamTypeId).toInt()); + gpio = m_beagleboneBlackGpios.value(device->paramValue(gpioSwitchBbbGpioParamTypeId).toInt()); // Check if gpio was found if (!gpio) { @@ -267,23 +294,44 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const } // GPIO Switch power action - if (action.actionTypeId() == powerValueActionTypeId) { - bool success = false; - if (action.param(powerValueStateParamTypeId).value().toBool()) { - success = gpio->setValue(Gpio::ValueHigh); - } else { - success = gpio->setValue(Gpio::ValueLow); + if (deviceClass.vendorId() == raspberryPiVendorId) { + if (action.actionTypeId() == gpioSwitchRpiPowerValueActionTypeId) { + bool success = false; + if (action.param(gpioSwitchRpiPowerValueStateParamTypeId).value().toBool()) { + success = gpio->setValue(Gpio::ValueHigh); + } else { + success = gpio->setValue(Gpio::ValueLow); + } + + if (!success) { + qCWarning(dcGpioController()) << "Could not set gpio value while execute action on" << device->name(); + return DeviceManager::DeviceErrorHardwareFailure; + } + + // Set the current state + device->setStateValue(gpioSwitchRpiPowerValueStateTypeId, action.param(gpioSwitchRpiPowerValueStateParamTypeId).value()); + + return DeviceManager::DeviceErrorNoError; } + } else if (deviceClass.vendorId() == beagleboneBlackVendorId) { + if (action.actionTypeId() == gpioSwitchBbbPowerValueActionTypeId) { + bool success = false; + if (action.param(gpioSwitchBbbPowerValueStateParamTypeId).value().toBool()) { + success = gpio->setValue(Gpio::ValueHigh); + } else { + success = gpio->setValue(Gpio::ValueLow); + } - if (!success) { - qCWarning(dcGpioController()) << "Could not set gpio value while execute action on" << device->name(); - return DeviceManager::DeviceErrorHardwareFailure; + if (!success) { + qCWarning(dcGpioController()) << "Could not set gpio value while execute action on" << device->name(); + return DeviceManager::DeviceErrorHardwareFailure; + } + + // Set the current state + device->setStateValue(gpioSwitchBbbPowerValueStateTypeId, action.param(gpioSwitchBbbPowerValueStateParamTypeId).value()); + + return DeviceManager::DeviceErrorNoError; } - - // Set the current state - device->setStateValue(powerValueStateTypeId, action.param(powerValueStateParamTypeId).value()); - - return DeviceManager::DeviceErrorNoError; } return DeviceManager::DeviceErrorNoError; @@ -297,7 +345,12 @@ void DevicePluginGpio::postSetupDevice(Device *device) return; gpio->setValue(Gpio::ValueLow); - device->setStateValue(powerValueStateTypeId, false); + if (device->deviceClassId() == gpioSwitchRpiDeviceClassId) { + device->setStateValue(gpioSwitchRpiPowerValueStateTypeId, false); + } + if (device->deviceClassId() == gpioSwitchBbbDeviceClassId) { + device->setStateValue(gpioSwitchBbbPowerValueStateTypeId, false); + } } if (device->deviceClassId() == gpioButtonRpiDeviceClassId || device->deviceClassId() == gpioButtonBbbDeviceClassId) { @@ -305,7 +358,11 @@ void DevicePluginGpio::postSetupDevice(Device *device) if (!monitor) return; - device->setStateValue(pressedStateTypeId, monitor->value()); + if (device->deviceClassId() == gpioButtonRpiDeviceClassId) { + device->setStateValue(gpioButtonRpiPressedStateTypeId, monitor->value()); + } else if (device->deviceClassId() == gpioButtonBbbDeviceClassId) { + device->setStateValue(gpioButtonBbbPressedStateTypeId, monitor->value()); + } } } @@ -424,6 +481,10 @@ void DevicePluginGpio::onGpioValueChanged(const bool &value) if (!device) return; - device->setStateValue(pressedStateTypeId, value); + if (device->deviceClassId() == gpioButtonRpiDeviceClassId) { + device->setStateValue(gpioButtonRpiPressedStateTypeId, value); + } else if (device->deviceClassId() == gpioButtonBbbDeviceClassId) { + device->setStateValue(gpioButtonBbbPressedStateTypeId, value); + } } diff --git a/intertechno/devicepluginintertechno.cpp b/intertechno/devicepluginintertechno.cpp index 7244a9a3..74fce34c 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(familyCodeParamTypeId).toString(); + QString familyCode = device->paramValue(switchFamilyCodeParamTypeId).toString(); // ======================================= // generate bin from family code @@ -102,7 +102,7 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device binCode.append("01010101"); } - QString buttonCode = device->paramValue(buttonCodeParamTypeId).toString(); + QString buttonCode = device->paramValue(switchButtonCodeParamTypeId).toString(); // ======================================= // generate bin from button code @@ -150,7 +150,7 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device // ======================================= // add power nibble - if (action.param(powerParamTypeId).value().toBool()) { + if (action.param(switchPowerParamTypeId).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(powerParamTypeId).value().toBool(); + qCDebug(dcIntertechno) << "transmitted" << pluginName() << device->name() << "power: " << action.param(switchPowerParamTypeId).value().toBool(); } else { - qCWarning(dcIntertechno) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(powerParamTypeId).value().toBool(); + qCWarning(dcIntertechno) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(switchPowerParamTypeId).value().toBool(); return DeviceManager::DeviceErrorHardwareNotAvailable; } return DeviceManager::DeviceErrorNoError; diff --git a/intertechno/devicepluginintertechno.json b/intertechno/devicepluginintertechno.json index cd8336cd..7241c5a4 100644 --- a/intertechno/devicepluginintertechno.json +++ b/intertechno/devicepluginintertechno.json @@ -23,7 +23,7 @@ { "id": "c4e2ec44-5e8e-4168-9f6d-a905ea3329c9", "name": "familyCode", - "displyName": "family code", + "displayName": "family code", "type": "QString", "allowedValues": ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P"] }, diff --git a/kodi/devicepluginkodi.cpp b/kodi/devicepluginkodi.cpp index 5583359d..299d67c6 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(ipParamTypeId).toString(); - Kodi *kodi= new Kodi(QHostAddress(device->paramValue(ipParamTypeId).toString()), 9090, this); + qCDebug(dcKodi) << "Setup Kodi device" << device->paramValue(kodiIpParamTypeId).toString(); + Kodi *kodi= new Kodi(QHostAddress(device->paramValue(kodiIpParamTypeId).toString()), 9090, this); connect(kodi, &Kodi::connectionStatusChanged, this, &DevicePluginKodi::onConnectionChanged); connect(kodi, &Kodi::stateChanged, this, &DevicePluginKodi::onStateChanged); @@ -146,26 +146,26 @@ DeviceManager::DeviceError DevicePluginKodi::executeAction(Device *device, const return DeviceManager::DeviceErrorHardwareNotAvailable; } - if (action.actionTypeId() == showNotificationActionTypeId) { - kodi->showNotification(action.param(messageParamTypeId).value().toString(), 8000, action.param(typeParamTypeId).value().toString(), action.id()); + if (action.actionTypeId() == kodiShowNotificationActionTypeId) { + kodi->showNotification(action.param(kodiMessageParamTypeId).value().toString(), 8000, action.param(kodiTypeParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == volumeActionTypeId) { - kodi->setVolume(action.param(volumeStateParamTypeId).value().toInt(), action.id()); + } else if (action.actionTypeId() == kodiVolumeActionTypeId) { + kodi->setVolume(action.param(kodiVolumeStateParamTypeId).value().toInt(), action.id()); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == muteActionTypeId) { - kodi->setMuted(action.param(muteStateParamTypeId).value().toBool(), action.id()); + } else if (action.actionTypeId() == kodiMuteActionTypeId) { + kodi->setMuted(action.param(kodiMuteStateParamTypeId).value().toBool(), action.id()); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == pressButtonActionTypeId) { - kodi->pressButton(action.param(buttonParamTypeId).value().toString(), action.id()); + } else if (action.actionTypeId() == kodiPressButtonActionTypeId) { + kodi->pressButton(action.param(kodiButtonParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == systemActionTypeId) { - kodi->systemCommand(action.param(systemCommandParamTypeId).value().toString(), action.id()); + } else if (action.actionTypeId() == kodiSystemActionTypeId) { + kodi->systemCommand(action.param(kodiSystemCommandParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == videoLibraryActionTypeId) { - kodi->videoLibrary(action.param(videoCommandParamTypeId).value().toString(), action.id()); + } else if (action.actionTypeId() == kodiVideoLibraryActionTypeId) { + kodi->videoLibrary(action.param(kodiVideoCommandParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; - } else if (action.actionTypeId() == audioLibraryActionTypeId) { - kodi->audioLibrary(action.param(audioCommandParamTypeId).value().toString(), action.id()); + } else if (action.actionTypeId() == kodiAudioLibraryActionTypeId) { + kodi->audioLibrary(action.param(kodiAudioCommandParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; } return DeviceManager::DeviceErrorActionTypeNotFound; @@ -199,7 +199,7 @@ void DevicePluginKodi::onUpnpDiscoveryFinished() // check if we allready found the kodi on this ip bool alreadyAdded = false; foreach (const DeviceDescriptor dDescriptor, deviceDescriptors) { - if (dDescriptor.params().paramValue(ipParamTypeId).toString() == upnpDescriptor.hostAddress().toString()) { + if (dDescriptor.params().paramValue(kodiIpParamTypeId).toString() == upnpDescriptor.hostAddress().toString()) { alreadyAdded = true; break; } @@ -210,9 +210,9 @@ void DevicePluginKodi::onUpnpDiscoveryFinished() qCDebug(dcKodi) << upnpDescriptor; DeviceDescriptor deviceDescriptor(kodiDeviceClassId, "Kodi - Media Center", upnpDescriptor.hostAddress().toString()); ParamList params; - params.append(Param(nameParamTypeId, upnpDescriptor.friendlyName())); - params.append(Param(ipParamTypeId, upnpDescriptor.hostAddress().toString())); - params.append(Param(portParamTypeId, 9090)); + params.append(Param(kodiNameParamTypeId, upnpDescriptor.friendlyName())); + params.append(Param(kodiIpParamTypeId, upnpDescriptor.hostAddress().toString())); + params.append(Param(kodiPortParamTypeId, 9090)); deviceDescriptor.setParams(params); deviceDescriptors.append(deviceDescriptor); } @@ -233,7 +233,7 @@ void DevicePluginKodi::onConnectionChanged() } } - device->setStateValue(connectedStateTypeId, kodi->connected()); + device->setStateValue(kodiConnectedStateTypeId, kodi->connected()); } void DevicePluginKodi::onStateChanged() @@ -242,8 +242,8 @@ void DevicePluginKodi::onStateChanged() Device *device = m_kodis.value(kodi); // set device state values - device->setStateValue(volumeStateTypeId, kodi->volume()); - device->setStateValue(muteStateTypeId, kodi->muted()); + device->setStateValue(kodiVolumeStateTypeId, kodi->volume()); + device->setStateValue(kodiMuteStateTypeId, kodi->muted()); } void DevicePluginKodi::onActionExecuted(const ActionId &actionId, const bool &success) @@ -290,20 +290,20 @@ void DevicePluginKodi::onPlayerPlay() { Kodi *kodi = static_cast(sender()); Device *device = m_kodis.value(kodi); - emit emitEvent(Event(onPlayerPlayEventTypeId, device->id())); + emit emitEvent(Event(kodiOnPlayerPlayEventTypeId, device->id())); } void DevicePluginKodi::onPlayerPause() { Kodi *kodi = static_cast(sender()); Device *device = m_kodis.value(kodi); - emit emitEvent(Event(onPlayerPauseEventTypeId, device->id())); + emit emitEvent(Event(kodiOnPlayerPauseEventTypeId, device->id())); } void DevicePluginKodi::onPlayerStop() { Kodi *kodi = static_cast(sender()); Device *device = m_kodis.value(kodi); - emit emitEvent(Event(onPlayerStopEventTypeId, device->id())); + emit emitEvent(Event(kodiOnPlayerStopEventTypeId, device->id())); } diff --git a/leynew/devicepluginleynew.cpp b/leynew/devicepluginleynew.cpp index b443d585..58e76afc 100644 --- a/leynew/devicepluginleynew.cpp +++ b/leynew/devicepluginleynew.cpp @@ -82,63 +82,63 @@ 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(idParamTypeId) == "0115"){ + if (device->paramValue(rfControllerIdParamTypeId) == "0115"){ binCode.append("001101000001"); - } else if (device->paramValue(idParamTypeId) == "0014") { + } else if (device->paramValue(rfControllerIdParamTypeId) == "0014") { binCode.append("110000010101"); - } else if (device->paramValue(idParamTypeId) == "0008") { + } else if (device->paramValue(rfControllerIdParamTypeId) == "0008") { binCode.append("111101010101"); } else { - qCWarning(dcLeynew) << "Could not get id of device: invalid parameter" << device->paramValue(idParamTypeId); + qCWarning(dcLeynew) << "Could not get id of device: invalid parameter" << device->paramValue(rfControllerIdParamTypeId); return DeviceManager::DeviceErrorInvalidParameter; } int repetitions = 12; // ======================================= // bincode depending on the action - if (action.actionTypeId() == brightnessUpActionTypeId) { + if (action.actionTypeId() == rfControllerBrightnessUpActionTypeId) { binCode.append("000000000011"); repetitions = 8; - } else if (action.actionTypeId() == brightnessDownActionTypeId) { + } else if (action.actionTypeId() == rfControllerBrightnessDownActionTypeId) { binCode.append("000000001100"); repetitions = 8; - } else if (action.actionTypeId() == powerActionTypeId) { + } else if (action.actionTypeId() == rfControllerPowerActionTypeId) { binCode.append("000011000000"); - } else if (action.actionTypeId() == redActionTypeId) { + } else if (action.actionTypeId() == rfControllerRedActionTypeId) { binCode.append("000000001111"); - } else if (action.actionTypeId() == greenActionTypeId) { + } else if (action.actionTypeId() == rfControllerGreenActionTypeId) { binCode.append("000000110011"); - } else if (action.actionTypeId() == blueActionTypeId) { + } else if (action.actionTypeId() == rfControllerBlueActionTypeId) { binCode.append("000011000011"); - } else if (action.actionTypeId() == whiteActionTypeId) { + } else if (action.actionTypeId() == rfControllerWhiteActionTypeId) { binCode.append("000000111100"); - } else if (action.actionTypeId() == orangeActionTypeId) { + } else if (action.actionTypeId() == rfControllerOrangeActionTypeId) { binCode.append("000011001100"); - } else if (action.actionTypeId() == yellowActionTypeId) { + } else if (action.actionTypeId() == rfControllerYellowActionTypeId) { binCode.append("000011110000"); - } else if (action.actionTypeId() == cyanActionTypeId) { + } else if (action.actionTypeId() == rfControllerCyanActionTypeId) { binCode.append("001100000011"); - } else if (action.actionTypeId() == purpleActionTypeId) { + } else if (action.actionTypeId() == rfControllerPurpleActionTypeId) { binCode.append("110000000011"); - } else if (action.actionTypeId() == playPauseActionTypeId) { + } else if (action.actionTypeId() == rfControllerPlayPauseActionTypeId) { binCode.append("000000110000"); - } else if (action.actionTypeId() == speedUpActionTypeId) { + } else if (action.actionTypeId() == rfControllerSpeedUpActionTypeId) { binCode.append("001100110000"); repetitions = 8; - } else if (action.actionTypeId() == speedDownActionTypeId) { + } else if (action.actionTypeId() == rfControllerSpeedDownActionTypeId) { binCode.append("110000000000"); repetitions = 8; - } else if (action.actionTypeId() == autoActionTypeId) { + } else if (action.actionTypeId() == rfControllerAutoActionTypeId) { binCode.append("001100001100"); - } else if (action.actionTypeId() == flashActionTypeId) { + } else if (action.actionTypeId() == rfControllerFlashActionTypeId) { binCode.append("110011000000"); - } else if (action.actionTypeId() == jump3ActionTypeId) { + } else if (action.actionTypeId() == rfControllerJump3ActionTypeId) { binCode.append("111100001100"); - } else if (action.actionTypeId() == jump7ActionTypeId) { + } else if (action.actionTypeId() == rfControllerJump7ActionTypeId) { binCode.append("001111000000"); - } else if (action.actionTypeId() == fade3ActionTypeId) { + } else if (action.actionTypeId() == rfControllerFade3ActionTypeId) { binCode.append("110000110000"); - } else if (action.actionTypeId() == fade7ActionTypeId) { + } else if (action.actionTypeId() == rfControllerFade7ActionTypeId) { binCode.append("001100000000"); } else { return DeviceManager::DeviceErrorActionTypeNotFound; diff --git a/lgsmarttv/devicepluginlgsmarttv.cpp b/lgsmarttv/devicepluginlgsmarttv.cpp index ee497d05..da5dd5d4 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(hostAddressParamTypeId).toString()), - device->paramValue(portParamTypeId).toInt(), this); - tvDevice->setUuid(device->paramValue(uuidParamTypeId).toString()); + TvDevice *tvDevice = new TvDevice(QHostAddress(device->paramValue(lgSmartTvHostAddressParamTypeId).toString()), + device->paramValue(lgSmartTvPortParamTypeId).toInt(), this); + tvDevice->setUuid(device->paramValue(lgSmartTvUuidParamTypeId).toString()); // if the key is missing, this setup call comes from a pairing procedure - if (device->paramValue(keyParamTypeId) == QString()) { + if (device->paramValue(lgSmartTvKeyParamTypeId) == QString()) { // check if we know the key from the pairing procedure - if (!m_tvKeys.contains(device->paramValue(uuidParamTypeId).toString())) { + if (!m_tvKeys.contains(device->paramValue(lgSmartTvUuidParamTypeId).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(uuidParamTypeId).toString()); + QString key = m_tvKeys.value(device->paramValue(lgSmartTvUuidParamTypeId).toString()); tvDevice->setKey(key); - device->setParamValue(keyParamTypeId, key); + device->setParamValue(lgSmartTvKeyParamTypeId, key); } else { // add the key for editing - if (!m_tvKeys.contains(device->paramValue(uuidParamTypeId).toString())) { + if (!m_tvKeys.contains(device->paramValue(lgSmartTvUuidParamTypeId).toString())) { m_tvKeys.insert(tvDevice->uuid(), tvDevice->key()); } } @@ -136,92 +136,92 @@ DeviceManager::DeviceError DevicePluginLgSmartTv::executeAction(Device *device, return DeviceManager::DeviceErrorHardwareNotAvailable; } - if (action.actionTypeId() == commandVolumeUpActionTypeId) { + if (action.actionTypeId() == lgSmartTvCommandVolumeUpActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::VolUp); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandVolumeDownActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandVolumeDownActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::VolDown); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandMuteActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandMuteActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Mute); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandChannelUpActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandChannelUpActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::ChannelUp); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandChannelDownActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandChannelDownActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::ChannelDown); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandPowerOffActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandPowerOffActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Power); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandArrowUpActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandArrowUpActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Up); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandArrowDownActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandArrowDownActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Down); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandArrowLeftActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandArrowLeftActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Left); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandArrowRightActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandArrowRightActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Right); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandOkActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandOkActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Ok); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandBackActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandBackActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Back); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandHomeActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandHomeActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Home); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandInputSourceActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandInputSourceActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::ExternalInput); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandExitActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandExitActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Exit); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandInfoActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandInfoActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::Info); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandMyAppsActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandMyAppsActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::MyApps); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); m_asyncActions.insert(reply, action.id()); - } else if(action.actionTypeId() == commandProgramListActionTypeId) { + } else if(action.actionTypeId() == lgSmartTvCommandProgramListActionTypeId) { QPair request = tvDevice->createPressButtonRequest(TvDevice::ProgramList); QNetworkReply *reply = hardwareManager()->networkManager()->post(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginLgSmartTv::onNetworkManagerReplyFinished); @@ -236,8 +236,8 @@ DeviceManager::DeviceError DevicePluginLgSmartTv::displayPin(const PairingTransa { Q_UNUSED(pairingTransactionId) - QHostAddress host = QHostAddress(deviceDescriptor.params().paramValue(hostAddressParamTypeId).toString()); - int port = deviceDescriptor.params().paramValue(portParamTypeId).toInt(); + QHostAddress host = QHostAddress(deviceDescriptor.params().paramValue(lgSmartTvHostAddressParamTypeId).toString()); + int port = deviceDescriptor.params().paramValue(lgSmartTvPortParamTypeId).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(hostAddressParamTypeId).toString()); - int port = params.paramValue(portParamTypeId).toInt(); + QHostAddress host = QHostAddress(params.paramValue(lgSmartTvHostAddressParamTypeId).toString()); + int port = params.paramValue(lgSmartTvPortParamTypeId).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(uuidParamTypeId).toString(), secret); + m_tvKeys.insert(params.paramValue(lgSmartTvUuidParamTypeId).toString(), secret); return DeviceManager::DeviceSetupStatusAsync; } void DevicePluginLgSmartTv::pairTvDevice(Device *device, const bool &setup) { - QHostAddress host = QHostAddress(device->paramValue(hostAddressParamTypeId).toString()); - int port = device->paramValue(portParamTypeId).toInt(); - QString key = device->paramValue(keyParamTypeId).toString(); + QHostAddress host = QHostAddress(device->paramValue(lgSmartTvHostAddressParamTypeId).toString()); + int port = device->paramValue(lgSmartTvPortParamTypeId).toInt(); + QString key = device->paramValue(lgSmartTvKeyParamTypeId).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(hostAddressParamTypeId).toString()); - int port = device->paramValue(portParamTypeId).toInt(); + QHostAddress host = QHostAddress(device->paramValue(lgSmartTvHostAddressParamTypeId).toString()); + int port = device->paramValue(lgSmartTvPortParamTypeId).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(nameParamTypeId, upnpDeviceDescriptor.friendlyName())); - params.append(Param(uuidParamTypeId, upnpDeviceDescriptor.uuid())); - params.append(Param(modelParamTypeId, upnpDeviceDescriptor.modelName())); - params.append(Param(hostAddressParamTypeId, upnpDeviceDescriptor.hostAddress().toString())); - params.append(Param(portParamTypeId, upnpDeviceDescriptor.port())); - params.append(Param(keyParamTypeId, QString())); + 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())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -433,14 +433,14 @@ void DevicePluginLgSmartTv::stateChanged() TvDevice *tvDevice = static_cast(sender()); Device *device = m_tvList.value(tvDevice); - device->setStateValue(reachableStateTypeId, tvDevice->reachable()); - device->setStateValue(tv3DModeStateTypeId, tvDevice->is3DMode()); - device->setStateValue(tvVolumeLevelStateTypeId, tvDevice->volumeLevel()); - device->setStateValue(tvMuteStateTypeId, tvDevice->mute()); - device->setStateValue(tvChannelTypeStateTypeId, tvDevice->channelType()); - device->setStateValue(tvChannelNameStateTypeId, tvDevice->channelName()); - device->setStateValue(tvChannelNumberStateTypeId, tvDevice->channelNumber()); - device->setStateValue(tvProgramNameStateTypeId, tvDevice->programName()); - device->setStateValue(tvInputSourceIndexStateTypeId, tvDevice->inputSourceIndex()); - device->setStateValue(tvInputSourceLabelNameStateTypeId, tvDevice->inputSourceLabelName()); + device->setStateValue(lgSmartTvReachableStateTypeId, tvDevice->reachable()); + device->setStateValue(lgSmartTvTv3DModeStateTypeId, tvDevice->is3DMode()); + device->setStateValue(lgSmartTvTvVolumeLevelStateTypeId, tvDevice->volumeLevel()); + device->setStateValue(lgSmartTvTvMuteStateTypeId, tvDevice->mute()); + device->setStateValue(lgSmartTvTvChannelTypeStateTypeId, tvDevice->channelType()); + device->setStateValue(lgSmartTvTvChannelNameStateTypeId, tvDevice->channelName()); + device->setStateValue(lgSmartTvTvChannelNumberStateTypeId, tvDevice->channelNumber()); + device->setStateValue(lgSmartTvTvProgramNameStateTypeId, tvDevice->programName()); + device->setStateValue(lgSmartTvTvInputSourceIndexStateTypeId, tvDevice->inputSourceIndex()); + device->setStateValue(lgSmartTvTvInputSourceLabelNameStateTypeId, tvDevice->inputSourceLabelName()); } diff --git a/lircd/devicepluginlircd.cpp b/lircd/devicepluginlircd.cpp new file mode 100644 index 00000000..323e4329 --- /dev/null +++ b/lircd/devicepluginlircd.cpp @@ -0,0 +1,104 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * Copyright (C) 2015 Simon Stürz * + * Copyright (C) 2014 Michael Zanetti * + * * + * This file is part of guh. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; If not, see * + * . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*! + \page lirc.html + \title LIRC + \brief Plugin for the LIRC infrared daemon. + + \ingroup plugins + \ingroup guh-plugins-maker + + This plugin allows to interact with \l{http://www.lirc.org/}{LIRC} daemon and controll commonly used remote controls. + If lircd (LIRC daemon) is configured on your system, guh will connect to the lirc daemon and all configured remote + controls of lircd will appear in guh. + + \chapter Plugin properties + Following JSON file contains the definition and the description of all available \l{DeviceClass}{DeviceClasses} + and \l{Vendor}{Vendors} of this \l{DevicePlugin}. + + For more details how to read this JSON file please check out the documentation for \l{The plugin JSON File}. + + \quotefile plugins/deviceplugins/lircd/devicepluginlircd.json +*/ + +#include "devicepluginlircd.h" + +#include "plugin/device.h" +#include "devicemanager.h" +#include "plugininfo.h" +#include "lircdclient.h" + +#include +#include + +DeviceClassId lircdDeviceClassId = DeviceClassId("5c2bc4cd-ba6c-4052-b6cd-1db83323ea22"); +EventTypeId LircKeypressEventTypeId = EventTypeId("8711471a-fa0e-410b-b174-dfc3d2aeffb1"); + +DevicePluginLircd::DevicePluginLircd() +{ + m_lircClient = new LircClient(this); + + //m_lircClient->connect(); + connect(m_lircClient, &LircClient::buttonPressed, this, &DevicePluginLircd::buttonPressed); +} + +DeviceManager::HardwareResources DevicePluginLircd::requiredHardware() const +{ + return DeviceManager::HardwareResourceNone; +} + +void DevicePluginLircd::buttonPressed(const QString &remoteName, const QString &buttonName, int repeat) +{ + Device *remote = nullptr; + QList configuredRemotes = deviceManager()->findConfiguredDevices(lircdDeviceClassId); + foreach (Device *device, configuredRemotes) { + if (device->paramValue(irReceiverNameParamTypeId).toString() == remoteName) { + remote = device; + break; + } + } + if (!remote) { + qCWarning(dcLircd) << "Unhandled remote" << remoteName << buttonName; + return; + } + + qCDebug(dcLircd) << "found remote" << remoteName << supportedDevices().first().eventTypes().count(); + ParamList params; + Param buttonParam(irReceiverButtonParamTypeId, buttonName); + params.append(buttonParam); + Param repeatParam(irReceiverRepeatParamTypeId, repeat); + params.append(repeatParam); + Event event(LircKeypressEventTypeId, remote->id(), params); + emitEvent(event); +} + +//QVariantMap DevicePluginLircd::configuration() const +//{ +// return m_config; +//} + +//void DevicePluginLircd::setConfiguration(const QVariantMap &configuration) +//{ +// m_config = configuration; +//} diff --git a/mailnotification/devicepluginmailnotification.cpp b/mailnotification/devicepluginmailnotification.cpp index 968ae01a..7a8877f1 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(userParamTypeId).toString()); + smtpClient->setUser(device->paramValue(googleMailUserParamTypeId).toString()); // TODO: use cryptography to save password not as plain text - smtpClient->setPassword(device->paramValue(passwordParamTypeId).toString()); + smtpClient->setPassword(device->paramValue(googleMailPasswordParamTypeId).toString()); smtpClient->setAuthMethod(SmtpClient::AuthMethodLogin); smtpClient->setEncryptionType(SmtpClient::EncryptionTypeSSL); - smtpClient->setSender(device->paramValue(userParamTypeId).toString()); - smtpClient->setRecipient(device->paramValue(recipientParamTypeId).toString()); + smtpClient->setSender(device->paramValue(googleMailUserParamTypeId).toString()); + smtpClient->setRecipient(device->paramValue(googleMailRecipientParamTypeId).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(userParamTypeId).toString()); + smtpClient->setUser(device->paramValue(yahooMailUserParamTypeId).toString()); // TODO: use cryptography to save password not as plain text - smtpClient->setPassword(device->paramValue(passwordParamTypeId).toString()); + smtpClient->setPassword(device->paramValue(yahooMailPasswordParamTypeId).toString()); smtpClient->setAuthMethod(SmtpClient::AuthMethodLogin); smtpClient->setEncryptionType(SmtpClient::EncryptionTypeSSL); - smtpClient->setSender(device->paramValue(userParamTypeId).toString()); - smtpClient->setRecipient(device->paramValue(recipientParamTypeId).toString()); + smtpClient->setSender(device->paramValue(yahooMailUserParamTypeId).toString()); + smtpClient->setRecipient(device->paramValue(yahooMailRecipientParamTypeId).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(smtpParamTypeId).toString()); - smtpClient->setPort(device->paramValue(portParamTypeId).toInt()); - smtpClient->setUser(device->paramValue(customUserParamTypeId).toString()); + smtpClient->setHost(device->paramValue(customMailSmtpParamTypeId).toString()); + smtpClient->setPort(device->paramValue(customMailPortParamTypeId).toInt()); + smtpClient->setUser(device->paramValue(customMailCustomUserParamTypeId).toString()); // TODO: use cryptography to save password not as plain text - smtpClient->setPassword(device->paramValue(customPasswordParamTypeId).toString()); + smtpClient->setPassword(device->paramValue(customMailCustomPasswordParamTypeId).toString()); - if(device->paramValue(authenticationParamTypeId).toString() == "PLAIN") { + if(device->paramValue(customMailAuthenticationParamTypeId).toString() == "PLAIN") { smtpClient->setAuthMethod(SmtpClient::AuthMethodPlain); - } else if(device->paramValue(authenticationParamTypeId).toString() == "LOGIN") { + } else if(device->paramValue(customMailAuthenticationParamTypeId).toString() == "LOGIN") { smtpClient->setAuthMethod(SmtpClient::AuthMethodLogin); } else { return DeviceManager::DeviceSetupStatusFailure; } - if(device->paramValue(encryptionParamTypeId).toString() == "NONE") { + if(device->paramValue(customMailEncryptionParamTypeId).toString() == "NONE") { smtpClient->setEncryptionType(SmtpClient::EncryptionTypeNone); - } else if(device->paramValue(encryptionParamTypeId).toString() == "SSL") { + } else if(device->paramValue(customMailEncryptionParamTypeId).toString() == "SSL") { smtpClient->setEncryptionType(SmtpClient::EncryptionTypeSSL); - } else if(device->paramValue(encryptionParamTypeId).toString() == "TLS") { + } else if(device->paramValue(customMailEncryptionParamTypeId).toString() == "TLS") { smtpClient->setEncryptionType(SmtpClient::EncryptionTypeTLS); } else { return DeviceManager::DeviceSetupStatusFailure; } - smtpClient->setRecipient(device->paramValue(customRecipientParamTypeId).toString()); - smtpClient->setSender(device->paramValue(customSenderParamTypeId).toString()); + smtpClient->setRecipient(device->paramValue(customMailCustomRecipientParamTypeId).toString()); + smtpClient->setSender(device->paramValue(customMailCustomSenderParamTypeId).toString()); connect(smtpClient, &SmtpClient::testLoginFinished, this, &DevicePluginMailNotification::testLoginFinished); connect(smtpClient, &SmtpClient::sendMailFinished, this, &DevicePluginMailNotification::sendMailFinished); @@ -166,9 +166,9 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic DeviceManager::DeviceError DevicePluginMailNotification::executeAction(Device *device, const Action &action) { - if(action.actionTypeId() == sendMailActionTypeId) { + if(action.actionTypeId() == googleMailSendMailActionTypeId) { SmtpClient *smtpClient = m_clients.key(device); - smtpClient->sendMail(action.param(subjectParamTypeId).value().toString(), action.param(bodyParamTypeId).value().toString(), action.id()); + smtpClient->sendMail(action.param(googleMailSubjectParamTypeId).value().toString(), action.param(googleMailBodyParamTypeId).value().toString(), action.id()); return DeviceManager::DeviceErrorAsync; } return DeviceManager::DeviceErrorActionTypeNotFound; diff --git a/netatmo/devicepluginnetatmo.cpp b/netatmo/devicepluginnetatmo.cpp index c8a8128c..761eb97b 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(usernameParamTypeId).toString()); - authentication->setPassword(device->paramValue(passwordParamTypeId).toString()); + authentication->setUsername(device->paramValue(connectionUsernameParamTypeId).toString()); + authentication->setPassword(device->paramValue(connectionPasswordParamTypeId).toString()); authentication->setScope("read_station read_thermostat write_thermostat"); m_authentications.insert(authentication, device); @@ -84,9 +84,9 @@ 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(nameParamTypeId).toString(), - device->paramValue(macParamTypeId).toString(), - device->paramValue(connectionParamTypeId).toString(), this); + NetatmoBaseStation *indoor = new NetatmoBaseStation(device->paramValue(indoorNameParamTypeId).toString(), + device->paramValue(indoorMacParamTypeId).toString(), + device->paramValue(indoorConnectionParamTypeId).toString(), this); device->setParentId(DeviceId(indoor->connectionId())); m_indoorDevices.insert(indoor, device); @@ -95,10 +95,10 @@ 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(nameParamTypeId).toString(), - device->paramValue(macParamTypeId).toString(), - device->paramValue(connectionParamTypeId).toString(), - device->paramValue(baseStationParamTypeId).toString(),this); + NetatmoOutdoorModule *outdoor = new NetatmoOutdoorModule(device->paramValue(outdoorNameParamTypeId).toString(), + device->paramValue(outdoorMacParamTypeId).toString(), + device->paramValue(outdoorConnectionParamTypeId).toString(), + device->paramValue(outdoorBaseStationParamTypeId).toString(),this); device->setParentId(DeviceId(outdoor->connectionId())); m_outdoorDevices.insert(outdoor, device); @@ -165,9 +165,9 @@ void DevicePluginNetatmo::processRefreshData(const QVariantMap &data, const QStr if (!indoorDevice) { DeviceDescriptor descriptor(indoorDeviceClassId, "Indoor Station", deviceMap.value("station_name").toString()); ParamList params; - params.append(Param(nameParamTypeId, deviceMap.value("station_name").toString())); - params.append(Param(macParamTypeId, deviceMap.value("_id").toString())); - params.append(Param(connectionParamTypeId, connectionId)); + params.append(Param(indoorNameParamTypeId, deviceMap.value("station_name").toString())); + params.append(Param(indoorMacParamTypeId, deviceMap.value("_id").toString())); + params.append(Param(indoorConnectionParamTypeId, connectionId)); descriptor.setParams(params); emit autoDevicesAppeared(indoorDeviceClassId, QList() << descriptor); } else { @@ -192,10 +192,10 @@ void DevicePluginNetatmo::processRefreshData(const QVariantMap &data, const QStr if (!outdoorDevice) { DeviceDescriptor descriptor(outdoorDeviceClassId, "Outdoor Module", moduleMap.value("module_name").toString()); ParamList params; - params.append(Param(nameParamTypeId, moduleMap.value("module_name").toString())); - params.append(Param(macParamTypeId, moduleMap.value("_id").toString())); - params.append(Param(connectionParamTypeId, connectionId)); - params.append(Param(baseStationParamTypeId, moduleMap.value("main_device").toString())); + params.append(Param(outdoorNameParamTypeId, moduleMap.value("module_name").toString())); + params.append(Param(outdoorMacParamTypeId, moduleMap.value("_id").toString())); + params.append(Param(outdoorConnectionParamTypeId, connectionId)); + params.append(Param(outdoorBaseStationParamTypeId, moduleMap.value("main_device").toString())); descriptor.setParams(params); emit autoDevicesAppeared(outdoorDeviceClassId, QList() << descriptor); } else { @@ -213,7 +213,7 @@ Device *DevicePluginNetatmo::findIndoorDevice(const QString &macAddress) { foreach (Device *device, myDevices()) { if (device->deviceClassId() == indoorDeviceClassId) { - if (device->paramValue(macParamTypeId).toString() == macAddress) { + if (device->paramValue(indoorMacParamTypeId).toString() == macAddress) { return device; } } @@ -225,7 +225,7 @@ Device *DevicePluginNetatmo::findOutdoorDevice(const QString &macAddress) { foreach (Device *device, myDevices()) { if (device->deviceClassId() == outdoorDeviceClassId) { - if (device->paramValue(macParamTypeId).toString() == macAddress) { + if (device->paramValue(outdoorMacParamTypeId).toString() == macAddress) { return device; } } @@ -256,7 +256,7 @@ void DevicePluginNetatmo::onNetworkReplyFinished() // check HTTP status code if (status != 200) { qCWarning(dcNetatmo) << "Device list reply HTTP error:" << status << reply->errorString(); - device->setStateValue(availableStateTypeId, false); + device->setStateValue(connectionAvailableStateTypeId, false); reply->deleteLater(); return; } @@ -286,7 +286,7 @@ void DevicePluginNetatmo::onAuthenticationChanged() return; // set the available state - device->setStateValue(availableStateTypeId, authentication->authenticated()); + device->setStateValue(connectionAvailableStateTypeId, authentication->authenticated()); // check if this is was a setup athentication if (m_asyncSetups.contains(device)) { @@ -305,15 +305,15 @@ void DevicePluginNetatmo::onIndoorStatesChanged() NetatmoBaseStation *indoor = static_cast(sender()); Device *device = m_indoorDevices.value(indoor); - device->setStateValue(updateTimeStateTypeId, indoor->lastUpdate()); - device->setStateValue(temperatureStateTypeId, indoor->temperature()); - device->setStateValue(temperatureMinStateTypeId, indoor->minTemperature()); - device->setStateValue(temperatureMaxStateTypeId, indoor->maxTemperature()); - device->setStateValue(pressureStateTypeId, indoor->pressure()); - device->setStateValue(humidityStateTypeId, indoor->humidity()); - device->setStateValue(co2StateTypeId, indoor->co2()); - device->setStateValue(noiseStateTypeId, indoor->noise()); - device->setStateValue(wifiStrengthStateTypeId, indoor->wifiStrength()); + device->setStateValue(indoorUpdateTimeStateTypeId, indoor->lastUpdate()); + device->setStateValue(indoorTemperatureStateTypeId, indoor->temperature()); + device->setStateValue(indoorTemperatureMinStateTypeId, indoor->minTemperature()); + device->setStateValue(indoorTemperatureMaxStateTypeId, indoor->maxTemperature()); + device->setStateValue(indoorPressureStateTypeId, indoor->pressure()); + device->setStateValue(indoorHumidityStateTypeId, indoor->humidity()); + device->setStateValue(indoorCo2StateTypeId, indoor->co2()); + device->setStateValue(indoorNoiseStateTypeId, indoor->noise()); + device->setStateValue(indoorWifiStrengthStateTypeId, indoor->wifiStrength()); } void DevicePluginNetatmo::onOutdoorStatesChanged() @@ -321,13 +321,13 @@ void DevicePluginNetatmo::onOutdoorStatesChanged() NetatmoOutdoorModule *outdoor = static_cast(sender()); Device *device = m_outdoorDevices.value(outdoor); - device->setStateValue(updateTimeStateTypeId, outdoor->lastUpdate()); - device->setStateValue(temperatureStateTypeId, outdoor->temperature()); - device->setStateValue(temperatureMinStateTypeId, outdoor->minTemperature()); - device->setStateValue(temperatureMaxStateTypeId, outdoor->maxTemperature()); - device->setStateValue(humidityStateTypeId, outdoor->humidity()); - device->setStateValue(signalStrengthStateTypeId, outdoor->signalStrength()); - device->setStateValue(batteryStateTypeId, outdoor->battery()); + device->setStateValue(outdoorUpdateTimeStateTypeId, outdoor->lastUpdate()); + device->setStateValue(outdoorTemperatureStateTypeId, outdoor->temperature()); + device->setStateValue(outdoorTemperatureMinStateTypeId, outdoor->minTemperature()); + device->setStateValue(outdoorTemperatureMaxStateTypeId, outdoor->maxTemperature()); + device->setStateValue(outdoorHumidityStateTypeId, outdoor->humidity()); + device->setStateValue(outdoorSignalStrengthStateTypeId, outdoor->signalStrength()); + device->setStateValue(outdoorBatteryStateTypeId, outdoor->battery()); } diff --git a/networkdetector/devicepluginnetworkdetector.cpp b/networkdetector/devicepluginnetworkdetector.cpp index dc88bdd2..77e65202 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(macAddressParamTypeId).toString(), device->paramValue(addressParamTypeId).toString(), this); + DeviceMonitor *monitor = new DeviceMonitor(device->paramValue(networkDeviceMacAddressParamTypeId).toString(), device->paramValue(networkDeviceAddressParamTypeId).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(macAddressParamTypeId, host.macAddress()); - Param address(addressParamTypeId, host.address()); + Param macAddress(networkDeviceMacAddressParamTypeId, host.macAddress()); + Param address(networkDeviceAddressParamTypeId, host.address()); paramList.append(macAddress); paramList.append(address); descriptor.setParams(paramList); @@ -141,9 +141,9 @@ void DevicePluginNetworkDetector::deviceReachableChanged(bool reachable) { DeviceMonitor *monitor = static_cast(sender()); Device *device = m_monitors.value(monitor); - if (device->stateValue(inRangeStateTypeId).toBool() != reachable) { - qCDebug(dcNetworkDetector()) << "Device" << device->paramValue(macAddressParamTypeId).toString() << "reachable changed" << reachable; - device->setStateValue(inRangeStateTypeId, reachable); + if (device->stateValue(networkDeviceInRangeStateTypeId).toBool() != reachable) { + qCDebug(dcNetworkDetector()) << "Device" << device->paramValue(networkDeviceMacAddressParamTypeId).toString() << "reachable changed" << reachable; + device->setStateValue(networkDeviceInRangeStateTypeId, 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(addressParamTypeId).toString() != address) { - device->setParamValue(addressParamTypeId.toString(), address); + if (device->paramValue(networkDeviceAddressParamTypeId).toString() != address) { + device->setParamValue(networkDeviceAddressParamTypeId.toString(), address); } } diff --git a/openweathermap/devicepluginopenweathermap.cpp b/openweathermap/devicepluginopenweathermap.cpp index b6a2ce07..c037fc0c 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(locationParamTypeId).toString(); + QString location = params.paramValue(openweathermapLocationParamTypeId).toString(); // if we have an empty search string, perform an autodetection of the location with the WAN ip... if (location.isEmpty()){ @@ -107,7 +107,7 @@ DeviceManager::DeviceSetupStatus DevicePluginOpenweathermap::setupDevice(Device DeviceManager::DeviceError DevicePluginOpenweathermap::executeAction(Device *device, const Action &action) { - if(action.actionTypeId() == refreshWeatherActionTypeId){ + if(action.actionTypeId() == openweathermapRefreshWeatherActionTypeId){ update(device); return DeviceManager::DeviceErrorNoError; } @@ -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(idParamTypeId).toString()); + query.addQueryItem("id", device->paramValue(openweathermapIdParamTypeId).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(nameParamTypeId, elemant.value("name")); + Param nameParam(openweathermapNameParamTypeId, elemant.value("name")); params.append(nameParam); - Param countryParam(countryParamTypeId, elemant.value("country")); + Param countryParam(openweathermapCountryParamTypeId, elemant.value("country")); params.append(countryParam); - Param idParam(idParamTypeId, elemant.value("id")); + Param idParam(openweathermapIdParamTypeId, elemant.value("id")); params.append(idParam); descriptor.setParams(params); retList.append(descriptor); @@ -343,11 +343,11 @@ void DevicePluginOpenweathermap::processWeatherData(const QByteArray &data, Devi QVariantMap dataMap = jsonDoc.toVariant().toMap(); if (dataMap.contains("clouds")) { int cloudiness = dataMap.value("clouds").toMap().value("all").toInt(); - device->setStateValue(cloudinessStateTypeId, cloudiness); + device->setStateValue(openweathermapCloudinessStateTypeId, cloudiness); } if (dataMap.contains("dt")) { uint lastUpdate = dataMap.value("dt").toUInt(); - device->setStateValue(updateTimeStateTypeId, lastUpdate); + device->setStateValue(openweathermapUpdateTimeStateTypeId, lastUpdate); } if (dataMap.contains("main")) { @@ -357,38 +357,38 @@ void DevicePluginOpenweathermap::processWeatherData(const QByteArray &data, Devi double pressure = dataMap.value("main").toMap().value("pressure").toDouble(); int humidity = dataMap.value("main").toMap().value("humidity").toInt(); - device->setStateValue(temperatureStateTypeId, temperatur); - device->setStateValue(temperatureMinStateTypeId, temperaturMin); - device->setStateValue(temperatureMaxStateTypeId, temperaturMax); - device->setStateValue(pressureStateTypeId, pressure); - device->setStateValue(humidityStateTypeId, humidity); + device->setStateValue(openweathermapTemperatureStateTypeId, temperatur); + device->setStateValue(openweathermapTemperatureMinStateTypeId, temperaturMin); + device->setStateValue(openweathermapTemperatureMaxStateTypeId, temperaturMax); + device->setStateValue(openweathermapPressureStateTypeId, pressure); + device->setStateValue(openweathermapHumidityStateTypeId, humidity); } if (dataMap.contains("sys")) { uint sunrise = dataMap.value("sys").toMap().value("sunrise").toUInt(); uint sunset = dataMap.value("sys").toMap().value("sunset").toUInt(); - device->setStateValue(sunriseStateTypeId, sunrise); - device->setStateValue(sunsetStateTypeId, sunset); + device->setStateValue(openweathermapSunriseStateTypeId, sunrise); + device->setStateValue(openweathermapSunsetStateTypeId, sunset); } if (dataMap.contains("visibility")) { int visibility = dataMap.value("visibility").toInt(); - device->setStateValue(visibilityStateTypeId, visibility); + device->setStateValue(openweathermapVisibilityStateTypeId, visibility); } // http://openweathermap.org/weather-conditions if (dataMap.contains("weather")) { QString description = dataMap.value("weather").toList().first().toMap().value("description").toString(); - device->setStateValue(weatherDescriptionStateTypeId, description); + device->setStateValue(openweathermapWeatherDescriptionStateTypeId, description); } if (dataMap.contains("wind")) { int windDirection = dataMap.value("wind").toMap().value("deg").toInt(); double windSpeed = dataMap.value("wind").toMap().value("speed").toDouble(); - device->setStateValue(windDirectionStateTypeId, windDirection); - device->setStateValue(windSpeedStateTypeId, windSpeed); + device->setStateValue(openweathermapWindDirectionStateTypeId, windDirection); + device->setStateValue(openweathermapWindSpeedStateTypeId, windSpeed); } } diff --git a/orderbutton/devicepluginorderbutton.cpp b/orderbutton/devicepluginorderbutton.cpp index 23ebb1ef..25c50f70 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(hostParamTypeId).toString()))) { + if (deviceAlreadyAdded(QHostAddress(device->paramValue(orderbuttonHostParamTypeId).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(rplParamTypeId).toString()); + QHostAddress address(configuration().paramValue(orderButtonRplParamTypeId).toString()); qCDebug(dcOrderButton) << "Scan for new nodes on RPL" << address.toString(); QUrl url; @@ -122,16 +122,16 @@ DeviceManager::DeviceError DevicePluginOrderButton::executeAction(Device *device qCDebug(dcOrderButton) << "Execute action" << device->name() << action.params(); // Check if the device is reachable - if (!device->stateValue(reachableStateTypeId).toBool()) { + if (!device->stateValue(orderbuttonReachableStateTypeId).toBool()) { qCWarning(dcOrderButton) << "Device not reachable."; return DeviceManager::DeviceErrorHardwareNotAvailable; } // Check which action sould be executed - if (action.actionTypeId() == resetActionTypeId) { + if (action.actionTypeId() == orderbuttonResetActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); url.setPath("/s/count"); CoapReply *reply = m_coap->post(CoapRequest(url), QByteArray("count=0")); @@ -146,12 +146,12 @@ DeviceManager::DeviceError DevicePluginOrderButton::executeAction(Device *device m_asyncActions.insert(action.id(), device); return DeviceManager::DeviceErrorAsync; - } else if(action.actionTypeId() == ledActionTypeId) { - bool led = action.param(ledStateParamTypeId).value().toBool(); + } else if(action.actionTypeId() == orderbuttonLedActionTypeId) { + bool led = action.param(orderbuttonLedStateParamTypeId).value().toBool(); QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(orderbuttonHostParamTypeId).toString()); url.setPath("/s/button"); m_enableNotification.insert(m_coap->enableResourceNotifications(CoapRequest(url)), device); @@ -273,7 +273,7 @@ void DevicePluginOrderButton::enableNotifications(Device *device) void DevicePluginOrderButton::setReachable(Device *device, const bool &reachable) { - if (device->stateValue(reachableStateTypeId).toBool() != reachable) { + if (device->stateValue(orderbuttonReachableStateTypeId).toBool() != reachable) { if (!reachable) { // Warn just once that the device is not reachable qCWarning(dcOrderButton()) << device->name() << "reachable changed" << reachable; @@ -291,14 +291,14 @@ void DevicePluginOrderButton::setReachable(Device *device, const bool &reachable } } - device->setStateValue(reachableStateTypeId, reachable); + device->setStateValue(orderbuttonReachableStateTypeId, reachable); } bool DevicePluginOrderButton::deviceAlreadyAdded(const QHostAddress &address) { // Check if we already have a device with the given address foreach (Device *device, myDevices()) { - if (device->paramValue(hostParamTypeId).toString() == address.toString()) { + if (device->paramValue(orderbuttonHostParamTypeId).toString() == address.toString()) { return true; } } @@ -309,7 +309,7 @@ Device *DevicePluginOrderButton::findDevice(const QHostAddress &address) { // Return the device pointer with the given address (otherwise 0) foreach (Device *device, myDevices()) { - if (device->paramValue(hostParamTypeId).toString() == address.toString()) { + if (device->paramValue(orderbuttonHostParamTypeId).toString() == address.toString()) { return device; } } @@ -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(hostParamTypeId, address.toString())); + params.append(Param(orderbuttonHostParamTypeId, address.toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -377,7 +377,7 @@ void DevicePluginOrderButton::coapReplyFinished(CoapReply *reply) // Check CoAP reply error if (reply->error() != CoapReply::NoError) { - if (device->stateValue(reachableStateTypeId).toBool()) + if (device->stateValue(orderbuttonReachableStateTypeId).toBool()) qCWarning(dcOrderButton) << "Ping device" << reply->request().url().toString() << "reply finished with error" << reply->errorString(); setReachable(device, false); @@ -408,17 +408,17 @@ void DevicePluginOrderButton::coapReplyFinished(CoapReply *reply) // Update corresponding device state if (urlPath == "/s/count") { qCDebug(dcOrderButton()) << "Updated count value:" << reply->payload(); - device->setStateValue(countStateTypeId, reply->payload().toInt()); + device->setStateValue(orderbuttonCountStateTypeId, reply->payload().toInt()); } else if (urlPath == "/s/button") { qCDebug(dcOrderButton()) << "Updated button value:" << reply->payload(); //device->(buttonStateTypeId, QVariant(reply->payload().toInt()).toBool()); - emit emitEvent(Event(buttonEventTypeId, device->id())); + emit emitEvent(Event(orderbuttonButtonEventTypeId, device->id())); } else if (urlPath == "/s/battery") { qCDebug(dcOrderButton()) << "Updated battery value:" << reply->payload(); - device->setStateValue(batteryStateTypeId, reply->payload().toDouble()); + device->setStateValue(orderbuttonBatteryStateTypeId, reply->payload().toDouble()); } else if (urlPath == "/a/led") { qCDebug(dcOrderButton()) << "Updated led value:" << reply->payload(); - device->setStateValue(ledStateTypeId, QVariant(reply->payload().toInt()).toBool()); + device->setStateValue(orderbuttonLedStateTypeId, QVariant(reply->payload().toInt()).toBool()); } } else if (m_resetCounterRequests.contains(reply)) { @@ -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(ledStateTypeId, action.param(ledStateParamTypeId).value().toBool()); + device->setStateValue(orderbuttonLedStateTypeId, action.param(orderbuttonLedStateParamTypeId).value().toBool()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -506,13 +506,13 @@ void DevicePluginOrderButton::onNotificationReceived(const CoapObserveResource & // Update the corresponding device state if (resource.url().path() == "/s/button") { - emit emitEvent(Event(buttonEventTypeId, device->id())); + emit emitEvent(Event(orderbuttonButtonEventTypeId, device->id())); //device->setStateValue(buttonStateTypeId, QVariant(payload.toInt()).toBool()); } else if (resource.url().path() == "/s/battery") { - device->setStateValue(batteryStateTypeId, payload.toDouble()); + device->setStateValue(orderbuttonBatteryStateTypeId, payload.toDouble()); } else if (resource.url().path() == "/a/led") { - device->setStateValue(ledStateTypeId, QVariant(payload.toInt()).toBool()); + device->setStateValue(orderbuttonLedStateTypeId, QVariant(payload.toInt()).toBool()); } else if (resource.url().path() == "/s/count") { - device->setStateValue(countStateTypeId, payload.toInt()); + device->setStateValue(orderbuttonCountStateTypeId, payload.toInt()); } } diff --git a/orderbutton/devicepluginorderbutton.json b/orderbutton/devicepluginorderbutton.json index 91cb30ee..6e9ba234 100644 --- a/orderbutton/devicepluginorderbutton.json +++ b/orderbutton/devicepluginorderbutton.json @@ -1,6 +1,6 @@ { "displayName": "Order Button", - "name": "OrderButton", + "name": "orderButton", "id": "939a6557-649d-43de-990b-3484f972ad86", "paramTypes": [ { diff --git a/osdomotics/devicepluginosdomotics.cpp b/osdomotics/devicepluginosdomotics.cpp index e361b139..f6e45091 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(hostParamTypeId).toString(); - QHostAddress address(device->paramValue(hostParamTypeId).toString()); + qCDebug(dcOsdomotics) << "Setup RPL router" << device->paramValue(rplRouterRplHostParamTypeId).toString(); + QHostAddress address(device->paramValue(rplRouterRplHostParamTypeId).toString()); if (address.isNull()) { - qCWarning(dcOsdomotics) << "Got invalid address" << device->paramValue(hostParamTypeId).toString(); + qCWarning(dcOsdomotics) << "Got invalid address" << device->paramValue(rplRouterRplHostParamTypeId).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(hostParamTypeId).toString(); - device->setParentId(DeviceId(device->paramValue(routerParamTypeId).toString())); + qCDebug(dcOsdomotics) << "Setup Merkur node" << device->paramValue(merkurNodeHostParamTypeId).toString(); + device->setParentId(DeviceId(device->paramValue(merkurNodeRouterParamTypeId).toString())); return DeviceManager::DeviceSetupStatusSuccess; } return DeviceManager::DeviceSetupStatusFailure; @@ -108,10 +108,10 @@ void DevicePluginOsdomotics::postSetupDevice(Device *device) DeviceManager::DeviceError DevicePluginOsdomotics::executeAction(Device *device, const Action &action) { if (device->deviceClassId() == merkurNodeDeviceClassId) { - if (action.actionTypeId() == toggleLedActionTypeId) { + if (action.actionTypeId() == merkurNodeToggleLedActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(merkurNodeHostParamTypeId).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(hostParamTypeId).toString()); + QHostAddress address(device->paramValue(merkurNodeHostParamTypeId).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 allready have found this node foreach (Device *device, myDevices()) { - if (device->paramValue(hostParamTypeId).toString() == nodeAddress.toString()) { + if (device->paramValue(merkurNodeHostParamTypeId).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(hostParamTypeId).toString() << "battery value"; + qCDebug(dcOsdomotics) << "Update node" << device->paramValue(merkurNodeHostParamTypeId).toString() << "battery value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(merkurNodeHostParamTypeId).toString()); url.setPath("/sensors/battery"); CoapReply *reply = m_coap->get(CoapRequest(url)); @@ -213,7 +213,7 @@ void DevicePluginOsdomotics::updateNode(Device *device) Device *DevicePluginOsdomotics::findDevice(const QHostAddress &address) { foreach (Device *device, myDevices()) { - if (device->paramValue(hostParamTypeId).toString() == address.toString()) { + if (device->paramValue(merkurNodeHostParamTypeId).toString() == address.toString()) { return device; } } @@ -285,9 +285,9 @@ void DevicePluginOsdomotics::coapReplyFinished(CoapReply *reply) DeviceDescriptor descriptor(merkurNodeDeviceClassId, "Merkur Node", reply->request().url().host()); ParamList params; - params.append(Param(nameParamTypeId, "Merkur Node")); - params.append(Param(hostParamTypeId, reply->request().url().host())); - params.append(Param(routerParamTypeId, device->id())); + params.append(Param(merkurNodeNameParamTypeId, "Merkur Node")); + params.append(Param(merkurNodeHostParamTypeId, reply->request().url().host())); + params.append(Param(merkurNodeRouterParamTypeId, device->id())); descriptor.setParams(params); emit autoDevicesAppeared(merkurNodeDeviceClassId, QList() << descriptor); @@ -310,7 +310,7 @@ void DevicePluginOsdomotics::coapReplyFinished(CoapReply *reply) } int batteryValue = reply->payload().toInt(); qCDebug(dcOsdomotics) << "Node updated" << batteryValue; - device->setStateValue(batteryStateTypeId, batteryValue); + device->setStateValue(merkurNodeBatteryStateTypeId, batteryValue); } reply->deleteLater(); diff --git a/philipshue/devicepluginphilipshue.cpp b/philipshue/devicepluginphilipshue.cpp index 49449619..db8b78d4 100644 --- a/philipshue/devicepluginphilipshue.cpp +++ b/philipshue/devicepluginphilipshue.cpp @@ -88,17 +88,17 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev if (device->deviceClassId() == hueBridgeDeviceClassId) { // unconfigured bridges (from pairing) foreach (HueBridge *b, m_unconfiguredBridges) { - if (b->hostAddress().toString() == device->paramValue(bridgeHostParamTypeId).toString()) { + if (b->hostAddress().toString() == device->paramValue(hueBridgeBridgeHostParamTypeId).toString()) { m_unconfiguredBridges.removeAll(b); qCDebug(dcPhilipsHue) << "Setup unconfigured Hue Bridge" << b->name(); // set data which was not known during discovery - device->setParamValue(bridgeNameParamTypeId, b->name()); - device->setParamValue(bridgeApiParamTypeId, b->apiKey()); - device->setParamValue(bridgeZigbeeChannelParamTypeId, b->zigbeeChannel()); - device->setParamValue(bridgeIdParamTypeId, b->id()); - device->setParamValue(bridgeMacParamTypeId, b->macAddress()); + 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()); m_bridges.insert(b, device); - device->setStateValue(bridgeReachableStateTypeId, true); + device->setStateValue(hueBridgeBridgeReachableStateTypeId, true); discoverBridgeDevices(b); return DeviceManager::DeviceSetupStatusSuccess; } @@ -108,12 +108,12 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev qCDebug(dcPhilipsHue) << "Setup Hue Bridge" << device->params(); HueBridge *bridge = new HueBridge(this); - bridge->setId(device->paramValue(bridgeIdParamTypeId).toString()); - bridge->setApiKey(device->paramValue(bridgeApiParamTypeId).toString()); - bridge->setHostAddress(QHostAddress(device->paramValue(bridgeHostParamTypeId).toString())); - bridge->setName(device->paramValue(bridgeNameParamTypeId).toString()); - bridge->setMacAddress(device->paramValue(bridgeMacParamTypeId).toString()); - bridge->setZigbeeChannel(device->paramValue(bridgeZigbeeChannelParamTypeId).toInt()); + 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()); m_bridges.insert(bridge, device); return DeviceManager::DeviceSetupStatusSuccess; @@ -124,14 +124,14 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev qCDebug(dcPhilipsHue) << "Setup Hue color light" << device->params(); HueLight *hueLight = new HueLight(this); - hueLight->setId(device->paramValue(lightIdParamTypeId).toInt()); - hueLight->setHostAddress(QHostAddress(device->paramValue(hostParamTypeId).toString())); - hueLight->setName(device->paramValue(nameParamTypeId).toString()); - hueLight->setApiKey(device->paramValue(apiKeyParamTypeId).toString()); - hueLight->setModelId(device->paramValue(modelIdParamTypeId).toString()); - hueLight->setUuid(device->paramValue(uuidParamTypeId).toString()); - hueLight->setType(device->paramValue(typeParamTypeId).toString()); - hueLight->setBridgeId(DeviceId(device->paramValue(bridgeParamTypeId).toString())); + hueLight->setId(device->paramValue(hueLightLightIdParamTypeId).toInt()); + hueLight->setHostAddress(QHostAddress(device->paramValue(hueLightHostParamTypeId).toString())); + hueLight->setName(device->paramValue(hueLightNameParamTypeId).toString()); + hueLight->setApiKey(device->paramValue(hueLightApiKeyParamTypeId).toString()); + hueLight->setModelId(device->paramValue(hueLightModelIdParamTypeId).toString()); + hueLight->setUuid(device->paramValue(hueLightUuidParamTypeId).toString()); + hueLight->setType(device->paramValue(hueLightTypeParamTypeId).toString()); + hueLight->setBridgeId(DeviceId(device->paramValue(hueLightBridgeParamTypeId).toString())); device->setParentId(hueLight->bridgeId()); connect(hueLight, &HueLight::stateChanged, this, &DevicePluginPhilipsHue::lightStateChanged); @@ -140,7 +140,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev device->setName(hueLight->name()); refreshLight(device); - setLightName(device, device->paramValue(nameParamTypeId).toString()); + setLightName(device, device->paramValue(hueLightNameParamTypeId).toString()); return DeviceManager::DeviceSetupStatusSuccess; } @@ -150,14 +150,14 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev qCDebug(dcPhilipsHue) << "Setup Hue white light" << device->params(); HueLight *hueLight = new HueLight(this); - hueLight->setId(device->paramValue(lightIdParamTypeId).toInt()); - hueLight->setHostAddress(QHostAddress(device->paramValue(hostParamTypeId).toString())); - hueLight->setName(device->paramValue(nameParamTypeId).toString()); - hueLight->setApiKey(device->paramValue(apiKeyParamTypeId).toString()); - hueLight->setModelId(device->paramValue(modelIdParamTypeId).toString()); - hueLight->setUuid(device->paramValue(uuidParamTypeId).toString()); - hueLight->setType(device->paramValue(typeParamTypeId).toString()); - hueLight->setBridgeId(DeviceId(device->paramValue(bridgeParamTypeId).toString())); + hueLight->setId(device->paramValue(hueWhiteLightLightIdParamTypeId).toInt()); + hueLight->setHostAddress(QHostAddress(device->paramValue(hueWhiteLightHostParamTypeId).toString())); + hueLight->setName(device->paramValue(hueWhiteLightNameParamTypeId).toString()); + hueLight->setApiKey(device->paramValue(hueWhiteLightApiKeyParamTypeId).toString()); + hueLight->setModelId(device->paramValue(hueWhiteLightModelIdParamTypeId).toString()); + hueLight->setUuid(device->paramValue(hueWhiteLightUuidParamTypeId).toString()); + hueLight->setType(device->paramValue(hueWhiteLightTypeParamTypeId).toString()); + hueLight->setBridgeId(DeviceId(device->paramValue(hueWhiteLightBridgeParamTypeId).toString())); device->setParentId(hueLight->bridgeId()); connect(hueLight, &HueLight::stateChanged, this, &DevicePluginPhilipsHue::lightStateChanged); @@ -167,7 +167,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev m_lights.insert(hueLight, device); refreshLight(device); - setLightName(device, device->paramValue(nameParamTypeId).toString()); + setLightName(device, device->paramValue(hueWhiteLightNameParamTypeId).toString()); return DeviceManager::DeviceSetupStatusSuccess; } @@ -176,14 +176,14 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::setupDevice(Device *dev qCDebug(dcPhilipsHue) << "Setup Hue remote" << device->params(); HueRemote *hueRemote = new HueRemote(this); - hueRemote->setId(device->paramValue(sensorIdParamTypeId).toInt()); - hueRemote->setHostAddress(QHostAddress(device->paramValue(hostParamTypeId).toString())); - hueRemote->setName(device->paramValue(nameParamTypeId).toString()); - hueRemote->setApiKey(device->paramValue(apiKeyParamTypeId).toString()); - hueRemote->setModelId(device->paramValue(modelIdParamTypeId).toString()); - hueRemote->setType(device->paramValue(typeParamTypeId).toString()); - hueRemote->setUuid(device->paramValue(uuidParamTypeId).toString()); - hueRemote->setBridgeId(DeviceId(device->paramValue(bridgeParamTypeId).toString())); + hueRemote->setId(device->paramValue(hueRemoteSensorIdParamTypeId).toInt()); + hueRemote->setHostAddress(QHostAddress(device->paramValue(hueRemoteHostParamTypeId).toString())); + hueRemote->setName(device->paramValue(hueRemoteNameParamTypeId).toString()); + hueRemote->setApiKey(device->paramValue(hueRemoteApiKeyParamTypeId).toString()); + hueRemote->setModelId(device->paramValue(hueRemoteModelIdParamTypeId).toString()); + hueRemote->setType(device->paramValue(hueRemoteTypeParamTypeId).toString()); + hueRemote->setUuid(device->paramValue(hueRemoteUuidParamTypeId).toString()); + hueRemote->setBridgeId(DeviceId(device->paramValue(hueRemoteBridgeParamTypeId).toString())); device->setParentId(hueRemote->bridgeId()); device->setName(hueRemote->name()); @@ -228,7 +228,7 @@ DeviceManager::DeviceSetupStatus DevicePluginPhilipsHue::confirmPairing(const Pa PairingInfo *pairingInfo = new PairingInfo(this); pairingInfo->setPairingTransactionId(pairingTransactionId); - pairingInfo->setHost(QHostAddress(params.paramValue(bridgeHostParamTypeId).toString())); + pairingInfo->setHost(QHostAddress(params.paramValue(hueBridgeBridgeHostParamTypeId).toString())); QVariantMap deviceTypeParam; deviceTypeParam.insert("devicetype", "guh"); @@ -326,7 +326,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady() // check HTTP status code if (status != 200 || reply->error() != QNetworkReply::NoError) { - if (device->stateValue(bridgeReachableStateTypeId).toBool()) { + if (device->stateValue(hueBridgeBridgeReachableStateTypeId).toBool()) { qCWarning(dcPhilipsHue) << "Refresh Hue Bridge request error:" << status << reply->errorString(); bridgeReachableChanged(device, false); } @@ -352,7 +352,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady() // check HTTP status code if (status != 200 || reply->error() != QNetworkReply::NoError) { - if (device->stateValue(bridgeReachableStateTypeId).toBool()) { + if (device->stateValue(hueLightHueReachableStateTypeId).toBool()) { qCWarning(dcPhilipsHue) << "Refresh Hue lights request error:" << status << reply->errorString(); bridgeReachableChanged(device, false); } @@ -366,7 +366,7 @@ void DevicePluginPhilipsHue::networkManagerReplyReady() // check HTTP status code if (status != 200 || reply->error() != QNetworkReply::NoError) { - if (device->stateValue(bridgeReachableStateTypeId).toBool()) { + if (device->stateValue(hueRemoteHueReachableStateTypeId).toBool()) { qCWarning(dcPhilipsHue) << "Refresh Hue sensors request error:" << status << reply->errorString(); bridgeReachableChanged(device, false); } @@ -416,38 +416,38 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, return DeviceManager::DeviceErrorHardwareNotAvailable; } - if (action.actionTypeId() == huePowerActionTypeId) { - QPair request = light->createSetPowerRequest(action.param(huePowerStateParamTypeId).value().toBool()); + if (action.actionTypeId() == hueLightHuePowerActionTypeId) { + QPair request = light->createSetPowerRequest(action.param(hueLightHuePowerStateParamTypeId).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() == hueColorActionTypeId) { - QPair request = light->createSetColorRequest(action.param(hueColorStateParamTypeId).value().value()); + } else if (action.actionTypeId() == hueLightHueColorActionTypeId) { + QPair request = light->createSetColorRequest(action.param(hueLightHueColorStateParamTypeId).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() == hueBrightnessActionTypeId) { - QPair request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueBrightnessStateParamTypeId).value().toInt())); + } else if (action.actionTypeId() == hueLightHueBrightnessActionTypeId) { + QPair request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueLightHueBrightnessStateParamTypeId).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() == hueEffectActionTypeId) { - QPair request = light->createSetEffectRequest(action.param(hueEffectStateParamTypeId).value().toString()); + } else if (action.actionTypeId() == hueLightHueEffectActionTypeId) { + QPair request = light->createSetEffectRequest(action.param(hueLightHueEffectStateParamTypeId).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() == hueAlertActionTypeId) { - QPair request = light->createFlashRequest(action.param(alertParamTypeId).value().toString()); + } else if (action.actionTypeId() == hueLightHueAlertActionTypeId) { + QPair request = light->createFlashRequest(action.param(hueLightAlertParamTypeId).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() == hueTemperatureActionTypeId) { - QPair request = light->createSetTemperatureRequest(action.param(hueTemperatureStateParamTypeId).value().toInt()); + } else if (action.actionTypeId() == hueLightHueTemperatureActionTypeId) { + QPair request = light->createSetTemperatureRequest(action.param(hueLightHueTemperatureStateParamTypeId).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())); @@ -465,20 +465,20 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, return DeviceManager::DeviceErrorHardwareNotAvailable; } - if (action.actionTypeId() == huePowerActionTypeId) { - QPair request = light->createSetPowerRequest(action.param(huePowerStateParamTypeId).value().toBool()); + if (action.actionTypeId() == hueWhiteLightHuePowerActionTypeId) { + QPair request = light->createSetPowerRequest(action.param(hueWhiteLightHuePowerStateParamTypeId).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() == hueBrightnessActionTypeId) { - QPair request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueBrightnessStateParamTypeId).value().toInt())); + } else if (action.actionTypeId() == hueWhiteLightHueBrightnessActionTypeId) { + QPair request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueWhiteLightHueBrightnessStateParamTypeId).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() == hueAlertActionTypeId) { - QPair request = light->createFlashRequest(action.param(alertParamTypeId).value().toString()); + } else if (action.actionTypeId() == hueWhiteLightHueAlertActionTypeId) { + QPair request = light->createFlashRequest(action.param(hueWhiteLightAlertParamTypeId).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())); @@ -489,21 +489,21 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device, if (device->deviceClassId() == hueBridgeDeviceClassId) { HueBridge *bridge = m_bridges.key(device); - if (!device->stateValue(bridgeReachableStateTypeId).toBool()) { + if (!device->stateValue(hueBridgeBridgeReachableStateTypeId).toBool()) { qCWarning(dcPhilipsHue) << "Bridge" << bridge->hostAddress().toString() << "not reachable"; return DeviceManager::DeviceErrorHardwareNotAvailable; } - if (action.actionTypeId() == searchNewDevicesActionTypeId) { + if (action.actionTypeId() == hueBridgeSearchNewDevicesActionTypeId) { searchNewDevices(bridge); return DeviceManager::DeviceErrorNoError; - } else if (action.actionTypeId() == checkForUpdatesActionTypeId) { + } else if (action.actionTypeId() == hueBridgeCheckForUpdatesActionTypeId) { 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() == upgradeActionTypeId) { + } else if (action.actionTypeId() == hueBridgeUpgradeActionTypeId) { QPair request = bridge->createUpgradeRequest(); QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second); connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady); @@ -526,16 +526,16 @@ void DevicePluginPhilipsHue::lightStateChanged() } if (device->deviceClassId() == hueLightDeviceClassId) { - device->setStateValue(hueReachableStateTypeId, light->reachable()); - device->setStateValue(hueColorStateTypeId, QVariant::fromValue(light->color())); - device->setStateValue(huePowerStateTypeId, light->power()); - device->setStateValue(hueBrightnessStateTypeId, brightnessToPercentage(light->brightness())); - device->setStateValue(hueTemperatureStateTypeId, light->ct()); - device->setStateValue(hueEffectStateTypeId, light->effect()); + device->setStateValue(hueLightHueReachableStateTypeId, light->reachable()); + device->setStateValue(hueLightHueColorStateTypeId, QVariant::fromValue(light->color())); + device->setStateValue(hueLightHuePowerStateTypeId, light->power()); + device->setStateValue(hueLightHueBrightnessStateTypeId, brightnessToPercentage(light->brightness())); + device->setStateValue(hueLightHueTemperatureStateTypeId, light->ct()); + device->setStateValue(hueLightHueEffectStateTypeId, light->effect()); } else if (device->deviceClassId() == hueWhiteLightDeviceClassId) { - device->setStateValue(hueReachableStateTypeId, light->reachable()); - device->setStateValue(huePowerStateTypeId, light->power()); - device->setStateValue(hueBrightnessStateTypeId, brightnessToPercentage(light->brightness())); + device->setStateValue(hueWhiteLightHueReachableStateTypeId, light->reachable()); + device->setStateValue(hueWhiteLightHuePowerStateTypeId, light->power()); + device->setStateValue(hueWhiteLightHueBrightnessStateTypeId, brightnessToPercentage(light->brightness())); } } @@ -549,38 +549,39 @@ void DevicePluginPhilipsHue::remoteStateChanged() return; } - device->setStateValue(hueReachableStateTypeId, remote->reachable()); - device->setStateValue(batteryStateTypeId, remote->battery()); + device->setStateValue(hueRemoteHueReachableStateTypeId, remote->reachable()); + device->setStateValue(hueRemoteBatteryStateTypeId, remote->battery()); } void DevicePluginPhilipsHue::onRemoteButtonEvent(const int &buttonCode) { HueRemote *remote = static_cast(sender()); + // TODO: Legacy events should be removed eventually switch (buttonCode) { case HueRemote::OnPressed: - emitEvent(Event(onPressedEventTypeId, m_remotes.value(remote)->id())); + emitEvent(Event(hueRemoteOnPressedEventTypeId, m_remotes.value(remote)->id())); break; case HueRemote::OnLongPressed: - emitEvent(Event(onLongPressedEventTypeId, m_remotes.value(remote)->id())); + emitEvent(Event(hueRemoteOnLongPressedEventTypeId, m_remotes.value(remote)->id())); break; case HueRemote::DimUpPressed: - emitEvent(Event(dimUpPressedEventTypeId, m_remotes.value(remote)->id())); + emitEvent(Event(hueRemoteDimUpPressedEventTypeId, m_remotes.value(remote)->id())); break; case HueRemote::DimUpLongPressed: - emitEvent(Event(dimUpLongPressedEventTypeId, m_remotes.value(remote)->id())); + emitEvent(Event(hueRemoteDimUpLongPressedEventTypeId, m_remotes.value(remote)->id())); break; case HueRemote::DimDownPressed: - emitEvent(Event(dimDownPressedEventTypeId, m_remotes.value(remote)->id())); + emitEvent(Event(hueRemoteDimDownPressedEventTypeId, m_remotes.value(remote)->id())); break; case HueRemote::DimDownLongPressed: - emitEvent(Event(dimDownLongPressedEventTypeId, m_remotes.value(remote)->id())); + emitEvent(Event(hueRemoteDimDownLongPressedEventTypeId, m_remotes.value(remote)->id())); break; case HueRemote::OffPressed: - emitEvent(Event(offPressedEventTypeId, m_remotes.value(remote)->id())); + emitEvent(Event(hueRemoteOffPressedEventTypeId, m_remotes.value(remote)->id())); break; case HueRemote::OffLongPressed: - emitEvent(Event(offLongPressedEventTypeId, m_remotes.value(remote)->id())); + emitEvent(Event(hueRemoteOffLongPressedEventTypeId, m_remotes.value(remote)->id())); break; default: break; @@ -617,12 +618,12 @@ void DevicePluginPhilipsHue::onUpnpDiscoveryFinished() if (upnpDevice.modelDescription().contains("Philips")) { DeviceDescriptor descriptor(hueBridgeDeviceClassId, "Philips Hue Bridge", upnpDevice.hostAddress().toString()); ParamList params; - params.append(Param(bridgeNameParamTypeId, upnpDevice.friendlyName())); - params.append(Param(bridgeHostParamTypeId, upnpDevice.hostAddress().toString())); - params.append(Param(bridgeApiParamTypeId, QString())); - params.append(Param(bridgeMacParamTypeId, QString())); - params.append(Param(bridgeIdParamTypeId, upnpDevice.serialNumber().toLower())); - params.append(Param(bridgeZigbeeChannelParamTypeId, -1)); + 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)); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -746,12 +747,12 @@ void DevicePluginPhilipsHue::processNUpnpResponse(const QByteArray &data) QVariantMap bridgeMap = bridgeVariant.toMap(); DeviceDescriptor descriptor(hueBridgeDeviceClassId, "Philips Hue Bridge", bridgeMap.value("internalipaddress").toString()); ParamList params; - params.append(Param(bridgeNameParamTypeId, "Philips hue")); - params.append(Param(bridgeHostParamTypeId, bridgeMap.value("internalipaddress").toString())); - params.append(Param(bridgeApiParamTypeId, QString())); - params.append(Param(bridgeMacParamTypeId, QString())); - params.append(Param(bridgeIdParamTypeId, bridgeMap.value("internalipaddress").toString().toLower())); - params.append(Param(bridgeZigbeeChannelParamTypeId, -1)); + 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)); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -798,14 +799,14 @@ void DevicePluginPhilipsHue::processBridgeLightDiscoveryResponse(Device *device, if (model == "LWB004" || model == "LWB006" || model == "LWB007") { DeviceDescriptor descriptor(hueWhiteLightDeviceClassId, "Philips Hue White Light", lightMap.value("name").toString()); ParamList params; - params.append(Param(nameParamTypeId, lightMap.value("name").toString())); - params.append(Param(apiKeyParamTypeId, device->paramValue(bridgeApiParamTypeId).toString())); - params.append(Param(bridgeParamTypeId, device->id().toString())); - params.append(Param(hostParamTypeId, device->paramValue(bridgeHostParamTypeId).toString())); - params.append(Param(modelIdParamTypeId, model)); - params.append(Param(typeParamTypeId, lightMap.value("type").toString())); - params.append(Param(uuidParamTypeId, uuid)); - params.append(Param(lightIdParamTypeId, lightId)); + params.append(Param(hueWhiteLightNameParamTypeId, lightMap.value("name").toString())); + params.append(Param(hueWhiteLightApiKeyParamTypeId, device->paramValue(hueBridgeBridgeApiKeyParamTypeId).toString())); + params.append(Param(hueWhiteLightBridgeParamTypeId, device->id().toString())); + params.append(Param(hueWhiteLightHostParamTypeId, device->paramValue(hueBridgeBridgeHostParamTypeId).toString())); + params.append(Param(hueWhiteLightModelIdParamTypeId, model)); + params.append(Param(hueWhiteLightTypeParamTypeId, lightMap.value("type").toString())); + params.append(Param(hueWhiteLightUuidParamTypeId, uuid)); + params.append(Param(hueWhiteLightLightIdParamTypeId, lightId)); descriptor.setParams(params); whiteLightDescriptors.append(descriptor); @@ -814,14 +815,14 @@ void DevicePluginPhilipsHue::processBridgeLightDiscoveryResponse(Device *device, } else { DeviceDescriptor descriptor(hueLightDeviceClassId, "Philips Hue Light", lightMap.value("name").toString()); ParamList params; - params.append(Param(nameParamTypeId, lightMap.value("name").toString())); - params.append(Param(apiKeyParamTypeId, device->paramValue(bridgeApiParamTypeId).toString())); - params.append(Param(bridgeParamTypeId, device->id().toString())); - params.append(Param(hostParamTypeId, device->paramValue(bridgeHostParamTypeId).toString())); - params.append(Param(modelIdParamTypeId, model)); - params.append(Param(typeParamTypeId, lightMap.value("type").toString())); - params.append(Param(uuidParamTypeId, uuid)); - params.append(Param(lightIdParamTypeId, lightId)); + params.append(Param(hueLightNameParamTypeId, lightMap.value("name").toString())); + params.append(Param(hueLightApiKeyParamTypeId, device->paramValue(hueBridgeBridgeApiKeyParamTypeId).toString())); + params.append(Param(hueLightBridgeParamTypeId, device->id().toString())); + params.append(Param(hueLightHostParamTypeId, device->paramValue(hueBridgeBridgeHostParamTypeId).toString())); + params.append(Param(hueLightModelIdParamTypeId, model)); + params.append(Param(hueLightTypeParamTypeId, lightMap.value("type").toString())); + params.append(Param(hueLightUuidParamTypeId, uuid)); + params.append(Param(hueLightLightIdParamTypeId, lightId)); descriptor.setParams(params); lightDescriptors.append(descriptor); qCDebug(dcPhilipsHue) << "Found new color light" << lightMap.value("name").toString() << model; @@ -872,14 +873,14 @@ void DevicePluginPhilipsHue::processBridgeSensorDiscoveryResponse(Device *device if (model == "RWL021" || model == "RWL020") { DeviceDescriptor descriptor(hueRemoteDeviceClassId, "Philips Hue Remote", sensorMap.value("name").toString()); ParamList params; - params.append(Param(nameParamTypeId, sensorMap.value("name").toString())); - params.append(Param(apiKeyParamTypeId, device->paramValue(bridgeApiParamTypeId).toString())); - params.append(Param(bridgeParamTypeId, device->id().toString())); - params.append(Param(hostParamTypeId, device->paramValue(bridgeHostParamTypeId).toString())); - params.append(Param(modelIdParamTypeId, model)); - params.append(Param(typeParamTypeId, sensorMap.value("type").toString())); - params.append(Param(uuidParamTypeId, uuid)); - params.append(Param(sensorIdParamTypeId, sensorId)); + params.append(Param(hueRemoteNameParamTypeId, sensorMap.value("name").toString())); + params.append(Param(hueRemoteApiKeyParamTypeId, device->paramValue(hueBridgeBridgeApiKeyParamTypeId).toString())); + params.append(Param(hueRemoteBridgeParamTypeId, device->id().toString())); + params.append(Param(hueRemoteHostParamTypeId, device->paramValue(hueBridgeBridgeHostParamTypeId).toString())); + params.append(Param(hueRemoteModelIdParamTypeId, model)); + params.append(Param(hueRemoteTypeParamTypeId, sensorMap.value("type").toString())); + params.append(Param(hueRemoteUuidParamTypeId, uuid)); + params.append(Param(hueRemoteSensorIdParamTypeId, sensorId)); descriptor.setParams(params); sensorDescriptors.append(descriptor); qCDebug(dcPhilipsHue) << "Found new remote" << sensorMap.value("name").toString() << model; @@ -937,22 +938,22 @@ void DevicePluginPhilipsHue::processBridgeRefreshResponse(Device *device, const // mark bridge as reachable bridgeReachableChanged(device, true); - device->setStateValue(apiVersionStateTypeId, configMap.value("apiversion").toString()); - device->setStateValue(softwareVersionStateTypeId, configMap.value("swversion").toString()); + device->setStateValue(hueBridgeApiVersionStateTypeId, configMap.value("apiversion").toString()); + device->setStateValue(hueBridgeSoftwareVersionStateTypeId, configMap.value("swversion").toString()); int updateStatus = configMap.value("swupdate").toMap().value("updatestate").toInt(); switch (updateStatus) { case 0: - device->setStateValue(updateStatusStateTypeId, "Up to date"); + device->setStateValue(hueBridgeUpdateStatusStateTypeId, "Up to date"); break; case 1: - device->setStateValue(updateStatusStateTypeId, "Downloading updates"); + device->setStateValue(hueBridgeUpdateStatusStateTypeId, "Downloading updates"); break; case 2: - device->setStateValue(updateStatusStateTypeId, "Updates ready to install"); + device->setStateValue(hueBridgeUpdateStatusStateTypeId, "Updates ready to install"); break; case 3: - device->setStateValue(updateStatusStateTypeId, "Installing updates"); + device->setStateValue(hueBridgeUpdateStatusStateTypeId, "Installing updates"); break; default: break; @@ -1183,23 +1184,23 @@ void DevicePluginPhilipsHue::processActionResponse(Device *device, const ActionI void DevicePluginPhilipsHue::bridgeReachableChanged(Device *device, const bool &reachable) { if (reachable) { - device->setStateValue(bridgeReachableStateTypeId, true); + device->setStateValue(hueBridgeBridgeReachableStateTypeId, true); } else { // mark bridge and corresponding hue devices unreachable if (device->deviceClassId() == hueBridgeDeviceClassId) { - device->setStateValue(bridgeReachableStateTypeId, false); + device->setStateValue(hueBridgeBridgeReachableStateTypeId, false); foreach (HueLight *light, m_lights.keys()) { if (light->bridgeId() == device->id()) { light->setReachable(false); - m_lights.value(light)->setStateValue(hueReachableStateTypeId, false); + m_lights.value(light)->setStateValue(hueLightHueReachableStateTypeId, false); } } foreach (HueRemote *remote, m_remotes.keys()) { if (remote->bridgeId() == device->id()) { remote->setReachable(false); - m_remotes.value(remote)->setStateValue(hueReachableStateTypeId, false); + m_remotes.value(remote)->setStateValue(hueRemoteHueReachableStateTypeId, false); } } } @@ -1211,7 +1212,7 @@ bool DevicePluginPhilipsHue::bridgeAlreadyAdded(const QString &id) { foreach (Device *device, myDevices()) { if (device->deviceClassId() == hueBridgeDeviceClassId) { - if (device->paramValue(bridgeIdParamTypeId).toString() == id) { + if (device->paramValue(hueBridgeBridgeIdParamTypeId).toString() == id) { return true; } } @@ -1222,8 +1223,12 @@ bool DevicePluginPhilipsHue::bridgeAlreadyAdded(const QString &id) bool DevicePluginPhilipsHue::lightAlreadyAdded(const QString &uuid) { foreach (Device *device, myDevices()) { - if (device->deviceClassId() == hueLightDeviceClassId || device->deviceClassId() == hueWhiteLightDeviceClassId) { - if (device->paramValue(uuidParamTypeId).toString() == uuid) { + if (device->deviceClassId() == hueLightDeviceClassId) { + if (device->paramValue(hueLightUuidParamTypeId).toString() == uuid) { + return true; + } + } else if (device->deviceClassId() == hueWhiteLightDeviceClassId) { + if (device->paramValue(hueWhiteLightUuidParamTypeId).toString() == uuid) { return true; } } @@ -1235,7 +1240,7 @@ bool DevicePluginPhilipsHue::sensorAlreadyAdded(const QString &uuid) { foreach (Device *device, myDevices()) { if (device->deviceClassId() == hueRemoteDeviceClassId) { - if (device->paramValue(uuidParamTypeId).toString() == uuid) { + if (device->paramValue(hueRemoteUuidParamTypeId).toString() == uuid) { return true; } } diff --git a/philipshue/devicepluginphilipshue.json b/philipshue/devicepluginphilipshue.json index cafe53a0..b42ba95b 100644 --- a/philipshue/devicepluginphilipshue.json +++ b/philipshue/devicepluginphilipshue.json @@ -33,7 +33,7 @@ }, { "id": "8bf5776a-d5a6-4600-8b27-481f0d803a8f", - "name": "bridgeApi", + "name": "bridgeApiKey", "displayName": "api key", "type" : "QString", "inputType": "TextLine", diff --git a/plantcare/devicepluginplantcare.cpp b/plantcare/devicepluginplantcare.cpp index f37f75f8..f15c4aa2 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(hostParamTypeId).toString()))) { + if (deviceAlreadyAdded(QHostAddress(device->paramValue(plantCareHostParamTypeId).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(rplParamTypeId).toString()); + QHostAddress address(configuration().paramValue(PlantCareRplParamTypeId).toString()); qCDebug(dcPlantCare) << "Scan for new nodes on RPL" << address.toString(); QUrl url; @@ -123,16 +123,16 @@ DeviceManager::DeviceError DevicePluginPlantCare::executeAction(Device *device, qCDebug(dcPlantCare) << "Execute action" << device->name() << action.params(); // Check if the device is reachable - if (!device->stateValue(reachableStateTypeId).toBool()) { + if (!device->stateValue(plantCareReachableStateTypeId).toBool()) { qCWarning(dcPlantCare) << "Device not reachable."; return DeviceManager::DeviceErrorHardwareNotAvailable; } // Check which action sould be executed - if (action.actionTypeId() == toggleLedActionTypeId) { + if (action.actionTypeId() == plantCareToggleLedActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); url.setPath("/a/toggle"); CoapReply *reply = m_coap->post(CoapRequest(url)); @@ -147,12 +147,12 @@ DeviceManager::DeviceError DevicePluginPlantCare::executeAction(Device *device, m_asyncActions.insert(action.id(), device); return DeviceManager::DeviceErrorAsync; - } else if(action.actionTypeId() == ledPowerActionTypeId) { - int power = action.param(ledPowerStateParamTypeId).value().toInt(); + } else if(action.actionTypeId() == plantCareLedPowerActionTypeId) { + int power = action.param(plantCareLedPowerStateParamTypeId).value().toInt(); QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); url.setPath("/a/light"); QByteArray payload = QString("pwm=%1").arg(QString::number(power)).toUtf8(); @@ -169,12 +169,12 @@ DeviceManager::DeviceError DevicePluginPlantCare::executeAction(Device *device, m_asyncActions.insert(action.id(), device); return DeviceManager::DeviceErrorAsync; - } else if(action.actionTypeId() == waterPumpActionTypeId) { - bool pump = action.param(waterPumpStateParamTypeId).value().toBool(); + } else if(action.actionTypeId() == plantCareWaterPumpActionTypeId) { + bool pump = action.param(plantCareWaterPumpStateParamTypeId).value().toBool(); QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).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(hostParamTypeId).toString()); + url.setHost(device->paramValue(plantCareHostParamTypeId).toString()); url.setPath("/s/water"); m_enableNotification.insert(m_coap->enableResourceNotifications(CoapRequest(url)), device); @@ -316,7 +316,7 @@ void DevicePluginPlantCare::enableNotifications(Device *device) void DevicePluginPlantCare::setReachable(Device *device, const bool &reachable) { - if (device->stateValue(reachableStateTypeId).toBool() != reachable) { + if (device->stateValue(plantCareReachableStateTypeId).toBool() != reachable) { if (!reachable) { // Warn just once that the device is not reachable qCWarning(dcPlantCare()) << device->name() << "reachable changed" << reachable; @@ -335,14 +335,14 @@ void DevicePluginPlantCare::setReachable(Device *device, const bool &reachable) } } - device->setStateValue(reachableStateTypeId, reachable); + device->setStateValue(plantCareReachableStateTypeId, reachable); } bool DevicePluginPlantCare::deviceAlreadyAdded(const QHostAddress &address) { // Check if we already have a device with the given address foreach (Device *device, myDevices()) { - if (device->paramValue(hostParamTypeId).toString() == address.toString()) { + if (device->paramValue(plantCareHostParamTypeId).toString() == address.toString()) { return true; } } @@ -353,7 +353,7 @@ Device *DevicePluginPlantCare::findDevice(const QHostAddress &address) { // Return the device pointer with the given address (otherwise 0) foreach (Device *device, myDevices()) { - if (device->paramValue(hostParamTypeId).toString() == address.toString()) { + if (device->paramValue(plantCareHostParamTypeId).toString() == address.toString()) { return device; } } @@ -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(hostParamTypeId, address.toString())); + params.append(Param(plantCareHostParamTypeId, address.toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -421,7 +421,7 @@ void DevicePluginPlantCare::coapReplyFinished(CoapReply *reply) // Check CoAP reply error if (reply->error() != CoapReply::NoError) { - if (device->stateValue(reachableStateTypeId).toBool()) + if (device->stateValue(plantCareReachableStateTypeId).toBool()) qCWarning(dcPlantCare) << "Ping device" << reply->request().url().toString() << "reply finished with error" << reply->errorString(); setReachable(device, false); @@ -452,23 +452,23 @@ void DevicePluginPlantCare::coapReplyFinished(CoapReply *reply) // Update corresponding device state if (urlPath == "/s/moisture") { qCDebug(dcPlantCare()) << "Updated moisture value:" << reply->payload(); - device->setStateValue(moistureStateTypeId, qRound(reply->payload().toInt() * 100.0 / 1023.0)); + device->setStateValue(plantCareMoistureStateTypeId, qRound(reply->payload().toInt() * 100.0 / 1023.0)); } else if (urlPath == "/s/water") { qCDebug(dcPlantCare()) << "Updated water value:" << reply->payload(); - device->setStateValue(waterStateTypeId, QVariant(reply->payload().toInt()).toBool()); + device->setStateValue(plantCareWaterStateTypeId, QVariant(reply->payload().toInt()).toBool()); } else if (urlPath == "/s/battery") { qCDebug(dcPlantCare()) << "Updated battery value:" << reply->payload(); - device->setStateValue(batteryStateTypeId, reply->payload().toDouble()); + device->setStateValue(plantCareBatteryStateTypeId, reply->payload().toDouble()); } else if (urlPath == "/a/pump") { qCDebug(dcPlantCare()) << "Updated pump value:" << reply->payload(); - device->setStateValue(waterPumpStateTypeId, QVariant(reply->payload().toInt()).toBool()); + device->setStateValue(plantCareWaterPumpStateTypeId, QVariant(reply->payload().toInt()).toBool()); } else if (urlPath == "/a/light") { qCDebug(dcPlantCare()) << "Updated led power value:" << reply->payload(); int powerValue = reply->payload().toInt(); if (powerValue > 0) { - device->setStateValue(ledPowerStateTypeId, false); + device->setStateValue(plantCareLedPowerStateTypeId, false); } else { - device->setStateValue(ledPowerStateTypeId, true); + device->setStateValue(plantCareLedPowerStateTypeId, true); } } @@ -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(ledPowerStateTypeId, action.param(ledPowerStateParamTypeId).value().toBool()); + device->setStateValue(plantCareLedPowerStateTypeId, action.param(plantCareLedPowerStateParamTypeId).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(waterPumpStateTypeId, action.param(waterPumpStateParamTypeId).value().toBool()); + device->setStateValue(plantCareWaterPumpStateTypeId, action.param(plantCareWaterPumpStateParamTypeId).value().toBool()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -583,19 +583,19 @@ void DevicePluginPlantCare::onNotificationReceived(const CoapObserveResource &re // Update the corresponding device state if (resource.url().path() == "/s/moisture") { - device->setStateValue(moistureStateTypeId, qRound(payload.toInt() * 100.0 / 1023.0)); + device->setStateValue(plantCareMoistureStateTypeId, qRound(payload.toInt() * 100.0 / 1023.0)); } else if (resource.url().path() == "/s/water") { - device->setStateValue(waterStateTypeId, QVariant(payload.toInt()).toBool()); + device->setStateValue(plantCareWaterStateTypeId, QVariant(payload.toInt()).toBool()); } else if (resource.url().path() == "/s/battery") { - device->setStateValue(batteryStateTypeId, payload.toDouble()); + device->setStateValue(plantCareBatteryStateTypeId, payload.toDouble()); } else if (resource.url().path() == "/a/pump") { - device->setStateValue(waterPumpStateTypeId, QVariant(payload.toInt()).toBool()); + device->setStateValue(plantCareWaterPumpStateTypeId, QVariant(payload.toInt()).toBool()); } else if (resource.url().path() == "/a/light") { int powerValue = QVariant(payload).toInt(); if (powerValue > 0) { - device->setStateValue(ledPowerStateTypeId, false); + device->setStateValue(plantCareLedPowerStateTypeId, false); } else { - device->setStateValue(ledPowerStateTypeId, true); + device->setStateValue(plantCareLedPowerStateTypeId, true); } } } diff --git a/senic/devicepluginsenic.cpp b/senic/devicepluginsenic.cpp index d09d848e..a9f3400a 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(nameParamTypeId).toString(); - QBluetoothAddress address = QBluetoothAddress(device->paramValue(macParamTypeId).toString()); + QString name = device->paramValue(nuimoNameParamTypeId).toString(); + QBluetoothAddress address = QBluetoothAddress(device->paramValue(nuimoMacParamTypeId).toString()); QBluetoothDeviceInfo deviceInfo = QBluetoothDeviceInfo(address, name, 0); BluetoothLowEnergyDevice *bluetoothDevice = hardwareManager()->bluetoothLowEnergyManager()->registerDevice(deviceInfo, QLowEnergyController::RandomAddress); @@ -101,15 +101,14 @@ DeviceManager::DeviceError DevicePluginSenic::executeAction(Device *device, cons if (nuimo.isNull()) return DeviceManager::DeviceErrorHardwareFailure; - if (action.actionTypeId() == showLogoActionTypeId) { - - if (action.param(logoParamTypeId).value().toString() == "Guh") + if (action.actionTypeId() == nuimoShowLogoActionTypeId) { + if (action.param(nuimoLogoParamTypeId).value().toString() == "Guh") nuimo->showGuhLogo(); - if (action.param(logoParamTypeId).value().toString() == "Arrow up") + if (action.param(nuimoLogoParamTypeId).value().toString() == "Arrow up") nuimo->showArrowUp(); - if (action.param(logoParamTypeId).value().toString() == "Arrow down") + if (action.param(nuimoLogoParamTypeId).value().toString() == "Arrow down") nuimo->showArrowDown(); return DeviceManager::DeviceErrorNoError; @@ -131,7 +130,7 @@ void DevicePluginSenic::deviceRemoved(Device *device) bool DevicePluginSenic::verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo) { foreach (Device *device, myDevices()) { - if (device->paramValue(macParamTypeId).toString() == deviceInfo.address().toString()) + if (device->paramValue(nuimoMacParamTypeId).toString() == deviceInfo.address().toString()) return true; } @@ -164,8 +163,8 @@ void DevicePluginSenic::onBluetoothDiscoveryFinished() if (!verifyExistingDevices(deviceInfo)) { DeviceDescriptor descriptor(nuimoDeviceClassId, "Nuimo", deviceInfo.address().toString()); ParamList params; - params.append(Param(nameParamTypeId, deviceInfo.name())); - params.append(Param(macParamTypeId, deviceInfo.address().toString())); + params.append(Param(nuimoNameParamTypeId, deviceInfo.name())); + params.append(Param(nuimoMacParamTypeId, deviceInfo.address().toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -181,7 +180,7 @@ void DevicePluginSenic::onButtonPressed() { Nuimo *nuimo = static_cast(sender()); Device *device = m_nuimos.value(nuimo); - emitEvent(Event(clickedEventTypeId, device->id())); + emitEvent(Event(nuimoClickedEventTypeId, device->id())); } void DevicePluginSenic::onButtonReleased() @@ -196,16 +195,16 @@ void DevicePluginSenic::onSwipeDetected(const Nuimo::SwipeDirection &direction) switch (direction) { case Nuimo::SwipeDirectionLeft: - emitEvent(Event(swipeLeftEventTypeId, device->id())); + emitEvent(Event(nuimoSwipeLeftEventTypeId, device->id())); break; case Nuimo::SwipeDirectionRight: - emitEvent(Event(swipeRightEventTypeId, device->id())); + emitEvent(Event(nuimoSwipeRightEventTypeId, device->id())); break; case Nuimo::SwipeDirectionUp: - emitEvent(Event(swipeUpEventTypeId, device->id())); + emitEvent(Event(nuimoSwipeUpEventTypeId, device->id())); break; case Nuimo::SwipeDirectionDown: - emitEvent(Event(swipeDownEventTypeId, device->id())); + emitEvent(Event(nuimoSwipeDownEventTypeId, device->id())); break; default: break; @@ -216,7 +215,7 @@ void DevicePluginSenic::onRotationValueChanged(const uint &value) { Nuimo *nuimo = static_cast(sender()); Device *device = m_nuimos.value(nuimo); - device->setStateValue(rotationStateTypeId, value); + device->setStateValue(nuimoRotationStateTypeId, value); } diff --git a/senic/nuimo.cpp b/senic/nuimo.cpp index 89a51d06..0cf51557 100644 --- a/senic/nuimo.cpp +++ b/senic/nuimo.cpp @@ -143,13 +143,13 @@ void Nuimo::setBatteryValue(const QByteArray &data) int batteryPercentage = data.toHex().toUInt(0, 16); qCDebug(dcSenic()) << "Battery:" << batteryPercentage << "%"; - device()->setStateValue(batteryStateTypeId, batteryPercentage); + device()->setStateValue(nuimoBatteryStateTypeId, batteryPercentage); } void Nuimo::onConnectedChanged(const bool &connected) { qCDebug(dcSenic()) << m_bluetoothDevice->name() << m_bluetoothDevice->address().toString() << (connected ? "connected" : "disconnected"); - m_device->setStateValue(connectedStateTypeId, connected); + m_device->setStateValue(nuimoConnectedStateTypeId, connected); if (!connected) { // Clean up services @@ -264,9 +264,9 @@ void Nuimo::onDeviceInfoServiceStateChanged(const QLowEnergyService::ServiceStat printService(m_deviceInfoService); - device()->setStateValue(firmwareRevisionStateTypeId, QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::FirmwareRevisionString).value())); - device()->setStateValue(hardwareRevisionStateTypeId, QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::HardwareRevisionString).value())); - device()->setStateValue(softwareRevisionStateTypeId, QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::SoftwareRevisionString).value())); + device()->setStateValue(nuimoFirmwareRevisionStateTypeId, QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::FirmwareRevisionString).value())); + device()->setStateValue(nuimoHardwareRevisionStateTypeId, QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::HardwareRevisionString).value())); + device()->setStateValue(nuimoSoftwareRevisionStateTypeId, QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::SoftwareRevisionString).value())); } diff --git a/tcpcommander/deviceplugintcpcommander.cpp b/tcpcommander/deviceplugintcpcommander.cpp index c22f54e9..bc3f2042 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(portParamTypeId).toInt(); + int port = device->paramValue(tcpInputPortParamTypeId).toInt(); TcpServer *tcpServer = new TcpServer(port, this); if (tcpServer->isValid()) { @@ -59,9 +59,9 @@ DeviceManager::DeviceError DevicePluginTcpCommander::executeAction(Device *devic { if (device->deviceClassId() == tcpOutputDeviceClassId) { - if (action.actionTypeId() == outputDataActionTypeId) { - int port = device->paramValue(portParamTypeId).toInt(); - QHostAddress address= QHostAddress(device->paramValue(ipv4addressParamTypeId).toString()); + if (action.actionTypeId() == tcpOutputOutputDataActionTypeId) { + int port = device->paramValue(tcpOutputPortParamTypeId).toInt(); + QHostAddress address= QHostAddress(device->paramValue(tcpOutputIpv4addressParamTypeId).toString()); QTcpSocket *tcpSocket = m_tcpSockets.key(device); tcpSocket->connectToHost(address, port); return DeviceManager::DeviceErrorNoError; @@ -93,14 +93,23 @@ void DevicePluginTcpCommander::onTcpSocketConnected() { QTcpSocket *tcpSocket = static_cast(sender()); Device *device = m_tcpSockets.value(tcpSocket); - if (!device->setupComplete()) { - qDebug(dcTCPCommander()) << device->name() << "Setup finished" ; - emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess); - } else { - QByteArray data = device->paramValue(outputDataAreaParamTypeId).toByteArray(); - tcpSocket->write(data); + if (device->deviceClassId() == tcpOutputDeviceClassId) { + if (!device->setupComplete()) { + qDebug(dcTCPCommander()) << device->name() << "Setup finished" ; + emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess); + } else { + QByteArray data = device->paramValue(tcpOutputOutputDataAreaParamTypeId).toByteArray(); + tcpSocket->write(data); + } + device->setStateValue(tcpOutputConnectedStateTypeId, true); + } + if (device->deviceClassId() == tcpInputDeviceClassId) { + if (!device->setupComplete()) { + qDebug(dcTCPCommander()) << device->name() << "Setup finished" ; + emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess); + } + device->setStateValue(tcpInputConnectedStateTypeId, true); } - device->setStateValue(connectedStateTypeId, true); } @@ -108,7 +117,11 @@ void DevicePluginTcpCommander::onTcpSocketDisconnected() { QTcpSocket *tcpSocket = static_cast(sender()); Device *device = m_tcpSockets.value(tcpSocket); - device->setStateValue(connectedStateTypeId, false); + if (device->deviceClassId() == tcpInputDeviceClassId) { + device->setStateValue(tcpInputConnectedStateTypeId, false); + } else if (device->deviceClassId() == tcpOutputDeviceClassId) { + device->setStateValue(tcpOutputConnectedStateTypeId, false); + } } @@ -123,7 +136,11 @@ void DevicePluginTcpCommander::onTcpServerConnected() TcpServer *tcpServer = static_cast(sender()); Device *device = m_tcpServer.value(tcpServer); qDebug(dcTCPCommander()) << device->name() << "Tcp Server Client connected" ; - device->setStateValue(connectedStateTypeId, true); + if (device->deviceClassId() == tcpInputDeviceClassId) { + device->setStateValue(tcpInputConnectedStateTypeId, true); + } else if (device->deviceClassId() == tcpOutputDeviceClassId) { + device->setStateValue(tcpOutputConnectedStateTypeId, true); + } connect(tcpServer, &TcpServer::textMessageReceived, this, &DevicePluginTcpCommander::onTcpServerTextMessageReceived); //send signal device Setup was successfull @@ -135,7 +152,11 @@ void DevicePluginTcpCommander::onTcpServerDisconnected() TcpServer *tcpServer = static_cast(sender()); Device *device = m_tcpServer.value(tcpServer); qDebug(dcTCPCommander()) << device->name() << "Tcp Server Client disconnected" ; - device->setStateValue(connectedStateTypeId, false); + if (device->deviceClassId() == tcpInputDeviceClassId) { + device->setStateValue(tcpInputConnectedStateTypeId, false); + } else if (device->deviceClassId() == tcpOutputDeviceClassId) { + device->setStateValue(tcpOutputConnectedStateTypeId, false); + } } void DevicePluginTcpCommander::onTcpServerTextMessageReceived(QByteArray data) @@ -143,30 +164,30 @@ void DevicePluginTcpCommander::onTcpServerTextMessageReceived(QByteArray data) TcpServer *tcpServer = static_cast(sender()); Device *device = m_tcpServer.value(tcpServer); qDebug(dcTCPCommander()) << device->name() << "Message received" << data; - device->setStateValue(dataReceivedStateTypeId, data); + device->setStateValue(tcpInputDataReceivedStateTypeId, data); - if (device->paramValue(comparisionParamTypeId).toString() == "Is exactly") { + if (device->paramValue(tcpInputComparisionParamTypeId).toString() == "Is exactly") { qDebug(dcTCPCommander()) << "is exacly"; - if (data == device->paramValue(inputDataParamTypeId)) { + if (data == device->paramValue(tcpInputInputDataParamTypeId)) { qDebug(dcTCPCommander()) << "comparison successful"; - emitEvent(Event(commandReceivedEventTypeId, device->id())); + emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); } - } else if (device->paramValue(comparisionParamTypeId).toString() == "Contains") { - if (data.contains(device->paramValue(inputDataParamTypeId).toByteArray())) { - emitEvent(Event(commandReceivedEventTypeId, device->id())); + } else if (device->paramValue(tcpInputComparisionParamTypeId).toString() == "Contains") { + if (data.contains(device->paramValue(tcpInputInputDataParamTypeId).toByteArray())) { + emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); } - } else if (device->paramValue(comparisionParamTypeId) == "Contains not") { - if (!data.contains(device->paramValue(inputDataParamTypeId).toByteArray())) - emitEvent(Event(commandReceivedEventTypeId, device->id())); + } else if (device->paramValue(tcpInputComparisionParamTypeId) == "Contains not") { + if (!data.contains(device->paramValue(tcpInputInputDataParamTypeId).toByteArray())) + emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); - } else if (device->paramValue(comparisionParamTypeId) == "Starts with") { - if (data.startsWith(device->paramValue(inputDataParamTypeId).toByteArray())) - emitEvent(Event(commandReceivedEventTypeId, device->id())); + } else if (device->paramValue(tcpInputComparisionParamTypeId) == "Starts with") { + if (data.startsWith(device->paramValue(tcpInputInputDataParamTypeId).toByteArray())) + emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); - } else if (device->paramValue(comparisionParamTypeId) == "Ends with") { - if (data.endsWith(device->paramValue(inputDataParamTypeId).toByteArray())) - emitEvent(Event(commandReceivedEventTypeId, device->id())); + } else if (device->paramValue(tcpInputComparisionParamTypeId) == "Ends with") { + if (data.endsWith(device->paramValue(tcpInputInputDataParamTypeId).toByteArray())) + emitEvent(Event(tcpInputCommandReceivedEventTypeId, device->id())); } } diff --git a/udpcommander/devicepluginudpcommander.cpp b/udpcommander/devicepluginudpcommander.cpp index 3f8f538d..8eddefac 100644 --- a/udpcommander/devicepluginudpcommander.cpp +++ b/udpcommander/devicepluginudpcommander.cpp @@ -71,9 +71,9 @@ DeviceManager::DeviceSetupStatus DevicePluginUdpCommander::setupDevice(Device *d { // check port bool portOk = false; - int port = device->paramValue(portParamTypeId).toInt(&portOk); + int port = device->paramValue(commanderPortParamTypeId).toInt(&portOk); if (!portOk || port <= 0 || port > 65535) { - qCWarning(dcUdpCommander) << device->name() << ": invalid port:" << device->paramValue(portParamTypeId).toString() << "."; + qCWarning(dcUdpCommander) << device->name() << ": invalid port:" << device->paramValue(commanderPortParamTypeId).toString() << "."; return DeviceManager::DeviceSetupStatusFailure; } @@ -114,10 +114,10 @@ void DevicePluginUdpCommander::readPendingDatagrams() socket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort); } - if (datagram == device->paramValue(commandParamTypeId).toByteArray() || - datagram == device->paramValue(commandParamTypeId).toByteArray() + "\n") { + if (datagram == device->paramValue(commanderCommandParamTypeId).toByteArray() || + datagram == device->paramValue(commanderCommandParamTypeId).toByteArray() + "\n") { qCDebug(dcUdpCommander) << device->name() << " got command from" << sender.toString() << senderPort; - emit emitEvent(Event(commandReceivedEventTypeId, device->id())); + emit emitEvent(Event(commanderCommandReceivedEventTypeId, device->id())); socket->writeDatagram("OK\n", sender, senderPort); } } diff --git a/unitec/devicepluginunitec.cpp b/unitec/devicepluginunitec.cpp index 9c6333b7..bdda754f 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(channelParamTypeId).toString() == device->paramValue(channelParamTypeId).toString()) { - qCWarning(dcUnitec) << "Unitec switch with channel " << device->paramValue(channelParamTypeId).toString() << "already added."; + if (d->paramValue(switchChannelParamTypeId).toString() == device->paramValue(switchChannelParamTypeId).toString()) { + qCWarning(dcUnitec) << "Unitec switch with channel " << device->paramValue(switchChannelParamTypeId).toString() << "already added."; return DeviceManager::DeviceSetupStatusFailure; } } @@ -83,26 +83,26 @@ DeviceManager::DeviceError DevicePluginUnitec::executeAction(Device *device, con QList rawData; QByteArray binCode; - if (action.actionTypeId() != powerActionTypeId) { + if (action.actionTypeId() != switchPowerActionTypeId) { return DeviceManager::DeviceErrorActionTypeNotFound; } // Bin codes for buttons - if (device->paramValue(channelParamTypeId).toString() == "A" && action.param(powerParamTypeId).value().toBool() == true) { + if (device->paramValue(switchChannelParamTypeId).toString() == "A" && action.param(switchPowerParamTypeId).value().toBool() == true) { binCode.append("111011000100111010111111"); - } else if (device->paramValue(channelParamTypeId).toString() == "A" && action.param(powerParamTypeId).value().toBool() == false) { + } else if (device->paramValue(switchChannelParamTypeId).toString() == "A" && action.param(switchPowerParamTypeId).value().toBool() == false) { binCode.append("111001100110100001011111"); - } else if (device->paramValue(channelParamTypeId).toString() == "B" && action.param(powerParamTypeId).value().toBool() == true) { + } else if (device->paramValue(switchChannelParamTypeId).toString() == "B" && action.param(switchPowerParamTypeId).value().toBool() == true) { binCode.append("111011000100111010111011"); - } else if (device->paramValue(channelParamTypeId).toString() == "B" && action.param(powerParamTypeId).value().toBool() == false) { + } else if (device->paramValue(switchChannelParamTypeId).toString() == "B" && action.param(switchPowerParamTypeId).value().toBool() == false) { binCode.append("111000111001100111101011"); - } else if (device->paramValue(channelParamTypeId).toString() == "C" && action.param(powerParamTypeId).value().toBool() == true) { + } else if (device->paramValue(switchChannelParamTypeId).toString() == "C" && action.param(switchPowerParamTypeId).value().toBool() == true) { binCode.append("111000000011011111000011"); - } else if (device->paramValue(channelParamTypeId).toString() == "C" && action.param(powerParamTypeId).value().toBool() == false) { + } else if (device->paramValue(switchChannelParamTypeId).toString() == "C" && action.param(switchPowerParamTypeId).value().toBool() == false) { binCode.append("111001100110100001010011"); - } else if (device->paramValue(channelParamTypeId).toString() == "D" && action.param(powerParamTypeId).value().toBool() == true) { + } else if (device->paramValue(switchChannelParamTypeId).toString() == "D" && action.param(switchPowerParamTypeId).value().toBool() == true) { binCode.append("111001100110100001011101"); - } else if (device->paramValue(channelParamTypeId).toString() == "D" && action.param(powerParamTypeId).value().toBool() == false) { + } else if (device->paramValue(switchChannelParamTypeId).toString() == "D" && action.param(switchPowerParamTypeId).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(powerParamTypeId).value().toBool(); + qCDebug(dcUnitec) << "transmitted" << pluginName() << device->name() << "power: " << action.param(switchPowerParamTypeId).value().toBool(); }else{ - qCWarning(dcUnitec) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(powerParamTypeId).value().toBool(); + qCWarning(dcUnitec) << "could not transmitt" << pluginName() << device->name() << "power: " << action.param(switchPowerParamTypeId).value().toBool(); return DeviceManager::DeviceErrorHardwareNotAvailable; } diff --git a/wakeonlan/devicepluginwakeonlan.cpp b/wakeonlan/devicepluginwakeonlan.cpp index 3eaf9a99..cb3b09a7 100644 --- a/wakeonlan/devicepluginwakeonlan.cpp +++ b/wakeonlan/devicepluginwakeonlan.cpp @@ -60,9 +60,9 @@ DevicePluginWakeOnLan::DevicePluginWakeOnLan() DeviceManager::DeviceError DevicePluginWakeOnLan::executeAction(Device *device, const Action &action) { - if(action.actionTypeId() == wolActionTypeId){ + if(action.actionTypeId() == wolWolActionTypeId){ qCDebug(dcWakeOnLan) << "Wake up" << device->name(); - wakeup(device->paramValue(macParamTypeId).toString()); + wakeup(device->paramValue(wolMacParamTypeId).toString()); } return DeviceManager::DeviceErrorNoError; } diff --git a/wemo/devicepluginwemo.cpp b/wemo/devicepluginwemo.cpp index 762ab0a3..d7343fb4 100644 --- a/wemo/devicepluginwemo.cpp +++ b/wemo/devicepluginwemo.cpp @@ -102,11 +102,11 @@ DeviceManager::DeviceError DevicePluginWemo::executeAction(Device *device, const return DeviceManager::DeviceErrorDeviceClassNotFound; // Set power - if (action.actionTypeId() == powerActionTypeId) { + if (action.actionTypeId() == wemoSwitchPowerActionTypeId) { // Check if wemo device is reachable - if (device->stateValue(reachableStateTypeId).toBool()) { + if (device->stateValue(wemoSwitchReachableStateTypeId).toBool()) { // setPower returns false, if the curent powerState is allready the new powerState - if (setPower(device, action.param(powerStateParamTypeId).value().toBool(), action.id())) { + if (setPower(device, action.param(wemoSwitchPowerStateParamTypeId).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(hostParamTypeId).toString() + ":" + device->paramValue(portParamTypeId).toString() + "/upnp/control/basicevent1")); + request.setUrl(QUrl("http://" + device->paramValue(wemoSwitchHostParamTypeId).toString() + ":" + device->paramValue(wemoSwitchPortParamTypeId).toString() + "/upnp/control/basicevent1")); request.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("text/xml; charset=\"utf-8\"")); request.setHeader(QNetworkRequest::UserAgentHeader,QVariant("guh")); request.setRawHeader("SOAPACTION", "\"urn:Belkin:service:basicevent:1#GetBinaryState\""); @@ -156,14 +156,14 @@ void DevicePluginWemo::refresh(Device *device) bool DevicePluginWemo::setPower(Device *device, const bool &power, const ActionId &actionId) { // check if the power would change... - if (device->stateValue(powerStateTypeId).toBool() == power) { + if (device->stateValue(wemoSwitchPowerStateTypeId).toBool() == power) { return false; } QByteArray setPowerMessage("" + QByteArray::number((int)power) + ""); QNetworkRequest request; - request.setUrl(QUrl("http://" + device->paramValue(hostParamTypeId).toString() + ":" + device->paramValue(portParamTypeId).toString() + "/upnp/control/basicevent1")); + request.setUrl(QUrl("http://" + device->paramValue(wemoSwitchHostParamTypeId).toString() + ":" + device->paramValue(wemoSwitchPortParamTypeId).toString() + "/upnp/control/basicevent1")); request.setHeader(QNetworkRequest::ContentTypeHeader,QVariant("text/xml; charset=\"utf-8\"")); request.setHeader(QNetworkRequest::UserAgentHeader,QVariant("guh")); request.setRawHeader("SOAPACTION", "\"urn:Belkin:service:basicevent:1#SetBinaryState\""); @@ -179,13 +179,13 @@ bool DevicePluginWemo::setPower(Device *device, const bool &power, const ActionI void DevicePluginWemo::processRefreshData(const QByteArray &data, Device *device) { if (data.contains("0")) { - device->setStateValue(powerStateTypeId, false); - device->setStateValue(reachableStateTypeId, true); + device->setStateValue(wemoSwitchPowerStateTypeId, false); + device->setStateValue(wemoSwitchReachableStateTypeId, true); } else if (data.contains("1")) { - device->setStateValue(powerStateTypeId, true); - device->setStateValue(reachableStateTypeId, true); + device->setStateValue(wemoSwitchPowerStateTypeId, true); + device->setStateValue(wemoSwitchReachableStateTypeId, true); } else { - device->setStateValue(reachableStateTypeId, false); + device->setStateValue(wemoSwitchReachableStateTypeId, false); } } @@ -193,10 +193,10 @@ void DevicePluginWemo::processSetPowerData(const QByteArray &data, Device *devic { if (data.contains("1") || data.contains("0")) { emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorNoError); - device->setStateValue(reachableStateTypeId, true); + device->setStateValue(wemoSwitchReachableStateTypeId, true); refresh(device); } else { - device->setStateValue(reachableStateTypeId, false); + device->setStateValue(wemoSwitchReachableStateTypeId, false); emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorHardwareNotAvailable); } } @@ -249,10 +249,10 @@ void DevicePluginWemo::onUpnpDiscoveryFinished() if (upnpDeviceDescriptor.friendlyName() == "WeMo Switch") { DeviceDescriptor descriptor(wemoSwitchDeviceClassId, "WeMo Switch", upnpDeviceDescriptor.serialNumber()); ParamList params; - params.append(Param(nameParamTypeId, upnpDeviceDescriptor.friendlyName())); - params.append(Param(hostParamTypeId, upnpDeviceDescriptor.hostAddress().toString())); - params.append(Param(portParamTypeId, upnpDeviceDescriptor.port())); - params.append(Param(serialParamTypeId, upnpDeviceDescriptor.serialNumber())); + 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())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } diff --git a/ws2812/devicepluginws2812.cpp b/ws2812/devicepluginws2812.cpp index ccab78b5..180545e7 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(hostParamTypeId).toString()))) { + if (deviceAlreadyAdded(QHostAddress(device->paramValue(ws2812HostParamTypeId).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(rplParamTypeId).toString()); + QHostAddress address(configuration().paramValue(Ws2812RplParamTypeId).toString()); qCDebug(dcWs2812) << "Scan for new nodes on RPL" << address.toString(); QUrl url; @@ -128,19 +128,19 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con qCDebug(dcWs2812) << "Execute action" << device->name() << action.params(); // Check if the device is reachable - if (!device->stateValue(reachableStateTypeId).toBool()) { + if (!device->stateValue(ws2812ReachableStateTypeId).toBool()) { qCWarning(dcWs2812) << "Device not reachable."; return DeviceManager::DeviceErrorHardwareNotAvailable; } - if(action.actionTypeId() == effectColorActionTypeId) { + if(action.actionTypeId() == ws2812EffectColorActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/a/color"); - QColor newColor = action.param(effectModeStateParamTypeId).value().value().toRgb(); + QColor newColor = action.param(ws2812EffectModeStateParamTypeId).value().value().toRgb(); QByteArray message = "color=" + newColor.name().remove("#").toUtf8(); qCDebug(dcWs2812) << "Sending" << url.toString() << message; @@ -157,14 +157,14 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con return DeviceManager::DeviceErrorAsync; - } else if(action.actionTypeId() == speedActionTypeId) { + } else if(action.actionTypeId() == ws2812SpeedActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/a/speed"); - int speed = action.param(speedStateParamTypeId).value().toInt(); + int speed = action.param(ws2812SpeedStateParamTypeId).value().toInt(); qCDebug(dcWs2812) << "Set Speed:" << speed; @@ -183,15 +183,14 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con return DeviceManager::DeviceErrorAsync; - } else if(action.actionTypeId() == brightnessActionTypeId) { - + } else if(action.actionTypeId() == ws2812BrightnessActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/a/brightness"); - int brightness = action.param(brightnessStateParamTypeId).value().toInt(); + int brightness = action.param(ws2812BrightnessStateParamTypeId).value().toInt(); qCDebug(dcWs2812) << "Set brightness:" << brightness; @@ -210,18 +209,18 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con return DeviceManager::DeviceErrorAsync; - } else if(action.actionTypeId() == maxPixActionTypeId) { + }else if(action.actionTypeId() == ws2812MaxPixActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).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(maxPixStateParamTypeId).value().toInt(); + int max = action.param(ws2812MaxPixStateParamTypeId).value().toInt(); qCDebug(dcWs2812) << "Max Pix" << max; @@ -243,16 +242,16 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con return DeviceManager::DeviceErrorAsync; - } else if(action.actionTypeId() == effectModeActionTypeId) { + }else if(action.actionTypeId() == ws2812EffectModeActionTypeId) { int effectmode = 0; - QString effectModeString = action.param(effectModeStateParamTypeId).value().toString(); + QString effectModeString = action.param(ws2812EffectModeStateParamTypeId).value().toString(); QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/a/effect"); qCDebug(dcWs2812) << "Set effect mode to:" << effectModeString; @@ -296,11 +295,11 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con m_asyncActions.insert(action.id(), device); return DeviceManager::DeviceErrorAsync; - } else if(action.actionTypeId() == tcolor1ActionTypeId || action.actionTypeId() == tcolor2ActionTypeId || action.actionTypeId() == tcolor3ActionTypeId) { + }else if(action.actionTypeId() == ws2812Tcolor1ActionTypeId || action.actionTypeId() == ws2812Tcolor2ActionTypeId || action.actionTypeId() == ws2812Tcolor3ActionTypeId) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/a/tcolor"); @@ -311,12 +310,12 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con * */ - if(action.actionTypeId() == tcolor1ActionTypeId) { - tColor1 = action.param(tcolor1StateParamTypeId).value().value().toRgb(); - } else if(action.actionTypeId() == tcolor2ActionTypeId){ - tColor2 = action.param(tcolor2StateParamTypeId).value().value().toRgb(); - } else if(action.actionTypeId() == tcolor3ActionTypeId){ - tColor3 = action.param(tcolor3StateParamTypeId).value().value().toRgb(); + if(action.actionTypeId() == ws2812Tcolor1ActionTypeId) { + tColor1 = action.param(ws2812Tcolor1StateParamTypeId).value().value().toRgb(); + } else if(action.actionTypeId() == ws2812Tcolor2ActionTypeId){ + tColor2 = action.param(ws2812Tcolor2StateParamTypeId).value().value().toRgb(); + } else if(action.actionTypeId() == ws2812Tcolor3ActionTypeId){ + tColor3 = action.param(ws2812Tcolor3StateParamTypeId).value().value().toRgb(); } QByteArray message = "color=" + tColor1.name().remove("#").toUtf8() + tColor2.name().remove("#").toUtf8() + tColor3.name().remove("#").toUtf8(); @@ -341,7 +340,7 @@ void DevicePluginWs2812::pingDevice(Device *device) { QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); m_pingReplies.insert(m_coap->ping(CoapRequest(url)), device); } @@ -350,7 +349,7 @@ void DevicePluginWs2812::updateBattery(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "battery value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/s/battery"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -369,7 +368,7 @@ void DevicePluginWs2812::updateColor(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "color value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/a/color"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -386,7 +385,7 @@ void DevicePluginWs2812::updateTricolore(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "tricolore value"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/a/tcolor"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -405,7 +404,7 @@ void DevicePluginWs2812::updateEffect(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "effect mode"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/a/effect"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -423,7 +422,7 @@ void DevicePluginWs2812::updateMaxPix(Device *device) qCDebug(dcWs2812) << "Update" << device->name() << "max pix"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/p/maxpix"); CoapReply *reply = m_coap->get(CoapRequest(url)); if (reply->isFinished() && reply->error() != CoapReply::NoError) { @@ -442,7 +441,7 @@ void DevicePluginWs2812::enableNotifications(Device *device) qCDebug(dcWs2812) << "Enable" << device->name() << "notifications"; QUrl url; url.setScheme("coap"); - url.setHost(device->paramValue(hostParamTypeId).toString()); + url.setHost(device->paramValue(ws2812HostParamTypeId).toString()); url.setPath("/s/battery"); @@ -469,7 +468,7 @@ void DevicePluginWs2812::enableNotifications(Device *device) void DevicePluginWs2812::setReachable(Device *device, const bool &reachable) { - if (device->stateValue(reachableStateTypeId).toBool() != reachable) { + if (device->stateValue(ws2812ReachableStateTypeId).toBool() != reachable) { if (!reachable) { // Warn just once that the device is not reachable qCWarning(dcWs2812()) << device->name() << "reachable changed" << reachable; @@ -488,14 +487,14 @@ void DevicePluginWs2812::setReachable(Device *device, const bool &reachable) } } - device->setStateValue(reachableStateTypeId, reachable); + device->setStateValue(ws2812ReachableStateTypeId, reachable); } bool DevicePluginWs2812::deviceAlreadyAdded(const QHostAddress &address) { // Check if we already have a device with the given address foreach (Device *device, myDevices()) { - if (device->paramValue(hostParamTypeId).toString() == address.toString()) { + if (device->paramValue(ws2812HostParamTypeId).toString() == address.toString()) { return true; } } @@ -506,7 +505,7 @@ Device *DevicePluginWs2812::findDevice(const QHostAddress &address) { // Return the device pointer with the given address (otherwise 0) foreach (Device *device, myDevices()) { - if (device->paramValue(hostParamTypeId).toString() == address.toString()) { + if (device->paramValue(ws2812HostParamTypeId).toString() == address.toString()) { return device; } } @@ -555,7 +554,7 @@ void DevicePluginWs2812::onNetworkReplyFinished() // Create a deviceDescriptor for each found address DeviceDescriptor descriptor(deviceClassId, "ws2812", address.toString()); ParamList params; - params.append(Param(hostParamTypeId, address.toString())); + params.append(Param(ws2812HostParamTypeId, address.toString())); descriptor.setParams(params); deviceDescriptors.append(descriptor); } @@ -574,7 +573,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) // Check CoAP reply error if (reply->error() != CoapReply::NoError) { - if (device->stateValue(reachableStateTypeId).toBool()) + if (device->stateValue(ws2812ReachableStateTypeId).toBool()) qCWarning(dcWs2812) << "Ping device" << reply->request().url().toString() << "reply finished with error" << reply->errorString(); setReachable(device, false); @@ -605,10 +604,10 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) // Update corresponding device state if (urlPath == "/s/battery") { qCDebug(dcWs2812()) << "Updated battery value:" << reply->payload(); - device->setStateValue(batteryStateTypeId, reply->payload().toDouble()); + device->setStateValue(ws2812BatteryStateTypeId, reply->payload().toDouble()); } else if (urlPath == "/a/color") { qCDebug(dcWs2812()) << "Updated color value:" << reply->payload(); - device->setStateValue(effectColorStateTypeId, QVariant::fromValue(reply->payload())); + device->setStateValue(ws2812EffectColorStateTypeId, QVariant::fromValue(reply->payload())); } else if (urlPath == "/a/effect") { qCDebug(dcWs2812()) << "Updated effect value:" << reply->payload(); @@ -649,16 +648,16 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) default: effectModeString == "Off"; } - device->setStateValue(effectModeStateTypeId, effectModeString); + device->setStateValue(ws2812EffectModeStateTypeId, effectModeString); }else if (urlPath == "/a/brightness") { qCDebug(dcWs2812()) << "Updated brightness value:" << reply->payload().toInt(); - device->setStateValue(brightnessStateTypeId, reply->payload().toInt()); + device->setStateValue(ws2812BrightnessStateTypeId, reply->payload().toInt()); }else if (urlPath == "/a/speed") { qCDebug(dcWs2812()) << "Updated speed value:" << reply->payload().toInt(); - device->setStateValue(speedStateTypeId, reply->payload().toInt()); + device->setStateValue(ws2812SpeedStateTypeId, reply->payload().toInt()); }else if (urlPath == "/p/maxpix") { qCDebug(dcWs2812()) << "Updated max pix value:" << reply->payload().toInt(); - device->setStateValue(maxPixStateTypeId, reply->payload().toInt()); + device->setStateValue(ws2812MaxPixStateTypeId, reply->payload().toInt()); } @@ -705,12 +704,12 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareFailure); return; } - QString tcolor = action.param(effectColorStateParamTypeId).value().toByteArray(); + QString tcolor = action.param(ws2812EffectColorStateParamTypeId).value().toByteArray(); // Update the state here, so we don't have to wait for the notification - device->setStateValue(tcolor1StateTypeId, tcolor.left(6)); - device->setStateValue(tcolor2StateTypeId, tcolor.mid(6,6)); - device->setStateValue(tcolor3StateTypeId, tcolor.right(6)); + device->setStateValue(ws2812Tcolor1StateTypeId, tcolor.left(6)); + device->setStateValue(ws2812Tcolor2StateTypeId, tcolor.mid(6,6)); + device->setStateValue(ws2812Tcolor3StateTypeId, tcolor.right(6)); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -737,7 +736,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(effectColorStateTypeId, action.param(effectColorStateParamTypeId).value().toInt()); + device->setStateValue(ws2812EffectColorStateTypeId, action.param(ws2812EffectColorStateParamTypeId).value().toInt()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -763,7 +762,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(brightnessStateTypeId, action.param(brightnessStateParamTypeId).value().toInt()); + device->setStateValue(ws2812BrightnessStateTypeId, action.param(ws2812BrightnessStateParamTypeId).value().toInt()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -789,7 +788,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(speedStateTypeId, action.param(speedStateParamTypeId).value().toInt()); + device->setStateValue(ws2812SpeedStateTypeId, action.param(ws2812SpeedStateParamTypeId).value().toInt()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -815,7 +814,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply) } // Update the state here, so we don't have to wait for the notification - device->setStateValue(maxPixStateTypeId, action.param(maxPixStateParamTypeId).value().toInt()); + device->setStateValue(ws2812MaxPixStateTypeId, action.param(ws2812MaxPixStateParamTypeId).value().toInt()); // Tell the user about the action execution result emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError); @@ -856,9 +855,9 @@ void DevicePluginWs2812::onNotificationReceived(const CoapObserveResource &resou // Update the corresponding device state if (resource.url().path() == "/s/battery") { - device->setStateValue(batteryStateTypeId, payload.toDouble()); + device->setStateValue(ws2812BatteryStateTypeId, payload.toDouble()); }else if (resource.url().path() == "/a/color") { - device->setStateValue(effectColorStateTypeId, QVariant::fromValue(payload)); + device->setStateValue(ws2812EffectColorStateTypeId, QVariant::fromValue(payload)); }else if (resource.url().path() == "/a/effect") { int effectmode = payload.toInt(); QString effectModeString; @@ -899,12 +898,12 @@ void DevicePluginWs2812::onNotificationReceived(const CoapObserveResource &resou } - device->setStateValue(effectModeStateTypeId, effectModeString); + device->setStateValue(ws2812EffectModeStateTypeId, effectModeString); }else if (resource.url().path() == "/a/brightness") { - device->setStateValue(effectColorStateTypeId, payload.toInt()); + device->setStateValue(ws2812EffectColorStateTypeId, payload.toInt()); }else if (resource.url().path() == "/a/speed") { - device->setStateValue(effectColorStateTypeId, payload.toInt()); + device->setStateValue(ws2812EffectColorStateTypeId, payload.toInt()); }else if (resource.url().path() == "/p/maxpix") { - device->setStateValue(maxPixStateTypeId, payload.toInt()); + device->setStateValue(ws2812MaxPixStateTypeId, payload.toInt()); } }