fixed tune execute action
This commit is contained in:
parent
4ba4e67582
commit
1f48651dee
@ -1085,12 +1085,12 @@ DeviceManager::DeviceError DeviceManager::verifyParam(const ParamType ¶mType
|
||||
return DeviceErrorInvalidParameter;
|
||||
}
|
||||
|
||||
if (paramType.maxValue().isValid() && param.value() > paramType.maxValue()) {
|
||||
if (paramType.maxValue().isValid() && param.value().convert(paramType.type()) > paramType.maxValue().convert(paramType.type())) {
|
||||
qWarning() << "Value out of range for param" << param.name() << " Got:" << param.value() << " Max:" << paramType.maxValue();
|
||||
return DeviceErrorInvalidParameter;
|
||||
}
|
||||
if (paramType.minValue().isValid() && param.value() < paramType.minValue()) {
|
||||
qWarning() << "Value out of range for param" << param.name() << " Got:" << param.value() << " Min:" << paramType.minValue();
|
||||
qWarning() << "Value out of range for param" << param.name() << " Got:" << param.value().convert(paramType.type()) << " Min:" << paramType.minValue().convert(paramType.type());
|
||||
return DeviceErrorInvalidParameter;
|
||||
}
|
||||
if (!paramType.allowedValues().isEmpty() && !paramType.allowedValues().contains(param.value())) {
|
||||
|
||||
@ -175,7 +175,7 @@ void DevicePluginTune::updateTune(const QVariantMap &message)
|
||||
void DevicePluginTune::processActionResponse(const QVariantMap &message)
|
||||
{
|
||||
bool success = message.value("success").toBool();
|
||||
ActionId actionId = ActionId(message.value("params").toMap().value("actionId").toString());
|
||||
ActionId actionId = ActionId(message.value("actionId").toString());
|
||||
if (success) {
|
||||
emit actionExecutionFinished(actionId, DeviceManager::DeviceErrorNoError);
|
||||
} else {
|
||||
@ -189,16 +189,20 @@ DeviceManager::DeviceError DevicePluginTune::executeAction(Device *device, const
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() != moodDeviceClassId || device->deviceClassId() != tuneDeviceClassId) {
|
||||
// check DeviceClassId
|
||||
if (device->deviceClassId() != moodDeviceClassId && device->deviceClassId() != tuneDeviceClassId) {
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
if (action.actionTypeId() != powerActionTypeId ||
|
||||
action.actionTypeId() != brightnessActionTypeId ||
|
||||
action.actionTypeId() != valueActionTypeId){
|
||||
// check ActionTypeId
|
||||
if (action.actionTypeId() != powerActionTypeId &&
|
||||
action.actionTypeId() != brightnessActionTypeId &&
|
||||
action.actionTypeId() != valueActionTypeId &&
|
||||
action.actionTypeId() != activeActionTypeId){
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
// request the action execution on tune
|
||||
m_server->executeAction(device, action);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
@ -110,13 +110,13 @@ void JsonRpcServer::executeAction(Device *device, const Action &action)
|
||||
QVariantMap message;
|
||||
QVariantMap params;
|
||||
|
||||
params.insert("deviceId", device->deviceClassId());
|
||||
params.insert("deviceId", device->id());
|
||||
params.insert("actionId", action.id());
|
||||
|
||||
if (device->deviceClassId() == moodDeviceClassId) {
|
||||
message.insert("method", "Mood.ExecuteAction");
|
||||
if (action.actionTypeId() == valueActionTypeId) {
|
||||
params.insert("value", action.param("percentage").value().toInt());
|
||||
params.insert("value", action.param("value").value().toInt());
|
||||
params.insert("active", device->stateValue(activeStateTypeId).toBool());
|
||||
} else if (action.actionTypeId() == activeActionTypeId) {
|
||||
params.insert("value", device->stateValue(valueStateTypeId).toInt());
|
||||
@ -124,10 +124,10 @@ void JsonRpcServer::executeAction(Device *device, const Action &action)
|
||||
}
|
||||
} else if(device->deviceClassId() == tuneDeviceClassId) {
|
||||
message.insert("method", "Tune.ExecuteAction");
|
||||
if (action.actionTypeId() == valueActionTypeId) {
|
||||
if (action.actionTypeId() == brightnessActionTypeId) {
|
||||
params.insert("brightness", action.param("brightness").value().toInt());
|
||||
params.insert("power", device->stateValue(powerStateTypeId).toBool());
|
||||
} else if (action.actionTypeId() == activeActionTypeId) {
|
||||
} else if (action.actionTypeId() == powerActionTypeId) {
|
||||
params.insert("brightness", device->stateValue(brightnessStateTypeId).toInt());
|
||||
params.insert("power", action.param("power").value().toBool());
|
||||
}
|
||||
@ -173,7 +173,7 @@ void JsonRpcServer::handleResponse(const QVariantMap &response)
|
||||
return;
|
||||
}
|
||||
|
||||
// remove it request since we have a response now...
|
||||
// remove it request because we have a response now...
|
||||
QVariantMap request = m_requests.take(responseId);
|
||||
|
||||
// Note: maby we have to do something if any request fails
|
||||
|
||||
Reference in New Issue
Block a user