This commit is contained in:
Michael Zanetti 2020-03-03 17:07:47 +01:00
parent 2fbbaeda97
commit 8208473302
55 changed files with 3017 additions and 2854 deletions

View File

@ -1,4 +1,4 @@
usr/lib/@DEB_HOST_MULTIARCH@/libnymea.so usr/lib/@DEB_HOST_MULTIARCH@/libnymea.so
usr/include/nymea/* usr/include/nymea usr/include/nymea/* usr/include/nymea
libnymea/devices/plugin.pri usr/include/nymea/ libnymea/integrations/plugin.pri usr/include/nymea/
usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/nymea.pc usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/nymea.pc

View File

@ -1,3 +1,3 @@
usr/tests/* usr/lib/@DEB_HOST_MULTIARCH@/nymea/tests usr/tests/* usr/lib/@DEB_HOST_MULTIARCH@/nymea/tests
usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_devicepluginmock.so usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_integrationpluginmock.so
usr/lib/@DEB_HOST_MULTIARCH@/libnymea-testlib.so* usr/lib/@DEB_HOST_MULTIARCH@/libnymea-testlib.so*

View File

@ -1062,10 +1062,10 @@ void ThingManagerImplementation::loadPlugins()
qCDebug(dcThingManager) << "Loading plugins from:" << dir.absolutePath(); qCDebug(dcThingManager) << "Loading plugins from:" << dir.absolutePath();
foreach (const QString &entry, dir.entryList()) { foreach (const QString &entry, dir.entryList()) {
QFileInfo fi; QFileInfo fi;
if (entry.startsWith("libnymea_deviceplugin") && entry.endsWith(".so")) { if (entry.startsWith("libnymea_integrationplugin") && entry.endsWith(".so")) {
fi.setFile(path + "/" + entry); fi.setFile(path + "/" + entry);
} else { } else {
fi.setFile(path + "/" + entry + "/libnymea_deviceplugin" + entry + ".so"); fi.setFile(path + "/" + entry + "/libnymea_integrationplugin" + entry + ".so");
} }
if (!fi.exists()) if (!fi.exists())

View File

@ -37,8 +37,8 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QDir> #include <QDir>
Translator::Translator(ThingManagerImplementation *deviceManager): Translator::Translator(ThingManagerImplementation *thingManager):
m_deviceManager(deviceManager) m_thingManager(thingManager)
{ {
} }
@ -55,7 +55,7 @@ Translator::~Translator()
QString Translator::translate(const PluginId &pluginId, const QString &string, const QLocale &locale) QString Translator::translate(const PluginId &pluginId, const QString &string, const QLocale &locale)
{ {
IntegrationPlugin *plugin = m_deviceManager->plugins().findById(pluginId); IntegrationPlugin *plugin = m_thingManager->plugins().findById(pluginId);
if (!plugin) { if (!plugin) {
qCWarning(dcThingManager()) << "Unable to translate" << string << "Plugin not found"; qCWarning(dcThingManager()) << "Unable to translate" << string << "Plugin not found";
return string; return string;
@ -101,7 +101,7 @@ void Translator::loadTranslator(IntegrationPlugin *plugin, const QLocale &locale
} else { } else {
QString pluginId = plugin->pluginId().toString().remove(QRegExp("[{}]")); QString pluginId = plugin->pluginId().toString().remove(QRegExp("[{}]"));
foreach (const QString &pluginPath, m_deviceManager->pluginSearchDirs()) { foreach (const QString &pluginPath, m_thingManager->pluginSearchDirs()) {
if (translator->load(locale, pluginId, "-", QDir(pluginPath + "/translations/").absolutePath(), ".qm")) { if (translator->load(locale, pluginId, "-", QDir(pluginPath + "/translations/").absolutePath(), ".qm")) {
qCDebug(dcTranslations()) << "* Loaded translation" << locale.name() << "for plugin" << plugin->pluginName() << "from" << QDir(pluginPath + "/translations/").absolutePath(); qCDebug(dcTranslations()) << "* Loaded translation" << locale.name() << "for plugin" << plugin->pluginName() << "from" << QDir(pluginPath + "/translations/").absolutePath();
loaded = true; loaded = true;

View File

@ -42,7 +42,7 @@ class ThingManagerImplementation;
class Translator class Translator
{ {
public: public:
Translator(ThingManagerImplementation *deviceManager); Translator(ThingManagerImplementation *thingManager);
~Translator(); ~Translator();
QString translate(const PluginId &pluginId, const QString &string, const QLocale &locale); QString translate(const PluginId &pluginId, const QString &string, const QLocale &locale);
@ -51,7 +51,7 @@ private:
void loadTranslator(IntegrationPlugin *plugin, const QLocale &locale); void loadTranslator(IntegrationPlugin *plugin, const QLocale &locale);
private: private:
ThingManagerImplementation *m_deviceManager = nullptr; ThingManagerImplementation *m_thingManager = nullptr;
struct TranslatorContext { struct TranslatorContext {
PluginId pluginId; PluginId pluginId;

View File

@ -233,7 +233,7 @@ ConfigurationHandler::ConfigurationHandler(QObject *parent):
registerNotification("BasicConfigurationChanged", description, params); registerNotification("BasicConfigurationChanged", description, params);
params.clear(); returns.clear(); params.clear(); returns.clear();
description = "Emitted whenever the language of the server changed. The Plugins, Vendors and DeviceClasses have to be reloaded to get the translated data."; description = "Emitted whenever the language of the server changed. The Plugins, Vendors and ThingClasses have to be reloaded to get the translated data.";
params.insert("language", enumValueName(String)); params.insert("language", enumValueName(String));
registerNotification("LanguageChanged", description, params); registerNotification("LanguageChanged", description, params);

View File

@ -104,7 +104,7 @@ JsonRPCServerImplementation::JsonRPCServerImplementation(const QSslConfiguration
QString description; QVariantMap returns; QVariantMap params; QString description; QVariantMap returns; QVariantMap params;
description = "Initiates a connection. Use this method to perform an initial handshake of the " description = "Initiates a connection. Use this method to perform an initial handshake of the "
"connection. Optionally, a parameter \"locale\" is can be passed to set up the used " "connection. Optionally, a parameter \"locale\" is can be passed to set up the used "
"locale for this connection. Strings such as DeviceClass displayNames etc will be " "locale for this connection. Strings such as ThingClass displayNames etc will be "
"localized to this locale. If this parameter is omitted, the default system locale " "localized to this locale. If this parameter is omitted, the default system locale "
"(depending on the configuration) is used. The reply of this method contains information " "(depending on the configuration) is used. The reply of this method contains information "
"about this core instance such as version information, uuid and its name. The locale value" "about this core instance such as version information, uuid and its name. The locale value"
@ -150,9 +150,9 @@ JsonRPCServerImplementation::JsonRPCServerImplementation(const QSslConfiguration
"deprecated and used for legacy compatibilty only. It will be set to true if at least " "deprecated and used for legacy compatibilty only. It will be set to true if at least "
"one namespace has been enabled."; "one namespace has been enabled.";
params.insert("o:namespaces", enumValueName(StringList)); params.insert("o:namespaces", enumValueName(StringList));
params.insert("o:enabled", enumValueName(Bool)); params.insert("d:o:enabled", enumValueName(Bool));
returns.insert("namespaces", enumValueName(StringList)); returns.insert("namespaces", enumValueName(StringList));
returns.insert("enabled", enumValueName(Bool)); returns.insert("d:enabled", enumValueName(Bool));
registerMethod("SetNotificationStatus", description, params, returns); registerMethod("SetNotificationStatus", description, params, returns);
params.clear(); returns.clear(); params.clear(); returns.clear();
@ -224,7 +224,7 @@ JsonRPCServerImplementation::JsonRPCServerImplementation(const QSslConfiguration
params.clear(); returns.clear(); params.clear(); returns.clear();
description = "Check whether the cloud is currently connected. \"connected\" will be true whenever connectionState equals CloudConnectionStateConnected and is deprecated. Please use the connectionState value instead."; description = "Check whether the cloud is currently connected. \"connected\" will be true whenever connectionState equals CloudConnectionStateConnected and is deprecated. Please use the connectionState value instead.";
returns.insert("connected", enumValueName(Bool)); returns.insert("d:connected", enumValueName(Bool));
returns.insert("connectionState", enumRef<CloudManager::CloudConnectionState>()); returns.insert("connectionState", enumRef<CloudManager::CloudConnectionState>());
registerMethod("IsCloudConnected", description, params, returns); registerMethod("IsCloudConnected", description, params, returns);

View File

@ -28,29 +28,6 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class nymeaserver::LoggingHandler
\brief This subclass of \l{JsonHandler} processes the JSON requests for the \tt Logging namespace of the JSON-RPC API.
\ingroup json
\inmodule core
This \l{JsonHandler} will be created in the \l{JsonRPCServer} and used to handle JSON-RPC requests
for the \tt {Logging} namespace of the API.
\sa LogEngine, JsonHandler, JsonRPCServer
*/
/*! \fn void nymeaserver::LoggingHandler::LogEntryAdded(const QVariantMap &params);
This signal is emitted to the API notifications when a \l{LogEntry} was added to the database.
The \a params contain the map for the notification.
*/
/*! \fn void nymeaserver::LoggingHandler::LogDatabaseUpdated(const QVariantMap &params);
This signal is emitted to the API notifications when the logging aatabase has been updated (i.e. \l{Device} or \l{Rule} removed).
The \a params contain the map for the notification.
*/
#include "logginghandler.h" #include "logginghandler.h"
#include "logging/logengine.h" #include "logging/logengine.h"
#include "logging/logfilter.h" #include "logging/logfilter.h"
@ -61,7 +38,6 @@
namespace nymeaserver { namespace nymeaserver {
/*! Constructs a new \l LoggingHandler with the given \a parent. */
LoggingHandler::LoggingHandler(QObject *parent) : LoggingHandler::LoggingHandler(QObject *parent) :
JsonHandler(parent) JsonHandler(parent)
{ {
@ -99,7 +75,8 @@ LoggingHandler::LoggingHandler(QObject *parent) :
params.insert("o:loggingLevels", QVariantList() << enumRef<Logging::LoggingLevel>()); params.insert("o:loggingLevels", QVariantList() << enumRef<Logging::LoggingLevel>());
params.insert("o:eventTypes", QVariantList() << enumRef<Logging::LoggingEventType>()); params.insert("o:eventTypes", QVariantList() << enumRef<Logging::LoggingEventType>());
params.insert("o:typeIds", QVariantList() << enumValueName(Uuid)); params.insert("o:typeIds", QVariantList() << enumValueName(Uuid));
params.insert("o:deviceIds", QVariantList() << enumValueName(Uuid)); params.insert("o:thingIds", QVariantList() << enumValueName(Uuid));
params.insert("d:o:deviceIds", QVariantList() << enumValueName(Uuid));
params.insert("o:values", QVariantList() << enumValueName(Variant)); params.insert("o:values", QVariantList() << enumValueName(Variant));
params.insert("o:limit", enumValueName(Int)); params.insert("o:limit", enumValueName(Int));
params.insert("o:offset", enumValueName(Int)); params.insert("o:offset", enumValueName(Int));
@ -118,7 +95,7 @@ LoggingHandler::LoggingHandler(QObject *parent) :
params.clear(); params.clear();
description = "Emitted whenever the database was updated. " description = "Emitted whenever the database was updated. "
"The database will be updated when a log entry was deleted. A log " "The database will be updated when a log entry was deleted. A log "
"entry will be deleted when the corresponding device or a rule will " "entry will be deleted when the corresponding thing or a rule will "
"be removed, or when the oldest entry of the database was deleted to " "be removed, or when the oldest entry of the database was deleted to "
"keep to database in the size limits."; "keep to database in the size limits.";
registerNotification("LogDatabaseUpdated", description, params); registerNotification("LogDatabaseUpdated", description, params);
@ -127,7 +104,6 @@ LoggingHandler::LoggingHandler(QObject *parent) :
connect(NymeaCore::instance()->logEngine(), &LogEngine::logDatabaseUpdated, this, &LoggingHandler::logDatabaseUpdated); connect(NymeaCore::instance()->logEngine(), &LogEngine::logDatabaseUpdated, this, &LoggingHandler::logDatabaseUpdated);
} }
/*! Returns the name of the \l{LoggingHandler}. In this case \b Logging.*/
QString LoggingHandler::name() const QString LoggingHandler::name() const
{ {
return "Logging"; return "Logging";
@ -212,7 +188,8 @@ QVariantMap LoggingHandler::packLogEntry(const LogEntry &logEntry)
if (!logEntry.typeId().isNull()) { if (!logEntry.typeId().isNull()) {
logEntryMap.insert("typeId", logEntry.typeId()); logEntryMap.insert("typeId", logEntry.typeId());
} }
logEntryMap.insert("deviceId", logEntry.thingId()); logEntryMap.insert("thingId", logEntry.thingId());
logEntryMap.insert("deviceId", logEntry.thingId()); // DEPRECATED
logEntryMap.insert("value", LogValueTool::convertVariantToString(logEntry.value())); logEntryMap.insert("value", LogValueTool::convertVariantToString(logEntry.value()));
break; break;
case Logging::LoggingSourceSystem: case Logging::LoggingSourceSystem:
@ -268,6 +245,13 @@ LogFilter LoggingHandler::unpackLogFilter(const QVariantMap &logFilterMap)
filter.addTypeId(typeId.toUuid()); filter.addTypeId(typeId.toUuid());
} }
} }
if (logFilterMap.contains("thingIds")) {
QVariantList thingIds = logFilterMap.value("thingIds").toList();
foreach (const QVariant &thingId, thingIds) {
filter.addThingId(ThingId(thingId.toString()));
}
}
// DEPRECATED
if (logFilterMap.contains("deviceIds")) { if (logFilterMap.contains("deviceIds")) {
QVariantList deviceIds = logFilterMap.value("deviceIds").toList(); QVariantList deviceIds = logFilterMap.value("deviceIds").toList();
foreach (const QVariant &deviceId, deviceIds) { foreach (const QVariant &deviceId, deviceIds) {

View File

@ -166,7 +166,8 @@ RulesHandler::RulesHandler(QObject *parent) :
params.clear(); returns.clear(); params.clear(); returns.clear();
description = "Find a list of rules containing any of the given parameters."; description = "Find a list of rules containing any of the given parameters.";
params.insert("deviceId", enumValueName(Uuid)); params.insert("o:thingId", enumValueName(Uuid)); // TODO: remove "o:" from thingId once we drop deviceId support
params.insert("d:o:deviceId", enumValueName(Uuid));
returns.insert("ruleIds", QVariantList() << enumValueName(Uuid)); returns.insert("ruleIds", QVariantList() << enumValueName(Uuid));
registerMethod("FindRules", description, params, returns); registerMethod("FindRules", description, params, returns);
@ -300,8 +301,11 @@ JsonReply* RulesHandler::RemoveRule(const QVariantMap &params)
JsonReply *RulesHandler::FindRules(const QVariantMap &params) JsonReply *RulesHandler::FindRules(const QVariantMap &params)
{ {
ThingId deviceId = ThingId(params.value("deviceId").toString()); ThingId thingId = ThingId(params.value("deviceId").toString()); // DEPRECATED
QList<RuleId> rules = NymeaCore::instance()->ruleEngine()->findRules(deviceId); if (params.contains("thingId")) {
thingId = ThingId(params.value("thingId").toString());
}
QList<RuleId> rules = NymeaCore::instance()->ruleEngine()->findRules(thingId);
QVariantList rulesList; QVariantList rulesList;
foreach (const RuleId &ruleId, rules) { foreach (const RuleId &ruleId, rules) {

View File

@ -45,8 +45,11 @@ TagsHandler::TagsHandler(QObject *parent) : JsonHandler(parent)
// Methods // Methods
QString description; QVariantMap params; QVariantMap returns; QString description; QVariantMap params; QVariantMap returns;
description = "Get the Tags matching the given filter. Tags can be filtered by a deviceID, a ruleId, an appId, a tagId or a combination of any (however, combining deviceId and ruleId will return an empty result set)."; description = "Get the Tags matching the given filter. "
params.insert("o:deviceId", enumValueName(Uuid)); "Tags can be filtered by a thingID, a ruleId, an appId, a tagId or a combination of any (however, "
"combining thingId and ruleId will return an empty result set).";
params.insert("o:thingId", enumValueName(Uuid));
params.insert("d:o:deviceId", enumValueName(Uuid));
params.insert("o:ruleId", enumValueName(Uuid)); params.insert("o:ruleId", enumValueName(Uuid));
params.insert("o:appId", enumValueName(String)); params.insert("o:appId", enumValueName(String));
params.insert("o:tagId", enumValueName(String)); params.insert("o:tagId", enumValueName(String));
@ -55,13 +58,20 @@ TagsHandler::TagsHandler(QObject *parent) : JsonHandler(parent)
registerMethod("GetTags", description, params, returns); registerMethod("GetTags", description, params, returns);
params.clear(); returns.clear(); params.clear(); returns.clear();
description = "Add a Tag. A Tag must have a deviceId OR a ruleId (call this method twice if you want to attach the same tag to a device and a rule), an appId (Use the appId of your app), a tagId (e.g. \"favorites\") and a value. Upon success, a TagAdded notification will be emitted. Calling this method twice for the same ids (device/rule, appId and tagId) but with a different value will update the tag's value and the TagValueChanged notification will be emitted."; description = "Add a Tag. "
"A Tag must have a thingId OR a ruleId (call this method twice if you want to attach the same tag "
"to a thing and a rule), an appId (Use the appId of your app), a tagId (e.g. \"favorites\") and a "
"value. Upon success, a TagAdded notification will be emitted. Calling this method twice for the "
"same ids (thing/rule, appId and tagId) but with a different value will update the tag's value and "
"the TagValueChanged notification will be emitted.";
params.insert("tag", objectRef("Tag")); params.insert("tag", objectRef("Tag"));
returns.insert("tagError", enumRef<TagsStorage::TagError>()); returns.insert("tagError", enumRef<TagsStorage::TagError>());
registerMethod("AddTag", description, params, returns); registerMethod("AddTag", description, params, returns);
params.clear(); returns.clear(); params.clear(); returns.clear();
description = "Remove a Tag. Tag value is optional and will be disregarded. If the ids match, the tag will be deleted and a TagRemoved notification will be emitted."; description = "Remove a Tag. "
"Tag value is optional and will be disregarded. If the ids match, the tag will be deleted and a "
"TagRemoved notification will be emitted.";
params.insert("tag", objectRef("Tag")); params.insert("tag", objectRef("Tag"));
returns.insert("tagError", enumRef<TagsStorage::TagError>()); returns.insert("tagError", enumRef<TagsStorage::TagError>());
registerMethod("RemoveTag", description, params, returns); registerMethod("RemoveTag", description, params, returns);

View File

@ -28,99 +28,6 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class nymeaserver::LogEngine
\brief The engine which creates the log databse and provides access to it.
\ingroup logs
\inmodule core
The \l{LogEngine} creates a \l{https://sqlite.org/}{SQLite3} database to stores everything what's
happening in the system. The database can be accessed from the API's. To control the size of the database the
limit of the databse are 8000 entries.
\sa LogEntry, LogFilter, LogsResource, LoggingHandler
*/
/*! \fn void nymeaserver::LogEngine::logEntryAdded(const LogEntry &logEntry);
This signal is emitted when an \a logEntry was added to the database.
\sa LogEntry
*/
/*! \fn void nymeaserver::LogEngine::logDatabaseUpdated();
This signal is emitted when the log database was updated. The log database
will be updated when a \l{LogEntry} was added or when a device was removed
and all corresponding \l{LogEntry}{LogEntries} were removed from the database.
*/
/*!
\class nymeaserver::Logging
\brief The logging class provides enums and flags for the LogEngine.
\ingroup logs
\inmodule core
\sa LogEngine, LogEntry, LogFilter
*/
/*! \fn nymeaserver::Logging::Logging(QObject *parent)
Constructs the \l{Logging} object with the given \a parent.
*/
/*! \enum nymeaserver::Logging::LoggingError
Represents the possible errors from the \l{LogEngine}.
\value LoggingErrorNoError
No error happened. Everything is fine.
\value LoggingErrorLogEntryNotFound
The requested \l{LogEntry} could not be found.
\value LoggingErrorInvalidFilterParameter
The given \l{LogFilter} contains an invalid parameter.
*/
/*! \enum nymeaserver::Logging::LoggingEventType
Represents the event type of this \l{LogEntry}.
\value LoggingEventTypeTrigger
This event type describes an \l{Event} which has triggered.
\value LoggingEventTypeActiveChange
This event type describes a \l{Rule} which has changed its active status.
\value LoggingEventTypeActionsExecuted
This event type describes the actions execution of a \l{Rule}.
\value LoggingEventTypeExitActionsExecuted
This event type describes the exit actions execution of a \l{Rule}.
\value LoggingEventTypeEnabledChange
*/
/*! \enum nymeaserver::Logging::LoggingLevel
Indicates if the corresponding \l{LogEntry} is an information or an alert.
\value LoggingLevelInfo
This \l{LogEntry} represents an information.
\value LoggingLevelAlert
This \l{LogEntry} represents an alert. Something is not ok.
*/
/*! \enum nymeaserver::Logging::LoggingSource
Indicates from where the \l{LogEntry} was created. Can be used as flag.
\value LoggingSourceSystem
This \l{LogEntry} was created from the nymea system (server).
\value LoggingSourceEvents
This \l{LogEntry} was created from an \l{Event} which trigged.
\value LoggingSourceActions
This \l{LogEntry} was created from an \l{Action} which was executed.
\value LoggingSourceStates
This \l{LogEntry} was created from an \l{State} which hase changed.
\value LoggingSourceRules
This \l{LogEntry} represents the enable/disable event from an \l{Rule}.
\value LoggingSourceBrowserActions
This \l{LogEntry} was created from a \l{BrowserItemAction}.
*/
#include "nymeasettings.h" #include "nymeasettings.h"
#include "logengine.h" #include "logengine.h"
#include "loggingcategories.h" #include "loggingcategories.h"
@ -143,12 +50,6 @@
namespace nymeaserver { namespace nymeaserver {
/*! Constructs the log engine with the given parameters.
The Qt Database backend to be used. Depending on the installed Qt modules this can be any of QDB2 QIBASE QMYSQL QOCI QODBC QPSQL QSQLITE QSQLITE2 QTDS.
\a dbName is the name of the database. In case of SQLITE this should contain a file path. The Driver will create the file if required. In case of using a
database server like MYSQL, the database must exist on the host given by \a hostname and be accessible with the given \a username and \a password.
*/
// IMPORTANT: // IMPORTANT:
// DatabaseJobs run threaded, however, QSql is *not* threadsafe. // DatabaseJobs run threaded, however, QSql is *not* threadsafe.
// It is crucial to *not* access m_db while the job queue is being processed. // It is crucial to *not* access m_db while the job queue is being processed.
@ -189,7 +90,6 @@ LogEngine::LogEngine(const QString &driver, const QString &dbName, const QString
checkDBSize(); checkDBSize();
} }
/*! Destructs the \l{LogEngine}. */
LogEngine::~LogEngine() LogEngine::~LogEngine()
{ {
// Process the job queue before allowing to shut down // Process the job queue before allowing to shut down
@ -257,12 +157,12 @@ LogEntriesFetchJob *LogEngine::fetchLogEntries(const LogFilter &filter)
return fetchJob; return fetchJob;
} }
DevicesFetchJob *LogEngine::fetchDevices() ThingsFetchJob *LogEngine::fetchDevices()
{ {
QString queryString = QString("SELECT deviceId FROM entries WHERE deviceId != \"%1\" GROUP BY deviceId;").arg(QUuid().toString()); QString queryString = QString("SELECT deviceId FROM entries WHERE deviceId != \"%1\" GROUP BY deviceId;").arg(QUuid().toString());
DatabaseJob *job = new DatabaseJob(m_db, queryString); DatabaseJob *job = new DatabaseJob(m_db, queryString);
DevicesFetchJob *fetchJob = new DevicesFetchJob(this); ThingsFetchJob *fetchJob = new ThingsFetchJob(this);
connect(job, &DatabaseJob::finished, this, [job, fetchJob](){ connect(job, &DatabaseJob::finished, this, [job, fetchJob](){
fetchJob->deleteLater(); fetchJob->deleteLater();
if (job->error().type() != QSqlError::NoError) { if (job->error().type() != QSqlError::NoError) {

View File

@ -51,7 +51,7 @@ namespace nymeaserver {
class DatabaseJob; class DatabaseJob;
class LogEntriesFetchJob; class LogEntriesFetchJob;
class DevicesFetchJob; class ThingsFetchJob;
class LogEngine: public QObject class LogEngine: public QObject
{ {
@ -61,7 +61,7 @@ public:
~LogEngine(); ~LogEngine();
LogEntriesFetchJob *fetchLogEntries(const LogFilter &filter = LogFilter()); LogEntriesFetchJob *fetchLogEntries(const LogFilter &filter = LogFilter());
DevicesFetchJob *fetchDevices(); ThingsFetchJob *fetchDevices();
bool jobsRunning() const; bool jobsRunning() const;
@ -164,11 +164,11 @@ private:
friend class LogEngine; friend class LogEngine;
}; };
class DevicesFetchJob: public QObject class ThingsFetchJob: public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
DevicesFetchJob(QObject *parent): QObject(parent) {} ThingsFetchJob(QObject *parent): QObject(parent) {}
QList<ThingId> results() { return m_results; } QList<ThingId> results() { return m_results; }
signals: signals:
void finished(); void finished();

View File

@ -409,7 +409,7 @@ void NymeaCore::executeRuleActions(const QList<RuleAction> ruleActions)
QList<Action> actions; QList<Action> actions;
QList<BrowserAction> browserActions; QList<BrowserAction> browserActions;
foreach (const RuleAction &ruleAction, ruleActions) { foreach (const RuleAction &ruleAction, ruleActions) {
if (ruleAction.type() == RuleAction::TypeDevice) { if (ruleAction.type() == RuleAction::TypeThing) {
Thing *thing = m_thingManager->findConfiguredThing(ruleAction.thingId()); Thing *thing = m_thingManager->findConfiguredThing(ruleAction.thingId());
if (!thing) { if (!thing) {
qCWarning(dcRuleEngine()) << "Unable to find thing" << ruleAction.thingId() << "for rule action" << ruleAction; qCWarning(dcRuleEngine()) << "Unable to find thing" << ruleAction.thingId() << "for rule action" << ruleAction;
@ -859,8 +859,8 @@ void NymeaCore::thingManagerLoaded()
// Do some houskeeping... // Do some houskeeping...
qCDebug(dcApplication()) << "Starting housekeeping..."; qCDebug(dcApplication()) << "Starting housekeeping...";
QDateTime startTime = QDateTime::currentDateTime(); QDateTime startTime = QDateTime::currentDateTime();
DevicesFetchJob *job = m_logger->fetchDevices(); ThingsFetchJob *job = m_logger->fetchDevices();
connect(job, &DevicesFetchJob::finished, m_thingManager, [this, job, startTime](){ connect(job, &ThingsFetchJob::finished, m_thingManager, [this, job, startTime](){
foreach (const ThingId &thingId, job->results()) { foreach (const ThingId &thingId, job->results()) {
if (!m_thingManager->findConfiguredThing(thingId)) { if (!m_thingManager->findConfiguredThing(thingId)) {
qCDebug(dcApplication()) << "Cleaning stale thing entries from log DB for thing id" << thingId; qCDebug(dcApplication()) << "Cleaning stale thing entries from log DB for thing id" << thingId;

View File

@ -28,34 +28,8 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class RuleAction
\brief Describes an action for a \l{nymeaserver::Rule}.
\ingroup nymea-types
\ingroup rules
\inmodule libnymea
A RuleAction describes a special form of an \l{Action} for a \l{nymeaserver::Rule}. The main difference is
the \l{RuleActionParam}, which allows to use an EventTypeId within a \l{nymeaserver::Rule} to execute this \l{RuleAction}.
\sa nymeaserver::Rule, RuleActionParam,
*/
/*! \enum RuleAction::Type
\value TypeDevice
The RuleAction describes a device Action.
\value TypeInterface
The RuleAction describes an interface based Action.
*/
#include "ruleaction.h" #include "ruleaction.h"
/*! Constructs a RuleAction with the given by \a actionTypeId, \a deviceId and \a params.
* Use this to create a RuleAction for regular actions, that is, identifying the Action by deviceId and actionTypeId.
*/
RuleAction::RuleAction(const ActionTypeId &actionTypeId, const ThingId &thingId, const RuleActionParams &params): RuleAction::RuleAction(const ActionTypeId &actionTypeId, const ThingId &thingId, const RuleActionParams &params):
m_id(ActionId::createActionId()), m_id(ActionId::createActionId()),
m_thingId(thingId), m_thingId(thingId),
@ -65,9 +39,6 @@ RuleAction::RuleAction(const ActionTypeId &actionTypeId, const ThingId &thingId,
} }
/*! Constructs a RuleAction with the given by \a interface and \a interfaceAction.
* This will create an interface based RuleAction. Meaning, the Action is idenfified by an interface and and interfaceAction.
*/
RuleAction::RuleAction(const QString &interface, const QString &interfaceAction, const RuleActionParams &params) : RuleAction::RuleAction(const QString &interface, const QString &interfaceAction, const RuleActionParams &params) :
m_interface(interface), m_interface(interface),
m_interfaceAction(interfaceAction), m_interfaceAction(interfaceAction),
@ -76,9 +47,6 @@ RuleAction::RuleAction(const QString &interface, const QString &interfaceAction,
} }
/*! Constructs a RuleAction with the given by \a interface and \a interfaceAction.
* Use this to create a RuleAction for executing browser items.
*/
RuleAction::RuleAction(const ThingId &thingId, const QString &browserItemId): RuleAction::RuleAction(const ThingId &thingId, const QString &browserItemId):
m_thingId(thingId), m_thingId(thingId),
m_browserItemId(browserItemId) m_browserItemId(browserItemId)
@ -86,7 +54,6 @@ RuleAction::RuleAction(const ThingId &thingId, const QString &browserItemId):
} }
/*! Constructs a copy of the given \a other RuleAction. */
RuleAction::RuleAction(const RuleAction &other) : RuleAction::RuleAction(const RuleAction &other) :
m_id(other.id()), m_id(other.id()),
m_thingId(other.thingId()), m_thingId(other.thingId()),
@ -99,13 +66,11 @@ RuleAction::RuleAction(const RuleAction &other) :
} }
/*! Return the ActionId of this RuleAction.*/
ActionId RuleAction::id() const ActionId RuleAction::id() const
{ {
return m_id; return m_id;
} }
/*! Return true, if the actionTypeId and the deviceId of this RuleAction are valid (set).*/
bool RuleAction::isValid() const bool RuleAction::isValid() const
{ {
return (!m_actionTypeId.isNull() && !m_thingId.isNull()) return (!m_actionTypeId.isNull() && !m_thingId.isNull())
@ -113,11 +78,10 @@ bool RuleAction::isValid() const
|| (!m_thingId.isNull() && !m_browserItemId.isEmpty()); || (!m_thingId.isNull() && !m_browserItemId.isEmpty());
} }
/*! Returns whether this RuleAction is targetting a specific device or rather an interface. */
RuleAction::Type RuleAction::type() const RuleAction::Type RuleAction::type() const
{ {
if (!m_thingId.isNull() && !m_actionTypeId.isNull()) { if (!m_thingId.isNull() && !m_actionTypeId.isNull()) {
return TypeDevice; return TypeThing;
} }
if (!m_thingId.isNull() && !m_browserItemId.isEmpty()) { if (!m_thingId.isNull() && !m_browserItemId.isEmpty()) {
return TypeBrowser; return TypeBrowser;
@ -126,10 +90,9 @@ RuleAction::Type RuleAction::type() const
return TypeInterface; return TypeInterface;
} }
// uhmm... invalid... // uhmm... invalid...
return TypeDevice; return TypeThing;
} }
/*! Return true, if this RuleAction contains a \l{RuleActionParam} which is based on an EventTypeId.*/
bool RuleAction::isEventBased() const bool RuleAction::isEventBased() const
{ {
foreach (const RuleActionParam &param, m_ruleActionParams) { foreach (const RuleActionParam &param, m_ruleActionParams) {
@ -150,8 +113,6 @@ bool RuleAction::isStateBased() const
return false; return false;
} }
/*! Converts this \l{RuleAction} to a normal \l{Action}.
* \sa Action, */
Action RuleAction::toAction() const Action RuleAction::toAction() const
{ {
Action action(m_actionTypeId, m_thingId); Action action(m_actionTypeId, m_thingId);
@ -163,14 +124,11 @@ Action RuleAction::toAction() const
return action; return action;
} }
/*! Converts this \l{RuleAction} to a \l{BrowserItemAction}.
* \sa BrowserItemAction, */
BrowserItemAction RuleAction::toBrowserItemAction() const BrowserItemAction RuleAction::toBrowserItemAction() const
{ {
return BrowserItemAction(m_thingId, m_browserItemId); return BrowserItemAction(m_thingId, m_browserItemId);
} }
/*! Returns the actionTypeId of this RuleAction. */
ActionTypeId RuleAction::actionTypeId() const ActionTypeId RuleAction::actionTypeId() const
{ {
return m_actionTypeId; return m_actionTypeId;
@ -181,7 +139,6 @@ void RuleAction::setActionTypeId(const ActionTypeId &actionTypeId)
m_actionTypeId = actionTypeId; m_actionTypeId = actionTypeId;
} }
/*! Returns the browserItemId of this RuleAction. */
QString RuleAction::browserItemId() const QString RuleAction::browserItemId() const
{ {
return m_browserItemId; return m_browserItemId;
@ -192,7 +149,6 @@ void RuleAction::setBrowserItemId(const QString &browserItemId)
m_browserItemId = browserItemId; m_browserItemId = browserItemId;
} }
/*! Returns the \l{ThingId} of this RuleAction. */
ThingId RuleAction::thingId() const ThingId RuleAction::thingId() const
{ {
return m_thingId; return m_thingId;
@ -203,7 +159,6 @@ void RuleAction::setThingId(const ThingId &thingId)
m_thingId = thingId; m_thingId = thingId;
} }
/*! Returns the name of the interface associated with this RuleAction. */
QString RuleAction::interface() const QString RuleAction::interface() const
{ {
return m_interface; return m_interface;
@ -214,7 +169,6 @@ void RuleAction::setInterface(const QString &interface)
m_interface = interface; m_interface = interface;
} }
/*! Returns the name of the action of the associated interface. */
QString RuleAction::interfaceAction() const QString RuleAction::interfaceAction() const
{ {
return m_interfaceAction; return m_interfaceAction;
@ -225,23 +179,16 @@ void RuleAction::setInterfaceAction(const QString &interfaceAction)
m_interfaceAction = interfaceAction; m_interfaceAction = interfaceAction;
} }
/*! Returns the \l{RuleActionParamList} of this RuleAction.
* \sa RuleActionParam, */
RuleActionParams RuleAction::ruleActionParams() const RuleActionParams RuleAction::ruleActionParams() const
{ {
return m_ruleActionParams; return m_ruleActionParams;
} }
/*! Set the \l{RuleActionParamList} of this RuleAction to the given \a ruleActionParams.
* \sa RuleActionParam, */
void RuleAction::setRuleActionParams(const RuleActionParams &ruleActionParams) void RuleAction::setRuleActionParams(const RuleActionParams &ruleActionParams)
{ {
m_ruleActionParams = ruleActionParams; m_ruleActionParams = ruleActionParams;
} }
/*! Returns the \l{RuleActionParam} of this RuleAction with the given \a ruleActionParamTypeId.
* If there is no \l{RuleActionParam} with th given id an invalid \l{RuleActionParam} will be returnend.
* \sa RuleActionParam, */
RuleActionParam RuleAction::ruleActionParam(const ParamTypeId &ruleActionParamTypeId) const RuleActionParam RuleAction::ruleActionParam(const ParamTypeId &ruleActionParamTypeId) const
{ {
foreach (const RuleActionParam &ruleActionParam, m_ruleActionParams) { foreach (const RuleActionParam &ruleActionParam, m_ruleActionParams) {
@ -252,9 +199,6 @@ RuleActionParam RuleAction::ruleActionParam(const ParamTypeId &ruleActionParamTy
return RuleActionParam(); return RuleActionParam();
} }
/*! Returns the \l{RuleActionParam} of this RuleAction with the given \a ruleActionParamName.
* If there is no \l{RuleActionParam} with th given name an invalid \l{RuleActionParam} will be returnend.
* \sa RuleActionParam, */
RuleActionParam RuleAction::ruleActionParam(const QString &ruleActionParamName) const RuleActionParam RuleAction::ruleActionParam(const QString &ruleActionParamName) const
{ {
foreach (const RuleActionParam &ruleActionParam, m_ruleActionParams) { foreach (const RuleActionParam &ruleActionParam, m_ruleActionParams) {
@ -265,7 +209,6 @@ RuleActionParam RuleAction::ruleActionParam(const QString &ruleActionParamName)
return RuleActionParam(); return RuleActionParam();
} }
/*! Copy the data to a \l{RuleAction} from an \a other rule action. */
void RuleAction::operator=(const RuleAction &other) void RuleAction::operator=(const RuleAction &other)
{ {
m_id = other.id(); m_id = other.id();
@ -273,17 +216,15 @@ void RuleAction::operator=(const RuleAction &other)
m_ruleActionParams = other.ruleActionParams(); m_ruleActionParams = other.ruleActionParams();
} }
/*! Print a RuleAction including RuleActionParams to QDebug. */
QDebug operator<<(QDebug dbg, const RuleAction &ruleAction) QDebug operator<<(QDebug dbg, const RuleAction &ruleAction)
{ {
dbg.nospace() << "RuleAction(ActionTypeId:" << ruleAction.actionTypeId().toString() << ", DeviceId:" << ruleAction.thingId().toString() << ", Interface:" << ruleAction.interface() << ", InterfaceAction:" << ruleAction.interfaceAction() << ", BrowserItemId:" << ruleAction.browserItemId() << ")" << endl; dbg.nospace() << "RuleAction(ActionTypeId:" << ruleAction.actionTypeId().toString() << ", ThingId:" << ruleAction.thingId().toString() << ", Interface:" << ruleAction.interface() << ", InterfaceAction:" << ruleAction.interfaceAction() << ", BrowserItemId:" << ruleAction.browserItemId() << ")" << endl;
for (int i = 0; i < ruleAction.ruleActionParams().count(); i++) { for (int i = 0; i < ruleAction.ruleActionParams().count(); i++) {
dbg.nospace() << " " << i << ": " << ruleAction.ruleActionParams().at(i) << endl; dbg.nospace() << " " << i << ": " << ruleAction.ruleActionParams().at(i) << endl;
} }
return dbg; return dbg;
} }
/*! Print a List of RuleActions with all their contents to QDebug. */
QDebug operator<<(QDebug dbg, const QList<RuleAction> &ruleActionList) QDebug operator<<(QDebug dbg, const QList<RuleAction> &ruleActionList)
{ {
dbg.nospace() << "RuleActionList (count:" << ruleActionList.count() << "):" << endl; dbg.nospace() << "RuleActionList (count:" << ruleActionList.count() << "):" << endl;

View File

@ -49,7 +49,7 @@ class LIBNYMEA_EXPORT RuleAction
public: public:
enum Type { enum Type {
TypeDevice, TypeThing,
TypeInterface, TypeInterface,
TypeBrowser TypeBrowser
}; };

View File

@ -28,47 +28,14 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class RuleActionParam
\brief Holds the parameters for a \l{RuleAction}.
\ingroup nymea-types
\ingroup rules
\inmodule libnymea
A RuleActionParam allows rules to take over an \l{Event} parameter into a rule
\l{RuleAction}.
RuleActionParams are identified by either paramTypeId or paramName (for interface based actions).
The parameter value can either be a static \l{value}, a pair of \l{EventTypeId} and \l{ParamTypeId} or a pair of
\l{DeviceId} and \l{StateTypeId}.
When composing the actual Param for the executeAction() call the value is generated as follows:
- Static value params are filled with \l{RuleActionParam::paramTypeId()} and the \l{RuleActionParam::value()}
- Event based actions are filled with \l{RuleActionParam::paramTypeId()} and the param value of the event that triggered this rule, identified by \l{RuleActionParam::eventTypeId()} and \l{RuleActionParam::eventParamTypeId()}
- State based actions are filled with \l{RuleActionParam::paramTypeId()} and the current value of the state identified by \l{RuleActionParam::deviceId()} and \l{RuleActionParam::stateTypeId()}
If the param types are not matching, nymea will do a best effort to cast the values. E.g. a RuleActionParam for
a param of type "string" and a state of type "int" would cast the integer to a string which would always work.
However, the other way round, having a parameter requiring an "int" value, and reading the value from a state of type
"string" might work, if the string does only hold numbers but would fail.
\sa nymeaserver::Rule, RuleAction,
*/
#include "ruleactionparam.h" #include "ruleactionparam.h"
/*! Constructs a \l{RuleActionParam} with the given \a param.
* \sa Param, */
RuleActionParam::RuleActionParam(const Param &param) : RuleActionParam::RuleActionParam(const Param &param) :
m_paramTypeId(param.paramTypeId()), m_paramTypeId(param.paramTypeId()),
m_value(param.value()) m_value(param.value())
{ {
} }
/*! Constructs a \l{RuleActionParam} with the given \a paramTypeId and \a value.
* \sa Param, Event, */
RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const QVariant &value): RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const QVariant &value):
m_paramTypeId(paramTypeId), m_paramTypeId(paramTypeId),
m_value(value) m_value(value)
@ -76,8 +43,6 @@ RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const QVariant
} }
/*! Constructs a \l{RuleActionParam} with the given \a paramTypeId, \a eventTypeId and \a eventParamTypeId.
* \sa Param, Event, */
RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const EventTypeId &eventTypeId, const ParamTypeId &eventParamTypeId): RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const EventTypeId &eventTypeId, const ParamTypeId &eventParamTypeId):
m_paramTypeId(paramTypeId), m_paramTypeId(paramTypeId),
m_eventTypeId(eventTypeId), m_eventTypeId(eventTypeId),
@ -86,8 +51,6 @@ RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const EventType
} }
/*! Constructs a \l{RuleActionParam} with the given \a paramTypeId, \a stateDeviceId and \a stateTypeId.
* \sa Param, Event, */
RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const ThingId &stateThingId, const StateTypeId &stateTypeId): RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const ThingId &stateThingId, const StateTypeId &stateTypeId):
m_paramTypeId(paramTypeId), m_paramTypeId(paramTypeId),
m_stateThingId(stateThingId), m_stateThingId(stateThingId),
@ -96,8 +59,6 @@ RuleActionParam::RuleActionParam(const ParamTypeId &paramTypeId, const ThingId &
} }
/*! Constructs a \l{RuleActionParam} with the given \a paramName and \a value.
* \sa Param, Event, */
RuleActionParam::RuleActionParam(const QString &paramName, const QVariant &value): RuleActionParam::RuleActionParam(const QString &paramName, const QVariant &value):
m_paramName(paramName), m_paramName(paramName),
m_value(value) m_value(value)
@ -105,8 +66,6 @@ RuleActionParam::RuleActionParam(const QString &paramName, const QVariant &value
} }
/*! Constructs a \l{RuleActionParam} with the given \a paramName, \a eventTypeId and \a eventParamTypeId.
* \sa Param, Event, */
RuleActionParam::RuleActionParam(const QString &paramName, const EventTypeId &eventTypeId, const ParamTypeId &eventParamTypeId): RuleActionParam::RuleActionParam(const QString &paramName, const EventTypeId &eventTypeId, const ParamTypeId &eventParamTypeId):
m_paramName(paramName), m_paramName(paramName),
m_eventTypeId(eventTypeId), m_eventTypeId(eventTypeId),
@ -115,8 +74,6 @@ RuleActionParam::RuleActionParam(const QString &paramName, const EventTypeId &ev
} }
/*! Constructs a \l{RuleActionParam} with the given \a paramName, \a stateDeviceId and \a stateTypeId.
* \sa Param, Event, */
RuleActionParam::RuleActionParam(const QString &paramName, const ThingId &stateThingId, const StateTypeId &stateTypeId): RuleActionParam::RuleActionParam(const QString &paramName, const ThingId &stateThingId, const StateTypeId &stateTypeId):
m_paramName(paramName), m_paramName(paramName),
m_stateThingId(stateThingId), m_stateThingId(stateThingId),
@ -125,7 +82,6 @@ RuleActionParam::RuleActionParam(const QString &paramName, const ThingId &stateT
} }
/*! Returns the \l ParamTypeId of this \l RuleActionParam. */
ParamTypeId RuleActionParam::paramTypeId() const ParamTypeId RuleActionParam::paramTypeId() const
{ {
return m_paramTypeId; return m_paramTypeId;
@ -136,7 +92,6 @@ void RuleActionParam::setParamTypeId(const ParamTypeId &paramTypeId)
m_paramTypeId = paramTypeId; m_paramTypeId = paramTypeId;
} }
/*! Returns the name of this RuleActionParam. */
QString RuleActionParam::paramName() const QString RuleActionParam::paramName() const
{ {
return m_paramName; return m_paramName;
@ -147,67 +102,56 @@ void RuleActionParam::setParamName(const QString &paramName)
m_paramName = paramName; m_paramName = paramName;
} }
/*! Returns the value of this RuleActionParam. */
QVariant RuleActionParam::value() const QVariant RuleActionParam::value() const
{ {
return m_value; return m_value;
} }
/*! Sets the \a value of this RuleActionParam. */
void RuleActionParam::setValue(const QVariant &value) void RuleActionParam::setValue(const QVariant &value)
{ {
m_value = value; m_value = value;
} }
/*! Return the EventTypeId of the \l{Event} with the \l{Param} which will be taken over in the \l{RuleAction}. */
EventTypeId RuleActionParam::eventTypeId() const EventTypeId RuleActionParam::eventTypeId() const
{ {
return m_eventTypeId; return m_eventTypeId;
} }
/*! Sets the \a eventTypeId of the \l{Event} with the \l{Param} which will be taken over in the \l{RuleAction}. */
void RuleActionParam::setEventTypeId(const EventTypeId &eventTypeId) void RuleActionParam::setEventTypeId(const EventTypeId &eventTypeId)
{ {
m_eventTypeId = eventTypeId; m_eventTypeId = eventTypeId;
} }
/*! Returns the eventParamTypeId of this RuleActionParam. */
ParamTypeId RuleActionParam::eventParamTypeId() const ParamTypeId RuleActionParam::eventParamTypeId() const
{ {
return m_eventParamTypeId; return m_eventParamTypeId;
} }
/*! Sets the \a eventParamTypeId of this RuleActionParam. */
void RuleActionParam::setEventParamTypeId(const ParamTypeId &eventParamTypeId) void RuleActionParam::setEventParamTypeId(const ParamTypeId &eventParamTypeId)
{ {
m_eventParamTypeId = eventParamTypeId; m_eventParamTypeId = eventParamTypeId;
} }
/*! Returns the \l{ThingId} identifying the thing to use a state value from. */
ThingId RuleActionParam::stateThingId() const ThingId RuleActionParam::stateThingId() const
{ {
return m_stateThingId; return m_stateThingId;
} }
/*! Sets the \l{ThingId} identifying the thing to use a state value from. */
void RuleActionParam::setStateThingId(const ThingId &thingId) void RuleActionParam::setStateThingId(const ThingId &thingId)
{ {
m_stateThingId = thingId; m_stateThingId = thingId;
} }
/*! Returns the stateTypeId identifying the state to use the value. */
StateTypeId RuleActionParam::stateTypeId() const StateTypeId RuleActionParam::stateTypeId() const
{ {
return m_stateTypeId; return m_stateTypeId;
} }
/*! Sets the stateTypeId identifying the state to use the value from. */
void RuleActionParam::setStateTypeId(const StateTypeId &stateTypeId) void RuleActionParam::setStateTypeId(const StateTypeId &stateTypeId)
{ {
m_stateTypeId = stateTypeId; m_stateTypeId = stateTypeId;
} }
/*! Returns true if the \tt{(paramTypeId AND value) XOR (paramTypeId AND eventTypeId AND eventParamName)} of this RuleActionParam are set.*/
bool RuleActionParam::isValid() const bool RuleActionParam::isValid() const
{ {
if (m_paramTypeId.isNull() && m_paramName.isNull()) { if (m_paramTypeId.isNull() && m_paramName.isNull()) {
@ -231,7 +175,6 @@ bool RuleActionParam::isStateBased() const
return !m_stateThingId.isNull() && !m_stateTypeId.isNull(); return !m_stateThingId.isNull() && !m_stateTypeId.isNull();
} }
/*! Writes the paramTypeId, value, eventId and eventParamTypeId of the given \a ruleActionParam to \a dbg. */
QDebug operator<<(QDebug dbg, const RuleActionParam &ruleActionParam) QDebug operator<<(QDebug dbg, const RuleActionParam &ruleActionParam)
{ {
dbg.nospace() << "RuleActionParam(ParamTypeId: " << ruleActionParam.paramTypeId().toString() << ", Name:" << ruleActionParam.paramName() << ", Value:" << ruleActionParam.value(); dbg.nospace() << "RuleActionParam(ParamTypeId: " << ruleActionParam.paramTypeId().toString() << ", Name:" << ruleActionParam.paramName() << ", Value:" << ruleActionParam.value();
@ -243,24 +186,11 @@ QDebug operator<<(QDebug dbg, const RuleActionParam &ruleActionParam)
return dbg; return dbg;
} }
// ActionTypeParamList
/*!
\class RuleActionParamList
\brief Holds a list of \l{RuleActionParam}{RuleActionParams}
\ingroup types
\inmodule libnymea
\sa RuleActionParam, RuleAction,
*/
/*! Returns true if this \l{RuleActionParamList} contains a \l{RuleActionParam} with the given \a ruleActionParamTypeId. */
bool RuleActionParams::hasParam(const ParamTypeId &ruleActionParamTypeId) const bool RuleActionParams::hasParam(const ParamTypeId &ruleActionParamTypeId) const
{ {
return m_ids.contains(ruleActionParamTypeId); return m_ids.contains(ruleActionParamTypeId);
} }
/*! Returns true if this \l{RuleActionParamList} contains a \l{RuleActionParam} with the given \a ruleActionParamName. */
bool RuleActionParams::hasParam(const QString &ruleActionParamName) const bool RuleActionParams::hasParam(const QString &ruleActionParamName) const
{ {
foreach (const RuleActionParam &param, *this) { foreach (const RuleActionParam &param, *this) {
@ -271,7 +201,6 @@ bool RuleActionParams::hasParam(const QString &ruleActionParamName) const
return false; return false;
} }
/*! Returns the value of the \l{RuleActionParam} with the given \a ruleActionParamTypeId. */
QVariant RuleActionParams::paramValue(const ParamTypeId &ruleActionParamTypeId) const QVariant RuleActionParams::paramValue(const ParamTypeId &ruleActionParamTypeId) const
{ {
foreach (const RuleActionParam &param, *this) { foreach (const RuleActionParam &param, *this) {
@ -283,7 +212,6 @@ QVariant RuleActionParams::paramValue(const ParamTypeId &ruleActionParamTypeId)
return QVariant(); return QVariant();
} }
/*! Returns true if the \a value of the \l{RuleActionParam} with the given \a ruleActionParamTypeId could be set successfully. */
bool RuleActionParams::setParamValue(const ParamTypeId &ruleActionParamTypeId, const QVariant &value) bool RuleActionParams::setParamValue(const ParamTypeId &ruleActionParamTypeId, const QVariant &value)
{ {
for (int i = 0; i < count(); i++) { for (int i = 0; i < count(); i++) {
@ -296,7 +224,6 @@ bool RuleActionParams::setParamValue(const ParamTypeId &ruleActionParamTypeId, c
return false; return false;
} }
/*! Appends the given \a ruleActionParam to a RuleActionParamList. */
RuleActionParams RuleActionParams::operator<<(const RuleActionParam &ruleActionParam) RuleActionParams RuleActionParams::operator<<(const RuleActionParam &ruleActionParam)
{ {
this->append(ruleActionParam); this->append(ruleActionParam);
@ -304,7 +231,6 @@ RuleActionParams RuleActionParams::operator<<(const RuleActionParam &ruleActionP
return *this; return *this;
} }
/*! Writes the ruleActionParam of the given \a ruleActionParams to \a dbg. */
QDebug operator<<(QDebug dbg, const RuleActionParams &ruleActionParams) QDebug operator<<(QDebug dbg, const RuleActionParams &ruleActionParams)
{ {
dbg.nospace() << "RuleActionParamList (count:" << ruleActionParams.count() << ")" << endl; dbg.nospace() << "RuleActionParamList (count:" << ruleActionParams.count() << ")" << endl;

View File

@ -61,8 +61,8 @@
The given RuleId is not valid. The given RuleId is not valid.
\value RuleErrorRuleNotFound \value RuleErrorRuleNotFound
Couldn't find a \l{Rule} with the given id. Couldn't find a \l{Rule} with the given id.
\value RuleErrorDeviceNotFound \value RuleErrorThingNotFound
Couldn't find a \l{Device} with the given id. Couldn't find a \l{Thing} with the given id.
\value RuleErrorEventTypeNotFound \value RuleErrorEventTypeNotFound
Couldn't find a \l{EventType} with the given id. Couldn't find a \l{EventType} with the given id.
\value RuleErrorStateTypeNotFound \value RuleErrorStateTypeNotFound
@ -105,7 +105,7 @@
\value RemovePolicyCascade \value RemovePolicyCascade
Remove the whole \l{Rule}. Remove the whole \l{Rule}.
\value RemovePolicyUpdate \value RemovePolicyUpdate
Remove a \l{Device} from a rule. Remove a \l{Thing} from a rule.
*/ */
@ -152,11 +152,11 @@ QList<Rule> RuleEngine::evaluateEvent(const Event &event)
{ {
Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(event.thingId()); Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(event.thingId());
if (!thing) { if (!thing) {
qCWarning(dcRuleEngine()) << "Invalid event. DeviceID does not reference a valid device"; qCWarning(dcRuleEngine()) << "Invalid event. ThingID does not reference a valid thing";
return QList<Rule>(); return QList<Rule>();
} }
ThingClass deviceClass = NymeaCore::instance()->thingManager()->findThingClass(thing->thingClassId()); ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(thing->thingClassId());
EventType eventType = deviceClass.eventTypes().findById(event.eventTypeId()); EventType eventType = thingClass.eventTypes().findById(event.eventTypeId());
if (event.params().count() == 0) { if (event.params().count() == 0) {
@ -310,15 +310,15 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
// Check IDs in each EventDescriptor // Check IDs in each EventDescriptor
foreach (const EventDescriptor &eventDescriptor, rule.eventDescriptors()) { foreach (const EventDescriptor &eventDescriptor, rule.eventDescriptors()) {
if (!eventDescriptor.isValid()) { if (!eventDescriptor.isValid()) {
qWarning(dcRuleEngine()) << "EventDescriptor is incomplete. It must have either eventTypeId and deviceId, or interface and interfaceEvent"; qWarning(dcRuleEngine()) << "EventDescriptor is incomplete. It must have either eventTypeId and thingId, or interface and interfaceEvent";
return RuleErrorEventTypeNotFound; return RuleErrorEventTypeNotFound;
} }
if (eventDescriptor.type() == EventDescriptor::TypeDevice) { if (eventDescriptor.type() == EventDescriptor::TypeThing) {
// check deviceId // check thingId
Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(eventDescriptor.thingId()); Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(eventDescriptor.thingId());
if (!thing) { if (!thing) {
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device for eventTypeId" << eventDescriptor.eventTypeId(); qCWarning(dcRuleEngine) << "Cannot create rule. No configured thing for eventTypeId" << eventDescriptor.eventTypeId();
return RuleErrorDeviceNotFound; return RuleErrorThingNotFound;
} }
// Check eventTypeId for this deivce // Check eventTypeId for this deivce
@ -330,7 +330,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit)
} }
} }
if (!eventTypeFound) { if (!eventTypeFound) {
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + thing->name() + " has no event type:" << eventDescriptor.eventTypeId(); qCWarning(dcRuleEngine) << "Cannot create rule. Thing " + thing->name() + " has no event type:" << eventDescriptor.eventTypeId();
return RuleErrorEventTypeNotFound; return RuleErrorEventTypeNotFound;
} }
} else { } else {
@ -624,7 +624,6 @@ RuleEngine::RuleError RuleEngine::executeExitActions(const RuleId &ruleId)
return RuleErrorNoError; return RuleErrorNoError;
} }
/*! Returns the \l{Rule} with the given \a ruleId. If the \l{Rule} does not exist, it will return \l{Rule::Rule()} */
Rule RuleEngine::findRule(const RuleId &ruleId) Rule RuleEngine::findRule(const RuleId &ruleId)
{ {
if (!m_rules.contains(ruleId)) if (!m_rules.contains(ruleId))
@ -633,7 +632,6 @@ Rule RuleEngine::findRule(const RuleId &ruleId)
return m_rules.value(ruleId); return m_rules.value(ruleId);
} }
/*! Returns a list of all \l{Rule}{Rules} loaded in this Engine, which contains a \l{Device} with the given \a deviceId. */
QList<RuleId> RuleEngine::findRules(const ThingId &thingId) const QList<RuleId> RuleEngine::findRules(const ThingId &thingId) const
{ {
// Find all offending rules // Find all offending rules
@ -722,7 +720,6 @@ QList<ThingId> RuleEngine::thingsInRules() const
return tmp; return tmp;
} }
/*! Removes thing \l{Thing} with id \a thingId from the \l{Rule} with the given \a id. */
void RuleEngine::removeThingFromRule(const RuleId &id, const ThingId &thingId) void RuleEngine::removeThingFromRule(const RuleId &id, const ThingId &thingId)
{ {
if (!m_rules.contains(id)) if (!m_rules.contains(id))
@ -730,7 +727,7 @@ void RuleEngine::removeThingFromRule(const RuleId &id, const ThingId &thingId)
Rule rule = m_rules.value(id); Rule rule = m_rules.value(id);
// remove device from eventDescriptors // remove thing from eventDescriptors
QList<EventDescriptor> eventDescriptors = rule.eventDescriptors(); QList<EventDescriptor> eventDescriptors = rule.eventDescriptors();
QList<int> removeIndexes; QList<int> removeIndexes;
for (int i = 0; i < eventDescriptors.count(); i++) { for (int i = 0; i < eventDescriptors.count(); i++) {
@ -742,11 +739,11 @@ void RuleEngine::removeThingFromRule(const RuleId &id, const ThingId &thingId)
eventDescriptors.takeAt(removeIndexes.takeLast()); eventDescriptors.takeAt(removeIndexes.takeLast());
} }
// remove device from state evaluators // remove thing from state evaluators
StateEvaluator stateEvalatuator = rule.stateEvaluator(); StateEvaluator stateEvalatuator = rule.stateEvaluator();
stateEvalatuator.removeThing(thingId); stateEvalatuator.removeThing(thingId);
// remove device from actions // remove thing from actions
QList<RuleAction> actions = rule.actions(); QList<RuleAction> actions = rule.actions();
for (int i = 0; i < actions.count(); i++) { for (int i = 0; i < actions.count(); i++) {
if (actions.at(i).thingId() == thingId) { if (actions.at(i).thingId() == thingId) {
@ -764,7 +761,7 @@ void RuleEngine::removeThingFromRule(const RuleId &id, const ThingId &thingId)
actions.takeAt(removeIndexes.takeLast()); actions.takeAt(removeIndexes.takeLast());
} }
// remove device from exit actions // remove thing from exit actions
QList<RuleAction> exitActions = rule.exitActions(); QList<RuleAction> exitActions = rule.exitActions();
for (int i = 0; i < exitActions.count(); i++) { for (int i = 0; i < exitActions.count(); i++) {
if (exitActions.at(i).thingId() == thingId) { if (exitActions.at(i).thingId() == thingId) {
@ -814,18 +811,18 @@ void RuleEngine::removeThingFromRule(const RuleId &id, const ThingId &thingId)
bool RuleEngine::containsEvent(const Rule &rule, const Event &event, const ThingClassId &thingClassId) bool RuleEngine::containsEvent(const Rule &rule, const Event &event, const ThingClassId &thingClassId)
{ {
foreach (const EventDescriptor &eventDescriptor, rule.eventDescriptors()) { foreach (const EventDescriptor &eventDescriptor, rule.eventDescriptors()) {
// If this is a device based rule, eventTypeId and deviceId must match // If this is a thing based rule, eventTypeId and thingId must match
if (eventDescriptor.type() == EventDescriptor::TypeDevice) { if (eventDescriptor.type() == EventDescriptor::TypeThing) {
if (eventDescriptor.eventTypeId() != event.eventTypeId() || eventDescriptor.thingId() != event.thingId()) { if (eventDescriptor.eventTypeId() != event.eventTypeId() || eventDescriptor.thingId() != event.thingId()) {
continue; continue;
} }
} }
// If this is a interface based rule, the device must implement the interface // If this is a interface based rule, the thing must implement the interface
if (eventDescriptor.type() == EventDescriptor::TypeInterface) { if (eventDescriptor.type() == EventDescriptor::TypeInterface) {
ThingClass dc = NymeaCore::instance()->thingManager()->findThingClass(thingClassId); ThingClass dc = NymeaCore::instance()->thingManager()->findThingClass(thingClassId);
if (!dc.interfaces().contains(eventDescriptor.interface())) { if (!dc.interfaces().contains(eventDescriptor.interface())) {
// DeviceClass for this event doesn't implement the interface for this eventDescriptor // ThingClass for this event doesn't implement the interface for this eventDescriptor
continue; continue;
} }
@ -836,7 +833,7 @@ bool RuleEngine::containsEvent(const Rule &rule, const Event &event, const Thing
} }
} }
// Ok, either device/eventTypeId or interface/interfaceEvent are matching. Compare the paramdescriptor // Ok, either thing/eventTypeId or interface/interfaceEvent are matching. Compare the paramdescriptor
bool allOK = true; bool allOK = true;
foreach (const ParamDescriptor &paramDescriptor, eventDescriptor.paramDescriptors()) { foreach (const ParamDescriptor &paramDescriptor, eventDescriptor.paramDescriptors()) {
QVariant paramValue; QVariant paramValue;
@ -900,13 +897,13 @@ bool RuleEngine::containsEvent(const Rule &rule, const Event &event, const Thing
bool RuleEngine::containsState(const StateEvaluator &stateEvaluator, const Event &stateChangeEvent) bool RuleEngine::containsState(const StateEvaluator &stateEvaluator, const Event &stateChangeEvent)
{ {
if (stateEvaluator.stateDescriptor().isValid()) { if (stateEvaluator.stateDescriptor().isValid()) {
if (stateEvaluator.stateDescriptor().type() == StateDescriptor::TypeDevice) { if (stateEvaluator.stateDescriptor().type() == StateDescriptor::TypeThing) {
if (stateEvaluator.stateDescriptor().stateTypeId().toString() == stateChangeEvent.eventTypeId().toString()) { if (stateEvaluator.stateDescriptor().stateTypeId().toString() == stateChangeEvent.eventTypeId().toString()) {
return true; return true;
} }
} else { } else {
Thing *device = NymeaCore::instance()->thingManager()->findConfiguredThing(stateChangeEvent.thingId()); Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(stateChangeEvent.thingId());
ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(device->thingClassId()); ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(thing->thingClassId());
if (thingClass.interfaces().contains(stateEvaluator.stateDescriptor().interface())) { if (thingClass.interfaces().contains(stateEvaluator.stateDescriptor().interface())) {
return true; return true;
} }
@ -925,21 +922,21 @@ bool RuleEngine::containsState(const StateEvaluator &stateEvaluator, const Event
RuleEngine::RuleError RuleEngine::checkRuleAction(const RuleAction &ruleAction, const Rule &rule) RuleEngine::RuleError RuleEngine::checkRuleAction(const RuleAction &ruleAction, const Rule &rule)
{ {
if (!ruleAction.isValid()) { if (!ruleAction.isValid()) {
qWarning(dcRuleEngine()) << "Action is incomplete. It must have either deviceId and actionTypeId/browserItemId, or interface and interfaceAction:" << ruleAction; qWarning(dcRuleEngine()) << "Action is incomplete. It must have either thingId and actionTypeId/browserItemId, or interface and interfaceAction:" << ruleAction;
return RuleErrorActionTypeNotFound; return RuleErrorActionTypeNotFound;
} }
ActionType actionType; ActionType actionType;
if (ruleAction.type() == RuleAction::TypeDevice) { if (ruleAction.type() == RuleAction::TypeThing) {
Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(ruleAction.thingId()); Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(ruleAction.thingId());
if (!thing) { if (!thing) {
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device with ID" << ruleAction.thingId(); qCWarning(dcRuleEngine) << "Cannot create rule. No configured thing with ID" << ruleAction.thingId();
return RuleErrorDeviceNotFound; return RuleErrorThingNotFound;
} }
ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(thing->thingClassId()); ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(thing->thingClassId());
if (!thingClass.hasActionType(ruleAction.actionTypeId())) { if (!thingClass.hasActionType(ruleAction.actionTypeId())) {
qCWarning(dcRuleEngine) << "Cannot create rule. Device " + thing->name() + " has no action type:" << ruleAction.actionTypeId(); qCWarning(dcRuleEngine) << "Cannot create rule. Thing " + thing->name() + " has no action type:" << ruleAction.actionTypeId();
return RuleErrorActionTypeNotFound; return RuleErrorActionTypeNotFound;
} }
@ -956,10 +953,10 @@ RuleEngine::RuleError RuleEngine::checkRuleAction(const RuleAction &ruleAction,
return RuleError::RuleErrorActionTypeNotFound; return RuleError::RuleErrorActionTypeNotFound;
} }
} else if (ruleAction.type() == RuleAction::TypeBrowser) { } else if (ruleAction.type() == RuleAction::TypeBrowser) {
Thing *device = NymeaCore::instance()->thingManager()->findConfiguredThing(ruleAction.thingId()); Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(ruleAction.thingId());
if (!device) { if (!thing) {
qCWarning(dcRuleEngine) << "Cannot create rule. No configured device with ID" << ruleAction.thingId(); qCWarning(dcRuleEngine) << "Cannot create rule. No configured thing with ID" << ruleAction.thingId();
return RuleErrorDeviceNotFound; return RuleErrorThingNotFound;
} }
if (ruleAction.browserItemId().isEmpty()) { if (ruleAction.browserItemId().isEmpty()) {
qCWarning(dcRuleEngine()) << "Cannot create rule with empty browserItemId"; qCWarning(dcRuleEngine()) << "Cannot create rule with empty browserItemId";
@ -1036,8 +1033,8 @@ RuleEngine::RuleError RuleEngine::checkRuleActionParam(const RuleActionParam &ru
} else if (ruleActionParam.isStateBased()) { } else if (ruleActionParam.isStateBased()) {
Thing *d = NymeaCore::instance()->thingManager()->findConfiguredThing(ruleActionParam.stateThingId()); Thing *d = NymeaCore::instance()->thingManager()->findConfiguredThing(ruleActionParam.stateThingId());
if (!d) { if (!d) {
qCWarning(dcRuleEngine()) << "Cannot create Rule. DeviceId from RuleActionParam" << ruleActionParam.paramTypeId() << "not found in system."; qCWarning(dcRuleEngine()) << "Cannot create Rule. ThingId from RuleActionParam" << ruleActionParam.paramTypeId() << "not found in system.";
return RuleErrorDeviceNotFound; return RuleErrorThingNotFound;
} }
ThingClass stateThingClass = NymeaCore::instance()->thingManager()->findThingClass(d->thingClassId()); ThingClass stateThingClass = NymeaCore::instance()->thingManager()->findThingClass(d->thingClassId());
StateType stateType = stateThingClass.stateTypes().findById(ruleActionParam.stateTypeId()); StateType stateType = stateThingClass.stateTypes().findById(ruleActionParam.stateTypeId());
@ -1067,8 +1064,8 @@ RuleEngine::RuleError RuleEngine::checkRuleActionParam(const RuleActionParam &ru
QVariant::Type RuleEngine::getActionParamType(const ActionTypeId &actionTypeId, const ParamTypeId &paramTypeId) QVariant::Type RuleEngine::getActionParamType(const ActionTypeId &actionTypeId, const ParamTypeId &paramTypeId)
{ {
foreach (const ThingClass &deviceClass, NymeaCore::instance()->thingManager()->supportedThings()) { foreach (const ThingClass &thingClass, NymeaCore::instance()->thingManager()->supportedThings()) {
foreach (const ActionType &actionType, deviceClass.actionTypes()) { foreach (const ActionType &actionType, thingClass.actionTypes()) {
if (actionType.id() == actionTypeId) { if (actionType.id() == actionTypeId) {
foreach (const ParamType &paramType, actionType.paramTypes()) { foreach (const ParamType &paramType, actionType.paramTypes()) {
if (paramType.id() == paramTypeId) { if (paramType.id() == paramTypeId) {
@ -1084,8 +1081,8 @@ QVariant::Type RuleEngine::getActionParamType(const ActionTypeId &actionTypeId,
QVariant::Type RuleEngine::getEventParamType(const EventTypeId &eventTypeId, const ParamTypeId &paramTypeId) QVariant::Type RuleEngine::getEventParamType(const EventTypeId &eventTypeId, const ParamTypeId &paramTypeId)
{ {
foreach (const ThingClass &deviceClass, NymeaCore::instance()->thingManager()->supportedThings()) { foreach (const ThingClass &thingClass, NymeaCore::instance()->thingManager()->supportedThings()) {
foreach (const EventType &eventType, deviceClass.eventTypes()) { foreach (const EventType &eventType, thingClass.eventTypes()) {
if (eventType.id() == eventTypeId) { if (eventType.id() == eventTypeId) {
foreach (const ParamType &paramType, eventType.paramTypes()) { foreach (const ParamType &paramType, eventType.paramTypes()) {
if (paramType.id() == paramTypeId) { if (paramType.id() == paramTypeId) {
@ -1193,7 +1190,7 @@ void RuleEngine::saveRule(const Rule &rule)
for (int i = 0; i < rule.eventDescriptors().count(); i++) { for (int i = 0; i < rule.eventDescriptors().count(); i++) {
const EventDescriptor &eventDescriptor = rule.eventDescriptors().at(i); const EventDescriptor &eventDescriptor = rule.eventDescriptors().at(i);
settings.beginGroup("EventDescriptor-" + QString::number(i)); settings.beginGroup("EventDescriptor-" + QString::number(i));
settings.setValue("deviceId", eventDescriptor.thingId().toString()); settings.setValue("thingId", eventDescriptor.thingId().toString());
settings.setValue("eventTypeId", eventDescriptor.eventTypeId().toString()); settings.setValue("eventTypeId", eventDescriptor.eventTypeId().toString());
settings.setValue("interface", eventDescriptor.interface()); settings.setValue("interface", eventDescriptor.interface());
settings.setValue("interfaceEvent", eventDescriptor.interfaceEvent()); settings.setValue("interfaceEvent", eventDescriptor.interfaceEvent());
@ -1233,11 +1230,11 @@ void RuleEngine::saveRuleActions(NymeaSettings *settings, const QList<RuleAction
int i = 0; int i = 0;
foreach (const RuleAction &action, ruleActions) { foreach (const RuleAction &action, ruleActions) {
settings->beginGroup(QString::number(i)); settings->beginGroup(QString::number(i));
if (action.type() == RuleAction::TypeDevice) { if (action.type() == RuleAction::TypeThing) {
settings->setValue("deviceId", action.thingId().toString()); settings->setValue("thingId", action.thingId().toString());
settings->setValue("actionTypeId", action.actionTypeId().toString()); settings->setValue("actionTypeId", action.actionTypeId().toString());
} else if (action.type() == RuleAction::TypeBrowser) { } else if (action.type() == RuleAction::TypeBrowser) {
settings->setValue("deviceId", action.thingId().toString()); settings->setValue("thingId", action.thingId().toString());
settings->setValue("browserItemId", action.browserItemId()); settings->setValue("browserItemId", action.browserItemId());
} else if (action.type() == RuleAction::TypeInterface){ } else if (action.type() == RuleAction::TypeInterface){
settings->setValue("interface", action.interface()); settings->setValue("interface", action.interface());
@ -1257,7 +1254,7 @@ void RuleEngine::saveRuleActions(NymeaSettings *settings, const QList<RuleAction
settings->setValue("eventTypeId", param.eventTypeId().toString()); settings->setValue("eventTypeId", param.eventTypeId().toString());
settings->setValue("eventParamTypeId", param.eventParamTypeId()); settings->setValue("eventParamTypeId", param.eventParamTypeId());
} else if (param.isStateBased()) { } else if (param.isStateBased()) {
settings->setValue("stateDeviceId", param.stateThingId().toString()); settings->setValue("stateThingId", param.stateThingId().toString());
settings->setValue("stateTypeId", param.stateTypeId()); settings->setValue("stateTypeId", param.stateTypeId());
} }
settings->endGroup(); settings->endGroup();
@ -1328,6 +1325,7 @@ QList<RuleAction> RuleEngine::loadRuleActions(NymeaSettings *settings)
RuleAction action = RuleAction(ThingId(settings->value("thingId").toString()), settings->value("browserItemId").toString()); RuleAction action = RuleAction(ThingId(settings->value("thingId").toString()), settings->value("browserItemId").toString());
actions.append(action); actions.append(action);
} else if (settings->contains("deviceId") && settings->contains("browserItemId")) { } else if (settings->contains("deviceId") && settings->contains("browserItemId")) {
// nymea < 0.19
RuleAction action = RuleAction(ThingId(settings->value("deviceId").toString()), settings->value("browserItemId").toString()); RuleAction action = RuleAction(ThingId(settings->value("deviceId").toString()), settings->value("browserItemId").toString());
actions.append(action); actions.append(action);
} else if (settings->contains("interface") && settings->contains("interfaceAction")){ } else if (settings->contains("interface") && settings->contains("interfaceAction")){

View File

@ -51,7 +51,7 @@ public:
RuleErrorNoError, RuleErrorNoError,
RuleErrorInvalidRuleId, RuleErrorInvalidRuleId,
RuleErrorRuleNotFound, RuleErrorRuleNotFound,
RuleErrorDeviceNotFound, RuleErrorThingNotFound,
RuleErrorEventTypeNotFound, RuleErrorEventTypeNotFound,
RuleErrorStateTypeNotFound, RuleErrorStateTypeNotFound,
RuleErrorActionTypeNotFound, RuleErrorActionTypeNotFound,

View File

@ -28,20 +28,6 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*!
\class nymeaserver::StateEvaluator
\brief This class helps to evaluate a \l{State} and .
\ingroup rules
\inmodule core
The \l StateEvaluator class helps to evaluate a \l StateDescriptor and check if all \l {State}{States}
from the given \l StateDescriptor are valid. A \l StateDescriptor is valid if conditions of the
\l StateDescriptor are true.
\sa StateDescriptor, State, RuleEngine
*/
#include "stateevaluator.h" #include "stateevaluator.h"
#include "nymeacore.h" #include "nymeacore.h"
@ -51,14 +37,12 @@
namespace nymeaserver { namespace nymeaserver {
/*! Constructs a new StateEvaluator for the given \a stateDescriptor. */
StateEvaluator::StateEvaluator(const StateDescriptor &stateDescriptor): StateEvaluator::StateEvaluator(const StateDescriptor &stateDescriptor):
m_stateDescriptor(stateDescriptor), m_stateDescriptor(stateDescriptor),
m_operatorType(Types::StateOperatorAnd) m_operatorType(Types::StateOperatorAnd)
{ {
} }
/*! Constructs a new StateEvaluator for the given \a childEvaluators and \a stateOperator. */
StateEvaluator::StateEvaluator(QList<StateEvaluator> childEvaluators, Types::StateOperator stateOperator): StateEvaluator::StateEvaluator(QList<StateEvaluator> childEvaluators, Types::StateOperator stateOperator):
m_stateDescriptor(), m_stateDescriptor(),
m_childEvaluators(childEvaluators), m_childEvaluators(childEvaluators),
@ -66,7 +50,6 @@ StateEvaluator::StateEvaluator(QList<StateEvaluator> childEvaluators, Types::Sta
{ {
} }
/*! Returns the \l StateDescriptor of this \l StateEvaluator. */
StateDescriptor StateEvaluator::stateDescriptor() const StateDescriptor StateEvaluator::stateDescriptor() const
{ {
return m_stateDescriptor; return m_stateDescriptor;
@ -77,73 +60,64 @@ void StateEvaluator::setStateDescriptor(const StateDescriptor &stateDescriptor)
m_stateDescriptor = stateDescriptor; m_stateDescriptor = stateDescriptor;
} }
/*! Returns the list of child \l {StateEvaluator}{StateEvaluators} of this \l StateEvaluator. */
StateEvaluators StateEvaluator::childEvaluators() const StateEvaluators StateEvaluator::childEvaluators() const
{ {
return m_childEvaluators; return m_childEvaluators;
} }
/*! Sets the list of child evaluators of this \l StateEvaluator to the given \a stateEvaluators.*/
void StateEvaluator::setChildEvaluators(const StateEvaluators &stateEvaluators) void StateEvaluator::setChildEvaluators(const StateEvaluators &stateEvaluators)
{ {
m_childEvaluators = stateEvaluators; m_childEvaluators = stateEvaluators;
} }
/*! Appends the given \a stateEvaluator to the child evaluators of this \l StateEvaluator.
\sa childEvaluators()
*/
void StateEvaluator::appendEvaluator(const StateEvaluator &stateEvaluator) void StateEvaluator::appendEvaluator(const StateEvaluator &stateEvaluator)
{ {
m_childEvaluators.append(stateEvaluator); m_childEvaluators.append(stateEvaluator);
} }
/*! Returns the \l {Types::StateOperator}{StateOperator} for this \l StateEvaluator.*/
Types::StateOperator StateEvaluator::operatorType() const Types::StateOperator StateEvaluator::operatorType() const
{ {
return m_operatorType; return m_operatorType;
} }
/*! Sets the \l {Types::StateOperator}{StateOperator} for this \l StateEvaluator to the given.
* \a operatorType. This operator will be used to evaluate the child evaluator list.*/
void StateEvaluator::setOperatorType(Types::StateOperator operatorType) void StateEvaluator::setOperatorType(Types::StateOperator operatorType)
{ {
m_operatorType = operatorType; m_operatorType = operatorType;
} }
/*! Returns true, if all child evaluator conditions are true depending on the \l {Types::StateOperator}{StateOperator}.*/
bool StateEvaluator::evaluate() const bool StateEvaluator::evaluate() const
{ {
qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "Evaluating: Operator type" << m_operatorType << "Valid descriptor:" << m_stateDescriptor.isValid() << "Childs:" << m_childEvaluators.count(); qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "Evaluating: Operator type" << m_operatorType << "Valid descriptor:" << m_stateDescriptor.isValid() << "Childs:" << m_childEvaluators.count();
bool descriptorMatching = true; bool descriptorMatching = true;
if (m_stateDescriptor.isValid()) { if (m_stateDescriptor.isValid()) {
descriptorMatching = false; descriptorMatching = false;
if (m_stateDescriptor.type() == StateDescriptor::TypeDevice) { if (m_stateDescriptor.type() == StateDescriptor::TypeThing) {
Thing *device = NymeaCore::instance()->thingManager()->findConfiguredThing(m_stateDescriptor.thingId()); Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(m_stateDescriptor.thingId());
if (device) { if (thing) {
ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(device->thingClassId()); ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(thing->thingClassId());
if (device->hasState(m_stateDescriptor.stateTypeId())) { if (thing->hasState(m_stateDescriptor.stateTypeId())) {
if (m_stateDescriptor == device->state(m_stateDescriptor.stateTypeId())) { if (m_stateDescriptor == thing->state(m_stateDescriptor.stateTypeId())) {
qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "State" << device->name() << thingClass.stateTypes().findById(m_stateDescriptor.stateTypeId()).name() << (descriptorMatching ? "is" : "not") << "matching:" << m_stateDescriptor.stateValue() << m_stateDescriptor.operatorType() << device->stateValue(m_stateDescriptor.stateTypeId()); qCDebug(dcRuleEngineDebug()) << "StateEvaluator:" << this << "State" << thing->name() << thingClass.stateTypes().findById(m_stateDescriptor.stateTypeId()).name() << (descriptorMatching ? "is" : "not") << "matching:" << m_stateDescriptor.stateValue() << m_stateDescriptor.operatorType() << thing->stateValue(m_stateDescriptor.stateTypeId());
descriptorMatching = true; descriptorMatching = true;
} }
} else { } else {
qCWarning(dcRuleEngine) << "StateEvaluator:" << this << "Device found, but it does not appear to have such a state!"; qCWarning(dcRuleEngine) << "StateEvaluator:" << this << "Thing found, but it does not appear to have such a state!";
} }
} else { } else {
qCWarning(dcRuleEngine) << "StateEvaluator:" << this << "Device not existing!"; qCWarning(dcRuleEngine) << "StateEvaluator:" << this << "Thing not existing!";
} }
} else { // interface } else { // interface
foreach (Thing* device, NymeaCore::instance()->thingManager()->configuredThings()) { foreach (Thing* thing, NymeaCore::instance()->thingManager()->configuredThings()) {
ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(device->thingClassId()); ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(thing->thingClassId());
if (!thingClass.isValid()) { if (!thingClass.isValid()) {
qCWarning(dcRuleEngine()) << "Could not find DeviceClass for Device" << device->name() << device->id(); qCWarning(dcRuleEngine()) << "Could not find ThingClass for Thing" << thing->name() << thing->id();
continue; continue;
} }
if (thingClass.interfaces().contains(m_stateDescriptor.interface())) { if (thingClass.interfaces().contains(m_stateDescriptor.interface())) {
StateType stateType = thingClass.stateTypes().findByName(m_stateDescriptor.interfaceState()); StateType stateType = thingClass.stateTypes().findByName(m_stateDescriptor.interfaceState());
State state = device->state(stateType.id()); State state = thing->state(stateType.id());
// As the StateDescriptor can't compare on it's own against interfaces, generate custom one, matching the device // As the StateDescriptor can't compare on it's own against interfaces, generate custom one, matching the device
StateDescriptor temporaryDescriptor(stateType.id(), device->id(), m_stateDescriptor.stateValue(), m_stateDescriptor.operatorType()); StateDescriptor temporaryDescriptor(stateType.id(), thing->id(), m_stateDescriptor.stateValue(), m_stateDescriptor.operatorType());
if (temporaryDescriptor == state) { if (temporaryDescriptor == state) {
descriptorMatching = true; descriptorMatching = true;
break; break;
@ -183,7 +157,6 @@ bool StateEvaluator::evaluate() const
return true; return true;
} }
/*! Returns true if this \l StateEvaluator contains a \l{Thing} in it with the given \a thingId. */
bool StateEvaluator::containsThing(const ThingId &thingId) const bool StateEvaluator::containsThing(const ThingId &thingId) const
{ {
if (m_stateDescriptor.thingId() == thingId) if (m_stateDescriptor.thingId() == thingId)
@ -197,7 +170,6 @@ bool StateEvaluator::containsThing(const ThingId &thingId) const
return false; return false;
} }
/*! Removes the \l Thing with the given \a thingId from this \l StateEvaluator and all its child evaluators. */
void StateEvaluator::removeThing(const ThingId &thingId) void StateEvaluator::removeThing(const ThingId &thingId)
{ {
if (m_stateDescriptor.thingId() == thingId) if (m_stateDescriptor.thingId() == thingId)
@ -208,7 +180,6 @@ void StateEvaluator::removeThing(const ThingId &thingId)
} }
} }
/*! Returns a list of \l{ThingIds} of this StateEvaluator. */
QList<ThingId> StateEvaluator::containedThings() const QList<ThingId> StateEvaluator::containedThings() const
{ {
QList<ThingId> ret; QList<ThingId> ret;
@ -221,8 +192,6 @@ QList<ThingId> StateEvaluator::containedThings() const
return ret; return ret;
} }
/*! This method will be used to save this \l StateEvaluator to the given \a settings.
The \a groupName will normally be the corresponding \l Rule. */
void StateEvaluator::dumpToSettings(NymeaSettings &settings, const QString &groupName) const void StateEvaluator::dumpToSettings(NymeaSettings &settings, const QString &groupName) const
{ {
settings.beginGroup(groupName); settings.beginGroup(groupName);
@ -248,8 +217,6 @@ void StateEvaluator::dumpToSettings(NymeaSettings &settings, const QString &grou
settings.endGroup(); settings.endGroup();
} }
/*! This method will be used to load a \l StateEvaluator from the given \a settings.
The \a groupName will be the corresponding \l RuleId. Returns the loaded \l StateEvaluator. */
StateEvaluator StateEvaluator::loadFromSettings(NymeaSettings &settings, const QString &groupName) StateEvaluator StateEvaluator::loadFromSettings(NymeaSettings &settings, const QString &groupName)
{ {
settings.beginGroup(groupName); settings.beginGroup(groupName);
@ -296,19 +263,18 @@ StateEvaluator StateEvaluator::loadFromSettings(NymeaSettings &settings, const Q
return ret; return ret;
} }
/*! Returns true, if all child evaluators are valid, the devices exist and all descriptors are in allowed paramerters.*/
bool StateEvaluator::isValid() const bool StateEvaluator::isValid() const
{ {
if (m_stateDescriptor.isValid()) { if (m_stateDescriptor.isValid()) {
if (m_stateDescriptor.type() == StateDescriptor::TypeDevice) { if (m_stateDescriptor.type() == StateDescriptor::TypeThing) {
Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(m_stateDescriptor.thingId()); Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(m_stateDescriptor.thingId());
if (!thing) { if (!thing) {
qCWarning(dcRuleEngine) << "State evaluator device does not exist!"; qCWarning(dcRuleEngine) << "State evaluator thing does not exist!";
return false; return false;
} }
if (!thing->hasState(m_stateDescriptor.stateTypeId())) { if (!thing->hasState(m_stateDescriptor.stateTypeId())) {
qCWarning(dcRuleEngine) << "State evaluator device found, but it does not appear to have such a state!"; qCWarning(dcRuleEngine) << "State evaluator thing found, but it does not appear to have such a state!";
return false; return false;
} }
@ -373,13 +339,11 @@ bool StateEvaluator::isValid() const
return true; return true;
} }
/*! Returns true if the StateEvaluator is empty, that is, has no StateDescriptor and no ChildEvaluators */
bool StateEvaluator::isEmpty() const bool StateEvaluator::isEmpty() const
{ {
return !m_stateDescriptor.isValid() && m_childEvaluators.isEmpty(); return !m_stateDescriptor.isValid() && m_childEvaluators.isEmpty();
} }
/*! Print a StateEvaluator including childEvaluators recuresively to QDebug. */
QDebug operator<<(QDebug dbg, const StateEvaluator &stateEvaluator) QDebug operator<<(QDebug dbg, const StateEvaluator &stateEvaluator)
{ {
dbg.nospace() << "StateEvaluator: Operator:" << stateEvaluator.operatorType() << endl << " " << stateEvaluator.stateDescriptor() << endl; dbg.nospace() << "StateEvaluator: Operator:" << stateEvaluator.operatorType() << endl << " " << stateEvaluator.stateDescriptor() << endl;

View File

@ -35,27 +35,27 @@
namespace nymeaserver { namespace nymeaserver {
TagsStorage::TagsStorage(ThingManager *deviceManager, RuleEngine *ruleEngine, QObject *parent): TagsStorage::TagsStorage(ThingManager *thingManager, RuleEngine *ruleEngine, QObject *parent):
QObject(parent), QObject(parent),
m_deviceManager(deviceManager), m_thingManager(thingManager),
m_ruleEngine(ruleEngine) m_ruleEngine(ruleEngine)
{ {
connect(deviceManager, &ThingManager::thingRemoved, this, &TagsStorage::thingRemoved); connect(thingManager, &ThingManager::thingRemoved, this, &TagsStorage::thingRemoved);
NymeaSettings settings(NymeaSettings::SettingsRoleTags); NymeaSettings settings(NymeaSettings::SettingsRoleTags);
if (settings.childGroups().contains("Things")) { if (settings.childGroups().contains("Things")) {
settings.beginGroup("Things"); settings.beginGroup("Things");
} else { } else { // backwards compatibility with <= 0.19
settings.beginGroup("Devices"); settings.beginGroup("Devices");
} }
foreach (const QString &deviceId, settings.childGroups()) { foreach (const QString &thingId, settings.childGroups()) {
settings.beginGroup(deviceId); settings.beginGroup(thingId);
foreach (const QString &appId, settings.childGroups()) { foreach (const QString &appId, settings.childGroups()) {
settings.beginGroup(appId); settings.beginGroup(appId);
foreach (const QString &tagId, settings.childKeys()) { foreach (const QString &tagId, settings.childKeys()) {
Tag tag(ThingId(deviceId), appId, tagId, settings.value(tagId).toString()); Tag tag(ThingId(thingId), appId, tagId, settings.value(tagId).toString());
m_tags.append(tag); m_tags.append(tag);
} }
settings.endGroup(); settings.endGroup();
@ -64,9 +64,9 @@ TagsStorage::TagsStorage(ThingManager *deviceManager, RuleEngine *ruleEngine, QO
} }
settings.endGroup(); settings.endGroup();
// Migration path from nymea < 0.19 // Migration path from nymea <= 0.19
if (settings.childGroups().contains("Devices")) { if (settings.childGroups().contains("Devices")) {
// Save all Device tags to things tags and drop Devices group // Save all Devices tags to things tags and drop Devices group
foreach (const Tag &tag, m_tags) { foreach (const Tag &tag, m_tags) {
saveTag(tag); saveTag(tag);
} }
@ -119,8 +119,8 @@ QList<Tag> TagsStorage::tags(const RuleId &ruleId) const
TagsStorage::TagError TagsStorage::addTag(const Tag &tag) TagsStorage::TagError TagsStorage::addTag(const Tag &tag)
{ {
if (!tag.thingId().isNull()) { if (!tag.thingId().isNull()) {
if (!m_deviceManager->findConfiguredThing(tag.thingId())) { if (!m_thingManager->findConfiguredThing(tag.thingId())) {
return TagsStorage::TagErrorDeviceNotFound; return TagsStorage::TagErrorThingNotFound;
} }
} else if (!tag.ruleId().isNull()) { } else if (!tag.ruleId().isNull()) {
if (!m_ruleEngine->findRule(tag.ruleId()).isValid()) { if (!m_ruleEngine->findRule(tag.ruleId()).isValid()) {

View File

@ -49,13 +49,13 @@ class TagsStorage : public QObject
public: public:
enum TagError { enum TagError {
TagErrorNoError, TagErrorNoError,
TagErrorDeviceNotFound, TagErrorThingNotFound,
TagErrorRuleNotFound, TagErrorRuleNotFound,
TagErrorTagNotFound TagErrorTagNotFound
}; };
Q_ENUM(TagError) Q_ENUM(TagError)
explicit TagsStorage(ThingManager* deviceManager, RuleEngine* ruleEngine, QObject *parent = nullptr); explicit TagsStorage(ThingManager* thingManager, RuleEngine* ruleEngine, QObject *parent = nullptr);
TagError addTag(const Tag &tag); TagError addTag(const Tag &tag);
TagError removeTag(const Tag &tag); TagError removeTag(const Tag &tag);
@ -78,7 +78,7 @@ private:
void unsaveTag(const Tag &tag); void unsaveTag(const Tag &tag);
private: private:
ThingManager *m_deviceManager; ThingManager *m_thingManager;
RuleEngine *m_ruleEngine; RuleEngine *m_ruleEngine;
QList<Tag> m_tags; QList<Tag> m_tags;
}; };

View File

@ -22,8 +22,8 @@
# Example project file for a plugin: # Example project file for a plugin:
# include($$[QT_INSTALL_PREFIX]/include/nymea/plugi.pri) # include($$[QT_INSTALL_PREFIX]/include/nymea/plugi.pri)
# SOURCES += devicepluginexample.cpp # SOURCES += integrationpluginexample.cpp
# HEADERS += devicepluginexample.h # HEADERS += integrationpluginexample.h
TEMPLATE = lib TEMPLATE = lib
@ -34,7 +34,7 @@ PKGCONFIG += nymea
QMAKE_CXXFLAGS *= -Werror -std=c++11 -g QMAKE_CXXFLAGS *= -Werror -std=c++11 -g
QMAKE_LFLAGS *= -std=c++11 QMAKE_LFLAGS *= -std=c++11
JSONFILE=$${_PRO_FILE_PWD_}/deviceplugin"$$TARGET".json JSONFILE=$${_PRO_FILE_PWD_}/integrationplugin"$$TARGET".json
# Make the device plugin json file visible in the Qt Creator # Make the device plugin json file visible in the Qt Creator
OTHER_FILES += $$JSONFILE OTHER_FILES += $$JSONFILE
@ -81,7 +81,7 @@ translations.path = /usr/share/nymea/translations
translations.files = $$[QT_SOURCE_TREE]/translations/*.qm translations.files = $$[QT_SOURCE_TREE]/translations/*.qm
# Redefine target to make output file suite the plugin filename schema # Redefine target to make output file suite the plugin filename schema
TARGET = $$qtLibraryTarget(nymea_deviceplugin"$$TARGET") TARGET = $$qtLibraryTarget(nymea_integrationplugin"$$TARGET")
# Install plugin # Install plugin
target.path = $$[QT_INSTALL_LIBS]/nymea/plugins/ target.path = $$[QT_INSTALL_LIBS]/nymea/plugins/

View File

@ -134,7 +134,7 @@ ThingId ThingDescriptor::parentId() const
} }
/*! Sets the parent id for things created from this DeviceDescriptor. */ /*! Sets the parent id for things created from this DeviceDescriptor. */
void ThingDescriptor::setParentDeviceId(const ThingId &parentId) void ThingDescriptor::setParentId(const ThingId &parentId)
{ {
m_parentId = parentId; m_parentId = parentId;
} }

View File

@ -66,7 +66,7 @@ public:
void setDescription(const QString &description); void setDescription(const QString &description);
ThingId parentId() const; ThingId parentId() const;
void setParentDeviceId(const ThingId &parentId); void setParentId(const ThingId &parentId);
ParamList params() const; ParamList params() const;
void setParams(const ParamList &params); void setParams(const ParamList &params);

View File

@ -81,7 +81,7 @@ EventDescriptor::EventDescriptor(const QString &interface, const QString &interf
/*! Returns true \l{EventDescriptor::Type}{Type} of this descriptor. */ /*! Returns true \l{EventDescriptor::Type}{Type} of this descriptor. */
EventDescriptor::Type EventDescriptor::type() const EventDescriptor::Type EventDescriptor::type() const
{ {
return (!m_thingId.isNull() && !m_eventTypeId.isNull()) ? TypeDevice : TypeInterface; return (!m_thingId.isNull() && !m_eventTypeId.isNull()) ? TypeThing : TypeInterface;
} }
/*! Returns true if the EventDescriptor is valid, that is, when it has either enough data to describe a device/eventType or an interface/interfaceEvent pair. */ /*! Returns true if the EventDescriptor is valid, that is, when it has either enough data to describe a device/eventType or an interface/interfaceEvent pair. */

View File

@ -51,7 +51,7 @@ class LIBNYMEA_EXPORT EventDescriptor
Q_PROPERTY(ParamDescriptors paramDescriptors READ paramDescriptors WRITE setParamDescriptors USER true) Q_PROPERTY(ParamDescriptors paramDescriptors READ paramDescriptors WRITE setParamDescriptors USER true)
public: public:
enum Type { enum Type {
TypeDevice, TypeThing,
TypeInterface TypeInterface
}; };

View File

@ -83,7 +83,7 @@ StateDescriptor::StateDescriptor(const QString &interface, const QString &interf
/*! Returns true \l{StateDescriptor::Type}{Type} of this descriptor. */ /*! Returns true \l{StateDescriptor::Type}{Type} of this descriptor. */
StateDescriptor::Type StateDescriptor::type() const StateDescriptor::Type StateDescriptor::type() const
{ {
return (!m_thingId.isNull() && !m_stateTypeId.isNull()) ? TypeDevice : TypeInterface; return (!m_thingId.isNull() && !m_stateTypeId.isNull()) ? TypeThing : TypeInterface;
} }
/*! Returns the StateTypeId of this \l{State}.*/ /*! Returns the StateTypeId of this \l{State}.*/

View File

@ -53,7 +53,7 @@ class LIBNYMEA_EXPORT StateDescriptor
Q_PROPERTY(Types::ValueOperator operator READ operatorType WRITE setOperatorType) Q_PROPERTY(Types::ValueOperator operator READ operatorType WRITE setOperatorType)
public: public:
enum Type { enum Type {
TypeDevice, TypeThing,
TypeInterface TypeInterface
}; };

View File

@ -4,8 +4,8 @@ include(nymea.pri)
NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"') NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"')
# define protocol versions # define protocol versions
JSON_PROTOCOL_VERSION_MAJOR=4 JSON_PROTOCOL_VERSION_MAJOR=5
JSON_PROTOCOL_VERSION_MINOR=2 JSON_PROTOCOL_VERSION_MINOR=0
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=5 LIBNYMEA_API_VERSION_MAJOR=5
LIBNYMEA_API_VERSION_MINOR=0 LIBNYMEA_API_VERSION_MINOR=0

View File

@ -28,24 +28,7 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*! #include "integrationpluginmock.h"
\page mockdevices.html
\title Mock devices
\brief Devices for the nymea test base.
\ingroup plugins
\ingroup nymea-tests
The mock devices are used for testing.
\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}.
*/
#include "devicepluginmock.h"
#include "httpdaemon.h" #include "httpdaemon.h"
#include "types/mediabrowseritem.h" #include "types/mediabrowseritem.h"
@ -71,17 +54,17 @@
#include <QNetworkReply> #include <QNetworkReply>
#include <QJsonDocument> #include <QJsonDocument>
DevicePluginMock::DevicePluginMock() IntegrationPluginMock::IntegrationPluginMock()
{ {
generateBrowseItems(); generateBrowseItems();
} }
DevicePluginMock::~DevicePluginMock() IntegrationPluginMock::~IntegrationPluginMock()
{ {
delete m_virtualFs; delete m_virtualFs;
} }
void DevicePluginMock::discoverThings(ThingDiscoveryInfo *info) void IntegrationPluginMock::discoverThings(ThingDiscoveryInfo *info)
{ {
if (info->thingClassId() == mockThingClassId) { if (info->thingClassId() == mockThingClassId) {
qCDebug(dcMock()) << "starting mock discovery:" << info->params(); qCDebug(dcMock()) << "starting mock discovery:" << info->params();
@ -147,7 +130,7 @@ void DevicePluginMock::discoverThings(ThingDiscoveryInfo *info)
info->finish(Thing::ThingErrorThingNotFound); info->finish(Thing::ThingErrorThingNotFound);
} }
void DevicePluginMock::setupThing(ThingSetupInfo *info) void IntegrationPluginMock::setupThing(ThingSetupInfo *info)
{ {
if (info->thing()->thingClassId() == mockThingClassId || info->thing()->thingClassId() == autoMockThingClassId) { if (info->thing()->thingClassId() == mockThingClassId || info->thing()->thingClassId() == autoMockThingClassId) {
bool async = false; bool async = false;
@ -177,11 +160,11 @@ void DevicePluginMock::setupThing(ThingSetupInfo *info)
return; return;
} }
connect(daemon, &HttpDaemon::triggerEvent, this, &DevicePluginMock::triggerEvent); connect(daemon, &HttpDaemon::triggerEvent, this, &IntegrationPluginMock::triggerEvent);
connect(daemon, &HttpDaemon::setState, this, &DevicePluginMock::setState); connect(daemon, &HttpDaemon::setState, this, &IntegrationPluginMock::setState);
// Keep this queued or it might happen that the HttpDaemon is deleted before it is able to reply to the caller // Keep this queued or it might happen that the HttpDaemon is deleted before it is able to reply to the caller
connect(daemon, &HttpDaemon::disappear, this, &DevicePluginMock::onDisappear, Qt::QueuedConnection); connect(daemon, &HttpDaemon::disappear, this, &IntegrationPluginMock::onDisappear, Qt::QueuedConnection);
connect(daemon, &HttpDaemon::reconfigureAutodevice, this, &DevicePluginMock::onReconfigureAutoDevice, Qt::QueuedConnection); connect(daemon, &HttpDaemon::reconfigureAutodevice, this, &IntegrationPluginMock::onReconfigureAutoDevice, Qt::QueuedConnection);
} }
@ -254,7 +237,7 @@ void DevicePluginMock::setupThing(ThingSetupInfo *info)
info->finish(Thing::ThingErrorThingClassNotFound); info->finish(Thing::ThingErrorThingClassNotFound);
} }
void DevicePluginMock::postSetupThing(Thing *device) void IntegrationPluginMock::postSetupThing(Thing *device)
{ {
qCDebug(dcMock()) << "Postsetup mock" << device->name(); qCDebug(dcMock()) << "Postsetup mock" << device->name();
if (device->thingClassId() == parentMockThingClassId) { if (device->thingClassId() == parentMockThingClassId) {
@ -269,12 +252,12 @@ void DevicePluginMock::postSetupThing(Thing *device)
} }
} }
void DevicePluginMock::thingRemoved(Thing *device) void IntegrationPluginMock::thingRemoved(Thing *device)
{ {
delete m_daemons.take(device); delete m_daemons.take(device);
} }
void DevicePluginMock::startMonitoringAutoThings() void IntegrationPluginMock::startMonitoringAutoThings()
{ {
foreach (Thing *device, myThings()) { foreach (Thing *device, myThings()) {
if (device->thingClassId() == autoMockThingClassId) { if (device->thingClassId() == autoMockThingClassId) {
@ -297,7 +280,7 @@ void DevicePluginMock::startMonitoringAutoThings()
emit autoThingsAppeared(deviceDescriptorList); emit autoThingsAppeared(deviceDescriptorList);
} }
void DevicePluginMock::startPairing(ThingPairingInfo *info) void IntegrationPluginMock::startPairing(ThingPairingInfo *info)
{ {
if (info->thingClassId() == pushButtonMockThingClassId) { if (info->thingClassId() == pushButtonMockThingClassId) {
qCDebug(dcMock()) << "Push button. Pressing the button in 3 seconds."; qCDebug(dcMock()) << "Push button. Pressing the button in 3 seconds.";
@ -360,7 +343,7 @@ void DevicePluginMock::startPairing(ThingPairingInfo *info)
info->finish(Thing::ThingErrorCreationMethodNotSupported); info->finish(Thing::ThingErrorCreationMethodNotSupported);
} }
void DevicePluginMock::confirmPairing(ThingPairingInfo *info, const QString &username, const QString &secret) void IntegrationPluginMock::confirmPairing(ThingPairingInfo *info, const QString &username, const QString &secret)
{ {
qCDebug(dcMock()) << "Confirm pairing"; qCDebug(dcMock()) << "Confirm pairing";
@ -487,7 +470,7 @@ void DevicePluginMock::confirmPairing(ThingPairingInfo *info, const QString &use
info->finish(Thing::ThingErrorThingClassNotFound); info->finish(Thing::ThingErrorThingClassNotFound);
} }
void DevicePluginMock::browseThing(BrowseResult *result) void IntegrationPluginMock::browseThing(BrowseResult *result)
{ {
qCDebug(dcMock()) << "Browse thing called" << result->thing(); qCDebug(dcMock()) << "Browse thing called" << result->thing();
if (result->thing()->thingClassId() == mockThingClassId) { if (result->thing()->thingClassId() == mockThingClassId) {
@ -535,7 +518,7 @@ void DevicePluginMock::browseThing(BrowseResult *result)
result->finish(Thing::ThingErrorInvalidParameter); result->finish(Thing::ThingErrorInvalidParameter);
} }
void DevicePluginMock::browserItem(BrowserItemResult *result) void IntegrationPluginMock::browserItem(BrowserItemResult *result)
{ {
VirtualFsNode *node = m_virtualFs->findNode(result->itemId()); VirtualFsNode *node = m_virtualFs->findNode(result->itemId());
if (!node) { if (!node) {
@ -545,7 +528,7 @@ void DevicePluginMock::browserItem(BrowserItemResult *result)
result->finish(node->item); result->finish(node->item);
} }
void DevicePluginMock::executeAction(ThingActionInfo *info) void IntegrationPluginMock::executeAction(ThingActionInfo *info)
{ {
if (info->thing()->thingClassId() == mockThingClassId) { if (info->thing()->thingClassId() == mockThingClassId) {
if (info->action().actionTypeId() == mockAsyncActionTypeId || info->action().actionTypeId() == mockAsyncFailingActionTypeId) { if (info->action().actionTypeId() == mockAsyncActionTypeId || info->action().actionTypeId() == mockAsyncFailingActionTypeId) {
@ -711,7 +694,7 @@ void DevicePluginMock::executeAction(ThingActionInfo *info)
info->finish(Thing::ThingErrorThingClassNotFound); info->finish(Thing::ThingErrorThingClassNotFound);
} }
void DevicePluginMock::executeBrowserItem(BrowserActionInfo *info) void IntegrationPluginMock::executeBrowserItem(BrowserActionInfo *info)
{ {
qCDebug(dcMock()) << "ExecuteBrowserItem called" << info->browserAction().itemId(); qCDebug(dcMock()) << "ExecuteBrowserItem called" << info->browserAction().itemId();
bool broken = info->thing()->paramValue(mockThingBrokenParamTypeId).toBool(); bool broken = info->thing()->paramValue(mockThingBrokenParamTypeId).toBool();
@ -743,7 +726,7 @@ void DevicePluginMock::executeBrowserItem(BrowserActionInfo *info)
} }
void DevicePluginMock::executeBrowserItemAction(BrowserItemActionInfo *info) void IntegrationPluginMock::executeBrowserItemAction(BrowserItemActionInfo *info)
{ {
qCDebug(dcMock()) << "TODO" << info << info->browserItemAction().id(); qCDebug(dcMock()) << "TODO" << info << info->browserItemAction().id();
if (info->browserItemAction().actionTypeId() == mockAddToFavoritesBrowserItemActionTypeId) { if (info->browserItemAction().actionTypeId() == mockAddToFavoritesBrowserItemActionTypeId) {
@ -783,7 +766,7 @@ void DevicePluginMock::executeBrowserItemAction(BrowserItemActionInfo *info)
info->finish(Thing::ThingErrorActionTypeNotFound); info->finish(Thing::ThingErrorActionTypeNotFound);
} }
void DevicePluginMock::setState(const StateTypeId &stateTypeId, const QVariant &value) void IntegrationPluginMock::setState(const StateTypeId &stateTypeId, const QVariant &value)
{ {
HttpDaemon *daemon = qobject_cast<HttpDaemon*>(sender()); HttpDaemon *daemon = qobject_cast<HttpDaemon*>(sender());
if (!daemon) if (!daemon)
@ -793,7 +776,7 @@ void DevicePluginMock::setState(const StateTypeId &stateTypeId, const QVariant &
device->setStateValue(stateTypeId, value); device->setStateValue(stateTypeId, value);
} }
void DevicePluginMock::triggerEvent(const EventTypeId &id) void IntegrationPluginMock::triggerEvent(const EventTypeId &id)
{ {
HttpDaemon *daemon = qobject_cast<HttpDaemon*>(sender()); HttpDaemon *daemon = qobject_cast<HttpDaemon*>(sender());
if (!daemon) if (!daemon)
@ -807,7 +790,7 @@ void DevicePluginMock::triggerEvent(const EventTypeId &id)
emit emitEvent(event); emit emitEvent(event);
} }
void DevicePluginMock::onDisappear() void IntegrationPluginMock::onDisappear()
{ {
HttpDaemon *daemon = qobject_cast<HttpDaemon*>(sender()); HttpDaemon *daemon = qobject_cast<HttpDaemon*>(sender());
if (!daemon) { if (!daemon) {
@ -818,7 +801,7 @@ void DevicePluginMock::onDisappear()
emit autoThingDisappeared(device->id()); emit autoThingDisappeared(device->id());
} }
void DevicePluginMock::onReconfigureAutoDevice() void IntegrationPluginMock::onReconfigureAutoDevice()
{ {
HttpDaemon *daemon = qobject_cast<HttpDaemon *>(sender()); HttpDaemon *daemon = qobject_cast<HttpDaemon *>(sender());
if (!daemon) if (!daemon)
@ -842,7 +825,7 @@ void DevicePluginMock::onReconfigureAutoDevice()
emit autoThingsAppeared({deviceDescriptor}); emit autoThingsAppeared({deviceDescriptor});
} }
void DevicePluginMock::generateDiscoveredDevices(ThingDiscoveryInfo *info) void IntegrationPluginMock::generateDiscoveredDevices(ThingDiscoveryInfo *info)
{ {
if (m_discoveredDeviceCount > 0) { if (m_discoveredDeviceCount > 0) {
ThingDescriptor d1(mockThingClassId, "Mock Device 1 (Discovered)", "55555"); ThingDescriptor d1(mockThingClassId, "Mock Device 1 (Discovered)", "55555");
@ -877,7 +860,7 @@ void DevicePluginMock::generateDiscoveredDevices(ThingDiscoveryInfo *info)
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
} }
void DevicePluginMock::generateDiscoveredPushButtonDevices(ThingDiscoveryInfo *info) void IntegrationPluginMock::generateDiscoveredPushButtonDevices(ThingDiscoveryInfo *info)
{ {
if (m_discoveredDeviceCount > 0) { if (m_discoveredDeviceCount > 0) {
ThingDescriptor d1(pushButtonMockThingClassId, "Mocked Thing (Push Button)", "1"); ThingDescriptor d1(pushButtonMockThingClassId, "Mocked Thing (Push Button)", "1");
@ -891,7 +874,7 @@ void DevicePluginMock::generateDiscoveredPushButtonDevices(ThingDiscoveryInfo *i
info->finish(Thing::ThingErrorNoError, QT_TR_NOOP("This thing will simulate a push button press in 3 seconds.")); info->finish(Thing::ThingErrorNoError, QT_TR_NOOP("This thing will simulate a push button press in 3 seconds."));
} }
void DevicePluginMock::generateDiscoveredDisplayPinDevices(ThingDiscoveryInfo *info) void IntegrationPluginMock::generateDiscoveredDisplayPinDevices(ThingDiscoveryInfo *info)
{ {
if (m_discoveredDeviceCount > 0) { if (m_discoveredDeviceCount > 0) {
ThingDescriptor d1(displayPinMockThingClassId, "Mocked Thing (Display Pin)", "1"); ThingDescriptor d1(displayPinMockThingClassId, "Mocked Thing (Display Pin)", "1");
@ -919,18 +902,18 @@ void DevicePluginMock::generateDiscoveredDisplayPinDevices(ThingDiscoveryInfo *i
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
} }
void DevicePluginMock::onPushButtonPressed() void IntegrationPluginMock::onPushButtonPressed()
{ {
qCDebug(dcMock) << "PushButton pressed (automatically)"; qCDebug(dcMock) << "PushButton pressed (automatically)";
m_pushbuttonPressed = true; m_pushbuttonPressed = true;
} }
void DevicePluginMock::onPluginConfigChanged() void IntegrationPluginMock::onPluginConfigChanged()
{ {
} }
void DevicePluginMock::generateBrowseItems() void IntegrationPluginMock::generateBrowseItems()
{ {
m_virtualFs = new VirtualFsNode(BrowserItem()); m_virtualFs = new VirtualFsNode(BrowserItem());

View File

@ -28,8 +28,8 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef DEVICEPLUGINMOCK_H #ifndef INTEGRATIONPLUGINMOCK_H
#define DEVICEPLUGINMOCK_H #define INTEGRATIONPLUGINMOCK_H
#include "integrations/integrationplugin.h" #include "integrations/integrationplugin.h"
@ -37,16 +37,16 @@
class HttpDaemon; class HttpDaemon;
class DevicePluginMock : public IntegrationPlugin class IntegrationPluginMock : public IntegrationPlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "io.nymea.DevicePlugin" FILE "devicepluginmock.json") Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginmock.json")
Q_INTERFACES(IntegrationPlugin) Q_INTERFACES(IntegrationPlugin)
public: public:
explicit DevicePluginMock(); explicit IntegrationPluginMock();
~DevicePluginMock() override; ~IntegrationPluginMock() override;
void discoverThings(ThingDiscoveryInfo *info) override; void discoverThings(ThingDiscoveryInfo *info) override;
@ -109,4 +109,4 @@ private:
VirtualFsNode* m_virtualFs = nullptr; VirtualFsNode* m_virtualFs = nullptr;
}; };
#endif // DEVICEPLUGINMOCK_H #endif // INTEGRATIONPLUGINMOCK_H

View File

@ -2,14 +2,14 @@ include(../plugins.pri)
QT+= network QT+= network
TARGET = $$qtLibraryTarget(nymea_devicepluginmock) TARGET = $$qtLibraryTarget(nymea_integrationpluginmock)
OTHER_FILES += devicepluginmock.json OTHER_FILES += interationpluginmock.json
SOURCES += \ SOURCES += \
devicepluginmock.cpp \ integrationpluginmock.cpp \
httpdaemon.cpp httpdaemon.cpp
HEADERS += \ HEADERS += \
devicepluginmock.h \ integrationpluginmock.h \
httpdaemon.h httpdaemon.h

View File

@ -1,4 +1,4 @@
4.2 5.0
{ {
"enums": { "enums": {
"BasicType": [ "BasicType": [
@ -195,7 +195,7 @@
"RuleErrorNoError", "RuleErrorNoError",
"RuleErrorInvalidRuleId", "RuleErrorInvalidRuleId",
"RuleErrorRuleNotFound", "RuleErrorRuleNotFound",
"RuleErrorDeviceNotFound", "RuleErrorThingNotFound",
"RuleErrorEventTypeNotFound", "RuleErrorEventTypeNotFound",
"RuleErrorStateTypeNotFound", "RuleErrorStateTypeNotFound",
"RuleErrorActionTypeNotFound", "RuleErrorActionTypeNotFound",
@ -238,10 +238,45 @@
], ],
"TagError": [ "TagError": [
"TagErrorNoError", "TagErrorNoError",
"TagErrorDeviceNotFound", "TagErrorThingNotFound",
"TagErrorRuleNotFound", "TagErrorRuleNotFound",
"TagErrorTagNotFound" "TagErrorTagNotFound"
], ],
"ThingError": [
"ThingErrorNoError",
"ThingErrorPluginNotFound",
"ThingErrorVendorNotFound",
"ThingErrorThingNotFound",
"ThingErrorThingClassNotFound",
"ThingErrorActionTypeNotFound",
"ThingErrorStateTypeNotFound",
"ThingErrorEventTypeNotFound",
"ThingErrorThingDescriptorNotFound",
"ThingErrorMissingParameter",
"ThingErrorInvalidParameter",
"ThingErrorSetupFailed",
"ThingErrorDuplicateUuid",
"ThingErrorCreationMethodNotSupported",
"ThingErrorSetupMethodNotSupported",
"ThingErrorHardwareNotAvailable",
"ThingErrorHardwareFailure",
"ThingErrorAuthenticationFailure",
"ThingErrorThingInUse",
"ThingErrorThingInRule",
"ThingErrorThingIsChild",
"ThingErrorPairingTransactionIdNotFound",
"ThingErrorParameterNotWritable",
"ThingErrorItemNotFound",
"ThingErrorItemNotExecutable",
"ThingErrorUnsupportedFeature",
"ThingErrorTimeout"
],
"ThingSetupStatus": [
"ThingSetupStatusNone",
"ThingSetupStatusInProgress",
"ThingSetupStatusComplete",
"ThingSetupStatusFailed"
],
"Unit": [ "Unit": [
"UnitNone", "UnitNone",
"UnitSeconds", "UnitSeconds",
@ -324,7 +359,7 @@
}, },
"methods": { "methods": {
"Actions.ExecuteAction": { "Actions.ExecuteAction": {
"deprecated": "Please use Devices.ExecuteAction instead.", "deprecated": "Please use Integrations.ExecuteAction instead.",
"description": "Execute a single action.", "description": "Execute a single action.",
"params": { "params": {
"actionTypeId": "Uuid", "actionTypeId": "Uuid",
@ -337,7 +372,7 @@
} }
}, },
"Actions.ExecuteBrowserItem": { "Actions.ExecuteBrowserItem": {
"deprecated": "Please use Devices.ExecuteBrowserItem instead.", "deprecated": "Please use Integrations.ExecuteBrowserItem instead.",
"description": "Execute the item identified by itemId on the given device.", "description": "Execute the item identified by itemId on the given device.",
"params": { "params": {
"deviceId": "Uuid", "deviceId": "Uuid",
@ -348,7 +383,7 @@
} }
}, },
"Actions.ExecuteBrowserItemAction": { "Actions.ExecuteBrowserItemAction": {
"deprecated": "Please use Devices.ExecuteBrowserItem instead.", "deprecated": "Please use Integrations.ExecuteBrowserItem instead.",
"description": "Execute the action for the browser item identified by actionTypeId and the itemId on the given device.", "description": "Execute the action for the browser item identified by actionTypeId and the itemId on the given device.",
"params": { "params": {
"actionTypeId": "Uuid", "actionTypeId": "Uuid",
@ -361,7 +396,7 @@
} }
}, },
"Actions.GetActionType": { "Actions.GetActionType": {
"deprecated": "Please use the Devices namespace instead.", "deprecated": "Please use the Integrations namespace instead.",
"description": "Get the ActionType for the given ActionTypeId.", "description": "Get the ActionType for the given ActionTypeId.",
"params": { "params": {
"actionTypeId": "Uuid" "actionTypeId": "Uuid"
@ -856,6 +891,276 @@
"o:eventType": "$ref:EventType" "o:eventType": "$ref:EventType"
} }
}, },
"Integrations.AddThing": {
"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": {
"name": "String",
"o:thingDescriptorId": "Uuid",
"o:thingParams": "$ref:ParamList",
"thingClassId": "Uuid"
},
"returns": {
"o:displayMessage": "String",
"o:thingId": "Uuid",
"thingError": "$ref:ThingError"
}
},
"Integrations.BrowseThing": {
"description": "Browse a thing. If a ThingClass indicates a thing is browsable, this method will return the BrowserItems. If no parameter besides the thingId is used, the root node of this thingwill be returned. Any returned item which is browsable can be passed as node. Results will be children of the given node.",
"params": {
"o:itemId": "String",
"thingId": "Uuid"
},
"returns": {
"items": [
"$ref:BrowserItem"
],
"thingError": "$ref:ThingError"
}
},
"Integrations.ConfirmPairing": {
"description": "Confirm an ongoing pairing. For SetupMethodUserAndPassword, provide the username in the \"username\" field and the password in the \"secret\" field. For SetupMethodEnterPin and provide the PIN in the \"secret\" field. In case of SetupMethodOAuth, the previously opened web view will eventually be redirected to http://128.0.0.1:8888 and the OAuth code as query parameters to this url. Provide the entire unmodified URL in the secret field.",
"params": {
"o:secret": "String",
"o:username": "String",
"pairingTransactionId": "Uuid"
},
"returns": {
"o:displayMessage": "String",
"o:thingId": "Uuid",
"thingError": "$ref:ThingError"
}
},
"Integrations.DiscoverThings": {
"description": "Performs a thing discovery for things of the given thingClassId and returns the results. This function may take a while to return. Note that this method will include all the found things, that is, including things that may already have been added. Those things will have thingId set to the id of the already added thing. Such results may be used to reconfigure existing things and might be filtered in cases where only unknown things are of interest.",
"params": {
"o:discoveryParams": "$ref:ParamList",
"thingClassId": "Uuid"
},
"returns": {
"o:displayMessage": "String",
"o:thingDescriptors": "$ref:ThingDescriptors",
"thingError": "$ref:ThingError"
}
},
"Integrations.EditThing": {
"description": "Edit the name of a thing.",
"params": {
"name": "String",
"thingId": "Uuid"
},
"returns": {
"thingError": "$ref:ThingError"
}
},
"Integrations.ExecuteAction": {
"description": "Execute a single action.",
"params": {
"actionTypeId": "Uuid",
"o:params": "$ref:ParamList",
"thingId": "Uuid"
},
"returns": {
"o:displayMessage": "String",
"thingError": "$ref:ThingError"
}
},
"Integrations.ExecuteBrowserItem": {
"description": "Execute the item identified by itemId on the given thing.",
"params": {
"itemId": "String",
"thingId": "Uuid"
},
"returns": {
"thingError": "$ref:ThingError"
}
},
"Integrations.ExecuteBrowserItemAction": {
"description": "Execute the action for the browser item identified by actionTypeId and the itemId on the given thing.",
"params": {
"actionTypeId": "Uuid",
"itemId": "String",
"o:params": "$ref:ParamList",
"thingId": "Uuid"
},
"returns": {
"thingError": "$ref:ThingError"
}
},
"Integrations.GetActionTypes": {
"description": "Get action types for a specified thingClassId.",
"params": {
"thingClassId": "Uuid"
},
"returns": {
"actionTypes": "$ref:ActionTypes"
}
},
"Integrations.GetBrowserItem": {
"description": "Get a single item from the browser. This won't give any more info on an item than a regular BrowseThing call, but it allows to fetch details of an item if only the ID is known.",
"params": {
"o:itemId": "String",
"thingId": "Uuid"
},
"returns": {
"o:item": "$ref:BrowserItem",
"thingError": "$ref:ThingError"
}
},
"Integrations.GetEventTypes": {
"description": "Get event types for a specified thingClassId.",
"params": {
"thingClassId": "Uuid"
},
"returns": {
"eventTypes": "$ref:EventTypes"
}
},
"Integrations.GetPluginConfiguration": {
"description": "Get a plugin's params.",
"params": {
"pluginId": "Uuid"
},
"returns": {
"o:configuration": "$ref:ParamList",
"thingError": "$ref:ThingError"
}
},
"Integrations.GetPlugins": {
"description": "Returns a list of loaded plugins.",
"params": {
},
"returns": {
"plugins": "$ref:IntegrationPlugins"
}
},
"Integrations.GetStateTypes": {
"description": "Get state types for a specified thingClassId.",
"params": {
"thingClassId": "Uuid"
},
"returns": {
"stateTypes": "$ref:StateTypes"
}
},
"Integrations.GetStateValue": {
"description": "Get the value of the given thing and the given stateType",
"params": {
"stateTypeId": "Uuid",
"thingId": "Uuid"
},
"returns": {
"o:value": "Variant",
"thingError": "$ref:ThingError"
}
},
"Integrations.GetStateValues": {
"description": "Get all the state values of the given thing.",
"params": {
"thingId": "Uuid"
},
"returns": {
"o:values": "$ref:States",
"thingError": "$ref:ThingError"
}
},
"Integrations.GetThingClasses": {
"description": "Returns a list of supported thing classes, optionally filtered by vendorId.",
"params": {
"o:vendorId": "Uuid"
},
"returns": {
"o:thingClasses": "$ref:ThingClasses",
"thingError": "$ref:ThingError"
}
},
"Integrations.GetThings": {
"description": "Returns a list of configured things, optionally filtered by thingId.",
"params": {
"o:thingId": "Uuid"
},
"returns": {
"o:things": "$ref:Things",
"thingError": "$ref:ThingError"
}
},
"Integrations.GetVendors": {
"description": "Returns a list of supported Vendors.",
"params": {
},
"returns": {
"vendors": "$ref:Vendors"
}
},
"Integrations.PairThing": {
"description": "Pair a new thing. Use this to set up or reconfigure things for ThingClasses with a setupMethod different than SetupMethodJustAdd. Depending on the CreateMethod and whether a new thing is set up or an existing one is reconfigured, different parameters are required:\nCreateMethodJustAdd takes the thingClassId and the parameters you want to have with that thing.\nCreateMethodDiscovery requires the use of a thingDescriptorId, previously obtained with DiscoverThings. Optionally, parameters can be overridden with the give thingParams.\nIf an existing thing should be reconfigured, the thingId of said thing should be given additionally.\nIf success is true, the return values will contain a pairingTransactionId, a displayMessage and the setupMethod. Depending on the setupMethod, the application should present the use an appropriate login mask, that is, For SetupMethodDisplayPin the user should enter a pin that is displayed on the device or online service, for SetupMethodEnterPin the application should present the given PIN so the user can enter it on the device or online service. For SetupMethodPushButton, the displayMessage shall be presented to the user as informational hints to press a button on the device. For SetupMethodUserAndPassword a login mask for a user and password login should be presented to the user. In case of SetupMethodOAuth, an OAuth URL will be returned which shall be opened in a web view to allow the user logging in.\nOnce the login procedure has completed, the application shall proceed with ConfirmPairing, providing the results of the pairing procedure.",
"params": {
"o:name": "String",
"o:thingClassId": "Uuid",
"o:thingDescriptorId": "Uuid",
"o:thingId": "Uuid",
"o:thingParams": "$ref:ParamList"
},
"returns": {
"o:displayMessage": "String",
"o:oAuthUrl": "String",
"o:pairingTransactionId": "Uuid",
"o:pin": "String",
"o:setupMethod": "$ref:SetupMethod",
"thingError": "$ref:ThingError"
}
},
"Integrations.ReconfigureThing": {
"description": "Reconfigure a thing. This comes down to removing and recreating a thing with new parameters but keeping its thing id the same (and with that keeping rules, tags etc). For things with create method CreateMethodDiscovery, a discovery (DiscoverThings) shall be performed first and this method is to be called with a thingDescriptorId of the re-discovered thing instead of the thingId directly. Thing parameters will be taken from the discovery, but can be overridden individually here by providing them in the thingParams parameter. Only writable parameters can be changed.",
"params": {
"o:thingDescriptorId": "Uuid",
"o:thingId": "Uuid",
"o:thingParams": "$ref:ParamList"
},
"returns": {
"o:displayMessage": "String",
"thingError": "$ref:ThingError"
}
},
"Integrations.RemoveThing": {
"description": "Remove a thing from the system.",
"params": {
"o:removePolicy": "$ref:RemovePolicy",
"o:removePolicyList": [
{
"policy": "$ref:RemovePolicy",
"ruleId": "Uuid"
}
],
"thingId": "Uuid"
},
"returns": {
"o:ruleIds": [
"Uuid"
],
"thingError": "$ref:ThingError"
}
},
"Integrations.SetPluginConfiguration": {
"description": "Set a plugin's params.",
"params": {
"configuration": "$ref:ParamList",
"pluginId": "Uuid"
},
"returns": {
"thingError": "$ref:ThingError"
}
},
"Integrations.SetThingSettings": {
"description": "Change the settings of a thing.",
"params": {
"settings": "$ref:ParamList",
"thingId": "Uuid"
},
"returns": {
"thingError": "$ref:ThingError"
}
},
"JSONRPC.Authenticate": { "JSONRPC.Authenticate": {
"deprecated": "Use Users.Authenticate instead.", "deprecated": "Use Users.Authenticate instead.",
"description": "Authenticate a client to the api via user & password challenge. Provide a device name which allows the user to identify the client and revoke the token in case the device is lost or stolen. This will return a new token to be used to authorize a client at the API.", "description": "Authenticate a client to the api via user & password challenge. Provide a device name which allows the user to identify the client and revoke the token in case the device is lost or stolen. This will return a new token to be used to authorize a client at the API.",
@ -881,7 +1186,7 @@
} }
}, },
"JSONRPC.Hello": { "JSONRPC.Hello": {
"description": "Initiates a connection. Use this method to perform an initial handshake of the connection. Optionally, a parameter \"locale\" is can be passed to set up the used locale for this connection. Strings such as DeviceClass displayNames etc will be localized to this locale. If this parameter is omitted, the default system locale (depending on the configuration) is used. The reply of this method contains information about this core instance such as version information, uuid and its name. The locale valueindicates the locale used for this connection. Note: This method can be called multiple times. The locale used in the last call for this connection will be used. Other values, like initialSetupRequired might change if the setup has been performed in the meantime.", "description": "Initiates a connection. Use this method to perform an initial handshake of the connection. Optionally, a parameter \"locale\" is can be passed to set up the used locale for this connection. Strings such as ThingClass displayNames etc will be localized to this locale. If this parameter is omitted, the default system locale (depending on the configuration) is used. The reply of this method contains information about this core instance such as version information, uuid and its name. The locale valueindicates the locale used for this connection. Note: This method can be called multiple times. The locale used in the last call for this connection will be used. Other values, like initialSetupRequired might change if the setup has been performed in the meantime.",
"params": { "params": {
"o:locale": "String" "o:locale": "String"
}, },
@ -1011,7 +1316,7 @@
"Logging.GetLogEntries": { "Logging.GetLogEntries": {
"description": "Get the LogEntries matching the given filter. The result set will contain entries matching all filter rules combined. If multiple options are given for a single filter type, the result set will contain entries matching any of those. The offset starts at the newest entry in the result set. By default all items are returned. Example: If the specified filter returns a total amount of 100 entries:\n- a offset value of 10 would include the oldest 90 entries\n- a offset value of 0 would return all 100 entries\n\nThe offset is particularly useful in combination with the maxCount property and can be used for pagination. E.g. A result set of 10000 entries can be fetched in batches of 1000 entries by fetching\n1) offset 0, maxCount 1000: Entries 0 to 9999\n2) offset 10000, maxCount 1000: Entries 10000 - 19999\n3) offset 20000, maxCount 1000: Entries 20000 - 29999\n...", "description": "Get the LogEntries matching the given filter. The result set will contain entries matching all filter rules combined. If multiple options are given for a single filter type, the result set will contain entries matching any of those. The offset starts at the newest entry in the result set. By default all items are returned. Example: If the specified filter returns a total amount of 100 entries:\n- a offset value of 10 would include the oldest 90 entries\n- a offset value of 0 would return all 100 entries\n\nThe offset is particularly useful in combination with the maxCount property and can be used for pagination. E.g. A result set of 10000 entries can be fetched in batches of 1000 entries by fetching\n1) offset 0, maxCount 1000: Entries 0 to 9999\n2) offset 10000, maxCount 1000: Entries 10000 - 19999\n3) offset 20000, maxCount 1000: Entries 20000 - 29999\n...",
"params": { "params": {
"o:deviceIds": [ "d:o:deviceIds": [
"Uuid" "Uuid"
], ],
"o:eventTypes": [ "o:eventTypes": [
@ -1025,6 +1330,9 @@
"$ref:LoggingSource" "$ref:LoggingSource"
], ],
"o:offset": "Int", "o:offset": "Int",
"o:thingIds": [
"Uuid"
],
"o:timeFilters": [ "o:timeFilters": [
{ {
"o:endDate": "Int", "o:endDate": "Int",
@ -1217,7 +1525,8 @@
"Rules.FindRules": { "Rules.FindRules": {
"description": "Find a list of rules containing any of the given parameters.", "description": "Find a list of rules containing any of the given parameters.",
"params": { "params": {
"deviceId": "Uuid" "d:o:deviceId": "Uuid",
"o:thingId": "Uuid"
}, },
"returns": { "returns": {
"ruleIds": [ "ruleIds": [
@ -1306,7 +1615,7 @@
} }
}, },
"States.GetStateType": { "States.GetStateType": {
"deprecated": "Please use the Devices namespace instead.", "deprecated": "Please use the Integrations namespace instead.",
"description": "Get the StateType for the given stateTypeId.", "description": "Get the StateType for the given stateTypeId.",
"params": { "params": {
"stateTypeId": "Uuid" "stateTypeId": "Uuid"
@ -1449,7 +1758,7 @@
} }
}, },
"Tags.AddTag": { "Tags.AddTag": {
"description": "Add a Tag. A Tag must have a deviceId OR a ruleId (call this method twice if you want to attach the same tag to a device and a rule), an appId (Use the appId of your app), a tagId (e.g. \"favorites\") and a value. Upon success, a TagAdded notification will be emitted. Calling this method twice for the same ids (device/rule, appId and tagId) but with a different value will update the tag's value and the TagValueChanged notification will be emitted.", "description": "Add a Tag. A Tag must have a thingId OR a ruleId (call this method twice if you want to attach the same tag to a thing and a rule), an appId (Use the appId of your app), a tagId (e.g. \"favorites\") and a value. Upon success, a TagAdded notification will be emitted. Calling this method twice for the same ids (thing/rule, appId and tagId) but with a different value will update the tag's value and the TagValueChanged notification will be emitted.",
"params": { "params": {
"tag": "$ref:Tag" "tag": "$ref:Tag"
}, },
@ -1458,12 +1767,13 @@
} }
}, },
"Tags.GetTags": { "Tags.GetTags": {
"description": "Get the Tags matching the given filter. Tags can be filtered by a deviceID, a ruleId, an appId, a tagId or a combination of any (however, combining deviceId and ruleId will return an empty result set).", "description": "Get the Tags matching the given filter. Tags can be filtered by a thingID, a ruleId, an appId, a tagId or a combination of any (however, combining thingId and ruleId will return an empty result set).",
"params": { "params": {
"d:o:deviceId": "Uuid",
"o:appId": "String", "o:appId": "String",
"o:deviceId": "Uuid",
"o:ruleId": "Uuid", "o:ruleId": "Uuid",
"o:tagId": "String" "o:tagId": "String",
"o:thingId": "Uuid"
}, },
"returns": { "returns": {
"o:tags": "$ref:Tags", "o:tags": "$ref:Tags",
@ -1571,7 +1881,7 @@
} }
}, },
"Configuration.LanguageChanged": { "Configuration.LanguageChanged": {
"description": "Emitted whenever the language of the server changed. The Plugins, Vendors and DeviceClasses have to be reloaded to get the translated data.", "description": "Emitted whenever the language of the server changed. The Plugins, Vendors and ThingClasses have to be reloaded to get the translated data.",
"params": { "params": {
"language": "String" "language": "String"
} }
@ -1690,6 +2000,53 @@
"event": "$ref:Event" "event": "$ref:Event"
} }
}, },
"Integrations.EventTriggered": {
"description": "Emitted whenever an Event is triggered.",
"params": {
"event": "$ref:Event"
}
},
"Integrations.PluginConfigurationChanged": {
"description": "Emitted whenever a plugin's configuration is changed.",
"params": {
"configuration": "$ref:ParamList",
"pluginId": "Uuid"
}
},
"Integrations.StateChanged": {
"description": "Emitted whenever a state of a thing changes.",
"params": {
"stateTypeId": "Uuid",
"thingId": "Uuid",
"value": "Variant"
}
},
"Integrations.ThingAdded": {
"description": "Emitted whenever a thing was added.",
"params": {
"thing": "$ref:Thing"
}
},
"Integrations.ThingChanged": {
"description": "Emitted whenever the params or name of a thing are changed (by EditThing or ReconfigureThing).",
"params": {
"thing": "$ref:Thing"
}
},
"Integrations.ThingRemoved": {
"description": "Emitted whenever a thing was removed.",
"params": {
"thingId": "Uuid"
}
},
"Integrations.ThingSettingChanged": {
"description": "Emitted whenever the setting of a thing is changed.",
"params": {
"paramTypeId": "Uuid",
"thingId": "Uuid",
"value": "Variant"
}
},
"JSONRPC.CloudConnectedChanged": { "JSONRPC.CloudConnectedChanged": {
"description": "Emitted whenever the cloud connection status changes.", "description": "Emitted whenever the cloud connection status changes.",
"params": { "params": {
@ -1707,7 +2064,7 @@
} }
}, },
"Logging.LogDatabaseUpdated": { "Logging.LogDatabaseUpdated": {
"description": "Emitted whenever the database was updated. The database will be updated when a log entry was deleted. A log entry will be deleted when the corresponding device or a rule will be removed, or when the oldest entry of the database was deleted to keep to database in the size limits.", "description": "Emitted whenever the database was updated. The database will be updated when a log entry was deleted. A log entry will be deleted when the corresponding thing or a rule will be removed, or when the oldest entry of the database was deleted to keep to database in the size limits.",
"params": { "params": {
} }
}, },
@ -1910,8 +2267,9 @@
"types": { "types": {
"Action": { "Action": {
"actionTypeId": "Uuid", "actionTypeId": "Uuid",
"deviceId": "Uuid", "d:deviceId": "Uuid",
"o:params": "$ref:ParamList" "o:params": "$ref:ParamList",
"thingId": "Uuid"
}, },
"ActionType": { "ActionType": {
"displayName": "String", "displayName": "String",
@ -1955,9 +2313,10 @@
"r:o:parentId": "Uuid", "r:o:parentId": "Uuid",
"r:o:setupDisplayMessage": "String", "r:o:setupDisplayMessage": "String",
"r:params": "$ref:ParamList", "r:params": "$ref:ParamList",
"r:setupError": "$ref:DeviceError", "r:setupError": "$ref:ThingError",
"r:setupStatus": "$ref:DeviceSetupStatus", "r:setupStatus": "$ref:ThingSetupStatus",
"r:states": "$ref:States" "r:states": "$ref:States",
"r:thingClassId": "Uuid"
}, },
"DeviceClass": { "DeviceClass": {
"r:actionTypes": "$ref:ActionTypes", "r:actionTypes": "$ref:ActionTypes",
@ -1985,6 +2344,7 @@
"r:deviceParams": "$ref:ParamList", "r:deviceParams": "$ref:ParamList",
"r:id": "Uuid", "r:id": "Uuid",
"r:o:deviceId": "Uuid", "r:o:deviceId": "Uuid",
"r:o:thingId": "Uuid",
"r:title": "String" "r:title": "String"
}, },
"DeviceDescriptors": [ "DeviceDescriptors": [
@ -2003,16 +2363,18 @@
"$ref:Device" "$ref:Device"
], ],
"Event": { "Event": {
"r:deviceId": "Uuid", "d:r:deviceId": "Uuid",
"r:eventTypeId": "Uuid", "r:eventTypeId": "Uuid",
"r:params": "$ref:ParamList" "r:params": "$ref:ParamList",
"r:thingId": "Uuid"
}, },
"EventDescriptor": { "EventDescriptor": {
"o:deviceId": "Uuid", "d:o:deviceId": "Uuid",
"o:eventTypeId": "Uuid", "o:eventTypeId": "Uuid",
"o:interface": "String", "o:interface": "String",
"o:interfaceEvent": "String", "o:interfaceEvent": "String",
"o:paramDescriptors": "$ref:ParamDescriptors" "o:paramDescriptors": "$ref:ParamDescriptors",
"o:thingId": "Uuid"
}, },
"EventDescriptors": [ "EventDescriptors": [
"$ref:EventDescriptor" "$ref:EventDescriptor"
@ -2031,15 +2393,25 @@
"name": "String", "name": "String",
"version": "String" "version": "String"
}, },
"IntegrationPlugin": {
"r:displayName": "String",
"r:id": "Uuid",
"r:name": "String",
"r:paramTypes": "$ref:ParamTypes"
},
"IntegrationPlugins": [
"$ref:IntegrationPlugin"
],
"LogEntries": [ "LogEntries": [
"$ref:LogEntry" "$ref:LogEntry"
], ],
"LogEntry": { "LogEntry": {
"d:r:o:deviceId": "Uuid",
"r:loggingLevel": "$ref:LoggingLevel", "r:loggingLevel": "$ref:LoggingLevel",
"r:o:active": "Bool", "r:o:active": "Bool",
"r:o:deviceId": "Uuid",
"r:o:errorCode": "String", "r:o:errorCode": "String",
"r:o:eventType": "$ref:LoggingEventType", "r:o:eventType": "$ref:LoggingEventType",
"r:o:thingId": "Uuid",
"r:o:typeId": "Uuid", "r:o:typeId": "Uuid",
"r:o:value": "Variant", "r:o:value": "Variant",
"r:source": "$ref:LoggingSource", "r:source": "$ref:LoggingSource",
@ -2131,19 +2503,21 @@
"r:id": "Uuid" "r:id": "Uuid"
}, },
"RuleAction": { "RuleAction": {
"d:o:deviceId": "Uuid",
"o:actionTypeId": "Uuid", "o:actionTypeId": "Uuid",
"o:browserItemId": "String", "o:browserItemId": "String",
"o:deviceId": "Uuid",
"o:interface": "String", "o:interface": "String",
"o:interfaceAction": "String", "o:interfaceAction": "String",
"o:ruleActionParams": "$ref:RuleActionParams" "o:ruleActionParams": "$ref:RuleActionParams",
"o:thingId": "Uuid"
}, },
"RuleActionParam": { "RuleActionParam": {
"d:o:stateDeviceId": "Uuid",
"o:eventParamTypeId": "Uuid", "o:eventParamTypeId": "Uuid",
"o:eventTypeId": "Uuid", "o:eventTypeId": "Uuid",
"o:paramName": "String", "o:paramName": "String",
"o:paramTypeId": "Uuid", "o:paramTypeId": "Uuid",
"o:stateDeviceId": "Uuid", "o:stateThingId": "Uuid",
"o:stateTypeId": "Uuid", "o:stateTypeId": "Uuid",
"o:value": "Variant" "o:value": "Variant"
}, },
@ -2182,10 +2556,11 @@
"r:value": "Variant" "r:value": "Variant"
}, },
"StateDescriptor": { "StateDescriptor": {
"o:deviceId": "Uuid", "d:o:deviceId": "Uuid",
"o:interface": "String", "o:interface": "String",
"o:interfaceState": "String", "o:interfaceState": "String",
"o:stateTypeId": "Uuid", "o:stateTypeId": "Uuid",
"o:thingId": "Uuid",
"operator": "$ref:ValueOperator", "operator": "$ref:ValueOperator",
"value": "Variant" "value": "Variant"
}, },
@ -2219,14 +2594,62 @@
], ],
"Tag": { "Tag": {
"appId": "String", "appId": "String",
"o:deviceId": "Uuid", "d:o:deviceId": "Uuid",
"o:ruleId": "Uuid", "o:ruleId": "Uuid",
"o:thingId": "Uuid",
"o:value": "String", "o:value": "String",
"tagId": "String" "tagId": "String"
}, },
"Tags": [ "Tags": [
"$ref:Tag" "$ref:Tag"
], ],
"Thing": {
"d:r:setupComplete": "Bool",
"o:name": "String",
"o:settings": "$ref:ParamList",
"r:id": "Uuid",
"r:o:parentId": "Uuid",
"r:o:setupDisplayMessage": "String",
"r:params": "$ref:ParamList",
"r:setupError": "$ref:ThingError",
"r:setupStatus": "$ref:ThingSetupStatus",
"r:states": "$ref:States",
"r:thingClassId": "Uuid"
},
"ThingClass": {
"r:actionTypes": "$ref:ActionTypes",
"r:browsable": "Bool",
"r:browserItemActionTypes": "$ref:ActionTypes",
"r:createMethods": "$ref:CreateMethods",
"r:discoveryParamTypes": "$ref:ParamTypes",
"r:displayName": "String",
"r:eventTypes": "$ref:EventTypes",
"r:id": "Uuid",
"r:interfaces": "StringList",
"r:name": "String",
"r:paramTypes": "$ref:ParamTypes",
"r:pluginId": "Uuid",
"r:settingsTypes": "$ref:ParamTypes",
"r:setupMethod": "$ref:SetupMethod",
"r:stateTypes": "$ref:StateTypes",
"r:vendorId": "Uuid"
},
"ThingClasses": [
"$ref:ThingClass"
],
"ThingDescriptor": {
"r:description": "String",
"r:deviceParams": "$ref:ParamList",
"r:id": "Uuid",
"r:o:thingId": "Uuid",
"r:title": "String"
},
"ThingDescriptors": [
"$ref:ThingDescriptor"
],
"Things": [
"$ref:Thing"
],
"TimeDescriptor": { "TimeDescriptor": {
"o:calendarItems": "$ref:CalendarItems", "o:calendarItems": "$ref:CalendarItems",
"o:timeEventItems": "$ref:TimeEventItems" "o:timeEventItems": "$ref:TimeEventItems"

View File

@ -40,7 +40,7 @@
using namespace nymeaserver; using namespace nymeaserver;
class TestIntegrations : public NymeaTestBase class TestDevices : public NymeaTestBase
{ {
Q_OBJECT Q_OBJECT
@ -155,7 +155,7 @@ private slots:
void discoverDeviceParenting(); void discoverDeviceParenting();
}; };
void TestIntegrations::initTestCase() void TestDevices::initTestCase()
{ {
NymeaTestBase::initTestCase(); NymeaTestBase::initTestCase();
QLoggingCategory::setFilterRules("*.debug=false\n" QLoggingCategory::setFilterRules("*.debug=false\n"
@ -190,7 +190,7 @@ void TestIntegrations::initTestCase()
qCDebug(dcTests()) << "Created Async mock device with ID" << m_mockThingAsyncId; qCDebug(dcTests()) << "Created Async mock device with ID" << m_mockThingAsyncId;
} }
void TestIntegrations::getPlugins() void TestDevices::getPlugins()
{ {
QVariant response = injectAndWait("Devices.GetPlugins"); QVariant response = injectAndWait("Devices.GetPlugins");
@ -206,7 +206,7 @@ void TestIntegrations::getPlugins()
QCOMPARE(found, true); QCOMPARE(found, true);
} }
void TestIntegrations::getPluginConfig_data() void TestDevices::getPluginConfig_data()
{ {
QTest::addColumn<PluginId>("pluginId"); QTest::addColumn<PluginId>("pluginId");
QTest::addColumn<Device::DeviceError>("error"); QTest::addColumn<Device::DeviceError>("error");
@ -215,7 +215,7 @@ void TestIntegrations::getPluginConfig_data()
QTest::newRow("invalid plugin") << PluginId::createPluginId() << Device::DeviceErrorPluginNotFound; QTest::newRow("invalid plugin") << PluginId::createPluginId() << Device::DeviceErrorPluginNotFound;
} }
void TestIntegrations::getPluginConfig() void TestDevices::getPluginConfig()
{ {
QFETCH(PluginId, pluginId); QFETCH(PluginId, pluginId);
QFETCH(Device::DeviceError, error); QFETCH(Device::DeviceError, error);
@ -226,7 +226,7 @@ void TestIntegrations::getPluginConfig()
verifyDeviceError(response, error); verifyDeviceError(response, error);
} }
void TestIntegrations::setPluginConfig_data() void TestDevices::setPluginConfig_data()
{ {
QTest::addColumn<PluginId>("pluginId"); QTest::addColumn<PluginId>("pluginId");
QTest::addColumn<QVariant>("value"); QTest::addColumn<QVariant>("value");
@ -239,7 +239,7 @@ void TestIntegrations::setPluginConfig_data()
QTest::newRow("wrong type") << mockPluginId << QVariant("wrontType") << Device::DeviceErrorInvalidParameter; QTest::newRow("wrong type") << mockPluginId << QVariant("wrontType") << Device::DeviceErrorInvalidParameter;
} }
void TestIntegrations::setPluginConfig() void TestDevices::setPluginConfig()
{ {
QFETCH(PluginId, pluginId); QFETCH(PluginId, pluginId);
QFETCH(QVariant, value); QFETCH(QVariant, value);
@ -268,7 +268,7 @@ void TestIntegrations::setPluginConfig()
} }
} }
void TestIntegrations::getSupportedVendors() void TestDevices::getSupportedVendors()
{ {
QVariant supportedVendors = injectAndWait("Devices.GetSupportedVendors"); QVariant supportedVendors = injectAndWait("Devices.GetSupportedVendors");
qDebug() << "response" << supportedVendors; qDebug() << "response" << supportedVendors;
@ -285,7 +285,7 @@ void TestIntegrations::getSupportedVendors()
QCOMPARE(found, true); QCOMPARE(found, true);
} }
void TestIntegrations::getSupportedDevices_data() void TestDevices::getSupportedDevices_data()
{ {
QTest::addColumn<VendorId>("vendorId"); QTest::addColumn<VendorId>("vendorId");
QTest::addColumn<int>("resultCount"); QTest::addColumn<int>("resultCount");
@ -295,7 +295,7 @@ void TestIntegrations::getSupportedDevices_data()
QTest::newRow("invalid vendor") << VendorId("93e7d361-8025-4354-b17e-b68406c800bc") << 0; QTest::newRow("invalid vendor") << VendorId("93e7d361-8025-4354-b17e-b68406c800bc") << 0;
} }
void TestIntegrations::getSupportedDevices() void TestDevices::getSupportedDevices()
{ {
QFETCH(VendorId, vendorId); QFETCH(VendorId, vendorId);
QFETCH(int, resultCount); QFETCH(int, resultCount);
@ -311,7 +311,7 @@ void TestIntegrations::getSupportedDevices()
QCOMPARE(supportedDevices.count() >= resultCount, true); QCOMPARE(supportedDevices.count() >= resultCount, true);
} }
void TestIntegrations::verifyInterfaces() void TestDevices::verifyInterfaces()
{ {
QVariantMap params; QVariantMap params;
params.insert("vendorId", nymeaVendorId); params.insert("vendorId", nymeaVendorId);
@ -337,7 +337,7 @@ void TestIntegrations::verifyInterfaces()
QVERIFY(!interfaces.contains("gateway")); QVERIFY(!interfaces.contains("gateway"));
} }
void TestIntegrations::addConfiguredDevice_data() void TestDevices::addConfiguredDevice_data()
{ {
QTest::addColumn<ThingClassId>("thingClassId"); QTest::addColumn<ThingClassId>("thingClassId");
QTest::addColumn<QVariantList>("deviceParams"); QTest::addColumn<QVariantList>("deviceParams");
@ -389,7 +389,7 @@ void TestIntegrations::addConfiguredDevice_data()
} }
void TestIntegrations::addConfiguredDevice() void TestDevices::addConfiguredDevice()
{ {
QFETCH(ThingClassId, thingClassId); QFETCH(ThingClassId, thingClassId);
QFETCH(QVariantList, deviceParams); QFETCH(QVariantList, deviceParams);
@ -417,7 +417,7 @@ void TestIntegrations::addConfiguredDevice()
} }
} }
void TestIntegrations::deviceAddedRemovedNotifications() void TestDevices::deviceAddedRemovedNotifications()
{ {
enableNotifications({"Devices"}); enableNotifications({"Devices"});
@ -463,7 +463,7 @@ void TestIntegrations::deviceAddedRemovedNotifications()
QCOMPARE(disableNotifications(), true); QCOMPARE(disableNotifications(), true);
} }
void TestIntegrations::deviceChangedNotifications() void TestDevices::deviceChangedNotifications()
{ {
enableNotifications({"Devices"}); enableNotifications({"Devices"});
@ -545,7 +545,7 @@ void TestIntegrations::deviceChangedNotifications()
checkNotification(clientSpy, "Logging.LogDatabaseUpdated"); checkNotification(clientSpy, "Logging.LogDatabaseUpdated");
} }
void TestIntegrations::getConfiguredDevices() void TestDevices::getConfiguredDevices()
{ {
QVariant response = injectAndWait("Devices.GetConfiguredDevices"); QVariant response = injectAndWait("Devices.GetConfiguredDevices");
@ -553,7 +553,7 @@ void TestIntegrations::getConfiguredDevices()
QCOMPARE(devices.count(), 3); // There should be: one auto created mock device, one created in NymeaTestBase::initTestcase() and one created in TestDevices::initTestCase() QCOMPARE(devices.count(), 3); // There should be: one auto created mock device, one created in NymeaTestBase::initTestcase() and one created in TestDevices::initTestCase()
} }
void TestIntegrations::getConfiguredDevice_data() void TestDevices::getConfiguredDevice_data()
{ {
QTest::addColumn<DeviceId>("deviceId"); QTest::addColumn<DeviceId>("deviceId");
QTest::addColumn<Device::DeviceError>("expectedError"); QTest::addColumn<Device::DeviceError>("expectedError");
@ -562,7 +562,7 @@ void TestIntegrations::getConfiguredDevice_data()
QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << Device::DeviceErrorDeviceNotFound; QTest::newRow("invalid deviceId") << DeviceId::createDeviceId() << Device::DeviceErrorDeviceNotFound;
} }
void TestIntegrations::getConfiguredDevice() void TestDevices::getConfiguredDevice()
{ {
QFETCH(DeviceId, deviceId); QFETCH(DeviceId, deviceId);
QFETCH(Device::DeviceError, expectedError); QFETCH(Device::DeviceError, expectedError);
@ -579,7 +579,7 @@ void TestIntegrations::getConfiguredDevice()
} }
} }
void TestIntegrations::storedDevices() void TestDevices::storedDevices()
{ {
QVariantMap params; QVariantMap params;
params.insert("deviceClassId", mockThingClassId); params.insert("deviceClassId", mockThingClassId);
@ -627,7 +627,7 @@ void TestIntegrations::storedDevices()
verifyDeviceError(response); verifyDeviceError(response);
} }
void TestIntegrations::discoverDevices_data() void TestDevices::discoverDevices_data()
{ {
QTest::addColumn<ThingClassId>("thingClassId"); QTest::addColumn<ThingClassId>("thingClassId");
QTest::addColumn<int>("resultCount"); QTest::addColumn<int>("resultCount");
@ -645,7 +645,7 @@ void TestIntegrations::discoverDevices_data()
QTest::newRow("invalid ThingClassId") << ThingClassId::createThingClassId() << 0 << Device::DeviceErrorDeviceClassNotFound << QVariantList(); QTest::newRow("invalid ThingClassId") << ThingClassId::createThingClassId() << 0 << Device::DeviceErrorDeviceClassNotFound << QVariantList();
} }
void TestIntegrations::discoverDevices() void TestDevices::discoverDevices()
{ {
QFETCH(ThingClassId, thingClassId); QFETCH(ThingClassId, thingClassId);
QFETCH(int, resultCount); QFETCH(int, resultCount);
@ -682,7 +682,7 @@ void TestIntegrations::discoverDevices()
} }
} }
void TestIntegrations::addPushButtonDevices_data() void TestDevices::addPushButtonDevices_data()
{ {
QTest::addColumn<ThingClassId>("thingClassId"); QTest::addColumn<ThingClassId>("thingClassId");
QTest::addColumn<Device::DeviceError>("error"); QTest::addColumn<Device::DeviceError>("error");
@ -692,7 +692,7 @@ void TestIntegrations::addPushButtonDevices_data()
QTest::newRow("Invalid: Add PushButton device (press to early)") << pushButtonMockThingClassId << Device::DeviceErrorAuthenticationFailure << false; QTest::newRow("Invalid: Add PushButton device (press to early)") << pushButtonMockThingClassId << Device::DeviceErrorAuthenticationFailure << false;
} }
void TestIntegrations::addPushButtonDevices() void TestDevices::addPushButtonDevices()
{ {
QFETCH(ThingClassId, thingClassId); QFETCH(ThingClassId, thingClassId);
QFETCH(Device::DeviceError, error); QFETCH(Device::DeviceError, error);
@ -748,7 +748,7 @@ void TestIntegrations::addPushButtonDevices()
} }
} }
void TestIntegrations::addDisplayPinDevices_data() void TestDevices::addDisplayPinDevices_data()
{ {
QTest::addColumn<ThingClassId>("thingClassId"); QTest::addColumn<ThingClassId>("thingClassId");
QTest::addColumn<Device::DeviceError>("error"); QTest::addColumn<Device::DeviceError>("error");
@ -758,7 +758,7 @@ void TestIntegrations::addDisplayPinDevices_data()
QTest::newRow("Invalid: Add DisplayPin device (wrong pin)") << displayPinMockThingClassId << Device::DeviceErrorAuthenticationFailure << "243682"; QTest::newRow("Invalid: Add DisplayPin device (wrong pin)") << displayPinMockThingClassId << Device::DeviceErrorAuthenticationFailure << "243682";
} }
void TestIntegrations::addDisplayPinDevices() void TestDevices::addDisplayPinDevices()
{ {
QFETCH(ThingClassId, thingClassId); QFETCH(ThingClassId, thingClassId);
QFETCH(Device::DeviceError, error); QFETCH(Device::DeviceError, error);
@ -812,7 +812,7 @@ void TestIntegrations::addDisplayPinDevices()
} }
void TestIntegrations::parentChildDevices() void TestDevices::parentChildDevices()
{ {
// add parent device // add parent device
QVariantMap params; QVariantMap params;
@ -894,7 +894,7 @@ void TestIntegrations::parentChildDevices()
QVERIFY2(!found, "Could not find child device."); QVERIFY2(!found, "Could not find child device.");
} }
void TestIntegrations::getActionTypes_data() void TestDevices::getActionTypes_data()
{ {
QTest::addColumn<ThingClassId>("thingClassId"); QTest::addColumn<ThingClassId>("thingClassId");
QTest::addColumn<QList<ActionTypeId> >("actionTypeTestData"); QTest::addColumn<QList<ActionTypeId> >("actionTypeTestData");
@ -904,7 +904,7 @@ void TestIntegrations::getActionTypes_data()
QTest::newRow("invalid deviceclass") << ThingClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << QList<ActionTypeId>(); QTest::newRow("invalid deviceclass") << ThingClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << QList<ActionTypeId>();
} }
void TestIntegrations::getActionTypes() void TestDevices::getActionTypes()
{ {
QFETCH(ThingClassId, thingClassId); QFETCH(ThingClassId, thingClassId);
QFETCH(QList<ActionTypeId>, actionTypeTestData); QFETCH(QList<ActionTypeId>, actionTypeTestData);
@ -927,7 +927,7 @@ void TestIntegrations::getActionTypes()
} }
} }
void TestIntegrations::getEventTypes_data() void TestDevices::getEventTypes_data()
{ {
QTest::addColumn<ThingClassId>("deviceClassId"); QTest::addColumn<ThingClassId>("deviceClassId");
QTest::addColumn<int>("resultCount"); QTest::addColumn<int>("resultCount");
@ -936,7 +936,7 @@ void TestIntegrations::getEventTypes_data()
QTest::newRow("invalid deviceclass") << ThingClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << 0; QTest::newRow("invalid deviceclass") << ThingClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << 0;
} }
void TestIntegrations::getEventTypes() void TestDevices::getEventTypes()
{ {
QFETCH(ThingClassId, deviceClassId); QFETCH(ThingClassId, deviceClassId);
QFETCH(int, resultCount); QFETCH(int, resultCount);
@ -952,7 +952,7 @@ void TestIntegrations::getEventTypes()
} }
void TestIntegrations::getStateTypes_data() void TestDevices::getStateTypes_data()
{ {
QTest::addColumn<ThingClassId>("thingClassId"); QTest::addColumn<ThingClassId>("thingClassId");
QTest::addColumn<int>("resultCount"); QTest::addColumn<int>("resultCount");
@ -961,7 +961,7 @@ void TestIntegrations::getStateTypes_data()
QTest::newRow("invalid deviceclass") << ThingClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << 0; QTest::newRow("invalid deviceclass") << ThingClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << 0;
} }
void TestIntegrations::getStateTypes() void TestDevices::getStateTypes()
{ {
QFETCH(ThingClassId, thingClassId); QFETCH(ThingClassId, thingClassId);
QFETCH(int, resultCount); QFETCH(int, resultCount);
@ -977,7 +977,7 @@ void TestIntegrations::getStateTypes()
} }
} }
void TestIntegrations::getStateType_data() void TestDevices::getStateType_data()
{ {
QTest::addColumn<StateTypeId>("stateTypeId"); QTest::addColumn<StateTypeId>("stateTypeId");
QTest::addColumn<Device::DeviceError>("error"); QTest::addColumn<Device::DeviceError>("error");
@ -987,7 +987,7 @@ void TestIntegrations::getStateType_data()
QTest::newRow("invalid stateTypeId") << StateTypeId::createStateTypeId() << Device::DeviceErrorStateTypeNotFound; QTest::newRow("invalid stateTypeId") << StateTypeId::createStateTypeId() << Device::DeviceErrorStateTypeNotFound;
} }
void TestIntegrations::getStateType() void TestDevices::getStateType()
{ {
QFETCH(StateTypeId, stateTypeId); QFETCH(StateTypeId, stateTypeId);
QFETCH(Device::DeviceError, error); QFETCH(Device::DeviceError, error);
@ -1006,7 +1006,7 @@ void TestIntegrations::getStateType()
QCOMPARE(stateType.value("id").toUuid().toString(), stateTypeId.toString()); QCOMPARE(stateType.value("id").toUuid().toString(), stateTypeId.toString());
} }
void TestIntegrations::getStateValue_data() void TestDevices::getStateValue_data()
{ {
QTest::addColumn<DeviceId>("deviceId"); QTest::addColumn<DeviceId>("deviceId");
QTest::addColumn<StateTypeId>("stateTypeId"); QTest::addColumn<StateTypeId>("stateTypeId");
@ -1017,7 +1017,7 @@ void TestIntegrations::getStateValue_data()
QTest::newRow("invalid statetypeId") << DeviceId(m_mockThingId) << StateTypeId("120514f1-343e-4621-9bff-dac616169df9") << Device::DeviceErrorStateTypeNotFound; QTest::newRow("invalid statetypeId") << DeviceId(m_mockThingId) << StateTypeId("120514f1-343e-4621-9bff-dac616169df9") << Device::DeviceErrorStateTypeNotFound;
} }
void TestIntegrations::getStateValue() void TestDevices::getStateValue()
{ {
QFETCH(DeviceId, deviceId); QFETCH(DeviceId, deviceId);
QFETCH(StateTypeId, stateTypeId); QFETCH(StateTypeId, stateTypeId);
@ -1035,7 +1035,7 @@ void TestIntegrations::getStateValue()
} }
} }
void TestIntegrations::getStateValues_data() void TestDevices::getStateValues_data()
{ {
QTest::addColumn<DeviceId>("deviceId"); QTest::addColumn<DeviceId>("deviceId");
QTest::addColumn<Device::DeviceError>("statusCode"); QTest::addColumn<Device::DeviceError>("statusCode");
@ -1044,7 +1044,7 @@ void TestIntegrations::getStateValues_data()
QTest::newRow("invalid deviceId") << DeviceId("094f8024-5caa-48c1-ab6a-de486a92088f") << Device::DeviceErrorDeviceNotFound; QTest::newRow("invalid deviceId") << DeviceId("094f8024-5caa-48c1-ab6a-de486a92088f") << Device::DeviceErrorDeviceNotFound;
} }
void TestIntegrations::getStateValues() void TestDevices::getStateValues()
{ {
QFETCH(DeviceId, deviceId); QFETCH(DeviceId, deviceId);
QFETCH(Device::DeviceError, statusCode); QFETCH(Device::DeviceError, statusCode);
@ -1060,7 +1060,7 @@ void TestIntegrations::getStateValues()
} }
} }
void TestIntegrations::editDevices_data() void TestDevices::editDevices_data()
{ {
QTest::addColumn<QString>("name"); QTest::addColumn<QString>("name");
@ -1069,7 +1069,7 @@ void TestIntegrations::editDevices_data()
QTest::newRow("change name") << "Bar device"; QTest::newRow("change name") << "Bar device";
} }
void TestIntegrations::editDevices() void TestDevices::editDevices()
{ {
QFETCH(QString, name); QFETCH(QString, name);
@ -1131,7 +1131,7 @@ void TestIntegrations::editDevices()
verifyDeviceError(response); verifyDeviceError(response);
} }
void TestIntegrations::testDeviceSettings() void TestDevices::testDeviceSettings()
{ {
// add device // add device
QVariantList deviceParams; QVariantList deviceParams;
@ -1211,7 +1211,7 @@ void TestIntegrations::testDeviceSettings()
} }
void TestIntegrations::reconfigureDevices_data() void TestDevices::reconfigureDevices_data()
{ {
QVariantList asyncChangeDeviceParams; QVariantList asyncChangeDeviceParams;
QVariantMap asyncParamDifferent; QVariantMap asyncParamDifferent;
@ -1250,7 +1250,7 @@ void TestIntegrations::reconfigureDevices_data()
QTest::newRow("invalid - change all params (except broken)") << false << changeAllWritableDeviceParams << Device::DeviceErrorParameterNotWritable; QTest::newRow("invalid - change all params (except broken)") << false << changeAllWritableDeviceParams << Device::DeviceErrorParameterNotWritable;
} }
void TestIntegrations::reconfigureDevices() void TestDevices::reconfigureDevices()
{ {
QFETCH(bool, broken); QFETCH(bool, broken);
QFETCH(QVariantList, newDeviceParams); QFETCH(QVariantList, newDeviceParams);
@ -1376,7 +1376,7 @@ void TestIntegrations::reconfigureDevices()
} }
void TestIntegrations::reconfigureByDiscovery_data() void TestDevices::reconfigureByDiscovery_data()
{ {
QTest::addColumn<ThingClassId>("thingClassId"); QTest::addColumn<ThingClassId>("thingClassId");
QTest::addColumn<int>("resultCount"); QTest::addColumn<int>("resultCount");
@ -1392,7 +1392,7 @@ void TestIntegrations::reconfigureByDiscovery_data()
QTest::newRow("discover 2 devices with params") << mockThingClassId << 2 << Device::DeviceErrorNoError << discoveryParams; QTest::newRow("discover 2 devices with params") << mockThingClassId << 2 << Device::DeviceErrorNoError << discoveryParams;
} }
void TestIntegrations::reconfigureByDiscovery() void TestDevices::reconfigureByDiscovery()
{ {
QFETCH(ThingClassId, thingClassId); QFETCH(ThingClassId, thingClassId);
QFETCH(int, resultCount); QFETCH(int, resultCount);
@ -1526,7 +1526,7 @@ void TestIntegrations::reconfigureByDiscovery()
verifyDeviceError(response); verifyDeviceError(response);
} }
void TestIntegrations::reconfigureByDiscoveryAndPair() void TestDevices::reconfigureByDiscoveryAndPair()
{ {
QVariantList discoveryParams; QVariantList discoveryParams;
QVariantMap resultCountParam; QVariantMap resultCountParam;
@ -1627,7 +1627,7 @@ void TestIntegrations::reconfigureByDiscoveryAndPair()
} }
void TestIntegrations::reconfigureAutodevice() void TestDevices::reconfigureAutodevice()
{ {
qCDebug(dcTests()) << "Reconfigure auto device"; qCDebug(dcTests()) << "Reconfigure auto device";
@ -1656,7 +1656,7 @@ void TestIntegrations::reconfigureAutodevice()
} }
void TestIntegrations::removeDevice_data() void TestDevices::removeDevice_data()
{ {
QTest::addColumn<DeviceId>("deviceId"); QTest::addColumn<DeviceId>("deviceId");
QTest::addColumn<Device::DeviceError>("deviceError"); QTest::addColumn<Device::DeviceError>("deviceError");
@ -1666,7 +1666,7 @@ void TestIntegrations::removeDevice_data()
// QTest::newRow("Auto device") << m_mockDeviceAutoId << Device::DeviceErrorCreationMethodNotSupported; // QTest::newRow("Auto device") << m_mockDeviceAutoId << Device::DeviceErrorCreationMethodNotSupported;
} }
void TestIntegrations::removeDevice() void TestDevices::removeDevice()
{ {
QFETCH(DeviceId, deviceId); QFETCH(DeviceId, deviceId);
QFETCH(Device::DeviceError, deviceError); QFETCH(Device::DeviceError, deviceError);
@ -1692,7 +1692,7 @@ void TestIntegrations::removeDevice()
} }
} }
void TestIntegrations::removeAutoDevice() void TestDevices::removeAutoDevice()
{ {
// Setup connection to mock client // Setup connection to mock client
QNetworkAccessManager *nam = new QNetworkAccessManager(this); QNetworkAccessManager *nam = new QNetworkAccessManager(this);
@ -1735,7 +1735,7 @@ void TestIntegrations::removeAutoDevice()
QCOMPARE(NymeaCore::instance()->thingManager()->findConfiguredThings(autoMockThingClassId).count(), oldCount - 1); QCOMPARE(NymeaCore::instance()->thingManager()->findConfiguredThings(autoMockThingClassId).count(), oldCount - 1);
} }
void TestIntegrations::testBrowsing_data() void TestDevices::testBrowsing_data()
{ {
QTest::addColumn<DeviceId>("deviceId"); QTest::addColumn<DeviceId>("deviceId");
@ -1743,7 +1743,7 @@ void TestIntegrations::testBrowsing_data()
QTest::newRow("async mock device") << DeviceId(m_mockThingAsyncId); QTest::newRow("async mock device") << DeviceId(m_mockThingAsyncId);
} }
void TestIntegrations::testBrowsing() void TestDevices::testBrowsing()
{ {
QFETCH(DeviceId, deviceId); QFETCH(DeviceId, deviceId);
@ -1786,7 +1786,7 @@ void TestIntegrations::testBrowsing()
} }
void TestIntegrations::discoverDeviceParenting() void TestDevices::discoverDeviceParenting()
{ {
// Try to discover a mock child device. We don't have a mockParent yet, so it should fail // Try to discover a mock child device. We don't have a mockParent yet, so it should fail
ThingDiscoveryInfo *discoveryInfo = NymeaCore::instance()->thingManager()->discoverThings(childMockThingClassId, ParamList()); ThingDiscoveryInfo *discoveryInfo = NymeaCore::instance()->thingManager()->discoverThings(childMockThingClassId, ParamList());
@ -1854,7 +1854,7 @@ void TestIntegrations::discoverDeviceParenting()
} }
void TestIntegrations::testExecuteBrowserItem_data() void TestDevices::testExecuteBrowserItem_data()
{ {
QTest::addColumn<DeviceId>("deviceId"); QTest::addColumn<DeviceId>("deviceId");
QTest::addColumn<QString>("itemId"); QTest::addColumn<QString>("itemId");
@ -1865,7 +1865,7 @@ void TestIntegrations::testExecuteBrowserItem_data()
QTest::newRow("async mock device") << DeviceId(m_mockThingAsyncId) << "002" << "DeviceErrorNoError"; QTest::newRow("async mock device") << DeviceId(m_mockThingAsyncId) << "002" << "DeviceErrorNoError";
} }
void TestIntegrations::testExecuteBrowserItem() void TestDevices::testExecuteBrowserItem()
{ {
QFETCH(DeviceId, deviceId); QFETCH(DeviceId, deviceId);
QFETCH(QString, itemId); QFETCH(QString, itemId);
@ -1880,7 +1880,7 @@ void TestIntegrations::testExecuteBrowserItem()
QCOMPARE(response.toMap().value("params").toMap().value("deviceError").toString(), deviceError); QCOMPARE(response.toMap().value("params").toMap().value("deviceError").toString(), deviceError);
} }
void TestIntegrations::testExecuteBrowserItemAction_data() void TestDevices::testExecuteBrowserItemAction_data()
{ {
QTest::addColumn<DeviceId>("deviceId"); QTest::addColumn<DeviceId>("deviceId");
@ -1888,7 +1888,7 @@ void TestIntegrations::testExecuteBrowserItemAction_data()
QTest::newRow("async mock device") << DeviceId(m_mockThingAsyncId); QTest::newRow("async mock device") << DeviceId(m_mockThingAsyncId);
} }
void TestIntegrations::testExecuteBrowserItemAction() void TestDevices::testExecuteBrowserItemAction()
{ {
QFETCH(DeviceId, deviceId); QFETCH(DeviceId, deviceId);
@ -1959,7 +1959,7 @@ void TestIntegrations::testExecuteBrowserItemAction()
} }
void TestIntegrations::executeAction_data() void TestDevices::executeAction_data()
{ {
QTest::addColumn<DeviceId>("deviceId"); QTest::addColumn<DeviceId>("deviceId");
QTest::addColumn<ActionTypeId>("actionTypeId"); QTest::addColumn<ActionTypeId>("actionTypeId");
@ -1985,7 +1985,7 @@ void TestIntegrations::executeAction_data()
QTest::newRow("async broken action") << DeviceId(m_mockThingId) << mockAsyncFailingActionTypeId << QVariantList() << Device::DeviceErrorSetupFailed; QTest::newRow("async broken action") << DeviceId(m_mockThingId) << mockAsyncFailingActionTypeId << QVariantList() << Device::DeviceErrorSetupFailed;
} }
void TestIntegrations::executeAction() void TestDevices::executeAction()
{ {
QFETCH(DeviceId, deviceId); QFETCH(DeviceId, deviceId);
QFETCH(ActionTypeId, actionTypeId); QFETCH(ActionTypeId, actionTypeId);
@ -2037,7 +2037,7 @@ void TestIntegrations::executeAction()
} }
void TestIntegrations::triggerEvent() void TestDevices::triggerEvent()
{ {
enableNotifications({"Devices"}); enableNotifications({"Devices"});
QList<Thing*> devices = NymeaCore::instance()->thingManager()->findConfiguredThings(mockThingClassId); QList<Thing*> devices = NymeaCore::instance()->thingManager()->findConfiguredThings(mockThingClassId);
@ -2078,7 +2078,7 @@ void TestIntegrations::triggerEvent()
QCOMPARE(notificationContent.value("event").toMap().value("eventTypeId").toUuid().toString(), mockEvent1EventTypeId.toString()); QCOMPARE(notificationContent.value("event").toMap().value("eventTypeId").toUuid().toString(), mockEvent1EventTypeId.toString());
} }
void TestIntegrations::triggerStateChangeEvent() void TestDevices::triggerStateChangeEvent()
{ {
enableNotifications({"Devices"}); enableNotifications({"Devices"});
@ -2121,7 +2121,7 @@ void TestIntegrations::triggerStateChangeEvent()
} }
void TestIntegrations::params() void TestDevices::params()
{ {
Event event; Event event;
ParamList params; ParamList params;
@ -2134,7 +2134,7 @@ void TestIntegrations::params()
QVERIFY(!event.param(ParamTypeId::createParamTypeId()).value().isValid()); QVERIFY(!event.param(ParamTypeId::createParamTypeId()).value().isValid());
} }
void TestIntegrations::asyncSetupEmitsSetupStatusUpdate() void TestDevices::asyncSetupEmitsSetupStatusUpdate()
{ {
QVariantMap configuredDevices = injectAndWait("Devices.GetConfiguredDevices").toMap(); QVariantMap configuredDevices = injectAndWait("Devices.GetConfiguredDevices").toMap();
foreach (const QVariant &deviceVariant, configuredDevices.value("params").toMap().value("devices").toList()) { foreach (const QVariant &deviceVariant, configuredDevices.value("params").toMap().value("devices").toList()) {
@ -2184,5 +2184,5 @@ void TestIntegrations::asyncSetupEmitsSetupStatusUpdate()
} }
#include "testdevices.moc" #include "testdevices.moc"
QTEST_MAIN(TestIntegrations) QTEST_MAIN(TestDevices)

View File

@ -113,7 +113,7 @@ private slots:
void editThings_data(); void editThings_data();
void editThings(); void editThings();
void testDeviceSettings(); void testThingSettings();
void reconfigureThings_data(); void reconfigureThings_data();
void reconfigureThings(); void reconfigureThings();
@ -143,7 +143,7 @@ private slots:
void asyncSetupEmitsSetupStatusUpdate(); void asyncSetupEmitsSetupStatusUpdate();
// Keep those at last as they will remove devices // Keep those at last as they will remove things
void removeThing_data(); void removeThing_data();
void removeThing(); void removeThing();
@ -267,10 +267,10 @@ void TestIntegrations::setPluginConfig()
void TestIntegrations::getSupportedVendors() void TestIntegrations::getSupportedVendors()
{ {
QVariant supportedVendors = injectAndWait("Devices.GetSupportedVendors"); QVariant supportedVendors = injectAndWait("Integrations.GetVendors");
qDebug() << "response" << supportedVendors; qDebug() << "response" << supportedVendors;
// Make sure there is exactly 1 supported Vendor named "guh" // Make sure there is exactly 1 Vendor with nymea's id
QVariantList vendorList = supportedVendors.toMap().value("params").toMap().value("vendors").toList(); QVariantList vendorList = supportedVendors.toMap().value("params").toMap().value("vendors").toList();
QCOMPARE(vendorList.count() > 0, true); QCOMPARE(vendorList.count() > 0, true);
bool found = false; bool found = false;
@ -312,19 +312,19 @@ void TestIntegrations::verifyInterfaces()
{ {
QVariantMap params; QVariantMap params;
params.insert("vendorId", nymeaVendorId); params.insert("vendorId", nymeaVendorId);
QVariant result = injectAndWait("Devices.GetSupportedDevices", params); QVariant result = injectAndWait("Integrations.GetThingClasses", params);
QVariantList supportedDevices = result.toMap().value("params").toMap().value("deviceClasses").toList(); QVariantList supportedThings = result.toMap().value("params").toMap().value("thingClasses").toList();
QVariantMap mockDevice; QVariantMap mock;
foreach (const QVariant &deviceClass, supportedDevices) { foreach (const QVariant &thingClass, supportedThings) {
if (deviceClass.toMap().value("id").toUuid() == mockThingClassId) { if (thingClass.toMap().value("id").toUuid() == mockThingClassId) {
mockDevice = deviceClass.toMap(); mock = thingClass.toMap();
} }
} }
QVERIFY(!mockDevice.isEmpty()); QVERIFY(!mock.isEmpty());
QVariantList interfaces = mockDevice.value("interfaces").toList(); QVariantList interfaces = mock.value("interfaces").toList();
// Must contain system, power, light and battery, but must not contain gateway as the device manager should filter // Must contain system, power, light and battery, but must not contain gateway as the thing manager should filter
// that away because it doesn't implement all the required states. // that away because it doesn't implement all the required states.
QCOMPARE(interfaces.count(), 4); QCOMPARE(interfaces.count(), 4);
QVERIFY(interfaces.contains("system")); QVERIFY(interfaces.contains("system"));
@ -351,38 +351,38 @@ void TestIntegrations::addThing_data()
brokenParam.insert("paramTypeId", mockThingBrokenParamTypeId); brokenParam.insert("paramTypeId", mockThingBrokenParamTypeId);
brokenParam.insert("value", true); brokenParam.insert("value", true);
QVariantList deviceParams; QVariantList thingParams;
deviceParams.clear(); deviceParams << httpportParam; thingParams.clear(); thingParams << httpportParam;
QTest::newRow("User, JustAdd") << mockThingClassId << deviceParams << true << Thing::ThingErrorNoError; QTest::newRow("User, JustAdd") << mockThingClassId << thingParams << true << Thing::ThingErrorNoError;
deviceParams.clear(); deviceParams << httpportParam << asyncParam; thingParams.clear(); thingParams << httpportParam << asyncParam;
QTest::newRow("User, JustAdd, Async") << mockThingClassId << deviceParams << true << Thing::ThingErrorNoError; QTest::newRow("User, JustAdd, Async") << mockThingClassId << thingParams << true << Thing::ThingErrorNoError;
QTest::newRow("Invalid ThingClassId") << ThingClassId::createThingClassId() << deviceParams << true << Thing::ThingErrorThingClassNotFound; QTest::newRow("Invalid ThingClassId") << ThingClassId::createThingClassId() << thingParams << true << Thing::ThingErrorThingClassNotFound;
deviceParams.clear(); deviceParams << httpportParam << brokenParam; thingParams.clear(); thingParams << httpportParam << brokenParam;
QTest::newRow("Setup failure") << mockThingClassId << deviceParams << true << Thing::ThingErrorSetupFailed; QTest::newRow("Setup failure") << mockThingClassId << thingParams << true << Thing::ThingErrorSetupFailed;
deviceParams.clear(); deviceParams << httpportParam << asyncParam << brokenParam; thingParams.clear(); thingParams << httpportParam << asyncParam << brokenParam;
QTest::newRow("Setup failure, Async") << mockThingClassId << deviceParams << true << Thing::ThingErrorSetupFailed; QTest::newRow("Setup failure, Async") << mockThingClassId << thingParams << true << Thing::ThingErrorSetupFailed;
QVariantList invalidDeviceParams; QVariantList invalidThingParams;
QTest::newRow("User, JustAdd, missing params") << mockThingClassId << invalidDeviceParams << true << Thing::ThingErrorMissingParameter; QTest::newRow("User, JustAdd, missing params") << mockThingClassId << invalidThingParams << true << Thing::ThingErrorMissingParameter;
QVariantMap fakeparam; QVariantMap fakeparam;
fakeparam.insert("paramTypeId", ParamTypeId::createParamTypeId()); fakeparam.insert("paramTypeId", ParamTypeId::createParamTypeId());
invalidDeviceParams.append(fakeparam); invalidThingParams.append(fakeparam);
QTest::newRow("User, JustAdd, invalid param") << mockThingClassId << invalidDeviceParams << false << Thing::ThingErrorMissingParameter; QTest::newRow("User, JustAdd, invalid param") << mockThingClassId << invalidThingParams << false << Thing::ThingErrorMissingParameter;
QVariantMap fakeparam2; QVariantMap fakeparam2;
fakeparam2.insert("paramTypeId", mockThingHttpportParamTypeId.toString()); fakeparam2.insert("paramTypeId", mockThingHttpportParamTypeId.toString());
fakeparam2.insert("value", "blabla"); fakeparam2.insert("value", "blabla");
invalidDeviceParams.clear(); invalidThingParams.clear();
invalidDeviceParams.append(fakeparam2); invalidThingParams.append(fakeparam2);
QTest::newRow("User, JustAdd, wrong param") << mockThingClassId << invalidDeviceParams << true << Thing::ThingErrorInvalidParameter; QTest::newRow("User, JustAdd, wrong param") << mockThingClassId << invalidThingParams << true << Thing::ThingErrorInvalidParameter;
deviceParams.clear(); deviceParams << httpportParam << fakeparam; thingParams.clear(); thingParams << httpportParam << fakeparam;
QTest::newRow("USer, JustAdd, additional invalid param") << mockThingClassId << deviceParams << false << Thing::ThingErrorNoError; QTest::newRow("USer, JustAdd, additional invalid param") << mockThingClassId << thingParams << false << Thing::ThingErrorNoError;
deviceParams.clear(); deviceParams << httpportParam << fakeparam2; thingParams.clear(); thingParams << httpportParam << fakeparam2;
QTest::newRow("USer, JustAdd, additional param, valid but unused") << mockThingClassId << deviceParams << true << Thing::ThingErrorNoError; QTest::newRow("USer, JustAdd, additional param, valid but unused") << mockThingClassId << thingParams << true << Thing::ThingErrorNoError;
} }
@ -395,7 +395,7 @@ void TestIntegrations::addThing()
QVariantMap params; QVariantMap params;
params.insert("thingClassId", thingClassId); params.insert("thingClassId", thingClassId);
params.insert("name", "Test Add Device"); params.insert("name", "Test Add Thing");
params.insert("thingParams", thingParams); params.insert("thingParams", thingParams);
QVariant response = injectAndWait("Integrations.AddThing", params); QVariant response = injectAndWait("Integrations.AddThing", params);
@ -421,17 +421,17 @@ void TestIntegrations::thingAddedRemovedNotifications()
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
// add device and wait for notification // add thing and wait for notification
QVariantList deviceParams; QVariantList thingParams;
QVariantMap httpportParam; QVariantMap httpportParam;
httpportParam.insert("paramTypeId", mockThingHttpportParamTypeId); httpportParam.insert("paramTypeId", mockThingHttpportParamTypeId);
httpportParam.insert("value", 5678); httpportParam.insert("value", 5678);
deviceParams.append(httpportParam); thingParams.append(httpportParam);
QVariantMap params; clientSpy.clear(); QVariantMap params; clientSpy.clear();
params.insert("thingClassId", mockThingClassId); params.insert("thingClassId", mockThingClassId);
params.insert("name", "Mocked thing"); params.insert("name", "Mocked thing");
params.insert("thingParams", deviceParams); params.insert("thingParams", thingParams);
QVariant response = injectAndWait("Integrations.AddThing", params); QVariant response = injectAndWait("Integrations.AddThing", params);
if (clientSpy.count() == 0) clientSpy.wait(); if (clientSpy.count() == 0) clientSpy.wait();
verifyThingError(response); verifyThingError(response);
@ -440,7 +440,7 @@ void TestIntegrations::thingAddedRemovedNotifications()
ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString()); ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString());
QVERIFY(!thingId.isNull()); QVERIFY(!thingId.isNull());
// check the DeviceAdded notification // check the ThingAdded notification
QCOMPARE(notificationThingMap.value("thingClassId").toUuid(), QUuid(mockThingClassId)); QCOMPARE(notificationThingMap.value("thingClassId").toUuid(), QUuid(mockThingClassId));
QCOMPARE(notificationThingMap.value("id").toUuid(), QUuid(thingId)); QCOMPARE(notificationThingMap.value("id").toUuid(), QUuid(thingId));
foreach (const QVariant &param, notificationThingMap.value("params").toList()) { foreach (const QVariant &param, notificationThingMap.value("params").toList()) {
@ -449,7 +449,7 @@ void TestIntegrations::thingAddedRemovedNotifications()
} }
} }
// now remove the device and check the device removed notification // now remove the thong and check the thing removed notification
params.clear(); response.clear(); clientSpy.clear(); params.clear(); response.clear(); clientSpy.clear();
params.insert("thingId", thingId); params.insert("thingId", thingId);
response = injectAndWait("Integrations.RemoveThing", params); response = injectAndWait("Integrations.RemoveThing", params);
@ -468,44 +468,44 @@ void TestIntegrations::thingChangedNotifications()
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
// ADD // ADD
// add device and wait for notification // add thing and wait for notification
QVariantList deviceParams; QVariantList thingParams;
QVariantMap httpportParam; QVariantMap httpportParam;
httpportParam.insert("paramTypeId", mockThingHttpportParamTypeId); httpportParam.insert("paramTypeId", mockThingHttpportParamTypeId);
httpportParam.insert("value", 23234); httpportParam.insert("value", 23234);
deviceParams.append(httpportParam); thingParams.append(httpportParam);
clientSpy.clear(); clientSpy.clear();
QVariantMap params; QVariantMap params;
params.insert("thingClassId", mockThingClassId); params.insert("thingClassId", mockThingClassId);
params.insert("name", "Mock"); params.insert("name", "Mock");
params.insert("thingParams", deviceParams); params.insert("thingParams", thingParams);
QVariant response = injectAndWait("Integrations.AddThing", params); QVariant response = injectAndWait("Integrations.AddThing", params);
ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString()); ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString());
QVERIFY(!thingId.isNull()); QVERIFY(!thingId.isNull());
if (clientSpy.count() == 0) clientSpy.wait(); if (clientSpy.count() == 0) clientSpy.wait();
verifyThingError(response); verifyThingError(response);
QVariantMap notificationDeviceMap = checkNotification(clientSpy, "Integrations.ThingAdded").toMap().value("params").toMap().value("thing").toMap(); QVariantMap notificationThingMap = checkNotification(clientSpy, "Integrations.ThingAdded").toMap().value("params").toMap().value("thing").toMap();
QCOMPARE(notificationDeviceMap.value("thingClassId").toUuid(), QUuid(mockThingClassId)); QCOMPARE(notificationThingMap.value("thingClassId").toUuid(), QUuid(mockThingClassId));
QCOMPARE(notificationDeviceMap.value("id").toUuid(), QUuid(thingId)); QCOMPARE(notificationThingMap.value("id").toUuid(), QUuid(thingId));
foreach (const QVariant &param, notificationDeviceMap.value("params").toList()) { foreach (const QVariant &param, notificationThingMap.value("params").toList()) {
if (param.toMap().value("name").toString() == "httpport") { if (param.toMap().value("name").toString() == "httpport") {
QCOMPARE(param.toMap().value("value").toInt(), httpportParam.value("value").toInt()); QCOMPARE(param.toMap().value("value").toInt(), httpportParam.value("value").toInt());
} }
} }
// RECONFIGURE // RECONFIGURE
// now reconfigure the device and check the deviceChanged notification // now reconfigure the thing and check the thing changed notification
QVariantList newDeviceParams; QVariantList newThingParams;
QVariantMap newHttpportParam; QVariantMap newHttpportParam;
newHttpportParam.insert("paramTypeId", mockThingHttpportParamTypeId); newHttpportParam.insert("paramTypeId", mockThingHttpportParamTypeId);
newHttpportParam.insert("value", 45473); newHttpportParam.insert("value", 45473);
newDeviceParams.append(newHttpportParam); newThingParams.append(newHttpportParam);
params.clear(); response.clear(); clientSpy.clear(); params.clear(); response.clear(); clientSpy.clear();
params.insert("thingId", thingId); params.insert("thingId", thingId);
params.insert("thingParams", newDeviceParams); params.insert("thingParams", newThingParams);
response = injectAndWait("Integrations.ReconfigureThing", params); response = injectAndWait("Integrations.ReconfigureThing", params);
if (clientSpy.count() == 0) clientSpy.wait(); if (clientSpy.count() == 0) clientSpy.wait();
verifyThingError(response); verifyThingError(response);
@ -518,8 +518,8 @@ void TestIntegrations::thingChangedNotifications()
} }
} }
// EDIT device name // EDIT thing name
QString thingName = "Test device 1234"; QString thingName = "Test thing 1234";
params.clear(); response.clear(); clientSpy.clear(); params.clear(); response.clear(); clientSpy.clear();
params.insert("thingId", thingId); params.insert("thingId", thingId);
params.insert("name", thingName); params.insert("name", thingName);
@ -532,7 +532,7 @@ void TestIntegrations::thingChangedNotifications()
QCOMPARE(editThingNotificationMap.value("name").toString(), thingName); QCOMPARE(editThingNotificationMap.value("name").toString(), thingName);
// REMOVE // REMOVE
// now remove the device and check the device removed notification // now remove the thing and check the thing removed notification
params.clear(); response.clear(); clientSpy.clear(); params.clear(); response.clear(); clientSpy.clear();
params.insert("thingId", thingId); params.insert("thingId", thingId);
response = injectAndWait("Integrations.RemoveThing", params); response = injectAndWait("Integrations.RemoveThing", params);
@ -546,8 +546,8 @@ void TestIntegrations::getThings()
{ {
QVariant response = injectAndWait("Integrations.GetThings"); QVariant response = injectAndWait("Integrations.GetThings");
QVariantList devices = response.toMap().value("params").toMap().value("things").toList(); QVariantList things = response.toMap().value("params").toMap().value("things").toList();
QCOMPARE(devices.count(), 3); // There should be: one auto created mock, one created in NymeaTestBase::initTestcase() and one created in TestIntegrations::initTestCase() QCOMPARE(things.count(), 3); // There should be: one auto created mock, one created in NymeaTestBase::initTestcase() and one created in TestIntegrations::initTestCase()
} }
void TestIntegrations::getThing_data() void TestIntegrations::getThing_data()
@ -665,7 +665,7 @@ void TestIntegrations::discoverThings()
params.clear(); params.clear();
params.insert("thingClassId", thingClassId); params.insert("thingClassId", thingClassId);
params.insert("name", "Discoverd mock device"); params.insert("name", "Discoverd mock");
params.insert("thingDescriptorId", descriptorId.toString()); params.insert("thingDescriptorId", descriptorId.toString());
response = injectAndWait("Integrations.AddThing", params); response = injectAndWait("Integrations.AddThing", params);
@ -695,7 +695,7 @@ void TestIntegrations::addPushButtonThings()
QFETCH(Thing::ThingError, error); QFETCH(Thing::ThingError, error);
QFETCH(bool, waitForButtonPressed); QFETCH(bool, waitForButtonPressed);
// Discover device // Discover things
QVariantList discoveryParams; QVariantList discoveryParams;
QVariantMap resultCountParam; QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", pushButtonMockDiscoveryResultCountParamTypeId); resultCountParam.insert("paramTypeId", pushButtonMockDiscoveryResultCountParamTypeId);
@ -711,11 +711,11 @@ void TestIntegrations::addPushButtonThings()
QCOMPARE(response.toMap().value("params").toMap().value("thingDescriptors").toList().count(), 1); QCOMPARE(response.toMap().value("params").toMap().value("thingDescriptors").toList().count(), 1);
// Pair device // Pair thing
ThingDescriptorId descriptorId = ThingDescriptorId(response.toMap().value("params").toMap().value("thingDescriptors").toList().first().toMap().value("id").toString()); ThingDescriptorId descriptorId = ThingDescriptorId(response.toMap().value("params").toMap().value("thingDescriptors").toList().first().toMap().value("id").toString());
params.clear(); params.clear();
params.insert("thingClassId", thingClassId); params.insert("thingClassId", thingClassId);
params.insert("name", "Pushbutton device"); params.insert("name", "Pushbutton mock");
params.insert("thingDescriptorId", descriptorId.toString()); params.insert("thingDescriptorId", descriptorId.toString());
response = injectAndWait("Integrations.PairThing", params); response = injectAndWait("Integrations.PairThing", params);
@ -751,8 +751,8 @@ void TestIntegrations::addDisplayPinThings_data()
QTest::addColumn<Thing::ThingError>("error"); QTest::addColumn<Thing::ThingError>("error");
QTest::addColumn<QString>("secret"); QTest::addColumn<QString>("secret");
QTest::newRow("Valid: Add DisplayPin device") << displayPinMockThingClassId << Thing::ThingErrorNoError << "243681"; QTest::newRow("Valid: Add DisplayPin mock") << displayPinMockThingClassId << Thing::ThingErrorNoError << "243681";
QTest::newRow("Invalid: Add DisplayPin device (wrong pin)") << displayPinMockThingClassId << Thing::ThingErrorAuthenticationFailure << "243682"; QTest::newRow("Invalid: Add DisplayPin mock (wrong pin)") << displayPinMockThingClassId << Thing::ThingErrorAuthenticationFailure << "243682";
} }
void TestIntegrations::addDisplayPinThings() void TestIntegrations::addDisplayPinThings()
@ -761,7 +761,7 @@ void TestIntegrations::addDisplayPinThings()
QFETCH(Thing::ThingError, error); QFETCH(Thing::ThingError, error);
QFETCH(QString, secret); QFETCH(QString, secret);
// Discover device // Discover things
QVariantList discoveryParams; QVariantList discoveryParams;
QVariantMap resultCountParam; QVariantMap resultCountParam;
resultCountParam.insert("paramTypeId", displayPinMockDiscoveryResultCountParamTypeId); resultCountParam.insert("paramTypeId", displayPinMockDiscoveryResultCountParamTypeId);
@ -776,11 +776,11 @@ void TestIntegrations::addDisplayPinThings()
verifyThingError(response, Thing::ThingErrorNoError); verifyThingError(response, Thing::ThingErrorNoError);
QCOMPARE(response.toMap().value("params").toMap().value("thingDescriptors").toList().count(), 1); QCOMPARE(response.toMap().value("params").toMap().value("thingDescriptors").toList().count(), 1);
// Pair device // Pair thing
ThingDescriptorId descriptorId = ThingDescriptorId(response.toMap().value("params").toMap().value("thingDescriptors").toList().first().toMap().value("id").toString()); ThingDescriptorId descriptorId = ThingDescriptorId(response.toMap().value("params").toMap().value("thingDescriptors").toList().first().toMap().value("id").toString());
params.clear(); params.clear();
params.insert("thingClassId", thingClassId); params.insert("thingClassId", thingClassId);
params.insert("name", "Display pin mock device"); params.insert("name", "Display pin mock");
params.insert("thingDescriptorId", descriptorId.toString()); params.insert("thingDescriptorId", descriptorId.toString());
response = injectAndWait("Integrations.PairThing", params); response = injectAndWait("Integrations.PairThing", params);
@ -789,7 +789,7 @@ void TestIntegrations::addDisplayPinThings()
PairingTransactionId pairingTransactionId(response.toMap().value("params").toMap().value("pairingTransactionId").toString()); PairingTransactionId pairingTransactionId(response.toMap().value("params").toMap().value("pairingTransactionId").toString());
QString displayMessage = response.toMap().value("params").toMap().value("displayMessage").toString(); QString displayMessage = response.toMap().value("params").toMap().value("displayMessage").toString();
qDebug() << "displayMessage" << displayMessage; qCDebug(dcTests()) << "displayMessage" << displayMessage;
params.clear(); params.clear();
params.insert("pairingTransactionId", pairingTransactionId.toString()); params.insert("pairingTransactionId", pairingTransactionId.toString());
@ -809,7 +809,7 @@ void TestIntegrations::addDisplayPinThings()
void TestIntegrations::parentChildThings() void TestIntegrations::parentChildThings()
{ {
// add parent device // add parent
QVariantMap params; QVariantMap params;
params.insert("thingClassId", parentMockThingClassId); params.insert("thingClassId", parentMockThingClassId);
params.insert("name", "Parent"); params.insert("name", "Parent");
@ -825,41 +825,41 @@ void TestIntegrations::parentChildThings()
thingAddedSpy.wait(); thingAddedSpy.wait();
QCOMPARE(thingAddedSpy.count(), 2); QCOMPARE(thingAddedSpy.count(), 2);
// find child device // find child
response = injectAndWait("Integrations.GetThings"); response = injectAndWait("Integrations.GetThings");
QVariantList things = response.toMap().value("params").toMap().value("things").toList(); QVariantList things = response.toMap().value("params").toMap().value("things").toList();
ThingId childId; ThingId childId;
foreach (const QVariant thingVariant, things) { foreach (const QVariant thingVariant, things) {
QVariantMap deviceMap = thingVariant.toMap(); QVariantMap thingMap = thingVariant.toMap();
if (deviceMap.value("thingClassId").toUuid() == childMockThingClassId) { if (thingMap.value("thingClassId").toUuid() == childMockThingClassId) {
if (deviceMap.value("parentId").toUuid() == parentId) { if (thingMap.value("parentId").toUuid() == parentId) {
childId = ThingId(deviceMap.value("id").toString()); childId = ThingId(thingMap.value("id").toString());
break; break;
} }
} }
} }
QVERIFY2(!childId.isNull(), QString("Could not find child device:\nParent ID:%1\nResponse:%2") QVERIFY2(!childId.isNull(), QString("Could not find child:\nParent ID:%1\nResponse:%2")
.arg(parentId.toString()) .arg(parentId.toString())
.arg(qUtf8Printable(QJsonDocument::fromVariant(response).toJson())) .arg(qUtf8Printable(QJsonDocument::fromVariant(response).toJson()))
.toUtf8()); .toUtf8());
// Try to remove the child device // Try to remove the child
params.clear(); params.clear();
params.insert("thingId", childId.toString()); params.insert("thingId", childId.toString());
response = injectAndWait("Integrations.RemoveThing", params); response = injectAndWait("Integrations.RemoveThing", params);
verifyThingError(response, Thing::ThingErrorThingIsChild); verifyThingError(response, Thing::ThingErrorThingIsChild);
// check if the child device is still there // check if the child is still there
response = injectAndWait("Integrations.GetThings"); response = injectAndWait("Integrations.GetThings");
things = response.toMap().value("params").toMap().value("things").toList(); things = response.toMap().value("params").toMap().value("things").toList();
bool found = false; bool found = false;
foreach (const QVariant thingVariant, things) { foreach (const QVariant thingVariant, things) {
QVariantMap deviceMap = thingVariant.toMap(); QVariantMap thingMap = thingVariant.toMap();
if (deviceMap.value("thingClassId").toUuid() == childMockThingClassId) { if (thingMap.value("thingClassId").toUuid() == childMockThingClassId) {
if (deviceMap.value("id").toUuid() == childId) { if (thingMap.value("id").toUuid() == childId) {
found = true; found = true;
break; break;
} }
@ -867,13 +867,13 @@ void TestIntegrations::parentChildThings()
} }
QVERIFY2(found, "Could not find child."); QVERIFY2(found, "Could not find child.");
// remove the parent device // remove the parent
params.clear(); params.clear();
params.insert("thingId", parentId.toString()); params.insert("thingId", parentId.toString());
response = injectAndWait("Integrations.RemoveThing", params); response = injectAndWait("Integrations.RemoveThing", params);
verifyThingError(response); verifyThingError(response);
// check if the child device is still there // check if the child is still there
response = injectAndWait("Integrations.GetThings"); response = injectAndWait("Integrations.GetThings");
things = response.toMap().value("params").toMap().value("things").toList(); things = response.toMap().value("params").toMap().value("things").toList();
found = false; found = false;
@ -997,7 +997,7 @@ void TestIntegrations::getStateValue()
QCOMPARE(response.toMap().value("params").toMap().value("thingError").toString(), enumValueName(statusCode)); QCOMPARE(response.toMap().value("params").toMap().value("thingError").toString(), enumValueName(statusCode));
if (statusCode == Thing::ThingErrorNoError) { if (statusCode == Thing::ThingErrorNoError) {
QVariant value = response.toMap().value("params").toMap().value("value"); QVariant value = response.toMap().value("params").toMap().value("value");
QCOMPARE(value.toInt(), 10); // Mock device has value 10 by default... QCOMPARE(value.toInt(), 10); // Mock has value 10 by default...
} }
} }
@ -1022,7 +1022,7 @@ void TestIntegrations::getStateValues()
QCOMPARE(response.toMap().value("params").toMap().value("thingError").toString(), enumValueName(statusCode)); QCOMPARE(response.toMap().value("params").toMap().value("thingError").toString(), enumValueName(statusCode));
if (statusCode == Thing::ThingErrorNoError) { if (statusCode == Thing::ThingErrorNoError) {
QVariantList values = response.toMap().value("params").toMap().value("values").toList(); QVariantList values = response.toMap().value("params").toMap().value("values").toList();
QCOMPARE(values.count(), 6); // Mock device has 6 states... QCOMPARE(values.count(), 6); // Mock has 6 states...
} }
} }
@ -1031,8 +1031,8 @@ void TestIntegrations::editThings_data()
QTest::addColumn<QString>("name"); QTest::addColumn<QString>("name");
QTest::newRow("change name") << "New name"; QTest::newRow("change name") << "New name";
QTest::newRow("change name") << "Foo device"; QTest::newRow("change name") << "Foo";
QTest::newRow("change name") << "Bar device"; QTest::newRow("change name") << "Bar";
} }
void TestIntegrations::editThings() void TestIntegrations::editThings()
@ -1042,16 +1042,16 @@ void TestIntegrations::editThings()
QString originalName = "Test thing"; QString originalName = "Test thing";
// add thing // add thing
QVariantList deviceParams; QVariantList thingParams;
QVariantMap httpportParam; QVariantMap httpportParam;
httpportParam.insert("paramTypeId", mockThingHttpportParamTypeId); httpportParam.insert("paramTypeId", mockThingHttpportParamTypeId);
httpportParam.insert("value", 8889); httpportParam.insert("value", 8889);
deviceParams.append(httpportParam); thingParams.append(httpportParam);
QVariantMap params; QVariantMap params;
params.insert("thingClassId", mockThingClassId); params.insert("thingClassId", mockThingClassId);
params.insert("name", originalName); params.insert("name", originalName);
params.insert("thingParams", deviceParams); params.insert("thingParams", thingParams);
QVariant response = injectAndWait("Integrations.AddThing", params); QVariant response = injectAndWait("Integrations.AddThing", params);
verifyThingError(response); verifyThingError(response);
ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString()); ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString());
@ -1069,10 +1069,10 @@ void TestIntegrations::editThings()
response = injectAndWait("Integrations.GetThings"); response = injectAndWait("Integrations.GetThings");
QVariantList things = response.toMap().value("params").toMap().value("things").toList(); QVariantList things = response.toMap().value("params").toMap().value("things").toList();
foreach (const QVariant &deviceVariant, things) { foreach (const QVariant &thingVariant, things) {
QVariantMap device = deviceVariant.toMap(); QVariantMap thing = thingVariant.toMap();
if (ThingId(device.value("id").toString()) == thingId) { if (ThingId(thing.value("id").toString()) == thingId) {
newName = device.value("name").toString(); newName = thing.value("name").toString();
} }
} }
QCOMPARE(newName, name); QCOMPARE(newName, name);
@ -1083,9 +1083,9 @@ void TestIntegrations::editThings()
response = injectAndWait("Integrations.GetThings"); response = injectAndWait("Integrations.GetThings");
things = response.toMap().value("params").toMap().value("things").toList(); things = response.toMap().value("params").toMap().value("things").toList();
foreach (const QVariant &thingVariant, things) { foreach (const QVariant &thingVariant, things) {
QVariantMap device = thingVariant.toMap(); QVariantMap thing = thingVariant.toMap();
if (ThingId(device.value("id").toString()) == thingId) { if (ThingId(thing.value("id").toString()) == thingId) {
newName = device.value("name").toString(); newName = thing.value("name").toString();
break; break;
} }
} }
@ -1097,19 +1097,19 @@ void TestIntegrations::editThings()
verifyThingError(response); verifyThingError(response);
} }
void TestIntegrations::testDeviceSettings() void TestIntegrations::testThingSettings()
{ {
// add device // add thing
QVariantList deviceParams; QVariantList thingParams;
QVariantMap httpportParam; QVariantMap httpportParam;
httpportParam.insert("paramTypeId", mockThingHttpportParamTypeId); httpportParam.insert("paramTypeId", mockThingHttpportParamTypeId);
httpportParam.insert("value", 8889); httpportParam.insert("value", 8889);
deviceParams.append(httpportParam); thingParams.append(httpportParam);
QVariantMap params; QVariantMap params;
params.insert("thingClassId", mockThingClassId); params.insert("thingClassId", mockThingClassId);
params.insert("name", "Mock"); params.insert("name", "Mock");
params.insert("thingParams", deviceParams); params.insert("thingParams", thingParams);
QVariant response = injectAndWait("Integrations.AddThing", params); QVariant response = injectAndWait("Integrations.AddThing", params);
verifyThingError(response); verifyThingError(response);
ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString()); ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString());
@ -1188,7 +1188,7 @@ void TestIntegrations::reconfigureThings_data()
QVariantList httpportChangeThingParams; QVariantList httpportChangeThingParams;
QVariantMap httpportParamDifferent; QVariantMap httpportParamDifferent;
httpportParamDifferent.insert("paramTypeId", mockThingHttpportParamTypeId); httpportParamDifferent.insert("paramTypeId", mockThingHttpportParamTypeId);
httpportParamDifferent.insert("value", 8893); // if change -> change also newPort in reconfigureDevices() httpportParamDifferent.insert("value", 8893); // if changing this, change also newPort in reconfigureThings()
httpportChangeThingParams.append(httpportParamDifferent); httpportChangeThingParams.append(httpportParamDifferent);
QVariantList brokenChangedThingParams; QVariantList brokenChangedThingParams;
@ -1241,14 +1241,14 @@ void TestIntegrations::reconfigureThings()
thingParams.append(httpportParam); thingParams.append(httpportParam);
params.insert("thingParams", thingParams); params.insert("thingParams", thingParams);
// add a mockdevice // add a mock
QVariant response = injectAndWait("Integrations.AddThing", params); QVariant response = injectAndWait("Integrations.AddThing", params);
verifyThingError(response); verifyThingError(response);
ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString()); ThingId thingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString());
QVERIFY(!thingId.isNull()); QVERIFY(!thingId.isNull());
// now EDIT the added device // now EDIT the added mock
response.clear(); response.clear();
QVariantMap editParams; QVariantMap editParams;
editParams.insert("thingId", thingId); editParams.insert("thingId", thingId);
@ -1282,7 +1282,7 @@ void TestIntegrations::reconfigureThings()
foreach (const QVariant &thing, response.toMap().value("params").toMap().value("things").toList()) { foreach (const QVariant &thing, response.toMap().value("params").toMap().value("things").toList()) {
if (ThingId(thing.toMap().value("id").toString()) == thingId) { if (ThingId(thing.toMap().value("id").toString()) == thingId) {
qDebug() << "found added thing" << thing.toMap().value("params"); qDebug() << "found added thing" << thing.toMap().value("params");
qDebug() << "expected deviceParams:" << newThingParams; qDebug() << "expected params:" << newThingParams;
// check if the edit was ok // check if the edit was ok
verifyParams(newThingParams, thing.toMap().value("params").toList(), false); verifyParams(newThingParams, thing.toMap().value("params").toList(), false);
found = true; found = true;
@ -1376,12 +1376,12 @@ void TestIntegrations::reconfigureByDiscovery()
QCOMPARE(response.toMap().value("params").toMap().value("thingDescriptors").toList().count(), resultCount); QCOMPARE(response.toMap().value("params").toMap().value("thingDescriptors").toList().count(), resultCount);
} }
// add Discovered Device 1 port 55555 // add Discovered Thing 1 port 55555
QVariantList thingDescriptors = response.toMap().value("params").toMap().value("thingDescriptors").toList(); QVariantList thingDescriptors = response.toMap().value("params").toMap().value("thingDescriptors").toList();
ThingDescriptorId descriptorId; ThingDescriptorId descriptorId;
foreach (const QVariant &descriptor, thingDescriptors) { foreach (const QVariant &descriptor, thingDescriptors) {
// find the device with port 55555 // find the thing with port 55555
if (descriptor.toMap().value("description").toString() == "55555") { if (descriptor.toMap().value("description").toString() == "55555") {
descriptorId = ThingDescriptorId(descriptor.toMap().value("id").toString()); descriptorId = ThingDescriptorId(descriptor.toMap().value("id").toString());
qDebug() << descriptorId.toString(); qDebug() << descriptorId.toString();
@ -1396,14 +1396,14 @@ void TestIntegrations::reconfigureByDiscovery()
params.clear(); params.clear();
response.clear(); response.clear();
params.insert("thingClassId", thingClassId); params.insert("thingClassId", thingClassId);
params.insert("name", "Discoverd mock device"); params.insert("name", "Discoverd mock");
params.insert("thingDescriptorId", descriptorId); params.insert("thingDescriptorId", descriptorId);
response = injectAndWait("Integrations.AddThing", params); response = injectAndWait("Integrations.AddThing", params);
ThingId thingId(response.toMap().value("params").toMap().value("thingId").toString()); ThingId thingId(response.toMap().value("params").toMap().value("thingId").toString());
QVERIFY(!thingId.isNull()); QVERIFY(!thingId.isNull());
// and now rediscover and find the existing device in the discovery results // and now rediscover and find the existing thing in the discovery results
qCDebug(dcTests()) << "Re-Discovering..."; qCDebug(dcTests()) << "Re-Discovering...";
params.clear(); params.clear();
@ -1419,7 +1419,7 @@ void TestIntegrations::reconfigureByDiscovery()
thingDescriptors = response.toMap().value("params").toMap().value("thingDescriptors").toList(); thingDescriptors = response.toMap().value("params").toMap().value("thingDescriptors").toList();
// find the already added device // find the already added thing
descriptorId = ThingDescriptorId(); // reset it first descriptorId = ThingDescriptorId(); // reset it first
foreach (const QVariant &descriptor, thingDescriptors) { foreach (const QVariant &descriptor, thingDescriptors) {
if (descriptor.toMap().value("thingId").toUuid().toString() == thingId.toString()) { if (descriptor.toMap().value("thingId").toUuid().toString() == thingId.toString()) {
@ -1445,24 +1445,24 @@ void TestIntegrations::reconfigureByDiscovery()
response.clear(); response.clear();
response = injectAndWait("Integrations.GetThings", QVariantMap()); response = injectAndWait("Integrations.GetThings", QVariantMap());
QVariantMap deviceMap; QVariantMap thingMap;
bool found = false; bool found = false;
foreach (const QVariant &thing, response.toMap().value("params").toMap().value("things").toList()) { foreach (const QVariant &thing, response.toMap().value("params").toMap().value("things").toList()) {
if (ThingId(thing.toMap().value("id").toString()) == thingId) { if (ThingId(thing.toMap().value("id").toString()) == thingId) {
qDebug() << "found added thing" << thing.toMap().value("params"); qDebug() << "found added thing" << thing.toMap().value("params");
found = true; found = true;
deviceMap = thing.toMap(); thingMap = thing.toMap();
break; break;
} }
} }
QVERIFY2(found, "Thing missing in config!"); QVERIFY2(found, "Thing missing in config!");
QCOMPARE(deviceMap.value("id").toUuid(), QUuid(thingId)); QCOMPARE(thingMap.value("id").toUuid(), QUuid(thingId));
if (deviceMap.contains("setupComplete")) if (thingMap.contains("setupComplete"))
QVERIFY2(deviceMap.value("setupComplete").toBool(), "Setup not completed after edit"); QVERIFY2(thingMap.value("setupComplete").toBool(), "Setup not completed after edit");
// Note: this shows that by discovery a not editable param (name) can be changed! // Note: this shows that by discovery a not editable param (name) can be changed!
foreach (QVariant param, deviceMap.value("params").toList()) { foreach (QVariant param, thingMap.value("params").toList()) {
if (param.toMap().value("paramTypeId") == mockThingHttpportParamTypeId) { if (param.toMap().value("paramTypeId") == mockThingHttpportParamTypeId) {
QCOMPARE(param.toMap().value("value").toInt(), 55556); QCOMPARE(param.toMap().value("value").toInt(), 55556);
} }
@ -1524,7 +1524,7 @@ void TestIntegrations::reconfigureByDiscoveryAndPair()
params.clear(); params.clear();
response.clear(); response.clear();
params.insert("thingClassId", displayPinMockThingClassId); params.insert("thingClassId", displayPinMockThingClassId);
params.insert("name", "Discoverd mock device"); params.insert("name", "Discoverd mock");
params.insert("thingDescriptorId", descriptorId); params.insert("thingDescriptorId", descriptorId);
response = injectAndWait("Integrations.PairThing", params); response = injectAndWait("Integrations.PairThing", params);
verifyThingError(response); verifyThingError(response);
@ -1545,7 +1545,7 @@ void TestIntegrations::reconfigureByDiscoveryAndPair()
qCDebug(dcTests()) << "Discovering again..."; qCDebug(dcTests()) << "Discovering again...";
// and now rediscover, and edit the first device with the second // and now rediscover, and edit the first thing with the second
params.clear(); params.clear();
response.clear(); response.clear();
params.insert("thingClassId", displayPinMockThingClassId); params.insert("thingClassId", displayPinMockThingClassId);
@ -1566,7 +1566,7 @@ void TestIntegrations::reconfigureByDiscoveryAndPair()
QVERIFY(!descriptorId.isNull()); QVERIFY(!descriptorId.isNull());
qDebug() << "Reconfiguring device by pairing again" << descriptorId; qDebug() << "Reconfiguring thing by pairing again" << descriptorId;
params.clear(); params.clear();
response.clear(); response.clear();
@ -1597,16 +1597,16 @@ void TestIntegrations::reconfigureAutoThing()
{ {
qCDebug(dcTests()) << "Reconfigure auto thing"; qCDebug(dcTests()) << "Reconfigure auto thing";
// Get the autodevice // Get the auto mock
QList<Thing*> things = NymeaCore::instance()->thingManager()->findConfiguredThings(autoMockThingClassId); QList<Thing*> things = NymeaCore::instance()->thingManager()->findConfiguredThings(autoMockThingClassId);
QVERIFY2(things.count() > 0, "There needs to be at least one auto-created Mock Device for this test"); QVERIFY2(things.count() > 0, "There needs to be at least one auto-created Mock for this test");
// Get current auto device infos // Get current auto mock infos
Thing *currentThing = things.first(); Thing *currentThing = things.first();
ThingId thingId = currentThing->id(); ThingId thingId = currentThing->id();
int currentPort = currentThing->paramValue(autoMockThingHttpportParamTypeId).toInt(); int currentPort = currentThing->paramValue(autoMockThingHttpportParamTypeId).toInt();
// Trigger reconfigure signal in mock device // Trigger reconfigure signal in mock
QNetworkAccessManager *nam = new QNetworkAccessManager(this); QNetworkAccessManager *nam = new QNetworkAccessManager(this);
QSignalSpy spy(nam, &QNetworkAccessManager::finished); QSignalSpy spy(nam, &QNetworkAccessManager::finished);
QNetworkReply *reply = nam->get(QNetworkRequest(QUrl(QString("http://localhost:%1/reconfigureautodevice").arg(currentPort)))); QNetworkReply *reply = nam->get(QNetworkRequest(QUrl(QString("http://localhost:%1/reconfigureautodevice").arg(currentPort))));
@ -1617,7 +1617,7 @@ void TestIntegrations::reconfigureAutoThing()
Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(thingId); Thing *thing = NymeaCore::instance()->thingManager()->findConfiguredThing(thingId);
QVERIFY(thing); QVERIFY(thing);
int newPort = thing->paramValue(autoMockThingHttpportParamTypeId).toInt(); int newPort = thing->paramValue(autoMockThingHttpportParamTypeId).toInt();
// Note: reconfigure autodevice increases the http port by 1 // Note: reconfigure auto mock increases the http port by 1
QCOMPARE(newPort, currentPort + 1); QCOMPARE(newPort, currentPort + 1);
} }
@ -1629,7 +1629,7 @@ void TestIntegrations::removeThing_data()
QTest::newRow("Existing thing") << ThingId(m_mockThingId) << Thing::ThingErrorNoError; QTest::newRow("Existing thing") << ThingId(m_mockThingId) << Thing::ThingErrorNoError;
QTest::newRow("Not existing thing") << ThingId::createThingId() << Thing::ThingErrorThingNotFound; QTest::newRow("Not existing thing") << ThingId::createThingId() << Thing::ThingErrorThingNotFound;
// QTest::newRow("Auto device") << m_mockDeviceAutoId << Thing::ThingErrorCreationMethodNotSupported; // QTest::newRow("Auto device") << m_mockThingAutoId << Thing::ThingErrorCreationMethodNotSupported;
} }
void TestIntegrations::removeThing() void TestIntegrations::removeThing()

View File

@ -207,11 +207,11 @@ void TestJSONRPC::testHandshakeLocale()
QVariantMap handShake = injectAndWait("JSONRPC.Hello").toMap(); QVariantMap handShake = injectAndWait("JSONRPC.Hello").toMap();
QCOMPARE(handShake.value("params").toMap().value("locale").toString(), QString("en_US")); QCOMPARE(handShake.value("params").toMap().value("locale").toString(), QString("en_US"));
QVariantMap supportedDevices = injectAndWait("Devices.GetSupportedDevices").toMap(); QVariantMap supportedDevices = injectAndWait("Integrations.GetThingClasses").toMap();
bool found = false; bool found = false;
foreach (const QVariant &dcMap, supportedDevices.value("params").toMap().value("deviceClasses").toList()) { foreach (const QVariant &dcMap, supportedDevices.value("params").toMap().value("thingClasses").toList()) {
if (dcMap.toMap().value("id").toUuid() == autoMockThingClassId) { if (dcMap.toMap().value("id").toUuid() == autoMockThingClassId) {
QCOMPARE(dcMap.toMap().value("displayName").toString(), QString("Mock Device (Auto created)")); QCOMPARE(dcMap.toMap().value("displayName").toString(), QString("Mocked Thing (Auto created)"));
found = true; found = true;
} }
} }
@ -223,11 +223,11 @@ void TestJSONRPC::testHandshakeLocale()
handShake = injectAndWait("JSONRPC.Hello", params).toMap(); handShake = injectAndWait("JSONRPC.Hello", params).toMap();
QCOMPARE(handShake.value("params").toMap().value("locale").toString(), QString("de_DE")); QCOMPARE(handShake.value("params").toMap().value("locale").toString(), QString("de_DE"));
supportedDevices = injectAndWait("Devices.GetSupportedDevices").toMap(); supportedDevices = injectAndWait("Integrations.GetThingClasses").toMap();
found = false; found = false;
foreach (const QVariant &dcMap, supportedDevices.value("params").toMap().value("deviceClasses").toList()) { foreach (const QVariant &dcMap, supportedDevices.value("params").toMap().value("thingClasses").toList()) {
if (dcMap.toMap().value("id").toUuid() == autoMockThingClassId) { if (dcMap.toMap().value("id").toUuid() == autoMockThingClassId) {
QCOMPARE(dcMap.toMap().value("displayName").toString(), QString("Mock Gerät (Automatisch erzeugt)")); QCOMPARE(dcMap.toMap().value("displayName").toString(), QString("Mock \"Thing\" (automatisch erstellt)"));
found = true; found = true;
} }
} }
@ -1011,9 +1011,9 @@ void TestJSONRPC::stateChangeEmitsNotifications()
// Now check that the state has indeed changed even though we didn't get a notification // Now check that the state has indeed changed even though we didn't get a notification
QVariantMap params; QVariantMap params;
params.insert("deviceId", m_mockThingId); params.insert("thingId", m_mockThingId);
params.insert("stateTypeId", stateTypeId); params.insert("stateTypeId", stateTypeId);
QVariant response = injectAndWait("Devices.GetStateValue", params); QVariant response = injectAndWait("Integrations.GetStateValue", params);
QCOMPARE(response.toMap().value("params").toMap().value("value").toInt(), newVal); QCOMPARE(response.toMap().value("params").toMap().value("value").toInt(), newVal);
} }
@ -1036,10 +1036,10 @@ void TestJSONRPC::pluginConfigChangeEmitsNotification()
pluginParams.append(param1); pluginParams.append(param1);
params.insert("configuration", pluginParams); params.insert("configuration", pluginParams);
response = injectAndWait("Devices.SetPluginConfiguration", params); response = injectAndWait("Integrations.SetPluginConfiguration", params);
QVariantList notificationData = checkNotifications(clientSpy, "Devices.PluginConfigurationChanged"); QVariantList notificationData = checkNotifications(clientSpy, "Integrations.PluginConfigurationChanged");
QCOMPARE(notificationData.first().toMap().value("notification").toString() == "Devices.PluginConfigurationChanged", true); QCOMPARE(notificationData.first().toMap().value("notification").toString() == "Integrations.PluginConfigurationChanged", true);
} }
void TestJSONRPC::testPushButtonAuth() void TestJSONRPC::testPushButtonAuth()

File diff suppressed because it is too large Load Diff

View File

@ -52,16 +52,16 @@ private slots:
void removeTag(); void removeTag();
private: private:
QVariantMap createDeviceTag(const QString &deviceId, const QString &appId, const QString &tagId, const QString &value); QVariantMap createThingTag(const QString &thingId, const QString &appId, const QString &tagId, const QString &value);
bool compareDeviceTag(const QVariantMap &tag, const QUuid &thingId, const QString &appId, const QString &tagId, const QString &value); bool compareThingTag(const QVariantMap &tag, const QUuid &thingId, const QString &appId, const QString &tagId, const QString &value);
QVariantMap createRuleTag(const QString &ruleId, const QString &appId, const QString &tagId, const QString &value); QVariantMap createRuleTag(const QString &ruleId, const QString &appId, const QString &tagId, const QString &value);
bool comapreRuleTag(const QVariantMap &tag, const QString &ruleId, const QString &appId, const QString &tagId, const QString &value); bool comapreRuleTag(const QVariantMap &tag, const QString &ruleId, const QString &appId, const QString &tagId, const QString &value);
}; };
QVariantMap TestTags::createDeviceTag(const QString &deviceId, const QString &appId, const QString &tagId, const QString &value) QVariantMap TestTags::createThingTag(const QString &thingId, const QString &appId, const QString &tagId, const QString &value)
{ {
QVariantMap tag; QVariantMap tag;
tag.insert("deviceId", deviceId); tag.insert("thingId", thingId);
tag.insert("appId", appId); tag.insert("appId", appId);
tag.insert("tagId", tagId); tag.insert("tagId", tagId);
tag.insert("value", value); tag.insert("value", value);
@ -78,7 +78,7 @@ QVariantMap TestTags::createRuleTag(const QString &ruleId, const QString &appId,
return tag; return tag;
} }
bool TestTags::compareDeviceTag(const QVariantMap &tag, const QUuid &thingId, const QString &appId, const QString &tagId, const QString &value) bool TestTags::compareThingTag(const QVariantMap &tag, const QUuid &thingId, const QString &appId, const QString &tagId, const QString &value)
{ {
return tag.value("thingId").toUuid() == thingId && return tag.value("thingId").toUuid() == thingId &&
tag.value("deviceId").toUuid() == thingId && // backwards compatibility to < 0.19 adds deviceId along with thingId tag.value("deviceId").toUuid() == thingId && // backwards compatibility to < 0.19 adds deviceId along with thingId
@ -88,19 +88,19 @@ bool TestTags::compareDeviceTag(const QVariantMap &tag, const QUuid &thingId, co
} }
void TestTags::addTag_data() void TestTags::addTag_data()
{ {
QTest::addColumn<ThingId>("deviceId"); QTest::addColumn<ThingId>("thingId");
QTest::addColumn<QString>("appId"); QTest::addColumn<QString>("appId");
QTest::addColumn<QString>("tagId"); QTest::addColumn<QString>("tagId");
QTest::addColumn<QString>("value"); QTest::addColumn<QString>("value");
QTest::addColumn<TagsStorage::TagError>("expectedError"); QTest::addColumn<TagsStorage::TagError>("expectedError");
QTest::newRow("tagDevice") << m_mockThingId << "testtags" << "favorites" << "1" << TagsStorage::TagErrorNoError; QTest::newRow("tagThing") << m_mockThingId << "testtags" << "favorites" << "1" << TagsStorage::TagErrorNoError;
QTest::newRow("invalidDevice") << ThingId::createThingId() << "testtags" << "favorites" << "1" << TagsStorage::TagErrorDeviceNotFound; QTest::newRow("invalidThing") << ThingId::createThingId() << "testtags" << "favorites" << "1" << TagsStorage::TagErrorThingNotFound;
} }
void TestTags::addTag() void TestTags::addTag()
{ {
QFETCH(ThingId, deviceId); QFETCH(ThingId, thingId);
QFETCH(QString, appId); QFETCH(QString, appId);
QFETCH(QString, tagId); QFETCH(QString, tagId);
QFETCH(QString, value); QFETCH(QString, value);
@ -113,7 +113,7 @@ void TestTags::addTag()
// Create a tag; // Create a tag;
QVariantMap params; QVariantMap params;
params.insert("tag", createDeviceTag(deviceId.toString(), appId, tagId, value)); params.insert("tag", createThingTag(thingId.toString(), appId, tagId, value));
QVariant response = injectAndWait("Tags.AddTag", params); QVariant response = injectAndWait("Tags.AddTag", params);
verifyTagError(response, expectedError); verifyTagError(response, expectedError);
@ -125,17 +125,17 @@ void TestTags::addTag()
// Make sure the TagAdded notification is emitted. // Make sure the TagAdded notification is emitted.
QVariantMap notificationTagMap = checkNotification(clientSpy, "Tags.TagAdded").toMap().value("params").toMap().value("tag").toMap(); QVariantMap notificationTagMap = checkNotification(clientSpy, "Tags.TagAdded").toMap().value("params").toMap().value("tag").toMap();
QJsonDocument jsonDoc = QJsonDocument::fromVariant(notificationTagMap); QJsonDocument jsonDoc = QJsonDocument::fromVariant(notificationTagMap);
QVERIFY2(compareDeviceTag(notificationTagMap, deviceId, appId, tagId, value), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1()); QVERIFY2(compareThingTag(notificationTagMap, thingId, appId, tagId, value), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1());
// Try getting the tag via GetTag // Try getting the tag via GetTag
params.clear(); params.clear();
params.insert("deviceId", deviceId.toString()); params.insert("thingId", thingId.toString());
params.insert("appId", appId); params.insert("appId", appId);
params.insert("tagId", tagId); params.insert("tagId", tagId);
response = injectAndWait("Tags.GetTags", params); response = injectAndWait("Tags.GetTags", params);
QVariantList tagsList = response.toMap().value("params").toMap().value("tags").toList(); QVariantList tagsList = response.toMap().value("params").toMap().value("tags").toList();
QCOMPARE(tagsList.count(), 1); QCOMPARE(tagsList.count(), 1);
QVERIFY2(compareDeviceTag(tagsList.first().toMap(), deviceId, appId, tagId, value), "Fetched tag isn't matching the one we added"); QVERIFY2(compareThingTag(tagsList.first().toMap(), thingId, appId, tagId, value), "Fetched tag isn't matching the one we added");
} }
void TestTags::updateTagValue() void TestTags::updateTagValue()
@ -145,52 +145,52 @@ void TestTags::updateTagValue()
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
QString deviceId = m_mockThingId.toString(); QString thingId = m_mockThingId.toString();
QString appId = "testtags"; QString appId = "testtags";
QString tagId = "changedNotificationTag"; QString tagId = "changedNotificationTag";
// Create a Tag // Create a Tag
QVariantMap params; QVariantMap params;
params.insert("tag", createDeviceTag(deviceId, appId, tagId, "1")); params.insert("tag", createThingTag(thingId, appId, tagId, "1"));
QVariant response = injectAndWait("Tags.AddTag", params); QVariant response = injectAndWait("Tags.AddTag", params);
verifyTagError(response, TagsStorage::TagErrorNoError); verifyTagError(response, TagsStorage::TagErrorNoError);
// Check for TagAdded notification // Check for TagAdded notification
QVariantMap notificationTagMap = checkNotification(clientSpy, "Tags.TagAdded").toMap().value("params").toMap().value("tag").toMap(); QVariantMap notificationTagMap = checkNotification(clientSpy, "Tags.TagAdded").toMap().value("params").toMap().value("tag").toMap();
QJsonDocument jsonDoc = QJsonDocument::fromVariant(notificationTagMap); QJsonDocument jsonDoc = QJsonDocument::fromVariant(notificationTagMap);
QVERIFY2(compareDeviceTag(notificationTagMap, deviceId, appId, tagId, "1"), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1()); QVERIFY2(compareThingTag(notificationTagMap, thingId, appId, tagId, "1"), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1());
clientSpy.clear(); clientSpy.clear();
// Try getting the changed tag via GetTag // Try getting the changed tag via GetTag
params.clear(); params.clear();
params.insert("deviceId", deviceId); params.insert("thingId", thingId);
params.insert("appId", appId); params.insert("appId", appId);
params.insert("tagId", tagId); params.insert("tagId", tagId);
response = injectAndWait("Tags.GetTags", params); response = injectAndWait("Tags.GetTags", params);
QVariantList tagsList = response.toMap().value("params").toMap().value("tags").toList(); QVariantList tagsList = response.toMap().value("params").toMap().value("tags").toList();
QCOMPARE(tagsList.count(), 1); QCOMPARE(tagsList.count(), 1);
QVERIFY2(compareDeviceTag(tagsList.first().toMap(), deviceId, appId, tagId, "1"), "Fetched tag isn't matching the one we added"); QVERIFY2(compareThingTag(tagsList.first().toMap(), thingId, appId, tagId, "1"), "Fetched tag isn't matching the one we added");
// Now update the tag // Now update the tag
params.clear(); params.clear();
params.insert("tag", createDeviceTag(deviceId, appId, tagId, "2")); params.insert("tag", createThingTag(thingId, appId, tagId, "2"));
response = injectAndWait("Tags.AddTag", params); response = injectAndWait("Tags.AddTag", params);
verifyTagError(response, TagsStorage::TagErrorNoError); verifyTagError(response, TagsStorage::TagErrorNoError);
// Check for TagAdded notification // Check for TagAdded notification
notificationTagMap = checkNotification(clientSpy, "Tags.TagValueChanged").toMap().value("params").toMap().value("tag").toMap(); notificationTagMap = checkNotification(clientSpy, "Tags.TagValueChanged").toMap().value("params").toMap().value("tag").toMap();
jsonDoc = QJsonDocument::fromVariant(notificationTagMap); jsonDoc = QJsonDocument::fromVariant(notificationTagMap);
QVERIFY2(compareDeviceTag(notificationTagMap, deviceId, appId, tagId, "2"), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1()); QVERIFY2(compareThingTag(notificationTagMap, thingId, appId, tagId, "2"), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1());
// Try getting the changed tag via GetTag // Try getting the changed tag via GetTag
params.clear(); params.clear();
params.insert("deviceId", deviceId); params.insert("thingId", thingId);
params.insert("appId", appId); params.insert("appId", appId);
params.insert("tagId", tagId); params.insert("tagId", tagId);
response = injectAndWait("Tags.GetTags", params); response = injectAndWait("Tags.GetTags", params);
tagsList = response.toMap().value("params").toMap().value("tags").toList(); tagsList = response.toMap().value("params").toMap().value("tags").toList();
QCOMPARE(tagsList.count(), 1); QCOMPARE(tagsList.count(), 1);
QVERIFY2(compareDeviceTag(tagsList.first().toMap(), deviceId, appId, tagId, "2"), "Fetched tag isn't matching the one we added"); QVERIFY2(compareThingTag(tagsList.first().toMap(), thingId, appId, tagId, "2"), "Fetched tag isn't matching the one we added");
} }
void TestTags::removeTag() void TestTags::removeTag()
@ -200,47 +200,47 @@ void TestTags::removeTag()
// Setup connection to mock client // Setup connection to mock client
QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); QSignalSpy clientSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray)));
QString deviceId = m_mockThingId.toString(); QString thingId = m_mockThingId.toString();
QString appId = "testtags"; QString appId = "testtags";
QString tagId = "removeTagTest"; QString tagId = "removeTagTest";
QString value = "1"; QString value = "1";
// Create a Tag // Create a Tag
QVariantMap params; QVariantMap params;
params.insert("tag", createDeviceTag(deviceId, appId, tagId, value)); params.insert("tag", createThingTag(thingId, appId, tagId, value));
QVariant response = injectAndWait("Tags.AddTag", params); QVariant response = injectAndWait("Tags.AddTag", params);
verifyTagError(response, TagsStorage::TagErrorNoError); verifyTagError(response, TagsStorage::TagErrorNoError);
// Check for TagAdded notification // Check for TagAdded notification
QVariantMap notificationTagMap = checkNotification(clientSpy, "Tags.TagAdded").toMap().value("params").toMap().value("tag").toMap(); QVariantMap notificationTagMap = checkNotification(clientSpy, "Tags.TagAdded").toMap().value("params").toMap().value("tag").toMap();
QJsonDocument jsonDoc = QJsonDocument::fromVariant(notificationTagMap); QJsonDocument jsonDoc = QJsonDocument::fromVariant(notificationTagMap);
QVERIFY2(compareDeviceTag(notificationTagMap, deviceId, appId, tagId, value), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1()); QVERIFY2(compareThingTag(notificationTagMap, thingId, appId, tagId, value), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1());
clientSpy.clear(); clientSpy.clear();
// Try getting the tag via GetTag // Try getting the tag via GetTag
params.clear(); params.clear();
params.insert("deviceId", deviceId); params.insert("thingId", thingId);
params.insert("appId", appId); params.insert("appId", appId);
params.insert("tagId", tagId); params.insert("tagId", tagId);
response = injectAndWait("Tags.GetTags", params); response = injectAndWait("Tags.GetTags", params);
QVariantList tagsList = response.toMap().value("params").toMap().value("tags").toList(); QVariantList tagsList = response.toMap().value("params").toMap().value("tags").toList();
QCOMPARE(tagsList.count(), 1); QCOMPARE(tagsList.count(), 1);
QVERIFY2(compareDeviceTag(tagsList.first().toMap(), deviceId, appId, tagId, value), "Fetched tag isn't matching the one we added"); QVERIFY2(compareThingTag(tagsList.first().toMap(), thingId, appId, tagId, value), "Fetched tag isn't matching the one we added");
// Now remove the tag // Now remove the tag
params.clear(); params.clear();
params.insert("tag", createDeviceTag(deviceId, appId, tagId, QString())); params.insert("tag", createThingTag(thingId, appId, tagId, QString()));
response = injectAndWait("Tags.RemoveTag", params); response = injectAndWait("Tags.RemoveTag", params);
verifyTagError(response, TagsStorage::TagErrorNoError); verifyTagError(response, TagsStorage::TagErrorNoError);
// Check for TagRemoved notification // Check for TagRemoved notification
notificationTagMap = checkNotification(clientSpy, "Tags.TagRemoved").toMap().value("params").toMap().value("tag").toMap(); notificationTagMap = checkNotification(clientSpy, "Tags.TagRemoved").toMap().value("params").toMap().value("tag").toMap();
jsonDoc = QJsonDocument::fromVariant(notificationTagMap); jsonDoc = QJsonDocument::fromVariant(notificationTagMap);
QVERIFY2(compareDeviceTag(notificationTagMap, deviceId, appId, tagId, QString()), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1()); QVERIFY2(compareThingTag(notificationTagMap, thingId, appId, tagId, QString()), QString("Tag in notification not matching: %1").arg(qUtf8Printable(jsonDoc.toJson())).toLatin1());
// Try getting the tag via GetTag // Try getting the tag via GetTag
params.clear(); params.clear();
params.insert("deviceId", deviceId); params.insert("thingId", thingId);
params.insert("appId", appId); params.insert("appId", appId);
params.insert("tagId", tagId); params.insert("tagId", tagId);
response = injectAndWait("Tags.GetTags", params); response = injectAndWait("Tags.GetTags", params);

View File

@ -146,7 +146,7 @@ void TestTimeManager::initTestCase()
"Tests.debug=true\n" "Tests.debug=true\n"
"RuleEngine.debug=true\n" "RuleEngine.debug=true\n"
// "RuleEngineDebug.debug=true\n" // "RuleEngineDebug.debug=true\n"
"MockDevice.debug=true\n" "Mock.debug=true\n"
"JsonRpc.debug=true\n" "JsonRpc.debug=true\n"
"TimeManager.debug=true"); "TimeManager.debug=true");
} }
@ -190,7 +190,7 @@ void TestTimeManager::loadSaveTimeDescriptor()
// Action (without params) // Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap ruleMap; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Create the rule map // Create the rule map
@ -351,7 +351,7 @@ void TestTimeManager::addTimeDescriptor()
// ADD the rule // ADD the rule
QVariantMap ruleMap; QVariantMap action; QVariantMap ruleMap; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
ruleMap.insert("name", "TimeBased rule"); ruleMap.insert("name", "TimeBased rule");
ruleMap.insert("timeDescriptor", timeDescriptor); ruleMap.insert("timeDescriptor", timeDescriptor);
@ -389,7 +389,7 @@ void TestTimeManager::addTimeDescriptorInvalidTimes()
// ADD the rule // ADD the rule
QVariantMap ruleMap; QVariantMap action; QVariantMap ruleMap; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
ruleMap.insert("name", "TimeBased rule"); ruleMap.insert("name", "TimeBased rule");
ruleMap.insert("timeDescriptor", timeDescriptor); ruleMap.insert("timeDescriptor", timeDescriptor);
@ -419,7 +419,7 @@ void TestTimeManager::testCalendarDateTime()
// Action (without params) // Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction; QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Exit action (with params) // Exit action (with params)
@ -433,7 +433,7 @@ void TestTimeManager::testCalendarDateTime()
param2.insert("value", true); param2.insert("value", true);
actionParams.append(param2); actionParams.append(param2);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId); exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockThingId); exitAction.insert("thingId", m_mockThingId);
exitAction.insert("ruleActionParams", actionParams); exitAction.insert("ruleActionParams", actionParams);
// CalendarItem // CalendarItem
@ -495,7 +495,7 @@ void TestTimeManager::testCalendarItemHourly()
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction; QVariantMap repeatingOptionHourly; QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction; QVariantMap repeatingOptionHourly;
repeatingOptionHourly.insert("mode", "RepeatingModeHourly"); repeatingOptionHourly.insert("mode", "RepeatingModeHourly");
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
exitAction.insert("actionTypeId", mockWithParamsActionTypeId); exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
QVariantList actionParams; QVariantList actionParams;
@ -507,7 +507,7 @@ void TestTimeManager::testCalendarItemHourly()
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId); param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true); param2.insert("value", true);
actionParams.append(param2); actionParams.append(param2);
exitAction.insert("deviceId", m_mockThingId); exitAction.insert("thingId", m_mockThingId);
exitAction.insert("ruleActionParams", actionParams); exitAction.insert("ruleActionParams", actionParams);
ruleMap.insert("name", "Time based hourly calendar rule"); ruleMap.insert("name", "Time based hourly calendar rule");
ruleMap.insert("timeDescriptor", createTimeDescriptorCalendar(createCalendarItem("08:05", duration, repeatingOptionHourly))); ruleMap.insert("timeDescriptor", createTimeDescriptorCalendar(createCalendarItem("08:05", duration, repeatingOptionHourly)));
@ -588,7 +588,7 @@ void TestTimeManager::testCalendarItemDaily()
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction; QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
exitAction.insert("actionTypeId", mockWithParamsActionTypeId); exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
QVariantList actionParams; QVariantList actionParams;
@ -600,7 +600,7 @@ void TestTimeManager::testCalendarItemDaily()
param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId); param2.insert("paramTypeId", mockWithParamsActionParam2ParamTypeId);
param2.insert("value", true); param2.insert("value", true);
actionParams.append(param2); actionParams.append(param2);
exitAction.insert("deviceId", m_mockThingId); exitAction.insert("thingId", m_mockThingId);
exitAction.insert("ruleActionParams", actionParams); exitAction.insert("ruleActionParams", actionParams);
ruleMap.insert("name", "Time based hourly calendar rule"); ruleMap.insert("name", "Time based hourly calendar rule");
ruleMap.insert("timeDescriptor", timeDescriptor); ruleMap.insert("timeDescriptor", timeDescriptor);
@ -687,7 +687,7 @@ void TestTimeManager::testCalendarItemWeekly()
// Action (without params) // Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction; QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Exit action (with params) // Exit action (with params)
@ -701,7 +701,7 @@ void TestTimeManager::testCalendarItemWeekly()
param2.insert("value", true); param2.insert("value", true);
actionParams.append(param2); actionParams.append(param2);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId); exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockThingId); exitAction.insert("thingId", m_mockThingId);
exitAction.insert("ruleActionParams", actionParams); exitAction.insert("ruleActionParams", actionParams);
// Create the rule map // Create the rule map
@ -842,7 +842,7 @@ void TestTimeManager::testCalendarItemMonthly()
// Action (without params) // Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction; QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Exit action (with params) // Exit action (with params)
@ -856,7 +856,7 @@ void TestTimeManager::testCalendarItemMonthly()
param2.insert("value", true); param2.insert("value", true);
actionParams.append(param2); actionParams.append(param2);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId); exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockThingId); exitAction.insert("thingId", m_mockThingId);
exitAction.insert("ruleActionParams", actionParams); exitAction.insert("ruleActionParams", actionParams);
// Create the rule map // Create the rule map
@ -970,7 +970,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
// Action (without params) // Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction; QVariantMap ruleMap; QVariantMap action; QVariantMap exitAction;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Exit action (with params) // Exit action (with params)
@ -984,7 +984,7 @@ void TestTimeManager::testCalendarYearlyDateTime()
param2.insert("value", true); param2.insert("value", true);
actionParams.append(param2); actionParams.append(param2);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId); exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockThingId); exitAction.insert("thingId", m_mockThingId);
exitAction.insert("ruleActionParams", actionParams); exitAction.insert("ruleActionParams", actionParams);
// RepeatingOption // RepeatingOption
@ -1073,7 +1073,7 @@ void TestTimeManager::testCalendarItemStates_data()
// Action // Action
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Exit action (with params) // Exit action (with params)
@ -1088,18 +1088,18 @@ void TestTimeManager::testCalendarItemStates_data()
param2.insert("value", true); param2.insert("value", true);
actionParams.append(param2); actionParams.append(param2);
exitAction.insert("actionTypeId", mockWithParamsActionTypeId); exitAction.insert("actionTypeId", mockWithParamsActionTypeId);
exitAction.insert("deviceId", m_mockThingId); exitAction.insert("thingId", m_mockThingId);
exitAction.insert("ruleActionParams", actionParams); exitAction.insert("ruleActionParams", actionParams);
// Stateevaluators // Stateevaluators
QVariantMap stateEvaluator; QVariantMap stateEvaluator;
QVariantMap stateDescriptorInt; QVariantMap stateDescriptorInt;
stateDescriptorInt.insert("deviceId", m_mockThingId); stateDescriptorInt.insert("thingId", m_mockThingId);
stateDescriptorInt.insert("operator", enumValueName(Types::ValueOperatorGreaterOrEqual)); stateDescriptorInt.insert("operator", enumValueName(Types::ValueOperatorGreaterOrEqual));
stateDescriptorInt.insert("stateTypeId", mockIntStateTypeId); stateDescriptorInt.insert("stateTypeId", mockIntStateTypeId);
stateDescriptorInt.insert("value", 65); stateDescriptorInt.insert("value", 65);
QVariantMap stateDescriptorBool; QVariantMap stateDescriptorBool;
stateDescriptorBool.insert("deviceId", m_mockThingId); stateDescriptorBool.insert("thingId", m_mockThingId);
stateDescriptorBool.insert("operator", enumValueName(Types::ValueOperatorEquals)); stateDescriptorBool.insert("operator", enumValueName(Types::ValueOperatorEquals));
stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId); stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId);
stateDescriptorBool.insert("value", true); stateDescriptorBool.insert("value", true);
@ -1188,12 +1188,12 @@ void TestTimeManager::testCalendarItemEvent_data()
// Action (without params) // Action (without params)
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
QVariantMap eventDescriptor; QVariantMap eventDescriptor;
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId); eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
eventDescriptor.insert("deviceId", m_mockThingId); eventDescriptor.insert("thingId", m_mockThingId);
// The rule // The rule
QVariantMap ruleMap; QVariantMap ruleMap;
@ -1252,17 +1252,17 @@ void TestTimeManager::testCalendarItemStatesEvent_data()
// Action (without params) // Action (without params)
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Event descriptor // Event descriptor
QVariantMap eventDescriptor; QVariantMap eventDescriptor;
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId); eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
eventDescriptor.insert("deviceId", m_mockThingId); eventDescriptor.insert("thingId", m_mockThingId);
// State evaluator // State evaluator
QVariantMap stateDescriptorBool; QVariantMap stateDescriptorBool;
stateDescriptorBool.insert("deviceId", m_mockThingId); stateDescriptorBool.insert("thingId", m_mockThingId);
stateDescriptorBool.insert("operator", enumValueName(Types::ValueOperatorEquals)); stateDescriptorBool.insert("operator", enumValueName(Types::ValueOperatorEquals));
stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId); stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId);
stateDescriptorBool.insert("value", true); stateDescriptorBool.insert("value", true);
@ -1326,7 +1326,7 @@ void TestTimeManager::testCalendarItemCrossesMidnight()
// Action // Action
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
QVariantMap repeatingOptionDaily; QVariantMap repeatingOptionDaily;
@ -1394,12 +1394,12 @@ void TestTimeManager::testEventBasedWithCalendarItemCrossingMidnight()
// Event descriptor // Event descriptor
QVariantMap eventDescriptor; QVariantMap eventDescriptor;
eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId); eventDescriptor.insert("eventTypeId", mockEvent1EventTypeId);
eventDescriptor.insert("deviceId", m_mockThingId); eventDescriptor.insert("thingId", m_mockThingId);
// Action // Action
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
QVariantMap repeatingOptionDaily; QVariantMap repeatingOptionDaily;
@ -1466,7 +1466,7 @@ void TestTimeManager::testEventItemDateTime()
// Action (without params) // Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap ruleMap; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Create the rule map // Create the rule map
@ -1523,7 +1523,7 @@ void TestTimeManager::testEventItemHourly()
// Action // Action
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
QVariantMap ruleMap; QVariantMap ruleMap;
@ -1592,7 +1592,7 @@ void TestTimeManager::testEventItemDaily()
// Action // Action
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
QVariantMap ruleMap; QVariantMap ruleMap;
@ -1665,7 +1665,7 @@ void TestTimeManager::testEventItemWeekly()
// Action // Action
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
QVariantMap ruleMap; QVariantMap ruleMap;
@ -1747,7 +1747,7 @@ void TestTimeManager::testEventItemMonthly()
// Action // Action
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
QVariantMap ruleMap; QVariantMap ruleMap;
@ -1826,7 +1826,7 @@ void TestTimeManager::testEventItemYearly()
// Action (without params) // Action (without params)
QVariantMap ruleMap; QVariantMap action; QVariantMap ruleMap; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Create the rule map // Create the rule map
@ -1885,7 +1885,7 @@ void TestTimeManager::testEventItemStates_data()
// Action (without params) // Action (without params)
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
// Time descriptor // Time descriptor
@ -1896,7 +1896,7 @@ void TestTimeManager::testEventItemStates_data()
// State evaluator // State evaluator
QVariantMap stateDescriptorBool; QVariantMap stateDescriptorBool;
stateDescriptorBool.insert("deviceId", m_mockThingId); stateDescriptorBool.insert("thingId", m_mockThingId);
stateDescriptorBool.insert("operator", enumValueName(Types::ValueOperatorEquals)); stateDescriptorBool.insert("operator", enumValueName(Types::ValueOperatorEquals));
stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId); stateDescriptorBool.insert("stateTypeId", mockBoolStateTypeId);
stateDescriptorBool.insert("value", true); stateDescriptorBool.insert("value", true);
@ -1968,7 +1968,7 @@ void TestTimeManager::testEnableDisableTimeRule()
// Action // Action
QVariantMap action; QVariantMap action;
action.insert("actionTypeId", mockWithoutParamsActionTypeId); action.insert("actionTypeId", mockWithoutParamsActionTypeId);
action.insert("deviceId", m_mockThingId); action.insert("thingId", m_mockThingId);
action.insert("ruleActionParams", QVariantList()); action.insert("ruleActionParams", QVariantList());
QVariantMap ruleMap; QVariantMap ruleMap;
@ -2028,7 +2028,7 @@ void TestTimeManager::initTimeManager()
{ {
cleanupMockHistory(); cleanupMockHistory();
removeAllRules(); removeAllRules();
enableNotifications({"Rules", "Devices", "Events"}); enableNotifications({"Rules", "Integrations", "Events"});
NymeaCore::instance()->timeManager()->stopTimer(); NymeaCore::instance()->timeManager()->stopTimer();
qDebug() << NymeaCore::instance()->timeManager()->currentDateTime().toString(); qDebug() << NymeaCore::instance()->timeManager()->currentDateTime().toString();
} }
@ -2090,10 +2090,10 @@ void TestTimeManager::setIntState(const int &value)
qDebug() << "Setting mock int state to" << value; qDebug() << "Setting mock int state to" << value;
QVariantMap params; QVariantMap params;
params.insert("deviceId", m_mockThingId); params.insert("thingId", m_mockThingId);
params.insert("stateTypeId", mockIntStateTypeId); params.insert("stateTypeId", mockIntStateTypeId);
QVariant response = injectAndWait("Devices.GetStateValue", params); QVariant response = injectAndWait("Integrations.GetStateValue", params);
verifyError(response, "deviceError", "DeviceErrorNoError"); verifyError(response, "thingError", "ThingErrorNoError");
int currentStateValue = response.toMap().value("params").toMap().value("value").toInt(); int currentStateValue = response.toMap().value("params").toMap().value("value").toInt();
bool shouldGetNotification = currentStateValue != value; bool shouldGetNotification = currentStateValue != value;
@ -2112,16 +2112,16 @@ void TestTimeManager::setIntState(const int &value)
if (shouldGetNotification) { if (shouldGetNotification) {
stateSpy.wait(100); stateSpy.wait(100);
// Wait for state changed notification // Wait for state changed notification
QVariantList stateChangedVariants = checkNotifications(stateSpy, "Devices.StateChanged"); QVariantList stateChangedVariants = checkNotifications(stateSpy, "Integrations.StateChanged");
QVERIFY2(stateChangedVariants.count() == 1, "Did not get Devices.StateChanged notification."); QVERIFY2(stateChangedVariants.count() == 1, "Did not get Integrations.StateChanged notification.");
QVariantMap notification = stateChangedVariants.first().toMap().value("params").toMap(); QVariantMap notification = stateChangedVariants.first().toMap().value("params").toMap();
QVERIFY2(notification.contains("deviceId"), "Devices.StateChanged notification does not contain deviceId"); QVERIFY2(notification.contains("thingId"), "Integrations.StateChanged notification does not contain thingId");
QVERIFY2(ThingId(notification.value("deviceId").toString()) == m_mockThingId, "Devices.StateChanged notification does not contain the correct deviceId"); QVERIFY2(ThingId(notification.value("thingId").toString()) == m_mockThingId, "Integrations.StateChanged notification does not contain the correct thingId");
QVERIFY2(notification.contains("stateTypeId"), "Devices.StateChanged notification does not contain stateTypeId"); QVERIFY2(notification.contains("stateTypeId"), "Integrations.StateChanged notification does not contain stateTypeId");
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockIntStateTypeId, "Devices.StateChanged notification does not contain the correct stateTypeId"); QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockIntStateTypeId, "Integrations.StateChanged notification does not contain the correct stateTypeId");
QVERIFY2(notification.contains("value"), "Devices.StateChanged notification does not contain new state value"); QVERIFY2(notification.contains("value"), "Integrations.StateChanged notification does not contain new state value");
QVERIFY2(notification.value("value").toInt() == value, "Devices.StateChanged notification does not contain the new value"); QVERIFY2(notification.value("value").toInt() == value, "Integrations.StateChanged notification does not contain the new value");
} }
} }
@ -2131,10 +2131,10 @@ void TestTimeManager::setBoolState(const bool &value)
// Get the current state value to check if we have to wait for state changed notfication // Get the current state value to check if we have to wait for state changed notfication
QVariantMap params; QVariantMap params;
params.insert("deviceId", m_mockThingId); params.insert("thingId", m_mockThingId);
params.insert("stateTypeId", mockBoolStateTypeId); params.insert("stateTypeId", mockBoolStateTypeId);
QVariant response = injectAndWait("Devices.GetStateValue", params); QVariant response = injectAndWait("Integrations.GetStateValue", params);
verifyError(response, "deviceError", "DeviceErrorNoError"); verifyError(response, "thingError", "ThingErrorNoError");
bool currentStateValue = response.toMap().value("params").toMap().value("value").toBool(); bool currentStateValue = response.toMap().value("params").toMap().value("value").toBool();
bool shouldGetNotification = currentStateValue != value; bool shouldGetNotification = currentStateValue != value;
@ -2152,16 +2152,16 @@ void TestTimeManager::setBoolState(const bool &value)
if (shouldGetNotification) { if (shouldGetNotification) {
stateSpy.wait(100); stateSpy.wait(100);
// Wait for state changed notification // Wait for state changed notification
QVariantList stateChangedSignals = checkNotifications(stateSpy, "Devices.StateChanged"); QVariantList stateChangedSignals = checkNotifications(stateSpy, "Integrations.StateChanged");
QCOMPARE(stateChangedSignals.count(), 1); QCOMPARE(stateChangedSignals.count(), 1);
QVariantMap notification = stateChangedSignals.first().toMap().value("params").toMap(); QVariantMap notification = stateChangedSignals.first().toMap().value("params").toMap();
QVERIFY2(notification.contains("deviceId"), "Devices.StateChanged notification does not contain deviceId"); QVERIFY2(notification.contains("thingId"), "Integrations.StateChanged notification does not contain thingId");
QVERIFY2(ThingId(notification.value("deviceId").toString()) == m_mockThingId, "Devices.StateChanged notification does not contain the correct deviceId"); QVERIFY2(ThingId(notification.value("thingId").toString()) == m_mockThingId, "Integrations.StateChanged notification does not contain the correct thingId");
QVERIFY2(notification.contains("stateTypeId"), "Devices.StateChanged notification does not contain stateTypeId"); QVERIFY2(notification.contains("stateTypeId"), "Integrations.StateChanged notification does not contain stateTypeId");
QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockBoolStateTypeId, "Devices.StateChanged notification does not contain the correct stateTypeId"); QVERIFY2(StateTypeId(notification.value("stateTypeId").toString()) == mockBoolStateTypeId, "Integrations.StateChanged notification does not contain the correct stateTypeId");
QVERIFY2(notification.contains("value"), "Devices.StateChanged notification does not contain new state value"); QVERIFY2(notification.contains("value"), "Integrations.StateChanged notification does not contain new state value");
QVERIFY2(notification.value("value").toBool() == value, "Devices.StateChanged notification does not contain the new value"); QVERIFY2(notification.value("value").toBool() == value, "Integrations.StateChanged notification does not contain the new value");
} }
} }
@ -2188,8 +2188,8 @@ void TestTimeManager::triggerMockEvent1()
QVERIFY2(eventTriggerVariants.first().toMap().value("params").toMap().contains("event"), "Notification Events.EventTriggered does not contain event."); QVERIFY2(eventTriggerVariants.first().toMap().value("params").toMap().contains("event"), "Notification Events.EventTriggered does not contain event.");
QVariantMap eventMap = eventTriggerVariants.first().toMap().value("params").toMap().value("event").toMap(); QVariantMap eventMap = eventTriggerVariants.first().toMap().value("params").toMap().value("event").toMap();
QVERIFY2(eventMap.contains("deviceId"), "Events.EventTriggered notification does not contain deviceId"); QVERIFY2(eventMap.contains("thingId"), "Events.EventTriggered notification does not contain thingId");
QVERIFY2(ThingId(eventMap.value("deviceId").toString()) == m_mockThingId, "Events.EventTriggered notification does not contain the correct deviceId"); QVERIFY2(ThingId(eventMap.value("thingId").toString()) == m_mockThingId, "Events.EventTriggered notification does not contain the correct thingId");
QVERIFY2(eventMap.contains("eventTypeId"), "Events.EventTriggered notification does not contain eventTypeId"); QVERIFY2(eventMap.contains("eventTypeId"), "Events.EventTriggered notification does not contain eventTypeId");
QVERIFY2(EventTypeId(eventMap.value("eventTypeId").toString()) == mockEvent1EventTypeId, "Events.EventTriggered notification does not contain the correct eventTypeId"); QVERIFY2(EventTypeId(eventMap.value("eventTypeId").toString()) == mockEvent1EventTypeId, "Events.EventTriggered notification does not contain the correct eventTypeId");
} }

View File

@ -527,18 +527,18 @@ void TestWebserver::getDebugServer_data()
QTest::newRow("DELETE /debug/settings/nymead | server disabled | 404") << "delete" << "/debug/settings/nymead" << false << 404; QTest::newRow("DELETE /debug/settings/nymead | server disabled | 404") << "delete" << "/debug/settings/nymead" << false << 404;
// settings/devices enabled // settings/devices enabled
QTest::newRow("GET /debug/settings/devices | server enabled | 200") << "get" << "/debug/settings/devices" << true << 200; QTest::newRow("GET /debug/settings/devices | server enabled | 200") << "get" << "/debug/settings/things" << true << 200;
QTest::newRow("OPTIONS /debug/settings/devices | server enabled | 200") << "options" << "/debug/settings/devices" << true << 200; QTest::newRow("OPTIONS /debug/settings/devices | server enabled | 200") << "options" << "/debug/settings/things" << true << 200;
QTest::newRow("PUT /debug/settings/devices | server enabled | 405") << "put" << "/debug/settings/devices" << true << 405; QTest::newRow("PUT /debug/settings/devices | server enabled | 405") << "put" << "/debug/settings/things" << true << 405;
QTest::newRow("POST /debug/settings/devices | server enabled | 405") << "post" << "/debug/settings/devices" << true << 405; QTest::newRow("POST /debug/settings/devices | server enabled | 405") << "post" << "/debug/settings/things" << true << 405;
QTest::newRow("DELETE /debug/settings/devices | server enabled | 405") << "delete" << "/debug/settings/devices" << true << 405; QTest::newRow("DELETE /debug/settings/devices | server enabled | 405") << "delete" << "/debug/settings/things" << true << 405;
// settings/devices disabled // settings/devices disabled
QTest::newRow("GET /debug/settings/devices | server disabled | 404") << "get" << "/debug/settings/devices" << false << 404; QTest::newRow("GET /debug/settings/devices | server disabled | 404") << "get" << "/debug/settings/things" << false << 404;
QTest::newRow("OPTIONS /debug/settings/devices | server disabled | 404") << "options" << "/debug/settings/devices" << false << 404; QTest::newRow("OPTIONS /debug/settings/devices | server disabled | 404") << "options" << "/debug/settings/things" << false << 404;
QTest::newRow("PUT /debug/settings/devices | server disabled | 404") << "put" << "/debug/settings/devices" << false << 404; QTest::newRow("PUT /debug/settings/devices | server disabled | 404") << "put" << "/debug/settings/things" << false << 404;
QTest::newRow("POST /debug/settings/devices | server disabled | 404") << "post" << "/debug/settings/devices" << false << 404; QTest::newRow("POST /debug/settings/devices | server disabled | 404") << "post" << "/debug/settings/things" << false << 404;
QTest::newRow("DELETE /debug/settings/devices | server disabled | 404") << "delete" << "/debug/settings/devices" << false << 404; QTest::newRow("DELETE /debug/settings/devices | server disabled | 404") << "delete" << "/debug/settings/things" << false << 404;
// settings/rules enabled // settings/rules enabled
QTest::newRow("GET /debug/settings/rules | server enabled | 200") << "get" << "/debug/settings/rules" << true << 200; QTest::newRow("GET /debug/settings/rules | server enabled | 200") << "get" << "/debug/settings/rules" << true << 200;
@ -555,18 +555,18 @@ void TestWebserver::getDebugServer_data()
QTest::newRow("DELETE /debug/settings/rules | server disabled | 404") << "delete" << "/debug/settings/rules" << false << 404; QTest::newRow("DELETE /debug/settings/rules | server disabled | 404") << "delete" << "/debug/settings/rules" << false << 404;
// settings/devicestates enabled // settings/devicestates enabled
QTest::newRow("GET /debug/settings/devicestates | server enabled | 200") << "get" << "/debug/settings/devicestates" << true << 200; QTest::newRow("GET /debug/settings/devicestates | server enabled | 200") << "get" << "/debug/settings/thingstates" << true << 200;
QTest::newRow("OPTIONS /debug/settings/devicestates | server enabled | 200") << "options" << "/debug/settings/devicestates" << true << 200; QTest::newRow("OPTIONS /debug/settings/devicestates | server enabled | 200") << "options" << "/debug/settings/thingstates" << true << 200;
QTest::newRow("PUT /debug/settings/devicestates | server enabled | 405") << "put" << "/debug/settings/devicestates" << true << 405; QTest::newRow("PUT /debug/settings/devicestates | server enabled | 405") << "put" << "/debug/settings/thingstates" << true << 405;
QTest::newRow("POST /debug/settings/devicestates | server enabled | 405") << "post" << "/debug/settings/devicestates" << true << 405; QTest::newRow("POST /debug/settings/devicestates | server enabled | 405") << "post" << "/debug/settings/thingstates" << true << 405;
QTest::newRow("DELETE /debug/settings/devicestates | server enabled | 405") << "delete" << "/debug/settings/devicestates" << true << 405; QTest::newRow("DELETE /debug/settings/devicestates | server enabled | 405") << "delete" << "/debug/settings/thingstates" << true << 405;
// settings/devicestates disabled // settings/devicestates disabled
QTest::newRow("GET /debug/settings/devicestates | server disabled | 404") << "get" << "/debug/settings/devicestates" << false << 404; QTest::newRow("GET /debug/settings/devicestates | server disabled | 404") << "get" << "/debug/settings/thingstates" << false << 404;
QTest::newRow("OPTIONS /debug/settings/devicestates | server disabled | 404") << "options" << "/debug/settings/devicestates" << false << 404; QTest::newRow("OPTIONS /debug/settings/devicestates | server disabled | 404") << "options" << "/debug/settings/thingstates" << false << 404;
QTest::newRow("PUT /debug/settings/devicestates | server disabled | 404") << "put" << "/debug/settings/devicestates" << false << 404; QTest::newRow("PUT /debug/settings/devicestates | server disabled | 404") << "put" << "/debug/settings/thingstates" << false << 404;
QTest::newRow("POST /debug/settings/devicestates | server disabled | 404") << "post" << "/debug/settings/devicestates" << false << 404; QTest::newRow("POST /debug/settings/devicestates | server disabled | 404") << "post" << "/debug/settings/thingstates" << false << 404;
QTest::newRow("DELETE /debug/settings/devicestates | server disabled | 404") << "delete" << "/debug/settings/devicestates" << false << 404; QTest::newRow("DELETE /debug/settings/devicestates | server disabled | 404") << "delete" << "/debug/settings/thingstates" << false << 404;
// settings/plugins enabled // settings/plugins enabled
QTest::newRow("GET /debug/settings/plugins | server enabled | 200") << "get" << "/debug/settings/plugins" << true << 200; QTest::newRow("GET /debug/settings/plugins | server enabled | 200") << "get" << "/debug/settings/plugins" << true << 200;

View File

@ -60,8 +60,8 @@ void NymeaTestBase::initTestCase()
// If testcase asserts cleanup won't do. Lets clear any previous test run settings leftovers // If testcase asserts cleanup won't do. Lets clear any previous test run settings leftovers
NymeaSettings rulesSettings(NymeaSettings::SettingsRoleRules); NymeaSettings rulesSettings(NymeaSettings::SettingsRoleRules);
rulesSettings.clear(); rulesSettings.clear();
NymeaSettings deviceSettings(NymeaSettings::SettingsRoleThings); NymeaSettings thingSettings(NymeaSettings::SettingsRoleThings);
deviceSettings.clear(); thingSettings.clear();
NymeaSettings pluginSettings(NymeaSettings::SettingsRolePlugins); NymeaSettings pluginSettings(NymeaSettings::SettingsRolePlugins);
pluginSettings.clear(); pluginSettings.clear();
NymeaSettings statesSettings(NymeaSettings::SettingsRoleThingStates); NymeaSettings statesSettings(NymeaSettings::SettingsRoleThingStates);
@ -71,7 +71,7 @@ void NymeaTestBase::initTestCase()
NymeaSettings nymeadSettings(NymeaSettings::SettingsRoleGlobal); NymeaSettings nymeadSettings(NymeaSettings::SettingsRoleGlobal);
nymeadSettings.clear(); nymeadSettings.clear();
QLoggingCategory::setFilterRules("*.debug=false\nApplication.debug=true\nTests.debug=true\nMockDevice.debug=true"); QLoggingCategory::setFilterRules("*.debug=false\nApplication.debug=true\nTests.debug=true\nMock.debug=true");
// Start the server // Start the server
qCDebug(dcTests()) << "Setting up nymea core instance"; qCDebug(dcTests()) << "Setting up nymea core instance";
@ -93,7 +93,7 @@ void NymeaTestBase::initTestCase()
exit(-1); exit(-1);
} }
// Add the mockdevice // Add the mock
m_mockTcpServer = MockTcpServer::servers().first(); m_mockTcpServer = MockTcpServer::servers().first();
m_clientId = QUuid::createUuid(); m_clientId = QUuid::createUuid();
m_mockTcpServer->clientConnected(m_clientId); m_mockTcpServer->clientConnected(m_clientId);
@ -101,12 +101,12 @@ void NymeaTestBase::initTestCase()
qCDebug(dcTests()) << "Starting JSON handshake"; qCDebug(dcTests()) << "Starting JSON handshake";
QVariant response = injectAndWait("JSONRPC.Hello"); QVariant response = injectAndWait("JSONRPC.Hello");
createMockDevice(); createMock();
response = injectAndWait("Devices.GetConfiguredDevices", {}); response = injectAndWait("Integrations.GetThings", {});
foreach (const QVariant &device, response.toMap().value("params").toMap().value("devices").toList()) { foreach (const QVariant &thing, response.toMap().value("params").toMap().value("things").toList()) {
if (device.toMap().value("deviceClassId").toUuid() == autoMockThingClassId) { if (thing.toMap().value("thingClassId").toUuid() == autoMockThingClassId) {
m_mockThingAutoId = ThingId(device.toMap().value("id").toString()); m_mockThingAutoId = ThingId(thing.toMap().value("id").toString());
} }
} }
} }
@ -118,9 +118,9 @@ void NymeaTestBase::cleanupTestCase()
void NymeaTestBase::cleanup() void NymeaTestBase::cleanup()
{ {
// In case a test deleted the mock device, lets recreate it. // In case a test deleted the mock, lets recreate it.
if (NymeaCore::instance()->thingManager()->findConfiguredThings(mockThingClassId).count() == 0) { if (NymeaCore::instance()->thingManager()->findConfiguredThings(mockThingClassId).count() == 0) {
createMockDevice(); createMock();
} }
} }
@ -429,24 +429,24 @@ void NymeaTestBase::clearLoggingDatabase()
NymeaCore::instance()->logEngine()->clearDatabase(); NymeaCore::instance()->logEngine()->clearDatabase();
} }
void NymeaTestBase::createMockDevice() void NymeaTestBase::createMock()
{ {
QVariantMap params; QVariantMap params;
params.insert("name", "Test Mock Device"); params.insert("name", "Test Mock");
params.insert("deviceClassId", mockThingClassId.toString()); params.insert("thingClassId", mockThingClassId.toString());
QVariantList deviceParams; QVariantList thingParams;
QVariantMap httpPortParam; QVariantMap httpPortParam;
httpPortParam.insert("paramTypeId", mockThingHttpportParamTypeId.toString()); httpPortParam.insert("paramTypeId", mockThingHttpportParamTypeId.toString());
httpPortParam.insert("value", m_mockThing1Port); httpPortParam.insert("value", m_mockThing1Port);
deviceParams.append(httpPortParam); thingParams.append(httpPortParam);
params.insert("deviceParams", deviceParams); params.insert("thingParams", thingParams);
QVariant response = injectAndWait("Devices.AddConfiguredDevice", params); QVariant response = injectAndWait("Integrations.AddThing", params);
verifyError(response, "deviceError", "DeviceErrorNoError"); verifyError(response, "thingError", "ThingErrorNoError");
m_mockThingId = ThingId(response.toMap().value("params").toMap().value("deviceId").toString()); m_mockThingId = ThingId(response.toMap().value("params").toMap().value("thingId").toString());
QVERIFY2(!m_mockThingId.isNull(), "Newly created mock device must not be null."); QVERIFY2(!m_mockThingId.isNull(), "Newly created mock thing id must not be null.");
} }

View File

@ -126,7 +126,7 @@ protected:
void clearLoggingDatabase(); void clearLoggingDatabase();
private: private:
void createMockDevice(); void createMock();
protected: protected:
PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1"); PluginId mockPluginId = PluginId("727a4a9a-c187-446f-aadf-f1b2220607d1");

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -298,6 +298,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation>Databáze Log</translation> <translation>Databáze Log</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -407,18 +424,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation>nastavení nymead</translation> <translation>nastavení nymead</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation>Nastavení zařízení</translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation>Nastavení stavu zařízení</translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -489,11 +494,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -298,6 +298,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation>Log-database</translation> <translation>Log-database</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -407,18 +424,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation>nymead-indstillinger</translation> <translation>nymead-indstillinger</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation>Enhedsindstillinger</translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation>Indstillinger for enhedstilstande</translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -489,11 +494,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -298,6 +298,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation>Logdatenbank</translation> <translation>Logdatenbank</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -407,18 +424,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation>nymead Einstellungen</translation> <translation>nymead Einstellungen</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation>Geräteeinstellungen</translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation>Gerätestatuseinstellungen</translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -489,11 +494,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -295,6 +295,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -404,18 +421,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -486,11 +491,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -298,6 +298,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation>Base da datos de registro</translation> <translation>Base da datos de registro</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -407,18 +424,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation>Ajustes nymea</translation> <translation>Ajustes nymea</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation>Ajustes de dispositivo</translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation>Ajustes de estados de dispositivo</translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -489,11 +494,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -298,6 +298,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation>Lokitietokanta</translation> <translation>Lokitietokanta</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -407,18 +424,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation>nymead-asetukset</translation> <translation>nymead-asetukset</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation>Laiteasetukset</translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation>Laitetilojen asetukset</translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -489,11 +494,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -298,6 +298,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation>Base de données journal</translation> <translation>Base de données journal</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -407,18 +424,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation>Paramètres nymead</translation> <translation>Paramètres nymead</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation>Paramètres de l&apos;appareil</translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation>Réglages des états de l&apos;appareil</translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -489,11 +494,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -298,6 +298,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation>Registro database</translation> <translation>Registro database</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -407,18 +424,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation>Impostazioni nymead</translation> <translation>Impostazioni nymead</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation>Impostazioni del dispositivo</translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation>Impostazioni dello stato del dispositivo</translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -489,11 +494,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -298,6 +298,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation>Log-database</translation> <translation>Log-database</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -407,18 +424,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation>nymead-instellingen</translation> <translation>nymead-instellingen</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation>Apparaatinstellingen</translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation>Instellingen apparaatstatus</translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -489,11 +494,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>

View File

@ -46,11 +46,11 @@
</message> </message>
</context> </context>
<context> <context>
<name>DeviceManagerImplementation</name> <name>ThingManagerImplementation</name>
<message> <message>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="262"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="258"/>
<location filename="../libnymea-core/devices/devicemanagerimplementation.cpp" line="1727"/> <location filename="../libnymea-core/integrations/thingmanagerimplementation.cpp" line="1696"/>
<source>The plugin for this device or service is not loaded.</source> <source>The plugin for this thing is not loaded.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -298,6 +298,23 @@ The network section of the debug interface</extracomment>
<extracomment>The log databse download description of the debug interface</extracomment> <extracomment>The log databse download description of the debug interface</extracomment>
<translation>Banco de dados de registo</translation> <translation>Banco de dados de registo</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Thing settings</source>
<extracomment>The thing settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Thing states settings</source>
<extracomment>The thing states settings download description of the debug interface</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test shows the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1731"/>
<source>This section allows you to see the live logs of the nymea server.</source> <source>This section allows you to see the live logs of the nymea server.</source>
@ -407,18 +424,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The nymead settings download description of the debug interface</extracomment> <extracomment>The nymead settings download description of the debug interface</extracomment>
<translation>Configurações nymead</translation> <translation>Configurações nymead</translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1320"/>
<source>Device settings</source>
<extracomment>The device settings download description of the debug interface</extracomment>
<translation>Configurações do dispositivo</translation>
</message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1370"/>
<source>Device states settings</source>
<extracomment>The device states settings download description of the debug interface</extracomment>
<translation>Configurações de estados do dispositivo</translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1420"/>
<source>Rules settings</source> <source>Rules settings</source>
@ -489,11 +494,6 @@ The download logs section of the debug interface</extracomment>
<extracomment>The trace section of the debug interface</extracomment> <extracomment>The trace section of the debug interface</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1692"/>
<source>This test showes the trace path from the nymea device to the nymea.io server.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/> <location filename="../libnymea-core/debugserverhandler.cpp" line="1701"/>
<source>Start trace path test</source> <source>Start trace path test</source>