Fix plugins json content according to new white list parsing

master
Simon Stürz 2018-03-29 10:15:57 +02:00 committed by Michael Zanetti
parent 6bd868f4a0
commit 540acbf2b1
19 changed files with 100 additions and 122 deletions

View File

@ -133,9 +133,9 @@ DeviceManager::DeviceError DevicePluginAwattar::executeAction(Device *device, co
return DeviceManager::DeviceErrorHardwareNotAvailable;
if (action.actionTypeId() == awattarSgSyncModeActionTypeId) {
qCDebug(dcAwattar) << "Set sg sync mode to" << action.param(awattarSgSyncModeStateParamTypeId).value();
device->setStateValue(awattarSgSyncModeStateTypeId, action.param(awattarSgSyncModeStateParamTypeId).value());
if (action.param(awattarSgSyncModeStateParamTypeId).value() == "auto")
qCDebug(dcAwattar) << "Set sg sync mode to" << action.param(awattarSgSyncModeActionParamTypeId).value();
device->setStateValue(awattarSgSyncModeStateTypeId, action.param(awattarSgSyncModeActionParamTypeId).value());
if (action.param(awattarSgSyncModeActionParamTypeId).value() == "auto")
setSgMode(m_autoSgMode);
return DeviceManager::DeviceErrorNoError;

View File

@ -116,9 +116,9 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons
// Print information that we are executing now the update action
qCDebug(dcDenon) << "set power action" << action.id();
qCDebug(dcDenon) << "power: " << action.param(AVRX1000PowerStateParamTypeId).value().Bool;
qCDebug(dcDenon) << "power: " << action.param(AVRX1000PowerActionParamTypeId).value().Bool;
if (action.param(AVRX1000PowerStateParamTypeId).value().toBool() == true){
if (action.param(AVRX1000PowerActionParamTypeId).value().toBool() == true){
QByteArray cmd = "PWON\r";
qCDebug(dcDenon) << "Execute power: " << action.id() << cmd;
m_denonConnection->sendData(cmd);
@ -132,7 +132,7 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons
} else if (action.actionTypeId() == AVRX1000VolumeActionTypeId) {
QByteArray vol = action.param(AVRX1000VolumeStateParamTypeId).value().toByteArray();
QByteArray vol = action.param(AVRX1000VolumeActionParamTypeId).value().toByteArray();
QByteArray cmd = "MV" + vol + "\r";
qCDebug(dcDenon) << "Execute volume" << action.id() << cmd;
@ -143,7 +143,7 @@ DeviceManager::DeviceError DevicePluginDenon::executeAction(Device *device, cons
} else if (action.actionTypeId() == AVRX1000ChannelActionTypeId) {
qCDebug(dcDenon) << "Execute update action" << action.id();
QByteArray channel = action.param(AVRX1000ChannelStateParamTypeId).value().toByteArray();
QByteArray channel = action.param(AVRX1000ChannelActionParamTypeId).value().toByteArray();
QByteArray cmd = "SI" + channel + "\r";
qCDebug(dcDenon) << "Change to channel:" << cmd;

View File

@ -478,53 +478,53 @@ DeviceManager::DeviceError DevicePluginElgato::executeAction(Device *device, con
AveaBulb *bulb = m_bulbs.value(device);
if (action.actionTypeId() == aveaPowerActionTypeId) {
bool power = action.param(aveaPowerStateParamTypeId).value().toBool();
bool power = action.param(aveaPowerActionParamTypeId).value().toBool();
device->setStateValue(aveaPowerStateTypeId, power);
if (!bulb->setPower(power))
return DeviceManager::DeviceErrorHardwareNotAvailable;
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaBrightnessActionTypeId) {
int percentage = action.param(aveaBrightnessStateParamTypeId).value().toInt();
int percentage = action.param(aveaBrightnessActionParamTypeId).value().toInt();
if (!bulb->setBrightness(percentage))
return DeviceManager::DeviceErrorHardwareNotAvailable;
device->setStateValue(aveaBrightnessStateTypeId, percentage);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaColorActionTypeId) {
QColor color = action.param(aveaColorStateParamTypeId).value().value<QColor>();
QColor color = action.param(aveaColorActionParamTypeId).value().value<QColor>();
if (!bulb->setColor(color))
return DeviceManager::DeviceErrorHardwareNotAvailable;
device->setStateValue(aveaColorStateTypeId, color);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaWhiteActionTypeId) {
int whiteValue = action.param(aveaWhiteStateParamTypeId).value().toInt();
int whiteValue = action.param(aveaWhiteActionParamTypeId).value().toInt();
if (!bulb->setWhite(whiteValue))
return DeviceManager::DeviceErrorHardwareNotAvailable;
device->setStateValue(aveaWhiteStateTypeId, whiteValue);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaGreenActionTypeId) {
int greenValue = action.param(aveaGreenStateParamTypeId).value().toInt();
int greenValue = action.param(aveaGreenActionParamTypeId).value().toInt();
if (!bulb->setGreen(greenValue))
return DeviceManager::DeviceErrorHardwareNotAvailable;
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaRedActionTypeId) {
int redValue = action.param(aveaRedStateParamTypeId).value().toInt();
int redValue = action.param(aveaRedActionParamTypeId).value().toInt();
if (!bulb->setRed(redValue))
return DeviceManager::DeviceErrorHardwareNotAvailable;
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaBlueActionTypeId) {
int blueValue = action.param(aveaBlueStateParamTypeId).value().toInt();
int blueValue = action.param(aveaBlueActionParamTypeId).value().toInt();
if (!bulb->setBlue(blueValue))
return DeviceManager::DeviceErrorHardwareNotAvailable;
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == aveaFadeActionTypeId) {
int fadeValue = action.param(aveaFadeStateParamTypeId).value().toInt();
int fadeValue = action.param(aveaFadeActionParamTypeId).value().toInt();
device->setStateValue(aveaFadeStateTypeId, fadeValue);
if (!bulb->setFade(fadeValue))
return DeviceManager::DeviceErrorHardwareNotAvailable;

View File

@ -162,7 +162,7 @@ DeviceManager::DeviceError DevicePluginEQ3::executeAction(Device *device, const
int roomId = device->paramValue(wallThermostateRoomParamTypeId).toInt();
if (action.actionTypeId() == wallThermostateDesiredTemperatureActionTypeId){
cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(wallThermostateDesiredTemperatureStateParamTypeId).value().toDouble(), action.id());
cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(wallThermostateDesiredTemperatureActionParamTypeId).value().toDouble(), action.id());
} else if (action.actionTypeId() == wallThermostateSetAutoModeActionTypeId){
cube->setDeviceAutoMode(rfAddress, roomId, action.id());
} else if (action.actionTypeId() == wallThermostateSetManualModeActionTypeId){
@ -183,7 +183,7 @@ DeviceManager::DeviceError DevicePluginEQ3::executeAction(Device *device, const
int roomId = device->paramValue(radiatorThermostateRoomParamTypeId).toInt();
if (action.actionTypeId() == radiatorThermostateDesiredTemperatureActionTypeId){
cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(radiatorThermostateDesiredTemperatureStateParamTypeId).value().toDouble(), action.id());
cube->setDeviceSetpointTemp(rfAddress, roomId, action.param(radiatorThermostateDesiredTemperatureActionParamTypeId).value().toDouble(), action.id());
} else if (action.actionTypeId() == radiatorThermostateSetAutoModeActionTypeId){
cube->setDeviceAutoMode(rfAddress, roomId, action.id());
} else if (action.actionTypeId() == radiatorThermostateSetManualModeActionTypeId){

View File

@ -297,7 +297,7 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const
if (deviceClass.vendorId() == raspberryPiVendorId) {
if (action.actionTypeId() == gpioOutputRpiPowerValueActionTypeId) {
bool success = false;
if (action.param(gpioOutputRpiPowerValueStateParamTypeId).value().toBool()) {
if (action.param(gpioOutputRpiPowerValueActionParamTypeId).value().toBool()) {
success = gpio->setValue(Gpio::ValueHigh);
} else {
success = gpio->setValue(Gpio::ValueLow);
@ -309,14 +309,14 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const
}
// Set the current state
device->setStateValue(gpioOutputRpiPowerValueStateTypeId, action.param(gpioOutputRpiPowerValueStateParamTypeId).value());
device->setStateValue(gpioOutputRpiPowerValueStateTypeId, action.param(gpioOutputRpiPowerValueActionParamTypeId).value());
return DeviceManager::DeviceErrorNoError;
}
} else if (deviceClass.vendorId() == beagleboneBlackVendorId) {
if (action.actionTypeId() == gpioOutputBbbPowerValueActionTypeId) {
bool success = false;
if (action.param(gpioOutputBbbPowerValueStateParamTypeId).value().toBool()) {
if (action.param(gpioOutputBbbPowerValueActionParamTypeId).value().toBool()) {
success = gpio->setValue(Gpio::ValueHigh);
} else {
success = gpio->setValue(Gpio::ValueLow);
@ -328,7 +328,7 @@ DeviceManager::DeviceError DevicePluginGpio::executeAction(Device *device, const
}
// Set the current state
device->setStateValue(gpioOutputBbbPowerValueStateTypeId, action.param(gpioOutputBbbPowerValueStateParamTypeId).value());
device->setStateValue(gpioOutputBbbPowerValueStateTypeId, action.param(gpioOutputBbbPowerValueActionParamTypeId).value());
return DeviceManager::DeviceErrorNoError;
}

View File

@ -120,17 +120,17 @@ DeviceManager::DeviceError DevicePluginKeba::executeAction(Device *device, const
if(action.actionTypeId() == wallboxMaxCurrentActionTypeId){
// Print information that we are executing now the update action
qCDebug(dcKebaKeContact()) << "Update max current to : " << action.param(wallboxMaxCurrentStateParamTypeId).value().toString();
qCDebug(dcKebaKeContact()) << "Update max current to : " << action.param(wallboxMaxCurrentActionParamTypeId).value().toString();
QByteArray datagram;
datagram.append("curr " + QVariant(action.param(wallboxMaxCurrentStateParamTypeId).value().toInt()*1000).toString());
datagram.append("curr " + QVariant(action.param(wallboxMaxCurrentActionParamTypeId).value().toInt()*1000).toString());
qCDebug(dcKebaKeContact()) << "Datagram : " << datagram;
m_kebaSocket->writeDatagram(datagram.data(),datagram.size(), QHostAddress(device->paramValue(wallboxIpParamTypeId).toString()) , 7090);
}
else if(action.actionTypeId() == wallboxOutEnableActionTypeId){
// Print information that we are executing now the update action
qCDebug(dcKebaKeContact()) << "output enable : " << action.param(wallboxOutEnableStateParamTypeId).value().toString();
qCDebug(dcKebaKeContact()) << "output enable : " << action.param(wallboxOutEnableActionParamTypeId).value().toString();
QByteArray datagram;
if(action.param(wallboxOutEnableStateParamTypeId).value().toBool()){
if(action.param(wallboxOutEnableActionParamTypeId).value().toBool()){
datagram.append("ena 1");
}
else{

View File

@ -148,10 +148,10 @@ DeviceManager::DeviceError DevicePluginKodi::executeAction(Device *device, const
kodi->showNotification(action.param(kodiMessageParamTypeId).value().toString(), 8000, action.param(kodiTypeParamTypeId).value().toString(), action.id());
return DeviceManager::DeviceErrorAsync;
} else if (action.actionTypeId() == kodiVolumeActionTypeId) {
kodi->setVolume(action.param(kodiVolumeStateParamTypeId).value().toInt(), action.id());
kodi->setVolume(action.param(kodiVolumeActionParamTypeId).value().toInt(), action.id());
return DeviceManager::DeviceErrorAsync;
} else if (action.actionTypeId() == kodiMuteActionTypeId) {
kodi->setMuted(action.param(kodiMuteStateParamTypeId).value().toBool(), action.id());
kodi->setMuted(action.param(kodiMuteActionParamTypeId).value().toBool(), action.id());
return DeviceManager::DeviceErrorAsync;
} else if (action.actionTypeId() == kodiPressButtonActionTypeId) {
kodi->pressButton(action.param(kodiButtonParamTypeId).value().toString(), action.id());

View File

@ -12,7 +12,7 @@
"id": "728d5a67-27a3-400e-b83c-2765f5196f69",
"name": "connection",
"displayName": "Netatmo Connection",
"critcalStateTypeId": "2f79bc1d-27ed-480a-b583-728363c83ea6",
"criticalStateTypeId": "2f79bc1d-27ed-480a-b583-728363c83ea6",
"deviceIcon": "Network",
"interfaces": ["gateway"],
"basicTags": [

View File

@ -147,7 +147,7 @@ DeviceManager::DeviceError DevicePluginOrderButton::executeAction(Device *device
return DeviceManager::DeviceErrorAsync;
} else if(action.actionTypeId() == orderbuttonLedActionTypeId) {
bool led = action.param(orderbuttonLedStateParamTypeId).value().toBool();
bool led = action.param(orderbuttonLedActionParamTypeId).value().toBool();
QUrl url;
url.setScheme("coap");
@ -466,7 +466,7 @@ void DevicePluginOrderButton::coapReplyFinished(CoapReply *reply)
}
// Update the state here, so we don't have to wait for the notification
device->setStateValue(orderbuttonLedStateTypeId, action.param(orderbuttonLedStateParamTypeId).value().toBool());
device->setStateValue(orderbuttonLedStateTypeId, action.param(orderbuttonLedActionParamTypeId).value().toBool());
// Tell the user about the action execution result
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);

View File

@ -459,25 +459,25 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
}
if (action.actionTypeId() == hueLightPowerActionTypeId) {
QPair<QNetworkRequest, QByteArray> request = light->createSetPowerRequest(action.param(hueLightPowerStateParamTypeId).value().toBool());
QPair<QNetworkRequest, QByteArray> request = light->createSetPowerRequest(action.param(hueLightPowerActionParamTypeId).value().toBool());
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
return DeviceManager::DeviceErrorAsync;
} else if (action.actionTypeId() == hueLightColorActionTypeId) {
QPair<QNetworkRequest, QByteArray> request = light->createSetColorRequest(action.param(hueLightColorStateParamTypeId).value().value<QColor>());
QPair<QNetworkRequest, QByteArray> request = light->createSetColorRequest(action.param(hueLightColorActionParamTypeId).value().value<QColor>());
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
m_asyncActions.insert(reply,QPair<Device *, ActionId>(device, action.id()));
return DeviceManager::DeviceErrorAsync;
} else if (action.actionTypeId() == hueLightBrightnessActionTypeId) {
QPair<QNetworkRequest, QByteArray> request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueLightBrightnessStateParamTypeId).value().toInt()));
QPair<QNetworkRequest, QByteArray> request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueLightBrightnessActionParamTypeId).value().toInt()));
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
return DeviceManager::DeviceErrorAsync;
} else if (action.actionTypeId() == hueLightHueEffectActionTypeId) {
QPair<QNetworkRequest, QByteArray> request = light->createSetEffectRequest(action.param(hueLightHueEffectStateParamTypeId).value().toString());
QPair<QNetworkRequest, QByteArray> request = light->createSetEffectRequest(action.param(hueLightHueEffectActionParamTypeId).value().toString());
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
@ -489,7 +489,7 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
return DeviceManager::DeviceErrorAsync;
} else if (action.actionTypeId() == hueLightColorTemperatureActionTypeId) {
QPair<QNetworkRequest, QByteArray> request = light->createSetTemperatureRequest(action.param(hueLightColorTemperatureStateParamTypeId).value().toInt());
QPair<QNetworkRequest, QByteArray> request = light->createSetTemperatureRequest(action.param(hueLightColorTemperatureActionParamTypeId).value().toInt());
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
@ -508,13 +508,13 @@ DeviceManager::DeviceError DevicePluginPhilipsHue::executeAction(Device *device,
}
if (action.actionTypeId() == hueWhiteLightPowerActionTypeId) {
QPair<QNetworkRequest, QByteArray> request = light->createSetPowerRequest(action.param(hueWhiteLightPowerStateParamTypeId).value().toBool());
QPair<QNetworkRequest, QByteArray> request = light->createSetPowerRequest(action.param(hueWhiteLightPowerActionParamTypeId).value().toBool());
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));
return DeviceManager::DeviceErrorAsync;
} else if (action.actionTypeId() == hueWhiteLightBrightnessActionTypeId) {
QPair<QNetworkRequest, QByteArray> request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueWhiteLightBrightnessStateParamTypeId).value().toInt()));
QPair<QNetworkRequest, QByteArray> request = light->createSetBrightnessRequest(percentageToBrightness(action.param(hueWhiteLightBrightnessActionParamTypeId).value().toInt()));
QNetworkReply *reply = hardwareManager()->networkManager()->put(request.first, request.second);
connect(reply, &QNetworkReply::finished, this, &DevicePluginPhilipsHue::networkManagerReplyReady);
m_asyncActions.insert(reply, QPair<Device *, ActionId>(device, action.id()));

View File

@ -102,7 +102,7 @@ DeviceManager::DeviceError DevicePluginPlantCare::discoverDevices(const DeviceCl
Q_UNUSED(params)
// Perform a HTTP GET on the RPL router address
QHostAddress address(configuration().paramValue(PlantCareRplParamTypeId).toString());
QHostAddress address(configuration().paramValue(plantCareRplParamTypeId).toString());
qCDebug(dcPlantCare) << "Scan for new nodes on RPL" << address.toString();
QUrl url;
@ -148,7 +148,7 @@ DeviceManager::DeviceError DevicePluginPlantCare::executeAction(Device *device,
return DeviceManager::DeviceErrorAsync;
} else if(action.actionTypeId() == plantCareLedPowerActionTypeId) {
int power = action.param(plantCareLedPowerStateParamTypeId).value().toInt();
int power = action.param(plantCareLedPowerActionParamTypeId).value().toInt();
QUrl url;
url.setScheme("coap");
@ -170,7 +170,7 @@ DeviceManager::DeviceError DevicePluginPlantCare::executeAction(Device *device,
return DeviceManager::DeviceErrorAsync;
} else if(action.actionTypeId() == plantCareWaterPumpActionTypeId) {
bool pump = action.param(plantCareWaterPumpStateParamTypeId).value().toBool();
bool pump = action.param(plantCareWaterPumpActionParamTypeId).value().toBool();
QUrl url;
url.setScheme("coap");
@ -517,7 +517,7 @@ void DevicePluginPlantCare::coapReplyFinished(CoapReply *reply)
}
// Update the state here, so we don't have to wait for the notification
device->setStateValue(plantCareLedPowerStateTypeId, action.param(plantCareLedPowerStateParamTypeId).value().toBool());
device->setStateValue(plantCareLedPowerStateTypeId, action.param(plantCareLedPowerActionParamTypeId).value().toBool());
// Tell the user about the action execution result
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);
@ -543,7 +543,7 @@ void DevicePluginPlantCare::coapReplyFinished(CoapReply *reply)
}
// Update the state here, so we don't have to wait for the notification
device->setStateValue(plantCareWaterPumpStateTypeId, action.param(plantCareWaterPumpStateParamTypeId).value().toBool());
device->setStateValue(plantCareWaterPumpStateTypeId, action.param(plantCareWaterPumpActionParamTypeId).value().toBool());
// Tell the user about the action execution result
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);

View File

@ -55,7 +55,7 @@ DeviceManager::DeviceError DevicePluginRemoteSsh::executeAction(Device *device,
if (action.actionTypeId() == reverseSshConnectedActionTypeId) {
if (action.param(reverseSshConnectedStateParamTypeId).value().toBool() == true) {
if (action.param(reverseSshConnectedActionParamTypeId).value().toBool() == true) {
QProcess *process = startReverseSSHProcess(device);
m_reverseSSHProcess.insert(process, device);
m_startingProcess.insert(process, action.id());

View File

@ -81,7 +81,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
if (action.actionTypeId() == alternativeButtonPowerActionTypeId) {
// get the param value
Param powerParam = action.param(alternativeButtonPowerStateParamTypeId);
Param powerParam = action.param(alternativeButtonPowerActionParamTypeId);
bool power = powerParam.value().toBool();
qCDebug(dcSimulation()) << "Set power" << power << "for button" << device->name();
@ -100,7 +100,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
if (action.actionTypeId() == heatingPowerActionTypeId) {
// get the param value
Param powerParam = action.param(heatingPowerStateParamTypeId);
Param powerParam = action.param(heatingPowerActionParamTypeId);
bool power = powerParam.value().toBool();
qCDebug(dcSimulation()) << "Set power" << power << "for heating device" << device->name();
device->setStateValue(heatingPowerStateTypeId, power);
@ -109,7 +109,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
} else if (action.actionTypeId() == heatingTargetTemperatureActionTypeId) {
// get the param value
Param temperatureParam = action.param(heatingTargetTemperatureStateParamTypeId);
Param temperatureParam = action.param(heatingTargetTemperatureActionParamTypeId);
int temperature = temperatureParam.value().toInt();
qCDebug(dcSimulation()) << "Set target temperature" << temperature << "for heating device" << device->name();
@ -124,7 +124,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
if (action.actionTypeId() == evChargerPowerActionTypeId){
// get the param value
Param powerParam = action.param(evChargerPowerStateParamTypeId);
Param powerParam = action.param(evChargerPowerActionParamTypeId);
bool power = powerParam.value().toBool();
qCDebug(dcSimulation()) << "Set power" << power << "for heating device" << device->name();
@ -134,7 +134,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
} else if(action.actionTypeId() == evChargerCurrentActionTypeId){
// get the param value
Param currentParam = action.param(evChargerCurrentStateParamTypeId);
Param currentParam = action.param(evChargerCurrentActionParamTypeId);
int current = currentParam.value().toInt();
qCDebug(dcSimulation()) << "Set current" << current << "for EV Charger device" << device->name();
device->setStateValue(evChargerCurrentStateTypeId, current);
@ -147,7 +147,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
if(action.actionTypeId() == socketPowerActionTypeId){
// get the param value
Param powerParam = action.param(socketPowerStateParamTypeId);
Param powerParam = action.param(socketPowerActionParamTypeId);
bool power = powerParam.value().toBool();
// Set the "power" state
qCDebug(dcSimulation()) << "Set power" << power << "for socket device" << device->name();
@ -160,25 +160,25 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
if(device->deviceClassId() == colorBulbDeviceClassId){
if(action.actionTypeId() == colorBulbBrightnessActionTypeId){
int brightness = action.param(colorBulbBrightnessStateParamTypeId).value().toInt();
int brightness = action.param(colorBulbBrightnessActionParamTypeId).value().toInt();
qCDebug(dcSimulation()) << "Set brightness" << brightness << "for color bulb device" << device->name();
device->setStateValue(colorBulbBrightnessStateTypeId, brightness);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == colorBulbColorTemperatureActionTypeId){
int temperature = action.param(colorBulbColorTemperatureStateParamTypeId).value().toInt();
int temperature = action.param(colorBulbColorTemperatureActionParamTypeId).value().toInt();
qCDebug(dcSimulation()) << "Set color temperature" << temperature << "for color bulb device" << device->name();
device->setStateValue(colorBulbColorTemperatureStateTypeId, temperature);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == colorBulbColorActionTypeId) {
QColor color = action.param(colorBulbColorStateParamTypeId).value().value<QColor>();
QColor color = action.param(colorBulbColorActionParamTypeId).value().value<QColor>();
qCDebug(dcSimulation()) << "Set color" << color << "for color bulb device" << device->name();
device->setStateValue(colorBulbColorStateTypeId, color);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == colorBulbPowerActionTypeId) {
bool power = action.param(colorBulbPowerStateParamTypeId).value().toBool();
bool power = action.param(colorBulbPowerActionParamTypeId).value().toBool();
qCDebug(dcSimulation()) << "Set power" << power << "for color bulb device" << device->name();
device->setStateValue(colorBulbPowerStateTypeId, power);
return DeviceManager::DeviceErrorNoError;
@ -190,17 +190,17 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
if (device->deviceClassId() == heatingRodDeviceClassId) {
if (action.actionTypeId() == heatingRodPowerActionTypeId) {
bool power = action.param(heatingRodPowerStateParamTypeId).value().toBool();
bool power = action.param(heatingRodPowerActionParamTypeId).value().toBool();
qCDebug(dcSimulation()) << "Set power" << power << "for heating rod device" << device->name();
device->setStateValue(heatingRodPowerStateTypeId, power);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == heatingRodWaterTemperatureActionTypeId) {
int temperature = action.param(heatingRodWaterTemperatureStateParamTypeId).value().toInt();
int temperature = action.param(heatingRodWaterTemperatureActionParamTypeId).value().toInt();
qCDebug(dcSimulation()) << "Set water temperature" << temperature << "for heating rod device" << device->name();
device->setStateValue(heatingRodWaterTemperatureStateTypeId, temperature);
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == heatingRodMaxPowerActionTypeId) {
double maxPower = action.param(heatingRodMaxPowerStateParamTypeId).value().toDouble();
double maxPower = action.param(heatingRodMaxPowerActionParamTypeId).value().toDouble();
qCDebug(dcSimulation()) << "Set max power" << maxPower << "for heating rod device" << device->name();
device->setStateValue(heatingRodMaxPowerStateTypeId, maxPower);
return DeviceManager::DeviceErrorNoError;
@ -211,7 +211,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
if (device->deviceClassId() == batteryDeviceClassId) {
if (action.actionTypeId() == batteryMaxChargingActionTypeId) {
int maxCharging = action.param(batteryMaxChargingStateParamTypeId).value().toInt();
int maxCharging = action.param(batteryMaxChargingActionParamTypeId).value().toInt();
device->setStateValue(batteryMaxChargingStateTypeId, maxCharging);
qCDebug(dcSimulation()) << "Set max charging power" << maxCharging << "for battery device" << device->name();
device->setStateValue(batteryChargingStateTypeId, maxCharging);
@ -222,7 +222,7 @@ DeviceManager::DeviceError DevicePluginSimulation::executeAction(Device *device,
if (device->deviceClassId() == waterValveDeviceClassId) {
if (action.actionTypeId() == waterValvePowerActionTypeId) {
bool power = action.param(waterValvePowerStateParamTypeId).value().toBool();
bool power = action.param(waterValvePowerActionParamTypeId).value().toBool();
device->setStateValue(waterValvePowerStateTypeId, power);
return DeviceManager::DeviceErrorNoError;
}
@ -255,7 +255,6 @@ bool DevicePluginSimulation::generateRandomBoolValue()
void DevicePluginSimulation::onPluginTimer20Seconds()
{
qCDebug(dcSimulation()) << "Update values for 20s timer";
foreach (Device *device, myDevices()) {
if (device->deviceClassId() == temperatureSensorDeviceClassId) {
// Temperature sensor
@ -292,7 +291,6 @@ void DevicePluginSimulation::onPluginTimer20Seconds()
void DevicePluginSimulation::onPluginTimer5Minutes()
{
qCDebug(dcSimulation()) << "Update values for 5 minutes timer";
foreach (Device *device, myDevices()) {
if(device->deviceClassId() == netatmoIndoorDeviceClassId) {
// Note: should change between > 1000 co2 < 1000 for showcase, please do not change this behaviour

View File

@ -7,7 +7,6 @@
"name": "simulation",
"displayName": "Simulation",
"id": "fd2ae067-2c3d-4332-9c4b-ee0af653bcaf",
"interfaces": ["simplebutton"],
"deviceClasses": [
{
"id": "73bb670b-e7a3-40da-bd6f-3260f017ec80",
@ -54,7 +53,6 @@
"displayNameEvent": "Power changed",
"displayNameAction": "Set power",
"defaultValue": false,
"index" : 0,
"writable": true
}
]
@ -284,20 +282,17 @@
{
"id": "1786029d-f3a6-4b47-978a-ac1a581aac0f",
"name": "open",
"displayName": "Open",
"type": "bool"
"displayName": "Open"
},
{
"id": "2786029d-f3a6-4b47-978a-ac1a581aac0f",
"name": "stop",
"displayName": "Stop",
"type": "bool"
"displayName": "Stop"
},
{
"id": "3786029d-f3a6-4b47-978a-ac1a581aac0f",
"name": "close",
"displayName": "Close",
"type": "bool"
"displayName": "Close"
}
]
},
@ -328,20 +323,17 @@
{
"id": "17860291-f3a6-4b47-978a-ac1a581aac0f",
"name": "open",
"displayName": "Open",
"type": "bool"
"displayName": "Open"
},
{
"id": "27860292-f3a6-4b47-978a-ac1a581aac0f",
"name": "stop",
"displayName": "stop",
"type": "bool"
"displayName": "stop"
},
{
"id": "37860293-f3a6-4b47-978a-ac1a581aac0f",
"name": "close",
"displayName": "close",
"type": "bool"
"displayName": "close"
}
]
},

View File

@ -39,8 +39,8 @@ DevicePluginSnapd::~DevicePluginSnapd()
void DevicePluginSnapd::init()
{
// Initialize plugin configurations
m_advancedMode = configValue(SnapdAdvancedModeParamTypeId).toBool();
m_refreshTime = configValue(SnapdRefreshScheduleParamTypeId).toInt();
m_advancedMode = configValue(snapdAdvancedModeParamTypeId).toBool();
m_refreshTime = configValue(snapdRefreshScheduleParamTypeId).toInt();
connect(this, &DevicePluginSnapd::configValueChanged, this, &DevicePluginSnapd::onPluginConfigurationChanged);
// Refresh timer for snapd checks
@ -114,7 +114,7 @@ DeviceManager::DeviceSetupStatus DevicePluginSnapd::setupDevice(Device *device)
}
m_snapdControl = new SnapdControl(device, this);
m_snapdControl->setPreferredRefreshTime(configValue(SnapdRefreshScheduleParamTypeId).toInt());
m_snapdControl->setPreferredRefreshTime(configValue(snapdRefreshScheduleParamTypeId).toInt());
connect(m_snapdControl, &SnapdControl::snapListUpdated, this, &DevicePluginSnapd::onSnapListUpdated);
} else if (device->deviceClassId() == snapDeviceClassId) {
@ -163,7 +163,7 @@ DeviceManager::DeviceError DevicePluginSnapd::executeAction(Device *device, cons
if (action.actionTypeId() == snapChannelActionTypeId) {
QString snapName = device->paramValue(snapNameParamTypeId).toString();
m_snapdControl->changeSnapChannel(snapName, action.param(snapChannelStateParamTypeId).value().toString());
m_snapdControl->changeSnapChannel(snapName, action.param(snapChannelActionParamTypeId).value().toString());
return DeviceManager::DeviceErrorNoError;
} else if (action.actionTypeId() == snapRevertActionTypeId) {
QString snapName = device->paramValue(snapNameParamTypeId).toString();
@ -182,7 +182,7 @@ void DevicePluginSnapd::onPluginConfigurationChanged(const ParamTypeId &paramTyp
qCDebug(dcSnapd()) << "Plugin configuration changed";
// Check advanced mode
if (paramTypeId == SnapdAdvancedModeParamTypeId) {
if (paramTypeId == snapdAdvancedModeParamTypeId) {
qCDebug(dcSnapd()) << "Advanced mode" << (value.toBool() ? "enabled." : "disabled.");
m_advancedMode = value.toBool();
@ -202,7 +202,7 @@ void DevicePluginSnapd::onPluginConfigurationChanged(const ParamTypeId &paramTyp
}
// Check refresh schedule
if (paramTypeId == SnapdRefreshScheduleParamTypeId) {
if (paramTypeId == snapdRefreshScheduleParamTypeId) {
if (!m_snapdControl)
return;

View File

@ -81,8 +81,8 @@
"displayNameEvent": "Last automatic system update time changed",
"unit": "UnixTime",
"type": "int",
"ruleRelevant": false,
"eventRuleRelevant": false,
"stateRuleRelevant": false,
"defaultValue": 0
},
{
@ -92,8 +92,8 @@
"displayNameEvent": "Next automatic system update time changed",
"unit": "UnixTime",
"type": "int",
"ruleRelevant": false,
"eventRuleRelevant": false,
"stateRuleRelevant": false,
"defaultValue": 0
},
{
@ -102,8 +102,8 @@
"displayName": "Status",
"displayNameEvent": "Status changed",
"type": "QString",
"ruleRelevant": false,
"eventRuleRelevant": false,
"stateRuleRelevant": false,
"defaultValue": "-"
}
]
@ -167,8 +167,8 @@
"displayNameEvent": "Channel changed",
"displayNameAction": "Set channel",
"type": "QString",
"ruleRelevant": false,
"eventRuleRelevant": false,
"stateRuleRelevant": false,
"defaultValue": "stable",
"writable": true,
"possibleValues": [
@ -184,8 +184,8 @@
"displayName": "Version",
"displayNameEvent": "Version changed",
"type": "QString",
"ruleRelevant": false,
"eventRuleRelevant": false,
"stateRuleRelevant": false,
"defaultValue": "-"
},
{
@ -194,8 +194,8 @@
"displayName": "Revision",
"displayNameEvent": "Revision changed",
"type": "QString",
"ruleRelevant": false,
"eventRuleRelevant": false,
"stateRuleRelevant": false,
"defaultValue": "-"
}
]

View File

@ -26,16 +26,14 @@
"displayName": "IPv4 Address",
"type": "QString",
"inputType": "IPv4Address",
"defaultValue": "127.0.0.1",
"index" : 0
"defaultValue": "127.0.0.1"
},
{
"id": "bee8b151-815a-4159-9d8a-42b76e99b42c",
"name": "port",
"displayName": "Port",
"type": "int",
"defaultValue": "22",
"index" : 1
"defaultValue": "22"
}
],
"stateTypes":[
@ -45,8 +43,7 @@
"displayName": "connected",
"type": "bool",
"defaultValue": false,
"displayNameEvent": "connection status changed",
"index" : 0
"displayNameEvent": "connection status changed"
}
],
"actionTypes": [
@ -54,14 +51,12 @@
"id": "6bc52462-b192-46a4-a6df-92cc5a479c89",
"name": "outputData",
"displayName": "Send Data",
"index": 0,
"paramTypes": [
{
"id": "6604c852-6b24-4707-b8e5-1ddd8032efcc",
"name": "outputDataArea",
"displayName": "Data",
"type": "QString",
"index": 0,
"inputType": "TextArea"
}
]
@ -84,8 +79,7 @@
"name": "port",
"displayName": "Port",
"type": "int",
"defaultValue": "22",
"index" : 0
"defaultValue": "22"
},
{
"id": "d99f55c7-0e14-45ee-b0f0-33f2d1d2e674",
@ -99,8 +93,7 @@
"Starts with",
"Ends with"
],
"defaultValue": "Exactly",
"index" : 1
"defaultValue": "Exactly"
},
{
"id": "23051bdf-3f50-41fa-abde-bc4fe0bcc4fc",
@ -108,8 +101,7 @@
"displayName": "Command",
"type": "QString",
"inputType": "TextArea",
"defaultValue": "",
"index" : 2
"defaultValue": ""
}
],
"stateTypes": [
@ -119,26 +111,22 @@
"displayName": "connected",
"type": "bool",
"defaultValue": false,
"displayNameEvent": "connection status changed",
"index" : 0
"displayNameEvent": "connection status changed"
},
{
"id": "b98fdacc-59d7-41c4-b790-1fdca50dfb22",
"name": "dataReceived",
"displayName": "Data Received",
"type": "QString",
"inputType": "TextArea",
"defaultValue": "",
"displayNameEvent": "Data received",
"index" : 1
"displayNameEvent": "Data received"
}
],
"eventTypes": [
{
"id": "6d7c6df6-cb61-4d9e-b0d7-37c43911ca4b",
"name": "commandReceived",
"displayName": "Command Received",
"index": 0
"displayName": "Command Received"
}
]
}

View File

@ -106,7 +106,7 @@ DeviceManager::DeviceError DevicePluginWemo::executeAction(Device *device, const
// Check if wemo device is reachable
if (device->stateValue(wemoSwitchReachableStateTypeId).toBool()) {
// setPower returns false, if the curent powerState is already the new powerState
if (setPower(device, action.param(wemoSwitchPowerStateParamTypeId).value().toBool(), action.id())) {
if (setPower(device, action.param(wemoSwitchPowerActionParamTypeId).value().toBool(), action.id())) {
return DeviceManager::DeviceErrorAsync;
} else {
return DeviceManager::DeviceErrorNoError;

View File

@ -101,7 +101,7 @@ DeviceManager::DeviceError DevicePluginWs2812::discoverDevices(const DeviceClass
Q_UNUSED(params)
// Perform a HTTP GET on the RPL router address
QHostAddress address(configuration().paramValue(Ws2812RplParamTypeId).toString());
QHostAddress address(configuration().paramValue(ws2812RplParamTypeId).toString());
qCDebug(dcWs2812) << "Scan for new nodes on RPL" << address.toString();
QUrl url;
@ -140,7 +140,7 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con
url.setHost(device->paramValue(ws2812HostParamTypeId).toString());
url.setPath("/a/color");
QColor newColor = action.param(ws2812EffectModeStateParamTypeId).value().value<QColor>().toRgb();
QColor newColor = action.param(ws2812EffectModeActionParamTypeId).value().value<QColor>().toRgb();
QByteArray message = "color=" + newColor.name().remove("#").toUtf8();
qCDebug(dcWs2812) << "Sending" << url.toString() << message;
@ -164,7 +164,7 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con
url.setHost(device->paramValue(ws2812HostParamTypeId).toString());
url.setPath("/a/speed");
int speed = action.param(ws2812SpeedStateParamTypeId).value().toInt();
int speed = action.param(ws2812SpeedActionParamTypeId).value().toInt();
qCDebug(dcWs2812) << "Set Speed:" << speed;
@ -190,7 +190,7 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con
url.setPath("/a/brightness");
int brightness = action.param(ws2812BrightnessStateParamTypeId).value().toInt();
int brightness = action.param(ws2812BrightnessActionParamTypeId).value().toInt();
qCDebug(dcWs2812) << "Set brightness:" << brightness;
@ -220,7 +220,7 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con
//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(ws2812MaxPixStateParamTypeId).value().toInt();
int max = action.param(ws2812MaxPixActionParamTypeId).value().toInt();
qCDebug(dcWs2812) << "Max Pix" << max;
@ -246,7 +246,7 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con
int effectmode = 0;
QString effectModeString = action.param(ws2812EffectModeStateParamTypeId).value().toString();
QString effectModeString = action.param(ws2812EffectModeActionParamTypeId).value().toString();
QUrl url;
@ -311,11 +311,11 @@ DeviceManager::DeviceError DevicePluginWs2812::executeAction(Device *device, con
*/
if(action.actionTypeId() == ws2812Tcolor1ActionTypeId) {
tColor1 = action.param(ws2812Tcolor1StateParamTypeId).value().value<QColor>().toRgb();
tColor1 = action.param(ws2812Tcolor1ActionParamTypeId).value().value<QColor>().toRgb();
} else if(action.actionTypeId() == ws2812Tcolor2ActionTypeId){
tColor2 = action.param(ws2812Tcolor2StateParamTypeId).value().value<QColor>().toRgb();
tColor2 = action.param(ws2812Tcolor2ActionParamTypeId).value().value<QColor>().toRgb();
} else if(action.actionTypeId() == ws2812Tcolor3ActionTypeId){
tColor3 = action.param(ws2812Tcolor3StateParamTypeId).value().value<QColor>().toRgb();
tColor3 = action.param(ws2812Tcolor3ActionParamTypeId).value().value<QColor>().toRgb();
}
QByteArray message = "color=" + tColor1.name().remove("#").toUtf8() + tColor2.name().remove("#").toUtf8() + tColor3.name().remove("#").toUtf8();
@ -704,7 +704,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply)
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorHardwareFailure);
return;
}
QString tcolor = action.param(ws2812EffectColorStateParamTypeId).value().toByteArray();
QString tcolor = action.param(ws2812EffectColorActionParamTypeId).value().toByteArray();
// Update the state here, so we don't have to wait for the notification
device->setStateValue(ws2812Tcolor1StateTypeId, tcolor.left(6));
@ -736,7 +736,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply)
}
// Update the state here, so we don't have to wait for the notification
device->setStateValue(ws2812EffectColorStateTypeId, action.param(ws2812EffectColorStateParamTypeId).value().toInt());
device->setStateValue(ws2812EffectColorStateTypeId, action.param(ws2812EffectColorActionParamTypeId).value().toInt());
// Tell the user about the action execution result
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);
@ -762,7 +762,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply)
}
// Update the state here, so we don't have to wait for the notification
device->setStateValue(ws2812BrightnessStateTypeId, action.param(ws2812BrightnessStateParamTypeId).value().toInt());
device->setStateValue(ws2812BrightnessStateTypeId, action.param(ws2812BrightnessActionParamTypeId).value().toInt());
// Tell the user about the action execution result
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);
@ -788,7 +788,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply)
}
// Update the state here, so we don't have to wait for the notification
device->setStateValue(ws2812SpeedStateTypeId, action.param(ws2812SpeedStateParamTypeId).value().toInt());
device->setStateValue(ws2812SpeedStateTypeId, action.param(ws2812SpeedActionParamTypeId).value().toInt());
// Tell the user about the action execution result
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);
@ -814,7 +814,7 @@ void DevicePluginWs2812::coapReplyFinished(CoapReply *reply)
}
// Update the state here, so we don't have to wait for the notification
device->setStateValue(ws2812MaxPixStateTypeId, action.param(ws2812MaxPixStateParamTypeId).value().toInt());
device->setStateValue(ws2812MaxPixStateTypeId, action.param(ws2812MaxPixActionParamTypeId).value().toInt());
// Tell the user about the action execution result
emit actionExecutionFinished(action.id(), DeviceManager::DeviceErrorNoError);