mirror of https://github.com/nymea/nymea.git
Make thingclassId optional in AddThing() when there's already a ThingDescriptor
parent
5674ba7567
commit
c004c0d81d
|
|
@ -140,7 +140,7 @@ IntegrationsHandler::IntegrationsHandler(ThingManager *thingManager, QObject *pa
|
||||||
"Things with CreateMethodDiscovery require the use of a thingDescriptorId. For discovered "
|
"Things with CreateMethodDiscovery require the use of a thingDescriptorId. For discovered "
|
||||||
"things, params are not required and will be taken from the ThingDescriptor, however, they "
|
"things, params are not required and will be taken from the ThingDescriptor, however, they "
|
||||||
"may be overridden by supplying thingParams.";
|
"may be overridden by supplying thingParams.";
|
||||||
params.insert("thingClassId", enumValueName(Uuid));
|
params.insert("o:thingClassId", enumValueName(Uuid));
|
||||||
params.insert("name", enumValueName(String));
|
params.insert("name", enumValueName(String));
|
||||||
params.insert("o:thingDescriptorId", enumValueName(Uuid));
|
params.insert("o:thingDescriptorId", enumValueName(Uuid));
|
||||||
params.insert("o:thingParams", objectRef<ParamList>());
|
params.insert("o:thingParams", objectRef<ParamList>());
|
||||||
|
|
@ -642,7 +642,7 @@ JsonReply* IntegrationsHandler::SetPluginConfiguration(const QVariantMap ¶ms
|
||||||
|
|
||||||
JsonReply* IntegrationsHandler::AddThing(const QVariantMap ¶ms, const JsonContext &context)
|
JsonReply* IntegrationsHandler::AddThing(const QVariantMap ¶ms, const JsonContext &context)
|
||||||
{
|
{
|
||||||
ThingClassId ThingClassId(params.value("thingClassId").toString());
|
ThingClassId thingClassId(params.value("thingClassId").toString());
|
||||||
QString thingName = params.value("name").toString();
|
QString thingName = params.value("name").toString();
|
||||||
ParamList thingParams = unpack<ParamList>(params.value("thingParams"));
|
ParamList thingParams = unpack<ParamList>(params.value("thingParams"));
|
||||||
ThingDescriptorId thingDescriptorId(params.value("thingDescriptorId").toString());
|
ThingDescriptorId thingDescriptorId(params.value("thingDescriptorId").toString());
|
||||||
|
|
@ -652,7 +652,16 @@ JsonReply* IntegrationsHandler::AddThing(const QVariantMap ¶ms, const JsonCo
|
||||||
|
|
||||||
ThingSetupInfo *info;
|
ThingSetupInfo *info;
|
||||||
if (thingDescriptorId.isNull()) {
|
if (thingDescriptorId.isNull()) {
|
||||||
info = NymeaCore::instance()->thingManager()->addConfiguredThing(ThingClassId, thingParams, thingName);
|
if (thingClassId.isNull()) {
|
||||||
|
qCWarning(dcJsonRpc()) << "Either thingClassId or thingDescriptorId is required.";
|
||||||
|
QVariantMap returns;
|
||||||
|
returns.insert("thingError", enumValueName<Thing::ThingError>(Thing::ThingErrorMissingParameter));
|
||||||
|
jsonReply->setData(returns);
|
||||||
|
jsonReply->finished();
|
||||||
|
return jsonReply;
|
||||||
|
}
|
||||||
|
info = NymeaCore::instance()->thingManager()->addConfiguredThing(thingClassId, thingParams, thingName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
info = NymeaCore::instance()->thingManager()->addConfiguredThing(thingDescriptorId, thingParams, thingName);
|
info = NymeaCore::instance()->thingManager()->addConfiguredThing(thingDescriptorId, thingParams, thingName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"
|
||||||
|
|
||||||
# define protocol versions
|
# define protocol versions
|
||||||
JSON_PROTOCOL_VERSION_MAJOR=6
|
JSON_PROTOCOL_VERSION_MAJOR=6
|
||||||
JSON_PROTOCOL_VERSION_MINOR=0
|
JSON_PROTOCOL_VERSION_MINOR=1
|
||||||
JSON_PROTOCOL_VERSION="$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}"
|
JSON_PROTOCOL_VERSION="$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}"
|
||||||
LIBNYMEA_API_VERSION_MAJOR=7
|
LIBNYMEA_API_VERSION_MAJOR=7
|
||||||
LIBNYMEA_API_VERSION_MINOR=3
|
LIBNYMEA_API_VERSION_MINOR=3
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
6.0
|
6.1
|
||||||
{
|
{
|
||||||
"enums": {
|
"enums": {
|
||||||
"BasicType": [
|
"BasicType": [
|
||||||
|
|
@ -698,9 +698,9 @@
|
||||||
"description": "Add a new thing to the system. Only things with a setupMethod of SetupMethodJustAdd can be added this way. For things with a setupMethod different than SetupMethodJustAdd, use PairThing. Things with CreateMethodJustAdd require all parameters to be supplied here. Things with CreateMethodDiscovery require the use of a thingDescriptorId. For discovered things, params are not required and will be taken from the ThingDescriptor, however, they may be overridden by supplying thingParams.",
|
"description": "Add a new thing to the system. Only things with a setupMethod of SetupMethodJustAdd can be added this way. For things with a setupMethod different than SetupMethodJustAdd, use PairThing. Things with CreateMethodJustAdd require all parameters to be supplied here. Things with CreateMethodDiscovery require the use of a thingDescriptorId. For discovered things, params are not required and will be taken from the ThingDescriptor, however, they may be overridden by supplying thingParams.",
|
||||||
"params": {
|
"params": {
|
||||||
"name": "String",
|
"name": "String",
|
||||||
|
"o:thingClassId": "Uuid",
|
||||||
"o:thingDescriptorId": "Uuid",
|
"o:thingDescriptorId": "Uuid",
|
||||||
"o:thingParams": "$ref:ParamList",
|
"o:thingParams": "$ref:ParamList"
|
||||||
"thingClassId": "Uuid"
|
|
||||||
},
|
},
|
||||||
"permissionScope": "PermissionScopeConfigureThings",
|
"permissionScope": "PermissionScopeConfigureThings",
|
||||||
"returns": {
|
"returns": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue