diff --git a/libnymea-core/integrations/thingmanagerimplementation.cpp b/libnymea-core/integrations/thingmanagerimplementation.cpp index f642014e..17c330f0 100644 --- a/libnymea-core/integrations/thingmanagerimplementation.cpp +++ b/libnymea-core/integrations/thingmanagerimplementation.cpp @@ -509,6 +509,30 @@ Thing::ThingError ThingManagerImplementation::setThingSettings(const ThingId &th return Thing::ThingErrorNoError; } +Thing::ThingError ThingManagerImplementation::setStateLogging(const ThingId &thingId, const StateTypeId &stateTypeId, bool enabled) +{ + Thing *thing = m_configuredThings.value(thingId); + if (!thing) { + qCWarning(dcThingManager()) << "Cannot configure event logging. Thing" << thingId.toString() << "not found"; + return Thing::ThingErrorThingNotFound; + } + if (!thing->thingClass().stateTypes().findById(stateTypeId).isValid()) { + qCWarning(dcThingManager()) << "Cannot configure state logging. Thing" << thingId.toString() << "has no state type with id" << stateTypeId; + return Thing::ThingErrorStateTypeNotFound; + } + QList loggedStateTypes = thing->loggedStateTypeIds(); + if (enabled && !loggedStateTypes.contains(stateTypeId)) { + loggedStateTypes.append(stateTypeId); + thing->setLoggedStateTypeIds(loggedStateTypes); + emit thingChanged(thing); + } else if (!enabled && loggedStateTypes.contains(stateTypeId)) { + loggedStateTypes.removeAll(stateTypeId); + thing->setLoggedStateTypeIds(loggedStateTypes); + emit thingChanged(thing); + } + return Thing::ThingErrorNoError; +} + Thing::ThingError ThingManagerImplementation::setEventLogging(const ThingId &thingId, const EventTypeId &eventTypeId, bool enabled) { Thing *thing = m_configuredThings.value(thingId); @@ -1836,10 +1860,6 @@ void ThingManagerImplementation::slotThingStateValueChanged(const StateTypeId &s emit thingStateChanged(thing, stateTypeId, value, minValue, maxValue); - Param valueParam(ParamTypeId(stateTypeId.toString()), value); - Event event(EventTypeId(stateTypeId.toString()), thing->id(), ParamList() << valueParam, true); - onEventTriggered(event); - syncIOConnection(thing, stateTypeId); } @@ -2091,6 +2111,13 @@ void ThingManagerImplementation::initThing(Thing *thing) } } thing->setLoggedEventTypeIds(loggedEventTypeIds); + QList loggedStateTypeIds; + foreach (const StateType &stateType, thingClass.stateTypes()) { + if (stateType.suggestLogging()) { + loggedStateTypeIds.append(stateType.id()); + } + } + thing->setLoggedStateTypeIds(loggedStateTypeIds); } void ThingManagerImplementation::postSetupThing(Thing *thing) diff --git a/libnymea-core/integrations/thingmanagerimplementation.h b/libnymea-core/integrations/thingmanagerimplementation.h index 41aba703..41cdea4e 100644 --- a/libnymea-core/integrations/thingmanagerimplementation.h +++ b/libnymea-core/integrations/thingmanagerimplementation.h @@ -106,6 +106,7 @@ public: Thing::ThingError editThing(const ThingId &thingId, const QString &name) override; Thing::ThingError setThingSettings(const ThingId &thingId, const ParamList &settings) override; + Thing::ThingError setStateLogging(const ThingId &thingId, const StateTypeId &stateTypeId, bool enabled) override; Thing::ThingError setEventLogging(const ThingId &thingId, const EventTypeId &eventTypeId, bool enabled) override; Thing::ThingError setStateFilter(const ThingId &thingId, const StateTypeId &stateTypeId, Types::StateValueFilter filter) override; diff --git a/libnymea-core/jsonrpc/integrationshandler.cpp b/libnymea-core/jsonrpc/integrationshandler.cpp index 9db3fd58..662092e8 100644 --- a/libnymea-core/jsonrpc/integrationshandler.cpp +++ b/libnymea-core/jsonrpc/integrationshandler.cpp @@ -242,6 +242,14 @@ IntegrationsHandler::IntegrationsHandler(ThingManager *thingManager, QObject *pa returns.insert("thingError", enumRef()); registerMethod("SetThingSettings", description, params, returns, Types::PermissionScopeConfigureThings); + params.clear(); returns.clear(); + description = "Enable/disable logging for the given state type on the given thing."; + params.insert("thingId", enumValueName(Uuid)); + params.insert("stateTypeId", enumValueName(Uuid)); + params.insert("enabled", enumValueName(Bool)); + returns.insert("thingError", enumRef()); + registerMethod("SetStateLogging", description, params, returns, Types::PermissionScopeConfigureThings); + params.clear(); returns.clear(); description = "Enable/disable logging for the given event type on the given thing."; params.insert("thingId", enumValueName(Uuid)); @@ -857,6 +865,15 @@ JsonReply *IntegrationsHandler::SetThingSettings(const QVariantMap ¶ms) return createReply(statusToReply(status)); } +JsonReply *IntegrationsHandler::SetStateLogging(const QVariantMap ¶ms) +{ + ThingId thingId = ThingId(params.value("thingId").toString()); + StateTypeId stateTypeId = StateTypeId(params.value("stateTypeId").toUuid()); + bool enabled = params.value("enabled").toBool(); + Thing::ThingError status = NymeaCore::instance()->thingManager()->setStateLogging(thingId, stateTypeId, enabled); + return createReply(statusToReply(status)); +} + JsonReply *IntegrationsHandler::SetEventLogging(const QVariantMap ¶ms) { ThingId thingId = ThingId(params.value("thingId").toString()); diff --git a/libnymea-core/jsonrpc/integrationshandler.h b/libnymea-core/jsonrpc/integrationshandler.h index 417e6e81..48ed2b83 100644 --- a/libnymea-core/jsonrpc/integrationshandler.h +++ b/libnymea-core/jsonrpc/integrationshandler.h @@ -59,6 +59,7 @@ public: Q_INVOKABLE JsonReply *EditThing(const QVariantMap ¶ms); Q_INVOKABLE JsonReply *RemoveThing(const QVariantMap ¶ms); Q_INVOKABLE JsonReply *SetThingSettings(const QVariantMap ¶ms); + Q_INVOKABLE JsonReply *SetStateLogging(const QVariantMap ¶ms); Q_INVOKABLE JsonReply *SetEventLogging(const QVariantMap ¶ms); Q_INVOKABLE JsonReply *SetStateFilter(const QVariantMap ¶ms); diff --git a/libnymea-core/libnymea-core.pro b/libnymea-core/libnymea-core.pro index 9436d7a6..7fa7607c 100644 --- a/libnymea-core/libnymea-core.pro +++ b/libnymea-core/libnymea-core.pro @@ -88,6 +88,7 @@ HEADERS += nymeacore.h \ scriptengine/scriptevent.h \ scriptengine/scriptinterfaceaction.h \ scriptengine/scriptinterfaceevent.h \ + scriptengine/scriptinterfacestate.h \ scriptengine/scriptstate.h \ transportinterface.h \ nymeaconfiguration.h \ @@ -180,6 +181,7 @@ SOURCES += nymeacore.cpp \ scriptengine/scriptevent.cpp \ scriptengine/scriptinterfaceaction.cpp \ scriptengine/scriptinterfaceevent.cpp \ + scriptengine/scriptinterfacestate.cpp \ scriptengine/scriptstate.cpp \ transportinterface.cpp \ nymeaconfiguration.cpp \ diff --git a/libnymea-core/logging/logengine.cpp b/libnymea-core/logging/logengine.cpp index a8f5b427..b30f18c2 100644 --- a/libnymea-core/logging/logengine.cpp +++ b/libnymea-core/logging/logengine.cpp @@ -110,6 +110,7 @@ void LogEngine::setThingManager(ThingManager *thingManager) { m_thingManager = thingManager; connect(thingManager, &ThingManager::eventTriggered, this, &LogEngine::logEvent); + connect(thingManager, &ThingManager::thingStateChanged, this, &LogEngine::logStateChange); connect(thingManager, &ThingManager::actionExecuted, this, &LogEngine::logAction); } @@ -237,22 +238,11 @@ void LogEngine::logEvent(const Event &event) } QVariantList valueList; - Logging::LoggingSource sourceType; - if (event.isStateChangeEvent()) { - sourceType = Logging::LoggingSourceStates; - - // There should only be one param - if (!event.params().isEmpty()) - valueList << event.params().first().value(); - - } else { - sourceType = Logging::LoggingSourceEvents; - foreach (const Param ¶m, event.params()) { - valueList << param.value(); - } + foreach (const Param ¶m, event.params()) { + valueList << param.value(); } - LogEntry entry(sourceType); + LogEntry entry(Logging::LoggingSourceEvents); entry.setTypeId(event.eventTypeId()); entry.setThingId(event.thingId()); if (valueList.count() == 1) { @@ -263,6 +253,19 @@ void LogEngine::logEvent(const Event &event) appendLogEntry(entry); } +void LogEngine::logStateChange(Thing *thing, const StateTypeId &stateTypeId, const QVariant &value) +{ + if (!thing->loggedStateTypeIds().contains(stateTypeId)) { + return; + } + + LogEntry entry(Logging::LoggingSourceStates); + entry.setTypeId(stateTypeId); + entry.setThingId(thing->id()); + entry.setValue(value); + appendLogEntry(entry); +} + void LogEngine::logAction(const Action &action, Thing::ThingError status) { Logging::LoggingLevel level = status == Thing::ThingErrorNoError ? Logging::LoggingLevelInfo : Logging::LoggingLevelAlert; diff --git a/libnymea-core/logging/logengine.h b/libnymea-core/logging/logengine.h index a3749a2e..b1b13372 100644 --- a/libnymea-core/logging/logengine.h +++ b/libnymea-core/logging/logengine.h @@ -86,6 +86,7 @@ public slots: private slots: void logEvent(const Event &event); + void logStateChange(Thing *thing, const StateTypeId &stateTypeId, const QVariant &value); void logAction(const Action &action, Thing::ThingError status); signals: diff --git a/libnymea-core/nymeacore.cpp b/libnymea-core/nymeacore.cpp index 2f3770ed..6d34657f 100644 --- a/libnymea-core/nymeacore.cpp +++ b/libnymea-core/nymeacore.cpp @@ -163,8 +163,8 @@ void NymeaCore::init(const QStringList &additionalInterfaces) { connect(m_configuration, &NymeaConfiguration::serverNameChanged, m_serverManager, &ServerManager::setServerName); connect(m_thingManager, &ThingManagerImplementation::pluginConfigChanged, this, &NymeaCore::pluginConfigChanged); - connect(m_thingManager, &ThingManagerImplementation::eventTriggered, this, &NymeaCore::gotEvent); - connect(m_thingManager, &ThingManagerImplementation::thingStateChanged, this, &NymeaCore::thingStateChanged); + connect(m_thingManager, &ThingManagerImplementation::eventTriggered, this, &NymeaCore::onEventTriggered); + connect(m_thingManager, &ThingManagerImplementation::thingStateChanged, this, &NymeaCore::onThingStateChanged); connect(m_thingManager, &ThingManagerImplementation::thingAdded, this, &NymeaCore::thingAdded); connect(m_thingManager, &ThingManagerImplementation::thingChanged, this, &NymeaCore::thingChanged); connect(m_thingManager, &ThingManagerImplementation::thingSettingChanged, this, &NymeaCore::thingSettingChanged); @@ -662,10 +662,27 @@ ModbusRtuManager *NymeaCore::modbusRtuManager() const return m_modbusRtuManager; } -void NymeaCore::gotEvent(const Event &event) +void NymeaCore::onEventTriggered(const Event &event) { emit eventTriggered(event); + evaluateRules(event); +} +void NymeaCore::onThingStateChanged(Thing *thing, const StateTypeId &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue) +{ + emit thingStateChanged(thing, stateTypeId, value, minValue, maxValue); + + // The rule engine can have event based rules that would trigger when a state changes + // without "binding" to the state (as a stateEvaluator would do). So generate a fake event + // for every state change. + // TODO: This whole rule engine related code in this file should probably move into the RuleEngine itself. + Param valueParam(ParamTypeId(stateTypeId.toString()), value); + Event event(EventTypeId(stateTypeId.toString()), thing->id(), ParamList() << valueParam); + evaluateRules(event); +} + +void NymeaCore::evaluateRules(const Event &event) +{ QList actions; QList eventBasedActions; foreach (const Rule &rule, m_ruleEngine->evaluateEvent(event)) { diff --git a/libnymea-core/nymeacore.h b/libnymea-core/nymeacore.h index 15f8d171..db373ef0 100644 --- a/libnymea-core/nymeacore.h +++ b/libnymea-core/nymeacore.h @@ -120,7 +120,7 @@ signals: void pluginConfigChanged(const PluginId &id, const ParamList &config); void eventTriggered(const Event &event); - void thingStateChanged(Thing *thing, const QUuid &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue); + void thingStateChanged(Thing *thing, const StateTypeId &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue); void thingRemoved(const ThingId &thingId); void thingAdded(Thing *thing); void thingChanged(Thing *thing); @@ -160,7 +160,9 @@ private: QList m_executingRules; private slots: - void gotEvent(const Event &event); + void onEventTriggered(const Event &event); + void onThingStateChanged(Thing *thing, const StateTypeId &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue); + void evaluateRules(const Event &event); void onDateTimeChanged(const QDateTime &dateTime); void onThingDisappeared(const ThingId &thingId); void thingManagerLoaded(); diff --git a/libnymea-core/ruleengine/ruleengine.cpp b/libnymea-core/ruleengine/ruleengine.cpp index 2f8cdf0d..4298cc1f 100644 --- a/libnymea-core/ruleengine/ruleengine.cpp +++ b/libnymea-core/ruleengine/ruleengine.cpp @@ -155,7 +155,7 @@ QList RuleEngine::evaluateEvent(const Event &event) qCWarning(dcRuleEngine()) << "Invalid event. ThingID does not reference a valid thing"; return QList(); } - ThingClass thingClass = NymeaCore::instance()->thingManager()->findThingClass(thing->thingClassId()); + ThingClass thingClass = thing->thingClass(); EventType eventType = thingClass.eventTypes().findById(event.eventTypeId()); @@ -329,6 +329,12 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit) eventTypeFound = true; } } + // Allow defining event descriptors with a stateTypeId as eventTypeId + foreach (const StateType &stateType, thingClass.stateTypes()) { + if (stateType.id() == eventDescriptor.eventTypeId()) { + eventTypeFound = true; + } + } if (!eventTypeFound) { qCWarning(dcRuleEngine) << "Cannot create rule. Thing " + thing->name() + " has no event type:" << eventDescriptor.eventTypeId(); return RuleErrorEventTypeNotFound; @@ -340,7 +346,7 @@ RuleEngine::RuleError RuleEngine::addRule(const Rule &rule, bool fromEdit) qWarning(dcRuleEngine()) << "No such interface:" << eventDescriptor.interface(); return RuleErrorInterfaceNotFound; } - if (iface.eventTypes().findByName(eventDescriptor.interfaceEvent()).name().isEmpty()) { + if (iface.eventTypes().findByName(eventDescriptor.interfaceEvent()).name().isEmpty() && iface.stateTypes().findByName(eventDescriptor.interfaceEvent()).name().isEmpty()) { qWarning(dcRuleEngine()) << "Interface" << iface.name() << "has no such event:" << eventDescriptor.interfaceEvent(); return RuleErrorEventTypeNotFound; } @@ -827,9 +833,17 @@ bool RuleEngine::containsEvent(const Rule &rule, const Event &event, const Thing } EventType et = dc.eventTypes().findById(event.eventTypeId()); - if (et.name() != eventDescriptor.interfaceEvent()) { - // The fired event name does not match with the eventDescriptor's interfaceEvent - continue; + StateType st = dc.stateTypes().findById(event.eventTypeId()); + if (et.isValid()) { + if (et.name() != eventDescriptor.interfaceEvent()) { + // The fired event name does not match with the eventDescriptor's interfaceEvent + continue; + } + } else if (st.isValid()) { + if (st.name() != eventDescriptor.interfaceEvent()) { + // The fired event name does not match with the eventDescriptor's interfaceEvent + continue; + } } } @@ -847,8 +861,13 @@ bool RuleEngine::containsEvent(const Rule &rule, const Event &event, const Thing } ThingClass dc = NymeaCore::instance()->thingManager()->findThingClass(thingClassId); EventType et = dc.eventTypes().findById(event.eventTypeId()); - ParamType pt = et.paramTypes().findByName(paramDescriptor.paramName()); - paramValue = event.param(pt.id()).value(); + StateType st = dc.stateTypes().findById(event.eventTypeId()); + if (et.isValid()) { + ParamType pt = et.paramTypes().findByName(paramDescriptor.paramName()); + paramValue = event.param(pt.id()).value(); + } else if (st.isValid()) { + paramValue = event.paramValue(st.id()); + } } switch (paramDescriptor.operatorType()) { @@ -1094,6 +1113,11 @@ QVariant::Type RuleEngine::getEventParamType(const EventTypeId &eventTypeId, con } } } + foreach (const StateType &stateType, thingClass.stateTypes()) { + if (stateType.id() == eventTypeId) { + return stateType.type(); + } + } } return QVariant::Invalid; diff --git a/libnymea-core/scriptengine/scriptengine.cpp b/libnymea-core/scriptengine/scriptengine.cpp index a11645c7..902e198d 100644 --- a/libnymea-core/scriptengine/scriptengine.cpp +++ b/libnymea-core/scriptengine/scriptengine.cpp @@ -36,6 +36,7 @@ #include "scriptstate.h" #include "scriptalarm.h" #include "scriptinterfaceaction.h" +#include "scriptinterfacestate.h" #include "scriptinterfaceevent.h" #include "nymeasettings.h" @@ -64,6 +65,7 @@ ScriptEngine::ScriptEngine(ThingManager *thingManager, QObject *parent) : QObjec qmlRegisterType("nymea", 1, 0, "ThingAction"); qmlRegisterType("nymea", 1, 0, "ThingState"); qmlRegisterType("nymea", 1, 0, "InterfaceAction"); + qmlRegisterType("nymea", 1, 0, "InterfaceState"); qmlRegisterType("nymea", 1, 0, "InterfaceEvent"); qmlRegisterType("nymea", 1, 0, "Alarm"); diff --git a/libnymea-core/scriptengine/scriptinterfacestate.cpp b/libnymea-core/scriptengine/scriptinterfacestate.cpp new file mode 100644 index 00000000..9b5ace72 --- /dev/null +++ b/libnymea-core/scriptengine/scriptinterfacestate.cpp @@ -0,0 +1,94 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* +* Copyright 2013 - 2022, nymea GmbH +* Contact: contact@nymea.io +* +* This file is part of nymea. +* This project including source code and documentation is protected by +* copyright law, and remains the property of nymea GmbH. All rights, including +* reproduction, publication, editing and translation, are reserved. The use of +* this project is subject to the terms of a license agreement to be concluded +* with nymea GmbH in accordance with the terms of use of nymea GmbH, available +* under https://nymea.io/license +* +* GNU General Public License Usage +* Alternatively, this project may be redistributed and/or modified under the +* terms of the GNU General Public License as published by the Free Software +* Foundation, GNU version 3. This project is distributed in the hope that it +* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +* Public License for more details. +* +* You should have received a copy of the GNU General Public License along with +* this project. If not, see . +* +* For any further details and any questions please contact us under +* contact@nymea.io or see our FAQ/Licensing Information on +* https://nymea.io/license/faq +* +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "scriptinterfacestate.h" + +#include +#include +#include + +namespace nymeaserver { + +ScriptInterfaceState::ScriptInterfaceState(QObject *parent) : QObject(parent) +{ +} + +void ScriptInterfaceState::classBegin() +{ + m_thingManager = reinterpret_cast(qmlEngine(this)->property("thingManager").toULongLong()); + connect(m_thingManager, &ThingManager::thingStateChanged, this, &ScriptInterfaceState::onStateChanged); +} + +void ScriptInterfaceState::componentComplete() +{ + +} + +QString ScriptInterfaceState::interfaceName() const +{ + return m_interfaceName; +} + +void ScriptInterfaceState::setInterfaceName(const QString &interfaceName) +{ + if (m_interfaceName != interfaceName) { + m_interfaceName = interfaceName; + emit interfaceNameChanged(); + } +} + +QString ScriptInterfaceState::stateName() const +{ + return m_stateName; +} + +void ScriptInterfaceState::setStateName(const QString &stateName) +{ + if (m_stateName != stateName) { + m_stateName = stateName; + emit stateNameChanged(); + } +} + +void ScriptInterfaceState::onStateChanged(Thing *thing, const StateTypeId &stateTypeId, const QVariant &value) +{ + if (!thing->thingClass().interfaces().contains(m_interfaceName)) { + return; + } + + if (!m_stateName.isEmpty() && thing->thingClass().stateTypes().findByName(m_stateName).id() != stateTypeId) { + return; + } + + emit stateChanged(thing->id().toString().remove(QRegExp("[{}]")), value); +} + +} + diff --git a/libnymea-core/scriptengine/scriptinterfacestate.h b/libnymea-core/scriptengine/scriptinterfacestate.h new file mode 100644 index 00000000..923b445c --- /dev/null +++ b/libnymea-core/scriptengine/scriptinterfacestate.h @@ -0,0 +1,80 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* +* Copyright 2013 - 2022, nymea GmbH +* Contact: contact@nymea.io +* +* This file is part of nymea. +* This project including source code and documentation is protected by +* copyright law, and remains the property of nymea GmbH. All rights, including +* reproduction, publication, editing and translation, are reserved. The use of +* this project is subject to the terms of a license agreement to be concluded +* with nymea GmbH in accordance with the terms of use of nymea GmbH, available +* under https://nymea.io/license +* +* GNU General Public License Usage +* Alternatively, this project may be redistributed and/or modified under the +* terms of the GNU General Public License as published by the Free Software +* Foundation, GNU version 3. This project is distributed in the hope that it +* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +* Public License for more details. +* +* You should have received a copy of the GNU General Public License along with +* this project. If not, see . +* +* For any further details and any questions please contact us under +* contact@nymea.io or see our FAQ/Licensing Information on +* https://nymea.io/license/faq +* +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef SCRIPTINTERFACESTATE_H +#define SCRIPTINTERFACESTATE_H + +#include +#include +#include + +#include "types/state.h" +#include "integrations/thingmanager.h" + +namespace nymeaserver { + +class ScriptParams; + +class ScriptInterfaceState: public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + Q_PROPERTY(QString interfaceName READ interfaceName WRITE setInterfaceName NOTIFY interfaceNameChanged) + Q_PROPERTY(QString stateName READ stateName WRITE setStateName NOTIFY stateNameChanged) +public: + ScriptInterfaceState(QObject *parent = nullptr); + void classBegin() override; + void componentComplete() override; + + QString interfaceName() const; + void setInterfaceName(const QString &interfaceName); + + QString stateName() const; + void setStateName(const QString &stateName); + +private slots: + void onStateChanged(Thing *thing, const StateTypeId &stateTypeId, const QVariant &value); + +signals: + void interfaceNameChanged(); + void stateNameChanged(); + + void stateChanged(const QString &thingId, const QVariant &value); + +private: + ThingManager *m_thingManager = nullptr; + + QString m_interfaceName; + QString m_stateName; +}; + +} + +#endif // SCRIPTINTERFACESTATE_H diff --git a/libnymea/integrations/pluginmetadata.cpp b/libnymea/integrations/pluginmetadata.cpp index c13665ea..5c50bbe3 100644 --- a/libnymea/integrations/pluginmetadata.cpp +++ b/libnymea/integrations/pluginmetadata.cpp @@ -489,24 +489,16 @@ void PluginMetadata::parse(const QJsonObject &jsonObject) } stateTypes.append(stateType); - // Events for state changed (Not checking for duplicate UUID, this is expected to be the same as the state!) - EventType eventType(EventTypeId(stateType.id().toString())); - eventType.setName(st.value("name").toString()); - eventType.setDisplayName(st.value("displayNameEvent").toString()); - ParamType paramType(ParamTypeId(stateType.id().toString()), st.value("name").toString(), stateType.type()); - paramType.setDisplayName(st.value("displayName").toString()); - paramType.setAllowedValues(stateType.possibleValues()); - paramType.setDefaultValue(stateType.defaultValue()); - paramType.setMinValue(stateType.minValue()); - paramType.setMaxValue(stateType.maxValue()); - paramType.setUnit(stateType.unit()); - eventType.setParamTypes(QList() << paramType); - eventType.setIndex(stateType.index()); - eventType.setSuggestLogging(st.value("suggestLogging").toBool()); - eventTypes.append(eventType); - // ActionTypes for writeable StateTypes if (writableState) { + ParamType paramType(ParamTypeId(stateType.id().toString()), st.value("name").toString(), stateType.type()); + paramType.setDisplayName(st.value("displayName").toString()); + paramType.setAllowedValues(stateType.possibleValues()); + paramType.setDefaultValue(stateType.defaultValue()); + paramType.setMinValue(stateType.minValue()); + paramType.setMaxValue(stateType.maxValue()); + paramType.setUnit(stateType.unit()); + ActionType actionType(ActionTypeId(stateType.id().toString())); actionType.setName(stateType.name()); actionType.setDisplayName(st.value("displayNameAction").toString()); diff --git a/libnymea/integrations/thing.cpp b/libnymea/integrations/thing.cpp index 5c95b6c6..36450d9b 100644 --- a/libnymea/integrations/thing.cpp +++ b/libnymea/integrations/thing.cpp @@ -584,6 +584,11 @@ State Thing::state(const QString &stateName) const return state(stateTypeId); } +QList Thing::loggedStateTypeIds() const +{ + return m_loggedStateTypeIds; +} + QList Thing::loggedEventTypeIds() const { return m_loggedEventTypeIds; @@ -655,6 +660,11 @@ void Thing::setSetupStatus(Thing::ThingSetupStatus status, Thing::ThingError set emit setupStatusChanged(); } +void Thing::setLoggedStateTypeIds(const QList loggedStateTypeIds) +{ + m_loggedStateTypeIds = loggedStateTypeIds; +} + void Thing::setLoggedEventTypeIds(const QList loggedEventTypeIds) { m_loggedEventTypeIds = loggedEventTypeIds; diff --git a/libnymea/integrations/thing.h b/libnymea/integrations/thing.h index e0d0f2f7..8e3aa879 100644 --- a/libnymea/integrations/thing.h +++ b/libnymea/integrations/thing.h @@ -61,6 +61,7 @@ class LIBNYMEA_EXPORT Thing: public QObject Q_PROPERTY(QString setupDisplayMessage READ setupDisplayMessage NOTIFY setupStatusChanged USER true) Q_PROPERTY(ThingError setupError READ setupError NOTIFY setupStatusChanged) Q_PROPERTY(QUuid parentId READ parentId USER true) + Q_PROPERTY(QList loggedStateTypeIds READ loggedStateTypeIds USER true) Q_PROPERTY(QList loggedEventTypeIds READ loggedEventTypeIds USER true) public: @@ -151,6 +152,7 @@ public: Q_INVOKABLE State state(const StateTypeId &stateTypeId) const; Q_INVOKABLE State state(const QString &stateName) const; + QList loggedStateTypeIds() const; QList loggedEventTypeIds() const; ThingId parentId() const; @@ -182,6 +184,7 @@ private: Thing(const PluginId &pluginId, const ThingClass &thingClass, QObject *parent = nullptr); void setSetupStatus(ThingSetupStatus status, ThingError setupError, const QString &displayMessage = QString()); + void setLoggedStateTypeIds(const QList loggedStateTypeIds); void setLoggedEventTypeIds(const QList loggedEventTypeIds); void setStateValueFilter(const StateTypeId &stateTypeId, Types::StateValueFilter filter); @@ -200,6 +203,7 @@ private: ThingError m_setupError = ThingErrorNoError; QString m_setupDisplayMessage; + QList m_loggedStateTypeIds; QList m_loggedEventTypeIds; QHash m_stateValueFilters; }; diff --git a/libnymea/integrations/thingmanager.h b/libnymea/integrations/thingmanager.h index 0a36d13e..f5fea03d 100644 --- a/libnymea/integrations/thingmanager.h +++ b/libnymea/integrations/thingmanager.h @@ -81,6 +81,7 @@ public: virtual Thing::ThingError editThing(const ThingId &thingId, const QString &name) = 0; virtual Thing::ThingError setThingSettings(const ThingId &thingId, const ParamList &settings) = 0; + virtual Thing::ThingError setStateLogging(const ThingId &thingId, const StateTypeId &stateTypeId, bool enabled) = 0; virtual Thing::ThingError setEventLogging(const ThingId &thingId, const EventTypeId &eventTypeId, bool enabled) = 0; virtual Thing::ThingError setStateFilter(const ThingId &thingId, const StateTypeId &stateTypeId, Types::StateValueFilter filter) = 0; diff --git a/libnymea/integrations/thingutils.cpp b/libnymea/integrations/thingutils.cpp index 59c728af..efdaa88b 100644 --- a/libnymea/integrations/thingutils.cpp +++ b/libnymea/integrations/thingutils.cpp @@ -215,19 +215,12 @@ Interface ThingUtils::loadInterface(const QString &name) } stateTypes.append(stateType); - InterfaceEventType stateChangeEventType; - stateChangeEventType.setName(stateType.name()); - stateChangeEventType.setOptional(stateType.optional()); - stateChangeEventType.setSuggestLogging(stateType.suggestLogging()); - stateChangeEventType.setLoggingOverride(stateType.loggingOverride()); ParamType stateChangeEventParamType; stateChangeEventParamType.setName(stateType.name()); stateChangeEventParamType.setType(stateType.type()); stateChangeEventParamType.setAllowedValues(stateType.possibleValues()); stateChangeEventParamType.setMinValue(stateType.minValue()); stateChangeEventParamType.setMaxValue(stateType.maxValue()); - stateChangeEventType.setParamTypes(ParamTypes() << stateChangeEventParamType); - eventTypes.append(stateChangeEventType); if (stateVariant.toMap().value("writable", false).toBool()) { InterfaceActionType stateChangeActionType; diff --git a/libnymea/types/event.cpp b/libnymea/types/event.cpp index 72360375..7e016bd2 100644 --- a/libnymea/types/event.cpp +++ b/libnymea/types/event.cpp @@ -54,11 +54,10 @@ Event::Event() * the \l{Device} given by \a deviceId and the parameters given by \a params. The parameter \a isStateChangeEvent * specifies if the \l{Event} will be autogeneratet or not. The parameters must * match the description in the reflecting \l{Event}. */ -Event::Event(const EventTypeId &eventTypeId, const ThingId &thingId, const ParamList ¶ms, bool isStateChangeEvent): +Event::Event(const EventTypeId &eventTypeId, const ThingId &thingId, const ParamList ¶ms): m_eventTypeId(eventTypeId), m_thingId(thingId), - m_params(params), - m_isStateChangeEvent(isStateChangeEvent) + m_params(params) { } @@ -120,12 +119,6 @@ QVariant Event::paramValue(const ParamTypeId ¶mTypeId) const return QVariant(); } -/*! Returns true if this event is autogenerated by a state change. */ -bool Event::isStateChangeEvent() const -{ - return m_isStateChangeEvent; -} - bool Event::logged() const { return m_logged; diff --git a/libnymea/types/event.h b/libnymea/types/event.h index 26eb1f8d..793bf2f7 100644 --- a/libnymea/types/event.h +++ b/libnymea/types/event.h @@ -47,7 +47,7 @@ class LIBNYMEA_EXPORT Event Q_PROPERTY(ParamList params READ params) public: Event(); - Event(const EventTypeId &eventTypeId, const ThingId &thingId, const ParamList ¶ms = ParamList(), bool isStateChangeEvent = false); + Event(const EventTypeId &eventTypeId, const ThingId &thingId, const ParamList ¶ms = ParamList()); EventTypeId eventTypeId() const; void setEventTypeId(const EventTypeId &eventTypeId); @@ -62,8 +62,6 @@ public: bool operator ==(const Event &other) const; - bool isStateChangeEvent() const; - bool logged() const; void setLogged(bool logged); @@ -72,7 +70,6 @@ private: ThingId m_thingId; ParamList m_params; - bool m_isStateChangeEvent; bool m_logged = false; }; Q_DECLARE_METATYPE(Event) diff --git a/plugins/mock/extern-plugininfo.h b/plugins/mock/extern-plugininfo.h index 3be28a3d..beafb528 100644 --- a/plugins/mock/extern-plugininfo.h +++ b/plugins/mock/extern-plugininfo.h @@ -39,33 +39,11 @@ extern StateTypeId mockSignalStrengthStateTypeId; extern StateTypeId mockUpdateStatusStateTypeId; extern StateTypeId mockCurrentVersionStateTypeId; extern StateTypeId mockAvailableVersionStateTypeId; -extern EventTypeId mockIntEventTypeId; -extern ParamTypeId mockIntEventIntParamTypeId; -extern EventTypeId mockIntWithLimitsEventTypeId; -extern ParamTypeId mockIntWithLimitsEventIntWithLimitsParamTypeId; -extern EventTypeId mockBoolEventTypeId; -extern ParamTypeId mockBoolEventBoolParamTypeId; -extern EventTypeId mockDoubleEventTypeId; -extern ParamTypeId mockDoubleEventDoubleParamTypeId; -extern EventTypeId mockBatteryLevelEventTypeId; -extern ParamTypeId mockBatteryLevelEventBatteryLevelParamTypeId; -extern EventTypeId mockBatteryCriticalEventTypeId; -extern ParamTypeId mockBatteryCriticalEventBatteryCriticalParamTypeId; -extern EventTypeId mockPowerEventTypeId; -extern ParamTypeId mockPowerEventPowerParamTypeId; -extern EventTypeId mockConnectedEventTypeId; -extern ParamTypeId mockConnectedEventConnectedParamTypeId; -extern EventTypeId mockSignalStrengthEventTypeId; -extern ParamTypeId mockSignalStrengthEventSignalStrengthParamTypeId; -extern EventTypeId mockUpdateStatusEventTypeId; -extern ParamTypeId mockUpdateStatusEventUpdateStatusParamTypeId; -extern EventTypeId mockCurrentVersionEventTypeId; -extern ParamTypeId mockCurrentVersionEventCurrentVersionParamTypeId; -extern EventTypeId mockAvailableVersionEventTypeId; -extern ParamTypeId mockAvailableVersionEventAvailableVersionParamTypeId; extern EventTypeId mockEvent1EventTypeId; extern EventTypeId mockEvent2EventTypeId; extern ParamTypeId mockEvent2EventIntParamParamTypeId; +extern EventTypeId mockPressedEventTypeId; +extern ParamTypeId mockPressedEventButtonNameParamTypeId; extern ActionTypeId mockIntWithLimitsActionTypeId; extern ParamTypeId mockIntWithLimitsActionIntWithLimitsParamTypeId; extern ActionTypeId mockBatteryLevelActionTypeId; @@ -84,6 +62,8 @@ extern ActionTypeId mockAsyncActionTypeId; extern ActionTypeId mockFailingActionTypeId; extern ActionTypeId mockAsyncFailingActionTypeId; extern ActionTypeId mockPerformUpdateActionTypeId; +extern ActionTypeId mockPressButtonActionTypeId; +extern ParamTypeId mockPressButtonActionButtonNameParamTypeId; extern ActionTypeId mockAddToFavoritesBrowserItemActionTypeId; extern ActionTypeId mockRemoveFromFavoritesBrowserItemActionTypeId; extern ThingClassId autoMockThingClassId; @@ -93,10 +73,6 @@ extern ParamTypeId autoMockThingBrokenParamTypeId; extern ParamTypeId autoMockSettingsMockSettingParamTypeId; extern StateTypeId autoMockIntStateTypeId; extern StateTypeId autoMockBoolValueStateTypeId; -extern EventTypeId autoMockIntEventTypeId; -extern ParamTypeId autoMockIntEventIntParamTypeId; -extern EventTypeId autoMockBoolValueEventTypeId; -extern ParamTypeId autoMockBoolValueEventBoolValueParamTypeId; extern EventTypeId autoMockEvent1EventTypeId; extern EventTypeId autoMockEvent2EventTypeId; extern ParamTypeId autoMockEvent2EventIntParamParamTypeId; @@ -114,16 +90,6 @@ extern StateTypeId pushButtonMockPercentageStateTypeId; extern StateTypeId pushButtonMockAllowedValuesStateTypeId; extern StateTypeId pushButtonMockDoubleStateTypeId; extern StateTypeId pushButtonMockBoolStateTypeId; -extern EventTypeId pushButtonMockColorEventTypeId; -extern ParamTypeId pushButtonMockColorEventColorParamTypeId; -extern EventTypeId pushButtonMockPercentageEventTypeId; -extern ParamTypeId pushButtonMockPercentageEventPercentageParamTypeId; -extern EventTypeId pushButtonMockAllowedValuesEventTypeId; -extern ParamTypeId pushButtonMockAllowedValuesEventAllowedValuesParamTypeId; -extern EventTypeId pushButtonMockDoubleEventTypeId; -extern ParamTypeId pushButtonMockDoubleEventDoubleParamTypeId; -extern EventTypeId pushButtonMockBoolEventTypeId; -extern ParamTypeId pushButtonMockBoolEventBoolParamTypeId; extern ActionTypeId pushButtonMockColorActionTypeId; extern ParamTypeId pushButtonMockColorActionColorParamTypeId; extern ActionTypeId pushButtonMockPercentageActionTypeId; @@ -143,16 +109,6 @@ extern StateTypeId displayPinMockPercentageStateTypeId; extern StateTypeId displayPinMockAllowedValuesStateTypeId; extern StateTypeId displayPinMockDoubleStateTypeId; extern StateTypeId displayPinMockBoolStateTypeId; -extern EventTypeId displayPinMockColorEventTypeId; -extern ParamTypeId displayPinMockColorEventColorParamTypeId; -extern EventTypeId displayPinMockPercentageEventTypeId; -extern ParamTypeId displayPinMockPercentageEventPercentageParamTypeId; -extern EventTypeId displayPinMockAllowedValuesEventTypeId; -extern ParamTypeId displayPinMockAllowedValuesEventAllowedValuesParamTypeId; -extern EventTypeId displayPinMockDoubleEventTypeId; -extern ParamTypeId displayPinMockDoubleEventDoubleParamTypeId; -extern EventTypeId displayPinMockBoolEventTypeId; -extern ParamTypeId displayPinMockBoolEventBoolParamTypeId; extern ActionTypeId displayPinMockColorActionTypeId; extern ParamTypeId displayPinMockColorActionColorParamTypeId; extern ActionTypeId displayPinMockPercentageActionTypeId; @@ -166,14 +122,12 @@ extern ParamTypeId displayPinMockBoolActionBoolParamTypeId; extern ActionTypeId displayPinMockTimeoutActionTypeId; extern ThingClassId parentMockThingClassId; extern StateTypeId parentMockBoolValueStateTypeId; -extern EventTypeId parentMockBoolValueEventTypeId; -extern ParamTypeId parentMockBoolValueEventBoolValueParamTypeId; +extern EventTypeId parentMockEvent1EventTypeId; extern ActionTypeId parentMockBoolValueActionTypeId; extern ParamTypeId parentMockBoolValueActionBoolValueParamTypeId; extern ThingClassId childMockThingClassId; extern StateTypeId childMockBoolValueStateTypeId; -extern EventTypeId childMockBoolValueEventTypeId; -extern ParamTypeId childMockBoolValueEventBoolValueParamTypeId; +extern EventTypeId childMockEvent1EventTypeId; extern ActionTypeId childMockBoolValueActionTypeId; extern ParamTypeId childMockBoolValueActionBoolValueParamTypeId; extern ThingClassId inputTypeMockThingClassId; @@ -208,50 +162,6 @@ extern StateTypeId inputTypeMockTimestampIntStateTypeId; extern StateTypeId inputTypeMockWritableTimestampIntStateTypeId; extern StateTypeId inputTypeMockTimestampUIntStateTypeId; extern StateTypeId inputTypeMockWritableTimestampUIntStateTypeId; -extern EventTypeId inputTypeMockBoolEventTypeId; -extern ParamTypeId inputTypeMockBoolEventBoolParamTypeId; -extern EventTypeId inputTypeMockWritableBoolEventTypeId; -extern ParamTypeId inputTypeMockWritableBoolEventWritableBoolParamTypeId; -extern EventTypeId inputTypeMockIntEventTypeId; -extern ParamTypeId inputTypeMockIntEventIntParamTypeId; -extern EventTypeId inputTypeMockWritableIntEventTypeId; -extern ParamTypeId inputTypeMockWritableIntEventWritableIntParamTypeId; -extern EventTypeId inputTypeMockWritableIntMinMaxEventTypeId; -extern ParamTypeId inputTypeMockWritableIntMinMaxEventWritableIntMinMaxParamTypeId; -extern EventTypeId inputTypeMockUintEventTypeId; -extern ParamTypeId inputTypeMockUintEventUintParamTypeId; -extern EventTypeId inputTypeMockWritableUIntEventTypeId; -extern ParamTypeId inputTypeMockWritableUIntEventWritableUIntParamTypeId; -extern EventTypeId inputTypeMockWritableUIntMinMaxEventTypeId; -extern ParamTypeId inputTypeMockWritableUIntMinMaxEventWritableUIntMinMaxParamTypeId; -extern EventTypeId inputTypeMockDoubleEventTypeId; -extern ParamTypeId inputTypeMockDoubleEventDoubleParamTypeId; -extern EventTypeId inputTypeMockWritableDoubleEventTypeId; -extern ParamTypeId inputTypeMockWritableDoubleEventWritableDoubleParamTypeId; -extern EventTypeId inputTypeMockWritableDoubleMinMaxEventTypeId; -extern ParamTypeId inputTypeMockWritableDoubleMinMaxEventWritableDoubleMinMaxParamTypeId; -extern EventTypeId inputTypeMockStringEventTypeId; -extern ParamTypeId inputTypeMockStringEventStringParamTypeId; -extern EventTypeId inputTypeMockWritableStringEventTypeId; -extern ParamTypeId inputTypeMockWritableStringEventWritableStringParamTypeId; -extern EventTypeId inputTypeMockWritableStringSelectionEventTypeId; -extern ParamTypeId inputTypeMockWritableStringSelectionEventWritableStringSelectionParamTypeId; -extern EventTypeId inputTypeMockColorEventTypeId; -extern ParamTypeId inputTypeMockColorEventColorParamTypeId; -extern EventTypeId inputTypeMockWritableColorEventTypeId; -extern ParamTypeId inputTypeMockWritableColorEventWritableColorParamTypeId; -extern EventTypeId inputTypeMockTimeEventTypeId; -extern ParamTypeId inputTypeMockTimeEventTimeParamTypeId; -extern EventTypeId inputTypeMockWritableTimeEventTypeId; -extern ParamTypeId inputTypeMockWritableTimeEventWritableTimeParamTypeId; -extern EventTypeId inputTypeMockTimestampIntEventTypeId; -extern ParamTypeId inputTypeMockTimestampIntEventTimestampIntParamTypeId; -extern EventTypeId inputTypeMockWritableTimestampIntEventTypeId; -extern ParamTypeId inputTypeMockWritableTimestampIntEventWritableTimestampIntParamTypeId; -extern EventTypeId inputTypeMockTimestampUIntEventTypeId; -extern ParamTypeId inputTypeMockTimestampUIntEventTimestampUIntParamTypeId; -extern EventTypeId inputTypeMockWritableTimestampUIntEventTypeId; -extern ParamTypeId inputTypeMockWritableTimestampUIntEventWritableTimestampUIntParamTypeId; extern ActionTypeId inputTypeMockWritableBoolActionTypeId; extern ParamTypeId inputTypeMockWritableBoolActionWritableBoolParamTypeId; extern ActionTypeId inputTypeMockWritableIntActionTypeId; @@ -290,22 +200,6 @@ extern StateTypeId genericIoMockAnalogInput1StateTypeId; extern StateTypeId genericIoMockAnalogInput2StateTypeId; extern StateTypeId genericIoMockAnalogOutput1StateTypeId; extern StateTypeId genericIoMockAnalogOutput2StateTypeId; -extern EventTypeId genericIoMockDigitalInput1EventTypeId; -extern ParamTypeId genericIoMockDigitalInput1EventDigitalInput1ParamTypeId; -extern EventTypeId genericIoMockDigitalInput2EventTypeId; -extern ParamTypeId genericIoMockDigitalInput2EventDigitalInput2ParamTypeId; -extern EventTypeId genericIoMockDigitalOutput1EventTypeId; -extern ParamTypeId genericIoMockDigitalOutput1EventDigitalOutput1ParamTypeId; -extern EventTypeId genericIoMockDigitalOutput2EventTypeId; -extern ParamTypeId genericIoMockDigitalOutput2EventDigitalOutput2ParamTypeId; -extern EventTypeId genericIoMockAnalogInput1EventTypeId; -extern ParamTypeId genericIoMockAnalogInput1EventAnalogInput1ParamTypeId; -extern EventTypeId genericIoMockAnalogInput2EventTypeId; -extern ParamTypeId genericIoMockAnalogInput2EventAnalogInput2ParamTypeId; -extern EventTypeId genericIoMockAnalogOutput1EventTypeId; -extern ParamTypeId genericIoMockAnalogOutput1EventAnalogOutput1ParamTypeId; -extern EventTypeId genericIoMockAnalogOutput2EventTypeId; -extern ParamTypeId genericIoMockAnalogOutput2EventAnalogOutput2ParamTypeId; extern ActionTypeId genericIoMockDigitalOutput1ActionTypeId; extern ParamTypeId genericIoMockDigitalOutput1ActionDigitalOutput1ParamTypeId; extern ActionTypeId genericIoMockDigitalOutput2ActionTypeId; @@ -318,8 +212,6 @@ extern ActionTypeId genericIoMockAnalogOutput2ActionTypeId; extern ParamTypeId genericIoMockAnalogOutput2ActionAnalogOutput2ParamTypeId; extern ThingClassId virtualIoLightMockThingClassId; extern StateTypeId virtualIoLightMockPowerStateTypeId; -extern EventTypeId virtualIoLightMockPowerEventTypeId; -extern ParamTypeId virtualIoLightMockPowerEventPowerParamTypeId; extern ActionTypeId virtualIoLightMockPowerActionTypeId; extern ParamTypeId virtualIoLightMockPowerActionPowerParamTypeId; extern ThingClassId virtualIoTemperatureSensorMockThingClassId; @@ -327,10 +219,6 @@ extern ParamTypeId virtualIoTemperatureSensorMockSettingsMinTempParamTypeId; extern ParamTypeId virtualIoTemperatureSensorMockSettingsMaxTempParamTypeId; extern StateTypeId virtualIoTemperatureSensorMockInputStateTypeId; extern StateTypeId virtualIoTemperatureSensorMockTemperatureStateTypeId; -extern EventTypeId virtualIoTemperatureSensorMockInputEventTypeId; -extern ParamTypeId virtualIoTemperatureSensorMockInputEventInputParamTypeId; -extern EventTypeId virtualIoTemperatureSensorMockTemperatureEventTypeId; -extern ParamTypeId virtualIoTemperatureSensorMockTemperatureEventTemperatureParamTypeId; extern ActionTypeId virtualIoTemperatureSensorMockInputActionTypeId; extern ParamTypeId virtualIoTemperatureSensorMockInputActionInputParamTypeId; diff --git a/plugins/mock/httpdaemon.cpp b/plugins/mock/httpdaemon.cpp index 5d5ab4c9..b397388e 100644 --- a/plugins/mock/httpdaemon.cpp +++ b/plugins/mock/httpdaemon.cpp @@ -107,7 +107,16 @@ void HttpDaemon::readClient() qCDebug(dcMock()) << "Setting state value" << stateValue; emit setState(stateTypeId, stateValue); } else if (url.path() == "/generateevent") { - emit triggerEvent(EventTypeId(query.queryItemValue("eventtypeid"))); + qCDebug(dcMock()) << "Generate event called" << url.query(); + QList> queryItems = query.queryItems(); + ParamList params; + for (int i = 0; i < queryItems.count(); i++) { + QPair item = queryItems.at(i); + if (item.first != "eventtypeid") { + params.append(Param(ParamTypeId(item.first), item.second)); + } + } + emit triggerEvent(EventTypeId(query.queryItemValue("eventtypeid")), params); } else if (url.path() == "/actionhistory") { qCDebug(dcMock()) << "Get action history called"; diff --git a/plugins/mock/httpdaemon.h b/plugins/mock/httpdaemon.h index 008987be..83787664 100644 --- a/plugins/mock/httpdaemon.h +++ b/plugins/mock/httpdaemon.h @@ -32,6 +32,7 @@ #define HTTPDAEMON_H #include "typeutils.h" +#include "types/param.h" #include #include @@ -52,7 +53,7 @@ public: signals: void setState(const StateTypeId &stateTypeId, const QVariant &value); - void triggerEvent(const EventTypeId &eventTypeId); + void triggerEvent(const EventTypeId &eventTypeId, const ParamList ¶ms); void disappear(); void reconfigureAutodevice(); diff --git a/plugins/mock/integrationpluginmock.cpp b/plugins/mock/integrationpluginmock.cpp index 3945f932..6d8daeea 100644 --- a/plugins/mock/integrationpluginmock.cpp +++ b/plugins/mock/integrationpluginmock.cpp @@ -896,7 +896,7 @@ void IntegrationPluginMock::setState(const StateTypeId &stateTypeId, const QVari device->setStateValue(stateTypeId, value); } -void IntegrationPluginMock::triggerEvent(const EventTypeId &id) +void IntegrationPluginMock::triggerEvent(const EventTypeId &id, const ParamList ¶ms) { HttpDaemon *daemon = qobject_cast(sender()); if (!daemon) @@ -904,8 +904,8 @@ void IntegrationPluginMock::triggerEvent(const EventTypeId &id) Thing *device = m_daemons.key(daemon); - qCDebug(dcMock) << "Emitting event " << id; - device->emitEvent(id); + qCDebug(dcMock) << "Emitting event " << id << params; + device->emitEvent(id, params); } void IntegrationPluginMock::onDisappear() diff --git a/plugins/mock/integrationpluginmock.h b/plugins/mock/integrationpluginmock.h index 1514c42a..24bb7c9c 100644 --- a/plugins/mock/integrationpluginmock.h +++ b/plugins/mock/integrationpluginmock.h @@ -69,7 +69,7 @@ public slots: private slots: void setState(const StateTypeId &stateTypeId, const QVariant &value); - void triggerEvent(const EventTypeId &id); + void triggerEvent(const EventTypeId &id, const ParamList ¶ms); void onDisappear(); void onReconfigureAutoDevice(); void generateDiscoveredDevices(ThingDiscoveryInfo *info); diff --git a/plugins/mock/integrationpluginmock.json b/plugins/mock/integrationpluginmock.json index 705c7955..33253ae3 100644 --- a/plugins/mock/integrationpluginmock.json +++ b/plugins/mock/integrationpluginmock.json @@ -30,7 +30,7 @@ "id": "753f0d32-0468-4d08-82ed-1964aab03298", "name": "mock", "displayName": "Mock Thing", - "interfaces": ["system", "light", "battery", "wirelessconnectable", "update"], + "interfaces": ["system", "light", "battery", "wirelessconnectable", "update", "multibutton"], "createMethods": ["user", "discovery"], "browsable": true, "discoveryParamTypes": [ @@ -231,6 +231,19 @@ "defaultValue": 10 } ] + }, + { + "id": "f2708625-4b7b-42fd-9a18-3501d89ce599", + "name": "pressed", + "displayName": "Button pressed", + "paramTypes": [ + { + "id": "5f8adeb2-04f0-4b2e-9dbf-a91966bdcc24", + "name": "buttonName", + "displayName": "Button name", + "type": "QString" + } + ] } ], "actionTypes": [ @@ -277,6 +290,19 @@ "id": "f2b847dd-ab40-4278-940b-3615f1d7dfd3", "name": "performUpdate", "displayName": "Update firmware" + }, + { + "id": "592dfded-0144-4947-bd02-ca84c2124f39", + "name": "pressButton", + "displayName": "Press button", + "paramTypes": [ + { + "id": "279e0157-78ea-4bb3-a756-b12fb46cf4fc", + "name": "buttonName", + "displayName": "Button name", + "type": "QString" + } + ] } ], "browserItemActionTypes": [ @@ -619,6 +645,13 @@ "defaultValue": false, "writable": true } + ], + "eventTypes": [ + { + "id": "61ebadc0-47ea-4800-8c45-ee5222cddb4b", + "name": "event1", + "displayName": "Event 1" + } ] }, { @@ -638,6 +671,13 @@ "defaultValue": false, "writable": true } + ], + "eventTypes": [ + { + "id": "dad344b4-fff3-4803-b5cb-7cbb65aa5102", + "name": "event1", + "displayName": "Event 1" + } ] }, { diff --git a/plugins/mock/plugininfo.h b/plugins/mock/plugininfo.h index 7df309ca..4e2d4d9a 100644 --- a/plugins/mock/plugininfo.h +++ b/plugins/mock/plugininfo.h @@ -14,7 +14,7 @@ #include #include -extern "C" const QString libnymea_api_version() { return QString("7.2.0");} +extern "C" const QString libnymea_api_version() { return QString("7.3.0");} Q_DECLARE_LOGGING_CATEGORY(dcMock) Q_LOGGING_CATEGORY(dcMock, "Mock") @@ -43,33 +43,11 @@ StateTypeId mockSignalStrengthStateTypeId = StateTypeId("{2a0213bf-4af3-4384-904 StateTypeId mockUpdateStatusStateTypeId = StateTypeId("{ebc41327-53d5-40c2-8e7b-1164a8ff359e}"); StateTypeId mockCurrentVersionStateTypeId = StateTypeId("{9f2e1e5d-3f1f-4794-aca3-4e05b7a48842}"); StateTypeId mockAvailableVersionStateTypeId = StateTypeId("{060d7947-2b70-4a2b-b33b-a3577f71faeb}"); -EventTypeId mockIntEventTypeId = EventTypeId("{80baec19-54de-4948-ac46-31eabfaceb83}"); -ParamTypeId mockIntEventIntParamTypeId = ParamTypeId("{80baec19-54de-4948-ac46-31eabfaceb83}"); -EventTypeId mockIntWithLimitsEventTypeId = EventTypeId("{5aa479bd-537a-4716-9852-52f6eec58722}"); -ParamTypeId mockIntWithLimitsEventIntWithLimitsParamTypeId = ParamTypeId("{5aa479bd-537a-4716-9852-52f6eec58722}"); -EventTypeId mockBoolEventTypeId = EventTypeId("{9dd6a97c-dfd1-43dc-acbd-367932742310}"); -ParamTypeId mockBoolEventBoolParamTypeId = ParamTypeId("{9dd6a97c-dfd1-43dc-acbd-367932742310}"); -EventTypeId mockDoubleEventTypeId = EventTypeId("{7cac53ee-7048-4dc9-b000-7b585390f34c}"); -ParamTypeId mockDoubleEventDoubleParamTypeId = ParamTypeId("{7cac53ee-7048-4dc9-b000-7b585390f34c}"); -EventTypeId mockBatteryLevelEventTypeId = EventTypeId("{6c8ab9a6-0164-4795-b829-f4394fe4edc4}"); -ParamTypeId mockBatteryLevelEventBatteryLevelParamTypeId = ParamTypeId("{6c8ab9a6-0164-4795-b829-f4394fe4edc4}"); -EventTypeId mockBatteryCriticalEventTypeId = EventTypeId("{580bc611-1a55-41f3-996f-8d3ccf543db3}"); -ParamTypeId mockBatteryCriticalEventBatteryCriticalParamTypeId = ParamTypeId("{580bc611-1a55-41f3-996f-8d3ccf543db3}"); -EventTypeId mockPowerEventTypeId = EventTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}"); -ParamTypeId mockPowerEventPowerParamTypeId = ParamTypeId("{064aed0d-da4c-49d4-b236-60f97e98ff84}"); -EventTypeId mockConnectedEventTypeId = EventTypeId("{9860d105-2bd9-4651-9bc9-13ff4b9039a7}"); -ParamTypeId mockConnectedEventConnectedParamTypeId = ParamTypeId("{9860d105-2bd9-4651-9bc9-13ff4b9039a7}"); -EventTypeId mockSignalStrengthEventTypeId = EventTypeId("{2a0213bf-4af3-4384-904e-3376348a597e}"); -ParamTypeId mockSignalStrengthEventSignalStrengthParamTypeId = ParamTypeId("{2a0213bf-4af3-4384-904e-3376348a597e}"); -EventTypeId mockUpdateStatusEventTypeId = EventTypeId("{ebc41327-53d5-40c2-8e7b-1164a8ff359e}"); -ParamTypeId mockUpdateStatusEventUpdateStatusParamTypeId = ParamTypeId("{ebc41327-53d5-40c2-8e7b-1164a8ff359e}"); -EventTypeId mockCurrentVersionEventTypeId = EventTypeId("{9f2e1e5d-3f1f-4794-aca3-4e05b7a48842}"); -ParamTypeId mockCurrentVersionEventCurrentVersionParamTypeId = ParamTypeId("{9f2e1e5d-3f1f-4794-aca3-4e05b7a48842}"); -EventTypeId mockAvailableVersionEventTypeId = EventTypeId("{060d7947-2b70-4a2b-b33b-a3577f71faeb}"); -ParamTypeId mockAvailableVersionEventAvailableVersionParamTypeId = ParamTypeId("{060d7947-2b70-4a2b-b33b-a3577f71faeb}"); EventTypeId mockEvent1EventTypeId = EventTypeId("{45bf3752-0fc6-46b9-89fd-ffd878b5b22b}"); EventTypeId mockEvent2EventTypeId = EventTypeId("{863d5920-b1cf-4eb9-88bd-8f7b8583b1cf}"); ParamTypeId mockEvent2EventIntParamParamTypeId = ParamTypeId("{0550e16d-60b9-4ba5-83f4-4d3cee656121}"); +EventTypeId mockPressedEventTypeId = EventTypeId("{f2708625-4b7b-42fd-9a18-3501d89ce599}"); +ParamTypeId mockPressedEventButtonNameParamTypeId = ParamTypeId("{5f8adeb2-04f0-4b2e-9dbf-a91966bdcc24}"); ActionTypeId mockIntWithLimitsActionTypeId = ActionTypeId("{5aa479bd-537a-4716-9852-52f6eec58722}"); ParamTypeId mockIntWithLimitsActionIntWithLimitsParamTypeId = ParamTypeId("{5aa479bd-537a-4716-9852-52f6eec58722}"); ActionTypeId mockBatteryLevelActionTypeId = ActionTypeId("{6c8ab9a6-0164-4795-b829-f4394fe4edc4}"); @@ -88,6 +66,8 @@ ActionTypeId mockAsyncActionTypeId = ActionTypeId("{fbae06d3-7666-483e-a39e-ec50 ActionTypeId mockFailingActionTypeId = ActionTypeId("{df3cf33d-26d5-4577-9132-9823bd33fad0}"); ActionTypeId mockAsyncFailingActionTypeId = ActionTypeId("{bfe89a1d-3497-4121-8318-e77c37537219}"); ActionTypeId mockPerformUpdateActionTypeId = ActionTypeId("{f2b847dd-ab40-4278-940b-3615f1d7dfd3}"); +ActionTypeId mockPressButtonActionTypeId = ActionTypeId("{592dfded-0144-4947-bd02-ca84c2124f39}"); +ParamTypeId mockPressButtonActionButtonNameParamTypeId = ParamTypeId("{279e0157-78ea-4bb3-a756-b12fb46cf4fc}"); ActionTypeId mockAddToFavoritesBrowserItemActionTypeId = ActionTypeId("{00b8f0a8-99ca-4aa4-833d-59eb8d4d6de3}"); ActionTypeId mockRemoveFromFavoritesBrowserItemActionTypeId = ActionTypeId("{da6faef8-2816-430e-93bb-57e8f9582d29}"); ThingClassId autoMockThingClassId = ThingClassId("{ab4257b3-7548-47ee-9bd4-7dc3004fd197}"); @@ -97,10 +77,6 @@ ParamTypeId autoMockThingBrokenParamTypeId = ParamTypeId("{66179395-ef7a-4013-9f ParamTypeId autoMockSettingsMockSettingParamTypeId = ParamTypeId("{da0b9106-03cf-4631-87e9-26ade3360182}"); StateTypeId autoMockIntStateTypeId = StateTypeId("{74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}"); StateTypeId autoMockBoolValueStateTypeId = StateTypeId("{978b0ba5-d008-41bd-b63d-a3bd23cb6469}"); -EventTypeId autoMockIntEventTypeId = EventTypeId("{74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}"); -ParamTypeId autoMockIntEventIntParamTypeId = ParamTypeId("{74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}"); -EventTypeId autoMockBoolValueEventTypeId = EventTypeId("{978b0ba5-d008-41bd-b63d-a3bd23cb6469}"); -ParamTypeId autoMockBoolValueEventBoolValueParamTypeId = ParamTypeId("{978b0ba5-d008-41bd-b63d-a3bd23cb6469}"); EventTypeId autoMockEvent1EventTypeId = EventTypeId("{00f81fca-26f1-4a84-aa2b-4c6a3d953ec6}"); EventTypeId autoMockEvent2EventTypeId = EventTypeId("{6e27922d-aa9d-44d1-b9b4-9faf31b6bd97}"); ParamTypeId autoMockEvent2EventIntParamParamTypeId = ParamTypeId("{12ed5a15-96b4-4381-9d9c-a24875283d4f}"); @@ -118,16 +94,6 @@ StateTypeId pushButtonMockPercentageStateTypeId = StateTypeId("{72981c04-267a-4b StateTypeId pushButtonMockAllowedValuesStateTypeId = StateTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}"); StateTypeId pushButtonMockDoubleStateTypeId = StateTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}"); StateTypeId pushButtonMockBoolStateTypeId = StateTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}"); -EventTypeId pushButtonMockColorEventTypeId = EventTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}"); -ParamTypeId pushButtonMockColorEventColorParamTypeId = ParamTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}"); -EventTypeId pushButtonMockPercentageEventTypeId = EventTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}"); -ParamTypeId pushButtonMockPercentageEventPercentageParamTypeId = ParamTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}"); -EventTypeId pushButtonMockAllowedValuesEventTypeId = EventTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}"); -ParamTypeId pushButtonMockAllowedValuesEventAllowedValuesParamTypeId = ParamTypeId("{05f63f9c-f61e-4dcf-ad55-3f13fde2765b}"); -EventTypeId pushButtonMockDoubleEventTypeId = EventTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}"); -ParamTypeId pushButtonMockDoubleEventDoubleParamTypeId = ParamTypeId("{53cd7c55-49b7-441b-b970-9048f20f0e2c}"); -EventTypeId pushButtonMockBoolEventTypeId = EventTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}"); -ParamTypeId pushButtonMockBoolEventBoolParamTypeId = ParamTypeId("{e680f7a4-b39e-46da-be41-fa3170fe3768}"); ActionTypeId pushButtonMockColorActionTypeId = ActionTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}"); ParamTypeId pushButtonMockColorActionColorParamTypeId = ParamTypeId("{20dc7c22-c50e-42db-837c-2bbced939f8e}"); ActionTypeId pushButtonMockPercentageActionTypeId = ActionTypeId("{72981c04-267a-4ba0-a59e-9921d2f3af9c}"); @@ -147,16 +113,6 @@ StateTypeId displayPinMockPercentageStateTypeId = StateTypeId("{527f0687-0b28-4c StateTypeId displayPinMockAllowedValuesStateTypeId = StateTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}"); StateTypeId displayPinMockDoubleStateTypeId = StateTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}"); StateTypeId displayPinMockBoolStateTypeId = StateTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}"); -EventTypeId displayPinMockColorEventTypeId = EventTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}"); -ParamTypeId displayPinMockColorEventColorParamTypeId = ParamTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}"); -EventTypeId displayPinMockPercentageEventTypeId = EventTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}"); -ParamTypeId displayPinMockPercentageEventPercentageParamTypeId = ParamTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}"); -EventTypeId displayPinMockAllowedValuesEventTypeId = EventTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}"); -ParamTypeId displayPinMockAllowedValuesEventAllowedValuesParamTypeId = ParamTypeId("{b463c5ae-4d55-402f-8480-a5cdb485c143}"); -EventTypeId displayPinMockDoubleEventTypeId = EventTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}"); -ParamTypeId displayPinMockDoubleEventDoubleParamTypeId = ParamTypeId("{17635624-7c19-4bae-8429-2f7aa5d2f843}"); -EventTypeId displayPinMockBoolEventTypeId = EventTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}"); -ParamTypeId displayPinMockBoolEventBoolParamTypeId = ParamTypeId("{7ffe514f-7999-4998-8350-0e73e222a8c4}"); ActionTypeId displayPinMockColorActionTypeId = ActionTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}"); ParamTypeId displayPinMockColorActionColorParamTypeId = ParamTypeId("{3e161294-8a0d-4384-9676-6959e08cc2fa}"); ActionTypeId displayPinMockPercentageActionTypeId = ActionTypeId("{527f0687-0b28-4c26-852c-25b8f83e4797}"); @@ -170,14 +126,12 @@ ParamTypeId displayPinMockBoolActionBoolParamTypeId = ParamTypeId("{7ffe514f-799 ActionTypeId displayPinMockTimeoutActionTypeId = ActionTypeId("{854a0a4a-803f-4b7f-9dce-b07794f9011b}"); ThingClassId parentMockThingClassId = ThingClassId("{a71fbde9-9a38-4bf8-beab-c8aade2608ba}"); StateTypeId parentMockBoolValueStateTypeId = StateTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}"); -EventTypeId parentMockBoolValueEventTypeId = EventTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}"); -ParamTypeId parentMockBoolValueEventBoolValueParamTypeId = ParamTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}"); +EventTypeId parentMockEvent1EventTypeId = EventTypeId("{61ebadc0-47ea-4800-8c45-ee5222cddb4b}"); ActionTypeId parentMockBoolValueActionTypeId = ActionTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}"); ParamTypeId parentMockBoolValueActionBoolValueParamTypeId = ParamTypeId("{d24ede5f-4064-4898-bb84-cfb533b1fbc0}"); ThingClassId childMockThingClassId = ThingClassId("{40893c9f-bc47-40c1-8bf7-b390c7c1b4fc}"); StateTypeId childMockBoolValueStateTypeId = StateTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}"); -EventTypeId childMockBoolValueEventTypeId = EventTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}"); -ParamTypeId childMockBoolValueEventBoolValueParamTypeId = ParamTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}"); +EventTypeId childMockEvent1EventTypeId = EventTypeId("{dad344b4-fff3-4803-b5cb-7cbb65aa5102}"); ActionTypeId childMockBoolValueActionTypeId = ActionTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}"); ParamTypeId childMockBoolValueActionBoolValueParamTypeId = ParamTypeId("{80ba1449-b485-47d4-a067-6bf306e2a568}"); ThingClassId inputTypeMockThingClassId = ThingClassId("{515ffdf1-55e5-498d-9abc-4e2fe768f3a9}"); @@ -212,50 +166,6 @@ StateTypeId inputTypeMockTimestampIntStateTypeId = StateTypeId("{2c91b5ef-c2d1-4 StateTypeId inputTypeMockWritableTimestampIntStateTypeId = StateTypeId("{88b6746a-b009-4df6-8986-d7884ffd94b2}"); StateTypeId inputTypeMockTimestampUIntStateTypeId = StateTypeId("{6c9a96e8-0d48-4f42-8967-848358fd7f79}"); StateTypeId inputTypeMockWritableTimestampUIntStateTypeId = StateTypeId("{45d0069a-63ac-4265-8170-8152778608ee}"); -EventTypeId inputTypeMockBoolEventTypeId = EventTypeId("{3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}"); -ParamTypeId inputTypeMockBoolEventBoolParamTypeId = ParamTypeId("{3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}"); -EventTypeId inputTypeMockWritableBoolEventTypeId = EventTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}"); -ParamTypeId inputTypeMockWritableBoolEventWritableBoolParamTypeId = ParamTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}"); -EventTypeId inputTypeMockIntEventTypeId = EventTypeId("{d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}"); -ParamTypeId inputTypeMockIntEventIntParamTypeId = ParamTypeId("{d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}"); -EventTypeId inputTypeMockWritableIntEventTypeId = EventTypeId("{857a8422-983c-47d6-a15f-d8450b3162f7}"); -ParamTypeId inputTypeMockWritableIntEventWritableIntParamTypeId = ParamTypeId("{857a8422-983c-47d6-a15f-d8450b3162f7}"); -EventTypeId inputTypeMockWritableIntMinMaxEventTypeId = EventTypeId("{86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}"); -ParamTypeId inputTypeMockWritableIntMinMaxEventWritableIntMinMaxParamTypeId = ParamTypeId("{86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}"); -EventTypeId inputTypeMockUintEventTypeId = EventTypeId("{19e74fcc-bfd5-491f-8eb6-af128e8f1162}"); -ParamTypeId inputTypeMockUintEventUintParamTypeId = ParamTypeId("{19e74fcc-bfd5-491f-8eb6-af128e8f1162}"); -EventTypeId inputTypeMockWritableUIntEventTypeId = EventTypeId("{563e9c4c-5198-400a-9f6c-358f4752af58}"); -ParamTypeId inputTypeMockWritableUIntEventWritableUIntParamTypeId = ParamTypeId("{563e9c4c-5198-400a-9f6c-358f4752af58}"); -EventTypeId inputTypeMockWritableUIntMinMaxEventTypeId = EventTypeId("{79238998-eaab-4d71-b406-5d78f1749751}"); -ParamTypeId inputTypeMockWritableUIntMinMaxEventWritableUIntMinMaxParamTypeId = ParamTypeId("{79238998-eaab-4d71-b406-5d78f1749751}"); -EventTypeId inputTypeMockDoubleEventTypeId = EventTypeId("{f7d2063d-959e-46ac-8568-8b99722d3b22}"); -ParamTypeId inputTypeMockDoubleEventDoubleParamTypeId = ParamTypeId("{f7d2063d-959e-46ac-8568-8b99722d3b22}"); -EventTypeId inputTypeMockWritableDoubleEventTypeId = EventTypeId("{8e2eb91b-d60b-4461-9a50-d7b8ad263170}"); -ParamTypeId inputTypeMockWritableDoubleEventWritableDoubleParamTypeId = ParamTypeId("{8e2eb91b-d60b-4461-9a50-d7b8ad263170}"); -EventTypeId inputTypeMockWritableDoubleMinMaxEventTypeId = EventTypeId("{00d3425e-1da6-4748-8906-4555ceefb136}"); -ParamTypeId inputTypeMockWritableDoubleMinMaxEventWritableDoubleMinMaxParamTypeId = ParamTypeId("{00d3425e-1da6-4748-8906-4555ceefb136}"); -EventTypeId inputTypeMockStringEventTypeId = EventTypeId("{27f69ca9-a321-40ff-bfee-4b0272a671b4}"); -ParamTypeId inputTypeMockStringEventStringParamTypeId = ParamTypeId("{27f69ca9-a321-40ff-bfee-4b0272a671b4}"); -EventTypeId inputTypeMockWritableStringEventTypeId = EventTypeId("{ef511043-bd1a-4a5f-984c-222b7da43f38}"); -ParamTypeId inputTypeMockWritableStringEventWritableStringParamTypeId = ParamTypeId("{ef511043-bd1a-4a5f-984c-222b7da43f38}"); -EventTypeId inputTypeMockWritableStringSelectionEventTypeId = EventTypeId("{209d7afc-6fe9-4fe9-939b-e472ea0ad639}"); -ParamTypeId inputTypeMockWritableStringSelectionEventWritableStringSelectionParamTypeId = ParamTypeId("{209d7afc-6fe9-4fe9-939b-e472ea0ad639}"); -EventTypeId inputTypeMockColorEventTypeId = EventTypeId("{4507d5c6-b692-4bd6-87f2-00364bc0cb4d}"); -ParamTypeId inputTypeMockColorEventColorParamTypeId = ParamTypeId("{4507d5c6-b692-4bd6-87f2-00364bc0cb4d}"); -EventTypeId inputTypeMockWritableColorEventTypeId = EventTypeId("{455f4f68-3cb0-4e8a-a707-62e4a2a8035c}"); -ParamTypeId inputTypeMockWritableColorEventWritableColorParamTypeId = ParamTypeId("{455f4f68-3cb0-4e8a-a707-62e4a2a8035c}"); -EventTypeId inputTypeMockTimeEventTypeId = EventTypeId("{8250c71e-59bc-41ab-b576-99fcfc34e8d1}"); -ParamTypeId inputTypeMockTimeEventTimeParamTypeId = ParamTypeId("{8250c71e-59bc-41ab-b576-99fcfc34e8d1}"); -EventTypeId inputTypeMockWritableTimeEventTypeId = EventTypeId("{d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}"); -ParamTypeId inputTypeMockWritableTimeEventWritableTimeParamTypeId = ParamTypeId("{d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}"); -EventTypeId inputTypeMockTimestampIntEventTypeId = EventTypeId("{2c91b5ef-c2d1-4367-bc65-5a13abf69641}"); -ParamTypeId inputTypeMockTimestampIntEventTimestampIntParamTypeId = ParamTypeId("{2c91b5ef-c2d1-4367-bc65-5a13abf69641}"); -EventTypeId inputTypeMockWritableTimestampIntEventTypeId = EventTypeId("{88b6746a-b009-4df6-8986-d7884ffd94b2}"); -ParamTypeId inputTypeMockWritableTimestampIntEventWritableTimestampIntParamTypeId = ParamTypeId("{88b6746a-b009-4df6-8986-d7884ffd94b2}"); -EventTypeId inputTypeMockTimestampUIntEventTypeId = EventTypeId("{6c9a96e8-0d48-4f42-8967-848358fd7f79}"); -ParamTypeId inputTypeMockTimestampUIntEventTimestampUIntParamTypeId = ParamTypeId("{6c9a96e8-0d48-4f42-8967-848358fd7f79}"); -EventTypeId inputTypeMockWritableTimestampUIntEventTypeId = EventTypeId("{45d0069a-63ac-4265-8170-8152778608ee}"); -ParamTypeId inputTypeMockWritableTimestampUIntEventWritableTimestampUIntParamTypeId = ParamTypeId("{45d0069a-63ac-4265-8170-8152778608ee}"); ActionTypeId inputTypeMockWritableBoolActionTypeId = ActionTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}"); ParamTypeId inputTypeMockWritableBoolActionWritableBoolParamTypeId = ParamTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}"); ActionTypeId inputTypeMockWritableIntActionTypeId = ActionTypeId("{857a8422-983c-47d6-a15f-d8450b3162f7}"); @@ -294,22 +204,6 @@ StateTypeId genericIoMockAnalogInput1StateTypeId = StateTypeId("{ac56977c-cbba-4 StateTypeId genericIoMockAnalogInput2StateTypeId = StateTypeId("{8e07e57e-ba4e-42df-81ee-5b72ed074532}"); StateTypeId genericIoMockAnalogOutput1StateTypeId = StateTypeId("{70cf053e-4abc-4d88-8e1e-2bd9a62256c7}"); StateTypeId genericIoMockAnalogOutput2StateTypeId = StateTypeId("{e40bcf7d-47b8-41fa-b213-3652a905b376}"); -EventTypeId genericIoMockDigitalInput1EventTypeId = EventTypeId("{07165c12-4d53-45c0-8bf1-34618443b706}"); -ParamTypeId genericIoMockDigitalInput1EventDigitalInput1ParamTypeId = ParamTypeId("{07165c12-4d53-45c0-8bf1-34618443b706}"); -EventTypeId genericIoMockDigitalInput2EventTypeId = EventTypeId("{0a4362ba-a086-4540-84ba-107ef7b99ed8}"); -ParamTypeId genericIoMockDigitalInput2EventDigitalInput2ParamTypeId = ParamTypeId("{0a4362ba-a086-4540-84ba-107ef7b99ed8}"); -EventTypeId genericIoMockDigitalOutput1EventTypeId = EventTypeId("{d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}"); -ParamTypeId genericIoMockDigitalOutput1EventDigitalOutput1ParamTypeId = ParamTypeId("{d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}"); -EventTypeId genericIoMockDigitalOutput2EventTypeId = EventTypeId("{35de8b68-0cf3-4850-a27d-cf9c4a26921f}"); -ParamTypeId genericIoMockDigitalOutput2EventDigitalOutput2ParamTypeId = ParamTypeId("{35de8b68-0cf3-4850-a27d-cf9c4a26921f}"); -EventTypeId genericIoMockAnalogInput1EventTypeId = EventTypeId("{ac56977c-cbba-47c6-a827-5735d8b0aed6}"); -ParamTypeId genericIoMockAnalogInput1EventAnalogInput1ParamTypeId = ParamTypeId("{ac56977c-cbba-47c6-a827-5735d8b0aed6}"); -EventTypeId genericIoMockAnalogInput2EventTypeId = EventTypeId("{8e07e57e-ba4e-42df-81ee-5b72ed074532}"); -ParamTypeId genericIoMockAnalogInput2EventAnalogInput2ParamTypeId = ParamTypeId("{8e07e57e-ba4e-42df-81ee-5b72ed074532}"); -EventTypeId genericIoMockAnalogOutput1EventTypeId = EventTypeId("{70cf053e-4abc-4d88-8e1e-2bd9a62256c7}"); -ParamTypeId genericIoMockAnalogOutput1EventAnalogOutput1ParamTypeId = ParamTypeId("{70cf053e-4abc-4d88-8e1e-2bd9a62256c7}"); -EventTypeId genericIoMockAnalogOutput2EventTypeId = EventTypeId("{e40bcf7d-47b8-41fa-b213-3652a905b376}"); -ParamTypeId genericIoMockAnalogOutput2EventAnalogOutput2ParamTypeId = ParamTypeId("{e40bcf7d-47b8-41fa-b213-3652a905b376}"); ActionTypeId genericIoMockDigitalOutput1ActionTypeId = ActionTypeId("{d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}"); ParamTypeId genericIoMockDigitalOutput1ActionDigitalOutput1ParamTypeId = ParamTypeId("{d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}"); ActionTypeId genericIoMockDigitalOutput2ActionTypeId = ActionTypeId("{35de8b68-0cf3-4850-a27d-cf9c4a26921f}"); @@ -322,8 +216,6 @@ ActionTypeId genericIoMockAnalogOutput2ActionTypeId = ActionTypeId("{e40bcf7d-47 ParamTypeId genericIoMockAnalogOutput2ActionAnalogOutput2ParamTypeId = ParamTypeId("{e40bcf7d-47b8-41fa-b213-3652a905b376}"); ThingClassId virtualIoLightMockThingClassId = ThingClassId("{98ab137e-757e-43f8-9d9b-5d50d990242a}"); StateTypeId virtualIoLightMockPowerStateTypeId = StateTypeId("{d1917b3d-1530-4cf9-90f7-263ee88e714b}"); -EventTypeId virtualIoLightMockPowerEventTypeId = EventTypeId("{d1917b3d-1530-4cf9-90f7-263ee88e714b}"); -ParamTypeId virtualIoLightMockPowerEventPowerParamTypeId = ParamTypeId("{d1917b3d-1530-4cf9-90f7-263ee88e714b}"); ActionTypeId virtualIoLightMockPowerActionTypeId = ActionTypeId("{d1917b3d-1530-4cf9-90f7-263ee88e714b}"); ParamTypeId virtualIoLightMockPowerActionPowerParamTypeId = ParamTypeId("{d1917b3d-1530-4cf9-90f7-263ee88e714b}"); ThingClassId virtualIoTemperatureSensorMockThingClassId = ThingClassId("{f8917e12-c9cb-4ea1-a06e-1ce6db2194f3}"); @@ -331,10 +223,6 @@ ParamTypeId virtualIoTemperatureSensorMockSettingsMinTempParamTypeId = ParamType ParamTypeId virtualIoTemperatureSensorMockSettingsMaxTempParamTypeId = ParamTypeId("{7077c56f-c35b-4252-8c15-8fb549be04ce}"); StateTypeId virtualIoTemperatureSensorMockInputStateTypeId = StateTypeId("{fd341f72-6d9a-4812-9f66-47197c48a935}"); StateTypeId virtualIoTemperatureSensorMockTemperatureStateTypeId = StateTypeId("{db9cc518-1012-47e2-8212-6e616fed07a6}"); -EventTypeId virtualIoTemperatureSensorMockInputEventTypeId = EventTypeId("{fd341f72-6d9a-4812-9f66-47197c48a935}"); -ParamTypeId virtualIoTemperatureSensorMockInputEventInputParamTypeId = ParamTypeId("{fd341f72-6d9a-4812-9f66-47197c48a935}"); -EventTypeId virtualIoTemperatureSensorMockTemperatureEventTypeId = EventTypeId("{db9cc518-1012-47e2-8212-6e616fed07a6}"); -ParamTypeId virtualIoTemperatureSensorMockTemperatureEventTemperatureParamTypeId = ParamTypeId("{db9cc518-1012-47e2-8212-6e616fed07a6}"); ActionTypeId virtualIoTemperatureSensorMockInputActionTypeId = ActionTypeId("{fd341f72-6d9a-4812-9f66-47197c48a935}"); ParamTypeId virtualIoTemperatureSensorMockInputActionInputParamTypeId = ParamTypeId("{fd341f72-6d9a-4812-9f66-47197c48a935}"); @@ -345,213 +233,102 @@ const QString translations[] { //: The name of the ParamType (ThingClass: genericIoMock, ActionType: analogInput1, ID: {ac56977c-cbba-47c6-a827-5735d8b0aed6}) QT_TRANSLATE_NOOP("mock", "Analog Input 1"), - //: The name of the ParamType (ThingClass: genericIoMock, EventType: analogInput1, ID: {ac56977c-cbba-47c6-a827-5735d8b0aed6}) - QT_TRANSLATE_NOOP("mock", "Analog Input 1"), - //: The name of the StateType ({ac56977c-cbba-47c6-a827-5735d8b0aed6}) of ThingClass genericIoMock QT_TRANSLATE_NOOP("mock", "Analog Input 1"), - //: The name of the EventType ({ac56977c-cbba-47c6-a827-5735d8b0aed6}) of ThingClass genericIoMock - QT_TRANSLATE_NOOP("mock", "Analog Input 1 changed"), - - //: The name of the ParamType (ThingClass: genericIoMock, EventType: analogInput2, ID: {8e07e57e-ba4e-42df-81ee-5b72ed074532}) - QT_TRANSLATE_NOOP("mock", "Analog Input 2"), - //: The name of the StateType ({8e07e57e-ba4e-42df-81ee-5b72ed074532}) of ThingClass genericIoMock QT_TRANSLATE_NOOP("mock", "Analog Input 2"), - //: The name of the EventType ({8e07e57e-ba4e-42df-81ee-5b72ed074532}) of ThingClass genericIoMock - QT_TRANSLATE_NOOP("mock", "Analog Input 2 changed"), - //: The name of the ParamType (ThingClass: genericIoMock, ActionType: analogOutput1, ID: {70cf053e-4abc-4d88-8e1e-2bd9a62256c7}) QT_TRANSLATE_NOOP("mock", "Analog Output 1"), - //: The name of the ParamType (ThingClass: genericIoMock, EventType: analogOutput1, ID: {70cf053e-4abc-4d88-8e1e-2bd9a62256c7}) - QT_TRANSLATE_NOOP("mock", "Analog Output 1"), - //: The name of the StateType ({70cf053e-4abc-4d88-8e1e-2bd9a62256c7}) of ThingClass genericIoMock QT_TRANSLATE_NOOP("mock", "Analog Output 1"), - //: The name of the EventType ({70cf053e-4abc-4d88-8e1e-2bd9a62256c7}) of ThingClass genericIoMock - QT_TRANSLATE_NOOP("mock", "Analog Output 1 changed"), - //: The name of the ParamType (ThingClass: genericIoMock, ActionType: analogOutput2, ID: {e40bcf7d-47b8-41fa-b213-3652a905b376}) QT_TRANSLATE_NOOP("mock", "Analog Output 2"), - //: The name of the ParamType (ThingClass: genericIoMock, EventType: analogOutput2, ID: {e40bcf7d-47b8-41fa-b213-3652a905b376}) - QT_TRANSLATE_NOOP("mock", "Analog Output 2"), - //: The name of the StateType ({e40bcf7d-47b8-41fa-b213-3652a905b376}) of ThingClass genericIoMock QT_TRANSLATE_NOOP("mock", "Analog Output 2"), - //: The name of the EventType ({e40bcf7d-47b8-41fa-b213-3652a905b376}) of ThingClass genericIoMock - QT_TRANSLATE_NOOP("mock", "Analog Output 2 changed"), - - //: The name of the ParamType (ThingClass: mock, EventType: availableVersion, ID: {060d7947-2b70-4a2b-b33b-a3577f71faeb}) - QT_TRANSLATE_NOOP("mock", "Available firmware version"), - //: The name of the StateType ({060d7947-2b70-4a2b-b33b-a3577f71faeb}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Available firmware version"), - //: The name of the EventType ({060d7947-2b70-4a2b-b33b-a3577f71faeb}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Available firmware version changed"), - //: The name of the ParamType (ThingClass: mock, ActionType: batteryLevel, ID: {6c8ab9a6-0164-4795-b829-f4394fe4edc4}) QT_TRANSLATE_NOOP("mock", "Battery level"), - //: The name of the ParamType (ThingClass: mock, EventType: batteryLevel, ID: {6c8ab9a6-0164-4795-b829-f4394fe4edc4}) - QT_TRANSLATE_NOOP("mock", "Battery level"), - - //: The name of the EventType ({6c8ab9a6-0164-4795-b829-f4394fe4edc4}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Battery level"), - //: The name of the StateType ({6c8ab9a6-0164-4795-b829-f4394fe4edc4}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Battery level"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: bool, ID: {3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}) - QT_TRANSLATE_NOOP("mock", "Bool"), - //: The name of the StateType ({3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Bool"), - //: The name of the EventType ({3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Bool changed"), + //: The name of the ParamType (ThingClass: mock, ActionType: pressButton, ID: {279e0157-78ea-4bb3-a756-b12fb46cf4fc}) + QT_TRANSLATE_NOOP("mock", "Button name"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: color, ID: {4507d5c6-b692-4bd6-87f2-00364bc0cb4d}) - QT_TRANSLATE_NOOP("mock", "Color"), + //: The name of the ParamType (ThingClass: mock, EventType: pressed, ID: {5f8adeb2-04f0-4b2e-9dbf-a91966bdcc24}) + QT_TRANSLATE_NOOP("mock", "Button name"), + + //: The name of the EventType ({f2708625-4b7b-42fd-9a18-3501d89ce599}) of ThingClass mock + QT_TRANSLATE_NOOP("mock", "Button pressed"), //: The name of the StateType ({4507d5c6-b692-4bd6-87f2-00364bc0cb4d}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Color"), - //: The name of the EventType ({4507d5c6-b692-4bd6-87f2-00364bc0cb4d}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Color changed"), - - //: The name of the ParamType (ThingClass: mock, EventType: connected, ID: {9860d105-2bd9-4651-9bc9-13ff4b9039a7}) - QT_TRANSLATE_NOOP("mock", "Connected"), - //: The name of the StateType ({9860d105-2bd9-4651-9bc9-13ff4b9039a7}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Connected"), - //: The name of the EventType ({9860d105-2bd9-4651-9bc9-13ff4b9039a7}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Connected changed"), - //: The name of the ParamType (ThingClass: genericIoMock, ActionType: digitalOutput1, ID: {d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}) QT_TRANSLATE_NOOP("mock", "Digital Output 1"), - //: The name of the ParamType (ThingClass: genericIoMock, EventType: digitalOutput1, ID: {d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}) - QT_TRANSLATE_NOOP("mock", "Digital Output 1"), - //: The name of the StateType ({d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}) of ThingClass genericIoMock QT_TRANSLATE_NOOP("mock", "Digital Output 1"), - //: The name of the EventType ({d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}) of ThingClass genericIoMock - QT_TRANSLATE_NOOP("mock", "Digital Output 1 changed"), - //: The name of the ParamType (ThingClass: genericIoMock, ActionType: digitalOutput2, ID: {35de8b68-0cf3-4850-a27d-cf9c4a26921f}) QT_TRANSLATE_NOOP("mock", "Digital Output 2"), - //: The name of the ParamType (ThingClass: genericIoMock, EventType: digitalOutput2, ID: {35de8b68-0cf3-4850-a27d-cf9c4a26921f}) - QT_TRANSLATE_NOOP("mock", "Digital Output 2"), - //: The name of the StateType ({35de8b68-0cf3-4850-a27d-cf9c4a26921f}) of ThingClass genericIoMock QT_TRANSLATE_NOOP("mock", "Digital Output 2"), - //: The name of the EventType ({35de8b68-0cf3-4850-a27d-cf9c4a26921f}) of ThingClass genericIoMock - QT_TRANSLATE_NOOP("mock", "Digital Output 2 changed"), - - //: The name of the ParamType (ThingClass: genericIoMock, EventType: digitalInput1, ID: {07165c12-4d53-45c0-8bf1-34618443b706}) - QT_TRANSLATE_NOOP("mock", "Digital input 1"), - //: The name of the StateType ({07165c12-4d53-45c0-8bf1-34618443b706}) of ThingClass genericIoMock QT_TRANSLATE_NOOP("mock", "Digital input 1"), - //: The name of the EventType ({07165c12-4d53-45c0-8bf1-34618443b706}) of ThingClass genericIoMock - QT_TRANSLATE_NOOP("mock", "Digital input 1 changed"), - - //: The name of the ParamType (ThingClass: genericIoMock, EventType: digitalInput2, ID: {0a4362ba-a086-4540-84ba-107ef7b99ed8}) - QT_TRANSLATE_NOOP("mock", "Digital input 2"), - //: The name of the StateType ({0a4362ba-a086-4540-84ba-107ef7b99ed8}) of ThingClass genericIoMock QT_TRANSLATE_NOOP("mock", "Digital input 2"), - //: The name of the EventType ({0a4362ba-a086-4540-84ba-107ef7b99ed8}) of ThingClass genericIoMock - QT_TRANSLATE_NOOP("mock", "Digital input 2 changed"), - - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: double, ID: {f7d2063d-959e-46ac-8568-8b99722d3b22}) - QT_TRANSLATE_NOOP("mock", "Double"), - //: The name of the StateType ({f7d2063d-959e-46ac-8568-8b99722d3b22}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Double"), - //: The name of the EventType ({f7d2063d-959e-46ac-8568-8b99722d3b22}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Double changed"), - - //: The name of the ParamType (ThingClass: autoMock, EventType: boolValue, ID: {978b0ba5-d008-41bd-b63d-a3bd23cb6469}) - QT_TRANSLATE_NOOP("mock", "Dummy bool state"), - //: The name of the StateType ({978b0ba5-d008-41bd-b63d-a3bd23cb6469}) of ThingClass autoMock QT_TRANSLATE_NOOP("mock", "Dummy bool state"), - //: The name of the ParamType (ThingClass: mock, EventType: bool, ID: {9dd6a97c-dfd1-43dc-acbd-367932742310}) - QT_TRANSLATE_NOOP("mock", "Dummy bool state"), - //: The name of the StateType ({9dd6a97c-dfd1-43dc-acbd-367932742310}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Dummy bool state"), - //: The name of the EventType ({978b0ba5-d008-41bd-b63d-a3bd23cb6469}) of ThingClass autoMock - QT_TRANSLATE_NOOP("mock", "Dummy bool state changed"), - - //: The name of the EventType ({9dd6a97c-dfd1-43dc-acbd-367932742310}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Dummy bool state changed"), - - //: The name of the ParamType (ThingClass: mock, EventType: double, ID: {7cac53ee-7048-4dc9-b000-7b585390f34c}) - QT_TRANSLATE_NOOP("mock", "Dummy double state"), - //: The name of the StateType ({7cac53ee-7048-4dc9-b000-7b585390f34c}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Dummy double state"), - //: The name of the EventType ({7cac53ee-7048-4dc9-b000-7b585390f34c}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Dummy double state changed"), - - //: The name of the ParamType (ThingClass: autoMock, EventType: int, ID: {74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}) - QT_TRANSLATE_NOOP("mock", "Dummy int state"), - //: The name of the StateType ({74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}) of ThingClass autoMock QT_TRANSLATE_NOOP("mock", "Dummy int state"), - //: The name of the ParamType (ThingClass: mock, EventType: int, ID: {80baec19-54de-4948-ac46-31eabfaceb83}) - QT_TRANSLATE_NOOP("mock", "Dummy int state"), - //: The name of the StateType ({80baec19-54de-4948-ac46-31eabfaceb83}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Dummy int state"), - //: The name of the EventType ({74b24296-ba0b-4fbd-87f3-1b09a8bc3e8c}) of ThingClass autoMock - QT_TRANSLATE_NOOP("mock", "Dummy int state changed"), - - //: The name of the EventType ({80baec19-54de-4948-ac46-31eabfaceb83}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Dummy int state changed"), - //: The name of the ParamType (ThingClass: mock, ActionType: intWithLimits, ID: {5aa479bd-537a-4716-9852-52f6eec58722}) QT_TRANSLATE_NOOP("mock", "Dummy int state with limits"), - //: The name of the ParamType (ThingClass: mock, EventType: intWithLimits, ID: {5aa479bd-537a-4716-9852-52f6eec58722}) - QT_TRANSLATE_NOOP("mock", "Dummy int state with limits"), - //: The name of the StateType ({5aa479bd-537a-4716-9852-52f6eec58722}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Dummy int state with limits"), - //: The name of the EventType ({5aa479bd-537a-4716-9852-52f6eec58722}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Dummy int state with limits changed"), + //: The name of the EventType ({dad344b4-fff3-4803-b5cb-7cbb65aa5102}) of ThingClass childMock + QT_TRANSLATE_NOOP("mock", "Event 1"), - //: The name of the ParamType (ThingClass: mock, EventType: currentVersion, ID: {9f2e1e5d-3f1f-4794-aca3-4e05b7a48842}) - QT_TRANSLATE_NOOP("mock", "Firmware version"), + //: The name of the EventType ({61ebadc0-47ea-4800-8c45-ee5222cddb4b}) of ThingClass parentMock + QT_TRANSLATE_NOOP("mock", "Event 1"), //: The name of the StateType ({9f2e1e5d-3f1f-4794-aca3-4e05b7a48842}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Firmware version"), - //: The name of the EventType ({9f2e1e5d-3f1f-4794-aca3-4e05b7a48842}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Firmware version changed"), - //: The name of the ThingClass ({7cbd729a-465b-4ccb-b59c-5733039dbbed}) QT_TRANSLATE_NOOP("mock", "Generic IO pins"), @@ -570,24 +347,12 @@ const QString translations[] { //: The name of the ParamType (ThingClass: virtualIoTemperatureSensorMock, ActionType: input, ID: {fd341f72-6d9a-4812-9f66-47197c48a935}) QT_TRANSLATE_NOOP("mock", "Input"), - //: The name of the ParamType (ThingClass: virtualIoTemperatureSensorMock, EventType: input, ID: {fd341f72-6d9a-4812-9f66-47197c48a935}) - QT_TRANSLATE_NOOP("mock", "Input"), - //: The name of the StateType ({fd341f72-6d9a-4812-9f66-47197c48a935}) of ThingClass virtualIoTemperatureSensorMock QT_TRANSLATE_NOOP("mock", "Input"), - //: The name of the EventType ({fd341f72-6d9a-4812-9f66-47197c48a935}) of ThingClass virtualIoTemperatureSensorMock - QT_TRANSLATE_NOOP("mock", "Input changed"), - - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: int, ID: {d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}) - QT_TRANSLATE_NOOP("mock", "Int"), - //: The name of the StateType ({d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Int"), - //: The name of the EventType ({d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Int changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, Type: thing, ID: {e93db587-7919-48f3-8c88-1651de63c765}) QT_TRANSLATE_NOOP("mock", "Mac address"), @@ -690,14 +455,11 @@ const QString translations[] { //: The name of the ParamType (ThingClass: virtualIoLightMock, ActionType: power, ID: {d1917b3d-1530-4cf9-90f7-263ee88e714b}) QT_TRANSLATE_NOOP("mock", "Power"), - //: The name of the ParamType (ThingClass: virtualIoLightMock, EventType: power, ID: {d1917b3d-1530-4cf9-90f7-263ee88e714b}) - QT_TRANSLATE_NOOP("mock", "Power"), - //: The name of the StateType ({d1917b3d-1530-4cf9-90f7-263ee88e714b}) of ThingClass virtualIoLightMock QT_TRANSLATE_NOOP("mock", "Power"), - //: The name of the EventType ({d1917b3d-1530-4cf9-90f7-263ee88e714b}) of ThingClass virtualIoLightMock - QT_TRANSLATE_NOOP("mock", "Power changed"), + //: The name of the ActionType ({592dfded-0144-4947-bd02-ca84c2124f39}) of ThingClass mock + QT_TRANSLATE_NOOP("mock", "Press button"), //: The name of the Browser Item ActionType ({da6faef8-2816-430e-93bb-57e8f9582d29}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Remove from favorites"), @@ -822,81 +584,39 @@ const QString translations[] { //: The name of the ParamType (ThingClass: mock, ActionType: signalStrength, ID: {2a0213bf-4af3-4384-904e-3376348a597e}) QT_TRANSLATE_NOOP("mock", "Signal strength"), - //: The name of the ParamType (ThingClass: mock, EventType: signalStrength, ID: {2a0213bf-4af3-4384-904e-3376348a597e}) - QT_TRANSLATE_NOOP("mock", "Signal strength"), - //: The name of the StateType ({2a0213bf-4af3-4384-904e-3376348a597e}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Signal strength"), - //: The name of the EventType ({2a0213bf-4af3-4384-904e-3376348a597e}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Signal strength changed"), - - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: string, ID: {27f69ca9-a321-40ff-bfee-4b0272a671b4}) - QT_TRANSLATE_NOOP("mock", "String"), - //: The name of the StateType ({27f69ca9-a321-40ff-bfee-4b0272a671b4}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "String"), - //: The name of the EventType ({27f69ca9-a321-40ff-bfee-4b0272a671b4}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "String changed"), - - //: The name of the ParamType (ThingClass: virtualIoTemperatureSensorMock, EventType: temperature, ID: {db9cc518-1012-47e2-8212-6e616fed07a6}) - QT_TRANSLATE_NOOP("mock", "Temperature"), - //: The name of the StateType ({db9cc518-1012-47e2-8212-6e616fed07a6}) of ThingClass virtualIoTemperatureSensorMock QT_TRANSLATE_NOOP("mock", "Temperature"), - //: The name of the EventType ({db9cc518-1012-47e2-8212-6e616fed07a6}) of ThingClass virtualIoTemperatureSensorMock - QT_TRANSLATE_NOOP("mock", "Temperature changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, Type: thing, ID: {716f0994-bc01-42b0-b64d-59236f7320d2}) QT_TRANSLATE_NOOP("mock", "Text area"), //: The name of the ParamType (ThingClass: inputTypeMock, Type: thing, ID: {e6acf0c7-4b8e-4296-ac62-855d20deb816}) QT_TRANSLATE_NOOP("mock", "Text line"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: time, ID: {8250c71e-59bc-41ab-b576-99fcfc34e8d1}) - QT_TRANSLATE_NOOP("mock", "Time"), - //: The name of the StateType ({8250c71e-59bc-41ab-b576-99fcfc34e8d1}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Time"), - //: The name of the EventType ({8250c71e-59bc-41ab-b576-99fcfc34e8d1}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Time changed"), - //: The name of the ActionType ({854a0a4a-803f-4b7f-9dce-b07794f9011b}) of ThingClass displayPinMock QT_TRANSLATE_NOOP("mock", "Timeout action"), //: The name of the ActionType ({54646e7c-bc54-4895-81a2-590d72d120f9}) of ThingClass pushButtonMock QT_TRANSLATE_NOOP("mock", "Timeout action"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: timestampInt, ID: {2c91b5ef-c2d1-4367-bc65-5a13abf69641}) - QT_TRANSLATE_NOOP("mock", "Timestamp (Int)"), - //: The name of the StateType ({2c91b5ef-c2d1-4367-bc65-5a13abf69641}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Timestamp (Int)"), - //: The name of the EventType ({2c91b5ef-c2d1-4367-bc65-5a13abf69641}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Timestamp (Int) changed"), - - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: timestampUInt, ID: {6c9a96e8-0d48-4f42-8967-848358fd7f79}) - QT_TRANSLATE_NOOP("mock", "Timestamp (UInt)"), - //: The name of the StateType ({6c9a96e8-0d48-4f42-8967-848358fd7f79}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Timestamp (UInt)"), - //: The name of the EventType ({6c9a96e8-0d48-4f42-8967-848358fd7f79}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Timestamp (UInt) changed"), - - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: uint, ID: {19e74fcc-bfd5-491f-8eb6-af128e8f1162}) - QT_TRANSLATE_NOOP("mock", "UInt"), - //: The name of the StateType ({19e74fcc-bfd5-491f-8eb6-af128e8f1162}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "UInt"), - //: The name of the EventType ({19e74fcc-bfd5-491f-8eb6-af128e8f1162}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "UInt changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, Type: thing, ID: {fa67229f-fcef-496f-b671-59a4b48f3ab5}) QT_TRANSLATE_NOOP("mock", "URL"), @@ -906,258 +626,132 @@ const QString translations[] { //: The name of the ParamType (ThingClass: mock, ActionType: updateStatus, ID: {ebc41327-53d5-40c2-8e7b-1164a8ff359e}) QT_TRANSLATE_NOOP("mock", "Update status"), - //: The name of the ParamType (ThingClass: mock, EventType: updateStatus, ID: {ebc41327-53d5-40c2-8e7b-1164a8ff359e}) - QT_TRANSLATE_NOOP("mock", "Update status"), - //: The name of the StateType ({ebc41327-53d5-40c2-8e7b-1164a8ff359e}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Update status"), - //: The name of the EventType ({ebc41327-53d5-40c2-8e7b-1164a8ff359e}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "Update status changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableBool, ID: {a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}) QT_TRANSLATE_NOOP("mock", "Writable Bool"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableBool, ID: {a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}) - QT_TRANSLATE_NOOP("mock", "Writable Bool"), - //: The name of the StateType ({a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable Bool"), - //: The name of the EventType ({a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable Bool changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableColor, ID: {455f4f68-3cb0-4e8a-a707-62e4a2a8035c}) QT_TRANSLATE_NOOP("mock", "Writable Color"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableColor, ID: {455f4f68-3cb0-4e8a-a707-62e4a2a8035c}) - QT_TRANSLATE_NOOP("mock", "Writable Color"), - //: The name of the StateType ({455f4f68-3cb0-4e8a-a707-62e4a2a8035c}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable Color"), - //: The name of the EventType ({455f4f68-3cb0-4e8a-a707-62e4a2a8035c}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable Color changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableDouble, ID: {8e2eb91b-d60b-4461-9a50-d7b8ad263170}) QT_TRANSLATE_NOOP("mock", "Writable Double"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableDouble, ID: {8e2eb91b-d60b-4461-9a50-d7b8ad263170}) - QT_TRANSLATE_NOOP("mock", "Writable Double"), - //: The name of the StateType ({8e2eb91b-d60b-4461-9a50-d7b8ad263170}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable Double"), //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableDoubleMinMax, ID: {00d3425e-1da6-4748-8906-4555ceefb136}) QT_TRANSLATE_NOOP("mock", "Writable Double (min/max)"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableDoubleMinMax, ID: {00d3425e-1da6-4748-8906-4555ceefb136}) - QT_TRANSLATE_NOOP("mock", "Writable Double (min/max)"), - //: The name of the StateType ({00d3425e-1da6-4748-8906-4555ceefb136}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable Double (min/max)"), - //: The name of the EventType ({00d3425e-1da6-4748-8906-4555ceefb136}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable Double (min/max) changed"), - - //: The name of the EventType ({8e2eb91b-d60b-4461-9a50-d7b8ad263170}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable Double changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableInt, ID: {857a8422-983c-47d6-a15f-d8450b3162f7}) QT_TRANSLATE_NOOP("mock", "Writable Int"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableInt, ID: {857a8422-983c-47d6-a15f-d8450b3162f7}) - QT_TRANSLATE_NOOP("mock", "Writable Int"), - //: The name of the StateType ({857a8422-983c-47d6-a15f-d8450b3162f7}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable Int"), //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableIntMinMax, ID: {86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}) QT_TRANSLATE_NOOP("mock", "Writable Int (min/max)"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableIntMinMax, ID: {86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}) - QT_TRANSLATE_NOOP("mock", "Writable Int (min/max)"), - //: The name of the StateType ({86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable Int (min/max)"), - //: The name of the EventType ({86a107bc-510a-4d38-bfeb-0a9c2b6d8d87}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable Int (min/max) changed"), - - //: The name of the EventType ({857a8422-983c-47d6-a15f-d8450b3162f7}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable Int changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableString, ID: {ef511043-bd1a-4a5f-984c-222b7da43f38}) QT_TRANSLATE_NOOP("mock", "Writable String"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableString, ID: {ef511043-bd1a-4a5f-984c-222b7da43f38}) - QT_TRANSLATE_NOOP("mock", "Writable String"), - //: The name of the StateType ({ef511043-bd1a-4a5f-984c-222b7da43f38}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable String"), //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableStringSelection, ID: {209d7afc-6fe9-4fe9-939b-e472ea0ad639}) QT_TRANSLATE_NOOP("mock", "Writable String (selection)"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableStringSelection, ID: {209d7afc-6fe9-4fe9-939b-e472ea0ad639}) - QT_TRANSLATE_NOOP("mock", "Writable String (selection)"), - //: The name of the StateType ({209d7afc-6fe9-4fe9-939b-e472ea0ad639}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable String (selection)"), - //: The name of the EventType ({209d7afc-6fe9-4fe9-939b-e472ea0ad639}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable String (selection) changed"), - - //: The name of the EventType ({ef511043-bd1a-4a5f-984c-222b7da43f38}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable String changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableTime, ID: {d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}) QT_TRANSLATE_NOOP("mock", "Writable Time"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableTime, ID: {d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}) - QT_TRANSLATE_NOOP("mock", "Writable Time"), - //: The name of the StateType ({d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable Time"), - //: The name of the EventType ({d64c8b3f-ca7d-47f6-b271-867ffd80a4d4}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable Time changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableTimestampInt, ID: {88b6746a-b009-4df6-8986-d7884ffd94b2}) QT_TRANSLATE_NOOP("mock", "Writable Timestamp (Int)"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableTimestampInt, ID: {88b6746a-b009-4df6-8986-d7884ffd94b2}) - QT_TRANSLATE_NOOP("mock", "Writable Timestamp (Int)"), - //: The name of the StateType ({88b6746a-b009-4df6-8986-d7884ffd94b2}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable Timestamp (Int)"), - //: The name of the EventType ({88b6746a-b009-4df6-8986-d7884ffd94b2}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable Timestamp (Int) changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableTimestampUInt, ID: {45d0069a-63ac-4265-8170-8152778608ee}) QT_TRANSLATE_NOOP("mock", "Writable Timestamp (UInt)"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableTimestampUInt, ID: {45d0069a-63ac-4265-8170-8152778608ee}) - QT_TRANSLATE_NOOP("mock", "Writable Timestamp (UInt)"), - //: The name of the StateType ({45d0069a-63ac-4265-8170-8152778608ee}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable Timestamp (UInt)"), - //: The name of the EventType ({45d0069a-63ac-4265-8170-8152778608ee}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable Timestamp (UInt) changed"), - //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableUInt, ID: {563e9c4c-5198-400a-9f6c-358f4752af58}) QT_TRANSLATE_NOOP("mock", "Writable UInt"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableUInt, ID: {563e9c4c-5198-400a-9f6c-358f4752af58}) - QT_TRANSLATE_NOOP("mock", "Writable UInt"), - //: The name of the StateType ({563e9c4c-5198-400a-9f6c-358f4752af58}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable UInt"), //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableUIntMinMax, ID: {79238998-eaab-4d71-b406-5d78f1749751}) QT_TRANSLATE_NOOP("mock", "Writable UInt (min/max)"), - //: The name of the ParamType (ThingClass: inputTypeMock, EventType: writableUIntMinMax, ID: {79238998-eaab-4d71-b406-5d78f1749751}) - QT_TRANSLATE_NOOP("mock", "Writable UInt (min/max)"), - //: The name of the StateType ({79238998-eaab-4d71-b406-5d78f1749751}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Writable UInt (min/max)"), - //: The name of the EventType ({79238998-eaab-4d71-b406-5d78f1749751}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable UInt (min/max) changed"), - - //: The name of the EventType ({563e9c4c-5198-400a-9f6c-358f4752af58}) of ThingClass inputTypeMock - QT_TRANSLATE_NOOP("mock", "Writable UInt changed"), - //: The name of the ParamType (ThingClass: displayPinMock, ActionType: allowedValues, ID: {b463c5ae-4d55-402f-8480-a5cdb485c143}) QT_TRANSLATE_NOOP("mock", "allowed values"), - //: The name of the ParamType (ThingClass: displayPinMock, EventType: allowedValues, ID: {b463c5ae-4d55-402f-8480-a5cdb485c143}) - QT_TRANSLATE_NOOP("mock", "allowed values"), - //: The name of the StateType ({b463c5ae-4d55-402f-8480-a5cdb485c143}) of ThingClass displayPinMock QT_TRANSLATE_NOOP("mock", "allowed values"), //: The name of the ParamType (ThingClass: pushButtonMock, ActionType: allowedValues, ID: {05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) QT_TRANSLATE_NOOP("mock", "allowed values"), - //: The name of the ParamType (ThingClass: pushButtonMock, EventType: allowedValues, ID: {05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) - QT_TRANSLATE_NOOP("mock", "allowed values"), - //: The name of the StateType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of ThingClass pushButtonMock QT_TRANSLATE_NOOP("mock", "allowed values"), - //: The name of the EventType ({b463c5ae-4d55-402f-8480-a5cdb485c143}) of ThingClass displayPinMock - QT_TRANSLATE_NOOP("mock", "allowed values changed"), - - //: The name of the EventType ({05f63f9c-f61e-4dcf-ad55-3f13fde2765b}) of ThingClass pushButtonMock - QT_TRANSLATE_NOOP("mock", "allowed values changed"), - //: The name of the ParamType (ThingClass: autoMock, Type: thing, ID: {a5c4315f-0624-4971-87c1-4bbfbfdbd16e}) QT_TRANSLATE_NOOP("mock", "async"), //: The name of the ParamType (ThingClass: mock, Type: thing, ID: {f2977061-4dd0-4ef5-85aa-3b7134743be3}) QT_TRANSLATE_NOOP("mock", "async"), - //: The name of the ParamType (ThingClass: mock, EventType: batteryCritical, ID: {580bc611-1a55-41f3-996f-8d3ccf543db3}) - QT_TRANSLATE_NOOP("mock", "battery level critical"), - - //: The name of the EventType ({580bc611-1a55-41f3-996f-8d3ccf543db3}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "battery level critical"), - //: The name of the StateType ({580bc611-1a55-41f3-996f-8d3ccf543db3}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "battery level critical"), //: The name of the ParamType (ThingClass: childMock, ActionType: boolValue, ID: {80ba1449-b485-47d4-a067-6bf306e2a568}) QT_TRANSLATE_NOOP("mock", "bool value"), - //: The name of the ParamType (ThingClass: childMock, EventType: boolValue, ID: {80ba1449-b485-47d4-a067-6bf306e2a568}) - QT_TRANSLATE_NOOP("mock", "bool value"), - //: The name of the StateType ({80ba1449-b485-47d4-a067-6bf306e2a568}) of ThingClass childMock QT_TRANSLATE_NOOP("mock", "bool value"), //: The name of the ParamType (ThingClass: parentMock, ActionType: boolValue, ID: {d24ede5f-4064-4898-bb84-cfb533b1fbc0}) QT_TRANSLATE_NOOP("mock", "bool value"), - //: The name of the ParamType (ThingClass: parentMock, EventType: boolValue, ID: {d24ede5f-4064-4898-bb84-cfb533b1fbc0}) - QT_TRANSLATE_NOOP("mock", "bool value"), - //: The name of the StateType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of ThingClass parentMock QT_TRANSLATE_NOOP("mock", "bool value"), //: The name of the ParamType (ThingClass: displayPinMock, ActionType: bool, ID: {7ffe514f-7999-4998-8350-0e73e222a8c4}) QT_TRANSLATE_NOOP("mock", "bool value"), - //: The name of the ParamType (ThingClass: displayPinMock, EventType: bool, ID: {7ffe514f-7999-4998-8350-0e73e222a8c4}) - QT_TRANSLATE_NOOP("mock", "bool value"), - //: The name of the StateType ({7ffe514f-7999-4998-8350-0e73e222a8c4}) of ThingClass displayPinMock QT_TRANSLATE_NOOP("mock", "bool value"), //: The name of the ParamType (ThingClass: pushButtonMock, ActionType: bool, ID: {e680f7a4-b39e-46da-be41-fa3170fe3768}) QT_TRANSLATE_NOOP("mock", "bool value"), - //: The name of the ParamType (ThingClass: pushButtonMock, EventType: bool, ID: {e680f7a4-b39e-46da-be41-fa3170fe3768}) - QT_TRANSLATE_NOOP("mock", "bool value"), - //: The name of the StateType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of ThingClass pushButtonMock QT_TRANSLATE_NOOP("mock", "bool value"), - //: The name of the EventType ({80ba1449-b485-47d4-a067-6bf306e2a568}) of ThingClass childMock - QT_TRANSLATE_NOOP("mock", "bool value changed"), - - //: The name of the EventType ({d24ede5f-4064-4898-bb84-cfb533b1fbc0}) of ThingClass parentMock - QT_TRANSLATE_NOOP("mock", "bool value changed"), - - //: The name of the EventType ({7ffe514f-7999-4998-8350-0e73e222a8c4}) of ThingClass displayPinMock - QT_TRANSLATE_NOOP("mock", "bool value changed"), - - //: The name of the EventType ({e680f7a4-b39e-46da-be41-fa3170fe3768}) of ThingClass pushButtonMock - QT_TRANSLATE_NOOP("mock", "bool value changed"), - //: The name of the ParamType (ThingClass: autoMock, Type: thing, ID: {66179395-ef7a-4013-9fc6-2084104eea09}) QT_TRANSLATE_NOOP("mock", "broken"), @@ -1167,27 +761,15 @@ const QString translations[] { //: The name of the ParamType (ThingClass: displayPinMock, ActionType: color, ID: {3e161294-8a0d-4384-9676-6959e08cc2fa}) QT_TRANSLATE_NOOP("mock", "color"), - //: The name of the ParamType (ThingClass: displayPinMock, EventType: color, ID: {3e161294-8a0d-4384-9676-6959e08cc2fa}) - QT_TRANSLATE_NOOP("mock", "color"), - //: The name of the StateType ({3e161294-8a0d-4384-9676-6959e08cc2fa}) of ThingClass displayPinMock QT_TRANSLATE_NOOP("mock", "color"), //: The name of the ParamType (ThingClass: pushButtonMock, ActionType: color, ID: {20dc7c22-c50e-42db-837c-2bbced939f8e}) QT_TRANSLATE_NOOP("mock", "color"), - //: The name of the ParamType (ThingClass: pushButtonMock, EventType: color, ID: {20dc7c22-c50e-42db-837c-2bbced939f8e}) - QT_TRANSLATE_NOOP("mock", "color"), - //: The name of the StateType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of ThingClass pushButtonMock QT_TRANSLATE_NOOP("mock", "color"), - //: The name of the EventType ({3e161294-8a0d-4384-9676-6959e08cc2fa}) of ThingClass displayPinMock - QT_TRANSLATE_NOOP("mock", "color changed"), - - //: The name of the EventType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of ThingClass pushButtonMock - QT_TRANSLATE_NOOP("mock", "color changed"), - //: The name of the ParamType (ThingClass: mock, Type: plugin, ID: {c75723b6-ea4f-4982-9751-6c5e39c88145}) QT_TRANSLATE_NOOP("mock", "configParamBool"), @@ -1197,27 +779,15 @@ const QString translations[] { //: The name of the ParamType (ThingClass: displayPinMock, ActionType: double, ID: {17635624-7c19-4bae-8429-2f7aa5d2f843}) QT_TRANSLATE_NOOP("mock", "double value"), - //: The name of the ParamType (ThingClass: displayPinMock, EventType: double, ID: {17635624-7c19-4bae-8429-2f7aa5d2f843}) - QT_TRANSLATE_NOOP("mock", "double value"), - //: The name of the StateType ({17635624-7c19-4bae-8429-2f7aa5d2f843}) of ThingClass displayPinMock QT_TRANSLATE_NOOP("mock", "double value"), //: The name of the ParamType (ThingClass: pushButtonMock, ActionType: double, ID: {53cd7c55-49b7-441b-b970-9048f20f0e2c}) QT_TRANSLATE_NOOP("mock", "double value"), - //: The name of the ParamType (ThingClass: pushButtonMock, EventType: double, ID: {53cd7c55-49b7-441b-b970-9048f20f0e2c}) - QT_TRANSLATE_NOOP("mock", "double value"), - //: The name of the StateType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of ThingClass pushButtonMock QT_TRANSLATE_NOOP("mock", "double value"), - //: The name of the EventType ({17635624-7c19-4bae-8429-2f7aa5d2f843}) of ThingClass displayPinMock - QT_TRANSLATE_NOOP("mock", "double value changed"), - - //: The name of the EventType ({53cd7c55-49b7-441b-b970-9048f20f0e2c}) of ThingClass pushButtonMock - QT_TRANSLATE_NOOP("mock", "double value changed"), - //: The name of the ParamType (ThingClass: autoMock, Type: thing, ID: {bfeb0613-dab6-408c-aa27-c362c921d0d1}) QT_TRANSLATE_NOOP("mock", "http port"), @@ -1248,42 +818,24 @@ const QString translations[] { //: The name of the ParamType (ThingClass: displayPinMock, ActionType: percentage, ID: {527f0687-0b28-4c26-852c-25b8f83e4797}) QT_TRANSLATE_NOOP("mock", "percentage"), - //: The name of the ParamType (ThingClass: displayPinMock, EventType: percentage, ID: {527f0687-0b28-4c26-852c-25b8f83e4797}) - QT_TRANSLATE_NOOP("mock", "percentage"), - //: The name of the StateType ({527f0687-0b28-4c26-852c-25b8f83e4797}) of ThingClass displayPinMock QT_TRANSLATE_NOOP("mock", "percentage"), //: The name of the ParamType (ThingClass: pushButtonMock, ActionType: percentage, ID: {72981c04-267a-4ba0-a59e-9921d2f3af9c}) QT_TRANSLATE_NOOP("mock", "percentage"), - //: The name of the ParamType (ThingClass: pushButtonMock, EventType: percentage, ID: {72981c04-267a-4ba0-a59e-9921d2f3af9c}) - QT_TRANSLATE_NOOP("mock", "percentage"), - //: The name of the StateType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of ThingClass pushButtonMock QT_TRANSLATE_NOOP("mock", "percentage"), - //: The name of the EventType ({527f0687-0b28-4c26-852c-25b8f83e4797}) of ThingClass displayPinMock - QT_TRANSLATE_NOOP("mock", "percentage changed"), - - //: The name of the EventType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of ThingClass pushButtonMock - QT_TRANSLATE_NOOP("mock", "percentage changed"), - //: The name of the ParamType (ThingClass: displayPinMock, Type: thing, ID: {da820e07-22dc-4173-9c07-2f49a4e265f9}) QT_TRANSLATE_NOOP("mock", "pin"), //: The name of the ParamType (ThingClass: mock, ActionType: power, ID: {064aed0d-da4c-49d4-b236-60f97e98ff84}) QT_TRANSLATE_NOOP("mock", "powered"), - //: The name of the ParamType (ThingClass: mock, EventType: power, ID: {064aed0d-da4c-49d4-b236-60f97e98ff84}) - QT_TRANSLATE_NOOP("mock", "powered"), - //: The name of the StateType ({064aed0d-da4c-49d4-b236-60f97e98ff84}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "powered"), - //: The name of the EventType ({064aed0d-da4c-49d4-b236-60f97e98ff84}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "powered changed"), - //: The name of the ParamType (ThingClass: displayPinMock, Type: discovery, ID: {35f6e4ba-28ad-4152-a58d-ec2600667bcf}) QT_TRANSLATE_NOOP("mock", "resultCount"), diff --git a/tests/auto/api.json b/tests/auto/api.json index 21d47c47..a4ac0c23 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -1039,6 +1039,18 @@ "thingError": "$ref:ThingError" } }, + "Integrations.SetStateLogging": { + "description": "Enable/disable logging for the given state type on the given thing.", + "params": { + "enabled": "Bool", + "stateTypeId": "Uuid", + "thingId": "Uuid" + }, + "permissionScope": "PermissionScopeConfigureThings", + "returns": { + "thingError": "$ref:ThingError" + } + }, "Integrations.SetThingSettings": { "description": "Change the settings of a thing.", "params": { @@ -2800,6 +2812,9 @@ "r:o:loggedEventTypeIds": [ "Uuid" ], + "r:o:loggedStateTypeIds": [ + "Uuid" + ], "r:o:parentId": "Uuid", "r:o:setupDisplayMessage": "String", "r:params": "$ref:ParamList", diff --git a/tests/auto/integrations/testintegrations.cpp b/tests/auto/integrations/testintegrations.cpp index 36f1a1ac..3133dff4 100644 --- a/tests/auto/integrations/testintegrations.cpp +++ b/tests/auto/integrations/testintegrations.cpp @@ -139,7 +139,7 @@ private slots: void executeAction(); void triggerEvent(); - void triggerStateChangeEvent(); + void triggerStateChangeSignal(); void params(); @@ -343,7 +343,7 @@ void TestIntegrations::verifyInterfaces() QVERIFY(!mock.isEmpty()); QVariantList interfaces = mock.value("interfaces").toList(); - QVariantList expectedInterfaces = {"system", "light", "power", "battery", "wirelessconnectable", "connectable", "update"}; + QVariantList expectedInterfaces = {"system", "light", "power", "battery", "wirelessconnectable", "connectable", "update", "multibutton", "button"}; qCDebug(dcTests()) << interfaces; qCDebug(dcTests()) << expectedInterfaces; QCOMPARE(interfaces, expectedInterfaces); @@ -991,7 +991,7 @@ void TestIntegrations::getActionTypes_data() QTest::addColumn >("actionTypeTestData"); QTest::newRow("valid thingClass") << mockThingClassId - << (QList() << mockIntWithLimitsActionTypeId << mockAsyncActionTypeId << mockAsyncFailingActionTypeId << mockFailingActionTypeId << mockWithoutParamsActionTypeId << mockPowerActionTypeId << mockWithoutParamsActionTypeId << mockBatteryLevelActionTypeId << mockSignalStrengthActionTypeId << mockUpdateStatusActionTypeId << mockPerformUpdateActionTypeId); + << (QList() << mockIntWithLimitsActionTypeId << mockAsyncActionTypeId << mockAsyncFailingActionTypeId << mockFailingActionTypeId << mockWithoutParamsActionTypeId << mockPowerActionTypeId << mockWithoutParamsActionTypeId << mockBatteryLevelActionTypeId << mockSignalStrengthActionTypeId << mockUpdateStatusActionTypeId << mockPerformUpdateActionTypeId << mockPressButtonActionTypeId); QTest::newRow("invalid thingClass") << ThingClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << QList(); } @@ -1023,7 +1023,7 @@ void TestIntegrations::getEventTypes_data() QTest::addColumn("thingClassId"); QTest::addColumn("resultCount"); - QTest::newRow("valid thingClass") << mockThingClassId << 14; + QTest::newRow("valid thingClass") << mockThingClassId << 3; QTest::newRow("invalid thingClass") << ThingClassId("094f8024-5caa-48c1-ab6a-de486a92088f") << 0; } @@ -2140,7 +2140,7 @@ void TestIntegrations::triggerEvent() QCOMPARE(notificationContent.value("event").toMap().value("eventTypeId").toUuid().toString(), mockEvent1EventTypeId.toString()); } -void TestIntegrations::triggerStateChangeEvent() +void TestIntegrations::triggerStateChangeSignal() { enableNotifications({"Integrations"}); @@ -2148,7 +2148,7 @@ void TestIntegrations::triggerStateChangeEvent() QVERIFY2(things.count() > 0, "There needs to be at least one configured Mock for this test"); Thing *thing = things.first(); - QSignalSpy spy(NymeaCore::instance(), SIGNAL(eventTriggered(const Event&))); + QSignalSpy spy(NymeaCore::instance(), SIGNAL(thingStateChanged(Thing *, const StateTypeId &, const QVariant &, const QVariant &, const QVariant &))); QSignalSpy notificationSpy(m_mockTcpServer, SIGNAL(outgoingData(QUuid,QByteArray))); // Setup connection to mock client @@ -2162,25 +2162,23 @@ void TestIntegrations::triggerStateChangeEvent() // Lets wait for the notification spy.wait(); - QVERIFY(spy.count() > 0); - for (int i = 0; i < spy.count(); i++ ){ - Event event = spy.at(i).at(0).value(); - if (event.thingId() == thing->id()) { - // Make sure the event contains all the stuff we expect - QCOMPARE(event.eventTypeId().toString(), mockIntStateTypeId.toString()); - QCOMPARE(event.param(ParamTypeId(mockIntStateTypeId.toString())).value().toInt(), 37); - } - } + QVERIFY(spy.count() == 1); + Thing *t = spy.at(0).at(0).value(); + QCOMPARE(t->id(), thing->id()); + StateTypeId stId = spy.at(0).at(1).value(); + QCOMPARE(stId, mockIntStateTypeId); + QVariant value = spy.at(0).at(2); + QCOMPARE(value.toInt(), 37); // Check for the notification on JSON API QVariantList notifications; - notifications = checkNotifications(notificationSpy, "Integrations.EventTriggered"); - QVERIFY2(notifications.count() == 1, "Should get Integrations.EventTriggered notification"); + notifications = checkNotifications(notificationSpy, "Integrations.StateChanged"); + QVERIFY2(notifications.count() == 1, "Should get Integrations.StateChanged notification"); QVariantMap notificationContent = notifications.first().toMap().value("params").toMap(); - QCOMPARE(notificationContent.value("event").toMap().value("thingId").toUuid().toString(), thing->id().toString()); - QCOMPARE(notificationContent.value("event").toMap().value("eventTypeId").toUuid().toString(), mockIntEventTypeId.toString()); - + QCOMPARE(notificationContent.value("thingId").toUuid().toString(), thing->id().toString()); + QCOMPARE(notificationContent.value("stateTypeId").toUuid().toString(), mockIntStateTypeId.toString()); + QCOMPARE(notificationContent.value("value").toInt(), 37); } void TestIntegrations::params() @@ -2376,9 +2374,9 @@ void TestIntegrations::testTranslations() bool etFound = false; foreach (const QVariant &etVariant, tcMap.value("eventTypes").toList()) { QVariantMap etMap = etVariant.toMap(); - if (etMap.value("id").toUuid() == autoMockIntEventTypeId) { + if (etMap.value("id").toUuid() == autoMockEvent1EventTypeId) { etFound = true; - QCOMPARE(etMap.value("displayName").toString(), QString("Simulierter Integer Zustand geƤndert")); + QCOMPARE(etMap.value("displayName").toString(), QString("Mock Ereignis 1")); } } QVERIFY2(etFound, "EventType not found in mock thing class."); diff --git a/tests/auto/jsonrpc/testjsonrpc.cpp b/tests/auto/jsonrpc/testjsonrpc.cpp index 5b3725cd..01744955 100644 --- a/tests/auto/jsonrpc/testjsonrpc.cpp +++ b/tests/auto/jsonrpc/testjsonrpc.cpp @@ -680,7 +680,7 @@ void TestJSONRPC::enableDisableNotifications_legacy() QStringList expectedNamespaces; if (enabled == "true") { - expectedNamespaces << "NetworkManager" << "Integrations" << "System" << "Rules"<< "Logging" << "Tags" << "AppData" << "JSONRPC" << "Configuration" << "Scripts" << "Users" << "Zigbee" << "ModbusRtu"; + expectedNamespaces << "NetworkManager" << "Integrations" << "System" << "Rules" << "Logging" << "Tags" << "AppData" << "JSONRPC" << "Configuration" << "Scripts" << "Users" << "Zigbee" << "ModbusRtu"; } std::sort(expectedNamespaces.begin(), expectedNamespaces.end()); @@ -690,7 +690,7 @@ void TestJSONRPC::enableDisableNotifications_legacy() } std::sort(actualNamespaces.begin(), actualNamespaces.end()); - QCOMPARE(expectedNamespaces, actualNamespaces); + QVERIFY2(expectedNamespaces == actualNamespaces, QString("Namespaces not matching.\nExpected: %1\nReceived: %2").arg(expectedNamespaces.join(",")).arg(actualNamespaces.join(",")).toUtf8()); } @@ -839,11 +839,12 @@ void TestJSONRPC::ruleActiveChangedNotifications() QSignalSpy spy(&nam, SIGNAL(finished(QNetworkReply*))); // state state to 20 - qDebug() << "setting mock int state to 20"; + qCDebug(dcTests) << "setting mock int state to 20"; QNetworkRequest request(QUrl(QString("http://localhost:%1/setstate?%2=%3").arg(m_mockThing1Port).arg(mockIntStateTypeId.toString()).arg(20))); QNetworkReply *reply = nam.get(request); connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater())); + qCDebug(dcTests()) << "Waiting for RuleActiveChanged"; if (spy.count() == 0) spy.wait(); notificationVariant = checkNotification(clientSpy, "Rules.RuleActiveChanged"); verifyRuleError(response); @@ -851,8 +852,6 @@ void TestJSONRPC::ruleActiveChangedNotifications() QCOMPARE(notificationVariant.toMap().value("params").toMap().value("ruleId").toUuid().toString(), ruleId.toString()); QCOMPARE(notificationVariant.toMap().value("params").toMap().value("active").toBool(), true); - clientSpy.wait(); - spy.clear(); clientSpy.clear(); // set the rule inactive @@ -862,12 +861,10 @@ void TestJSONRPC::ruleActiveChangedNotifications() connect(reply2, SIGNAL(finished()), reply2, SLOT(deleteLater())); // Waiting for notifications: - // Integrations.StateChanged for the change we did - // Integrations.EventTriggered // Rules.RuleActiveChanged - // Logging.LogEntryAdded // One for the state change we did - // Logging.LogEntryAdded // One for the rule state change - while (clientSpy.count() < 5) { + // Logging.LogEntryAdded + // Integrations.StateChanged for the change done by the rule + while (clientSpy.count() < 3) { clientSpy.wait(); } @@ -922,28 +919,6 @@ void TestJSONRPC::stateChangeEmitsNotifications() QVERIFY2(found, "Could not find the correct Devices.StateChanged notification"); - // Waiting for: - // Devices.StateChanged - // Devices.EventTriggered - // Events.EventTriggered <-- deprecated - while (clientSpy.count() < 3) { - clientSpy.wait(); - } - - // Make sure the notification contains all the stuff we expect - QVariantList eventTriggeredVariants = checkNotifications(clientSpy, "Integrations.EventTriggered"); - QVERIFY2(!eventTriggeredVariants.isEmpty(), "Did not get Integrations.EventTriggered notification."); - found = false; - foreach (const QVariant &eventTriggeredVariant, eventTriggeredVariants) { - if (eventTriggeredVariant.toMap().value("params").toMap().value("event").toMap().value("eventTypeId").toUuid() == stateTypeId) { - found = true; - QCOMPARE(eventTriggeredVariant.toMap().value("params").toMap().value("event").toMap().value("params").toList().first().toMap().value("value").toInt(), newVal); - break; - } - } - - QVERIFY2(found, "Could not find the corresponding Integrations.EventTriggered notification"); - // Now turn off notifications QCOMPARE(disableNotifications(), true); diff --git a/tests/auto/rules/testrules.cpp b/tests/auto/rules/testrules.cpp index 462e04d2..5a336f11 100644 --- a/tests/auto/rules/testrules.cpp +++ b/tests/auto/rules/testrules.cpp @@ -407,13 +407,12 @@ void TestRules::generateEvent(const EventTypeId &eventTypeId) void TestRules::initTestCase() { - NymeaTestBase::initTestCase(); - QLoggingCategory::setFilterRules("*.debug=false\n" - "Tests.debug=true\n" - "RuleEngine.debug=true\n" - "RuleEngineDebug.debug=true\n" - "JsonRpc.debug=true\n" - "Mock.*=true"); + NymeaTestBase::initTestCase("*.debug=false\n" + "Tests.debug=true\n" + "RuleEngine.debug=true\n" + "RuleEngineDebug.debug=true\n" + "JsonRpc.debug=true\n" + "Mock.*=true"); } void TestRules::addRemoveRules_data() @@ -2400,8 +2399,8 @@ void TestRules::removePolicyUpdate() // Add rule with child QVariantList eventDescriptors; - eventDescriptors.append(createEventDescriptor(childId, childMockBoolValueEventTypeId)); - eventDescriptors.append(createEventDescriptor(parentId, parentMockBoolValueEventTypeId)); + eventDescriptors.append(createEventDescriptor(childId, childMockEvent1EventTypeId)); + eventDescriptors.append(createEventDescriptor(parentId, parentMockEvent1EventTypeId)); eventDescriptors.append(createEventDescriptor(m_mockThingId, mockEvent1EventTypeId)); params.clear(); response.clear(); @@ -2486,8 +2485,8 @@ void TestRules::removePolicyCascade() // Add rule with child QVariantList eventDescriptors; - eventDescriptors.append(createEventDescriptor(childId, childMockBoolValueEventTypeId)); - eventDescriptors.append(createEventDescriptor(parentId, parentMockBoolValueEventTypeId)); + eventDescriptors.append(createEventDescriptor(childId, childMockEvent1EventTypeId)); + eventDescriptors.append(createEventDescriptor(parentId, parentMockEvent1EventTypeId)); eventDescriptors.append(createEventDescriptor(m_mockThingId, mockEvent1EventTypeId)); params.clear(); response.clear(); @@ -2563,8 +2562,8 @@ void TestRules::removePolicyUpdateRendersUselessRule() // Add rule with child QVariantList eventDescriptors; - eventDescriptors.append(createEventDescriptor(childId, childMockBoolValueEventTypeId)); - eventDescriptors.append(createEventDescriptor(parentId, parentMockBoolValueEventTypeId)); + eventDescriptors.append(createEventDescriptor(childId, childMockEvent1EventTypeId)); + eventDescriptors.append(createEventDescriptor(parentId, parentMockEvent1EventTypeId)); eventDescriptors.append(createEventDescriptor(m_mockThingId, mockEvent1EventTypeId)); params.clear(); response.clear(); diff --git a/tests/auto/scripts/testscripts.cpp b/tests/auto/scripts/testscripts.cpp index fa634403..2de9e853 100644 --- a/tests/auto/scripts/testscripts.cpp +++ b/tests/auto/scripts/testscripts.cpp @@ -72,6 +72,7 @@ private slots: void testScriptAlarm(); void testInterfaceEvent(); + void testInterfaceState(); void testInterfaceAction(); }; @@ -106,7 +107,7 @@ void TestScripts::testScriptEventById() " TestHelper.logEvent(thingId, eventTypeId, params);\n" " }\n" " }\n" - "}\n").arg(m_mockThingId.toString()).arg(mockPowerEventTypeId.toString()); + "}\n").arg(m_mockThingId.toString()).arg(mockEvent2EventTypeId.toString()); qCDebug(dcTests()) << "Adding script:\n" << qUtf8Printable(script); ScriptEngine::AddScriptReply reply = NymeaCore::instance()->scriptEngine()->addScript("TestEvent", script.toUtf8()); @@ -114,20 +115,30 @@ void TestScripts::testScriptEventById() QSignalSpy spy(TestHelper::instance(), &TestHelper::eventLogged); - // Generate event by setting state value of powerState - Action action(mockPowerActionTypeId, m_mockThingId); - action.setParams(ParamList() << Param(mockPowerActionPowerParamTypeId, true)); - NymeaCore::instance()->thingManager()->executeAction(action); + // trigger event in mock device + Thing* thing = NymeaCore::instance()->thingManager()->findConfiguredThing(m_mockThingId); + int port = thing->paramValue(mockThingHttpportParamTypeId).toInt(); + QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2&%3=%4") + .arg(port) + .arg(mockEvent2EventTypeId.toString()) + .arg(mockEvent2EventIntParamParamTypeId.toString()) + .arg(23))); + QNetworkAccessManager nam; + QNetworkReply *r = nam.get(request); + connect(r, &QNetworkReply::finished, r, &QNetworkReply::deleteLater); - spy.wait(1); + spy.wait(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.first().at(0).value(), m_mockThingId); - QCOMPARE(EventTypeId(spy.first().at(1).toUuid()), mockPowerEventTypeId); + QCOMPARE(EventTypeId(spy.first().at(1).toUuid()), mockEvent2EventTypeId); QVariantMap expectedParams; - expectedParams.insert(mockPowerEventTypeId.toString().remove(QRegExp("[{}]")), true); - expectedParams.insert("power", true); - QCOMPARE(spy.first().at(2).toMap(), expectedParams); + expectedParams.insert(mockEvent2EventIntParamParamTypeId.toString().remove(QRegExp("[{}]")), 23); + expectedParams.insert("intParam", 23); + QVERIFY2(spy.first().at(2).toMap() == expectedParams, QString("Params not matching.\nExpected: %1\nGot: %2") + .arg(QString(QJsonDocument::fromVariant(expectedParams).toJson(QJsonDocument::Indented))) + .arg(QString(QJsonDocument::fromVariant(spy.first().at(2).toMap()).toJson(QJsonDocument::Indented))) + .toUtf8()); } void TestScripts::testScriptEventByName() @@ -142,7 +153,7 @@ void TestScripts::testScriptEventByName() " TestHelper.logEvent(thingId, eventName, params);\n" " }\n" " }\n" - "}\n").arg(m_mockThingId.toString()).arg("power"); + "}\n").arg(m_mockThingId.toString()).arg("event2"); qCDebug(dcTests()) << "Adding script:\n" << qUtf8Printable(script); ScriptEngine::AddScriptReply reply = NymeaCore::instance()->scriptEngine()->addScript("TestEvent", script.toUtf8()); @@ -150,19 +161,26 @@ void TestScripts::testScriptEventByName() QSignalSpy spy(TestHelper::instance(), &TestHelper::eventLogged); - // Generate event by setting state value of powerState - Action action(mockPowerActionTypeId, m_mockThingId); - action.setParams(ParamList() << Param(mockPowerActionPowerParamTypeId, true)); - NymeaCore::instance()->thingManager()->executeAction(action); + // trigger event in mock device + Thing* thing = NymeaCore::instance()->thingManager()->findConfiguredThing(m_mockThingId); + int port = thing->paramValue(mockThingHttpportParamTypeId).toInt(); + QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2&%3=%4") + .arg(port) + .arg(mockEvent2EventTypeId.toString()) + .arg(mockEvent2EventIntParamParamTypeId.toString()) + .arg(10))); + QNetworkAccessManager nam; + QNetworkReply *r = nam.get(request); + connect(r, &QNetworkReply::finished, r, &QNetworkReply::deleteLater); - spy.wait(1); + spy.wait(); QCOMPARE(spy.count(), 1); QCOMPARE(spy.first().at(0).value(), m_mockThingId); - QCOMPARE(spy.first().at(1).toString(), QString("power")); + QCOMPARE(spy.first().at(1).toString(), QString("event2")); QVariantMap expectedParams; - expectedParams.insert(mockPowerEventTypeId.toString().remove(QRegExp("[{}]")), true); - expectedParams.insert("power", true); + expectedParams.insert(mockEvent2EventIntParamParamTypeId.toString().remove(QRegExp("[{}]")), 10); + expectedParams.insert("intParam", 10); QCOMPARE(spy.first().at(2).toMap(), expectedParams); } @@ -398,7 +416,7 @@ void TestScripts::testInterfaceEvent() " TestHelper.logEvent(thingId, eventName, params);\n" " }\n" " }\n" - "}\n").arg("power").arg("power"); + "}\n").arg("button").arg("pressed"); qCDebug(dcTests()) << "Adding script:\n" << qUtf8Printable(script); ScriptEngine::AddScriptReply reply = NymeaCore::instance()->scriptEngine()->addScript("TestEvent", script.toUtf8()); @@ -406,6 +424,50 @@ void TestScripts::testInterfaceEvent() QSignalSpy spy(TestHelper::instance(), &TestHelper::eventLogged); + // trigger event in mock device + Thing* thing = NymeaCore::instance()->thingManager()->findConfiguredThing(m_mockThingId); + int port = thing->paramValue(mockThingHttpportParamTypeId).toInt(); + QNetworkRequest request(QUrl(QString("http://localhost:%1/generateevent?eventtypeid=%2&%3=%4") + .arg(port) + .arg(mockPressedEventTypeId.toString()) + .arg(mockPressedEventButtonNameParamTypeId.toString()) + .arg("xxx"))); + QNetworkAccessManager nam; + QNetworkReply *r = nam.get(request); + connect(r, &QNetworkReply::finished, r, &QNetworkReply::deleteLater); + + spy.wait(); + + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.first().at(0).value(), m_mockThingId); + QCOMPARE(spy.first().at(1).toString(), QString("pressed")); + QVariantMap expectedParams; + expectedParams.insert(mockPressedEventButtonNameParamTypeId.toString().remove(QRegExp("[{}]")), "xxx"); + expectedParams.insert("buttonName", "xxx"); + QCOMPARE(spy.first().at(2).toMap(), expectedParams); + +} + +void TestScripts::testInterfaceState() +{ + QString script = QString("import QtQuick 2.0\n" + "import nymea 1.0\n" + "Item {\n" + " InterfaceState {\n" + " interfaceName: \"%1\"\n" + " stateName: \"%2\"\n" + " onStateChanged: {\n" + " TestHelper.logStateChange(thingId, stateName, value);\n" + " }\n" + " }\n" + "}\n").arg("power").arg("power"); + + qCDebug(dcTests()) << "Adding script:\n" << qUtf8Printable(script); + ScriptEngine::AddScriptReply reply = NymeaCore::instance()->scriptEngine()->addScript("TestInterfaceState", script.toUtf8()); + QCOMPARE(reply.scriptError, ScriptEngine::ScriptErrorNoError); + + QSignalSpy spy(TestHelper::instance(), &TestHelper::stateChangeLogged); + // Generate event by setting state value of powerState Action action(mockPowerActionTypeId, m_mockThingId); action.setParams(ParamList() << Param(mockPowerActionPowerParamTypeId, true)); @@ -416,11 +478,7 @@ void TestScripts::testInterfaceEvent() QCOMPARE(spy.count(), 1); QCOMPARE(spy.first().at(0).value(), m_mockThingId); QCOMPARE(spy.first().at(1).toString(), QString("power")); - QVariantMap expectedParams; - expectedParams.insert(mockPowerEventTypeId.toString().remove(QRegExp("[{}]")), true); - expectedParams.insert("power", true); - QCOMPARE(spy.first().at(2).toMap(), expectedParams); - + QCOMPARE(spy.first().at(2).toBool(), true); } void TestScripts::testInterfaceAction()