diff --git a/libnymea-core/integrations/thingmanagerimplementation.cpp b/libnymea-core/integrations/thingmanagerimplementation.cpp index dad343dc..c4fcea5d 100644 --- a/libnymea-core/integrations/thingmanagerimplementation.cpp +++ b/libnymea-core/integrations/thingmanagerimplementation.cpp @@ -1253,6 +1253,11 @@ StateType ThingManagerImplementation::translateStateType(const PluginId &pluginI { StateType translatedStateType = stateType; translatedStateType.setDisplayName(translate(pluginId, stateType.displayName(), locale)); + QStringList translatedPossibleValuesDisplayNames; + for (int i = 0; i < stateType.possibleValuesDisplayNames().count(); i++) { + translatedPossibleValuesDisplayNames.append(translate(pluginId, stateType.possibleValuesDisplayNames().at(i), locale)); + } + translatedStateType.setPossibleValuesDisplayNames(translatedPossibleValuesDisplayNames); return translatedStateType; } @@ -1992,7 +1997,7 @@ void ThingManagerImplementation::onEventTriggered(Event event) emit eventTriggered(event); } -void ThingManagerImplementation::slotThingStateValueChanged(const StateTypeId &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue) +void ThingManagerImplementation::slotThingStateValueChanged(const StateTypeId &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue, const QVariantList &possibleValues) { Thing *thing = qobject_cast(sender()); if (!thing || !m_configuredThings.contains(thing->id())) { @@ -2008,7 +2013,7 @@ void ThingManagerImplementation::slotThingStateValueChanged(const StateTypeId &s m_stateLoggers.value(thing->id().toString() + "-" + stateType.name())->log({}, {{stateType.name(), value}}); } - emit thingStateChanged(thing, stateTypeId, value, minValue, maxValue); + emit thingStateChanged(thing, stateTypeId, value, minValue, maxValue, possibleValues); syncIOConnection(thing, stateTypeId); } @@ -2311,13 +2316,15 @@ void ThingManagerImplementation::loadThingStates(Thing *thing) QVariant value = stateType.defaultValue(); QVariant minValue = stateType.minValue(); QVariant maxValue = stateType.maxValue(); + QVariantList possibleValues = stateType.possibleValues(); if (stateType.cached()) { if (settings->childGroups().contains(stateType.id().toString())) { settings->beginGroup(stateType.id().toString()); value = settings->value("value"); - minValue = settings->value("minValue"); - maxValue = settings->value("maxValue"); + minValue = settings->value("minValue", minValue); + maxValue = settings->value("maxValue", maxValue); + possibleValues = settings->value("possibleValues", possibleValues).toList(); settings->endGroup(); } else if (settings->contains(stateType.id().toString())) { // Migration from < 0.30 @@ -2326,10 +2333,17 @@ void ThingManagerImplementation::loadThingStates(Thing *thing) value.convert(stateType.type()); minValue.convert(stateType.type()); maxValue.convert(stateType.type()); + QVariantList convertedPossibleValues; + foreach (QVariant possibleValue, possibleValues) { + possibleValue.convert(stateType.type()); + convertedPossibleValues.append(possibleValue); + } + possibleValues = convertedPossibleValues; } thing->setStateValue(stateType.id(), value); thing->setStateMinMaxValues(stateType.id(), minValue, maxValue); + thing->setStatePossibleValues(stateType.id(), possibleValues); thing->setStateValueFilter(stateType.id(), stateType.filter()); } delete settings; @@ -2583,6 +2597,7 @@ void ThingManagerImplementation::storeThingState(Thing *thing, const StateTypeId settings.setValue("value", thing->stateValue(stateTypeId)); settings.setValue("minValue", thing->state(stateTypeId).minValue()); settings.setValue("maxValue", thing->state(stateTypeId).maxValue()); + settings.setValue("possibleValues", thing->state(stateTypeId).possibleValues()); settings.endGroup(); } diff --git a/libnymea-core/integrations/thingmanagerimplementation.h b/libnymea-core/integrations/thingmanagerimplementation.h index ecd68cbc..354e5543 100644 --- a/libnymea-core/integrations/thingmanagerimplementation.h +++ b/libnymea-core/integrations/thingmanagerimplementation.h @@ -147,7 +147,7 @@ private slots: void onEventTriggered(Event event); // Only connect this to Things. It will query the sender() - void slotThingStateValueChanged(const StateTypeId &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue); + void slotThingStateValueChanged(const StateTypeId &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue, const QVariantList &possibleValues); void slotThingSettingChanged(const ParamTypeId ¶mTypeId, const QVariant &value); void slotThingNameChanged(); diff --git a/libnymea-core/jsonrpc/integrationshandler.cpp b/libnymea-core/jsonrpc/integrationshandler.cpp index be50687b..8c24978c 100644 --- a/libnymea-core/jsonrpc/integrationshandler.cpp +++ b/libnymea-core/jsonrpc/integrationshandler.cpp @@ -410,6 +410,7 @@ IntegrationsHandler::IntegrationsHandler(ThingManager *thingManager, QObject *pa params.insert("value", enumValueName(Variant)); params.insert("minValue", enumValueName(Variant)); params.insert("maxValue", enumValueName(Variant)); + params.insert("possibleValues", QVariantList{enumValueName(Variant)}); registerNotification("StateChanged", description, params); params.clear(); returns.clear(); @@ -1149,7 +1150,7 @@ void IntegrationsHandler::pluginConfigChanged(const PluginId &id, const ParamLis emit PluginConfigurationChanged(params); } -void IntegrationsHandler::thingStateChanged(Thing *thing, const QUuid &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue) +void IntegrationsHandler::thingStateChanged(Thing *thing, const QUuid &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue, const QVariantList &possibleValues) { QVariantMap params; params.insert("thingId", thing->id()); @@ -1157,6 +1158,7 @@ void IntegrationsHandler::thingStateChanged(Thing *thing, const QUuid &stateType params.insert("value", value); params.insert("minValue", minValue); params.insert("maxValue", maxValue); + params.insert("possibleValues", possibleValues); emit StateChanged(params); } diff --git a/libnymea-core/jsonrpc/integrationshandler.h b/libnymea-core/jsonrpc/integrationshandler.h index e230d733..c6a80188 100644 --- a/libnymea-core/jsonrpc/integrationshandler.h +++ b/libnymea-core/jsonrpc/integrationshandler.h @@ -97,7 +97,7 @@ signals: private slots: void pluginConfigChanged(const PluginId &id, const ParamList &config); - void thingStateChanged(Thing *thing, const QUuid &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue); + void thingStateChanged(Thing *thing, const QUuid &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue, const QVariantList &possibleValues); void thingRemovedNotification(const ThingId &thingId); diff --git a/libnymea-core/jsonrpc/jsonvalidator.cpp b/libnymea-core/jsonrpc/jsonvalidator.cpp index 01598ea9..340b8556 100644 --- a/libnymea-core/jsonrpc/jsonvalidator.cpp +++ b/libnymea-core/jsonrpc/jsonvalidator.cpp @@ -281,7 +281,7 @@ JsonValidator::Result JsonValidator::validateEntry(const QVariant &value, const } return Result(true); } - Q_ASSERT_X(false, "JsonValildator", "Incomplete validation. Unexpected type in template"); + Q_ASSERT_X(false, "JsonValildator", QString("Incomplete validation. Unexpected type %1 in template").arg(definition.type()).toUtf8()); return Result(false); } diff --git a/libnymea/integrations/pluginmetadata.cpp b/libnymea/integrations/pluginmetadata.cpp index 4e13684b..2051bc41 100644 --- a/libnymea/integrations/pluginmetadata.cpp +++ b/libnymea/integrations/pluginmetadata.cpp @@ -417,12 +417,30 @@ void PluginMetadata::parse(const QJsonObject &jsonObject) if (st.contains("possibleValues")) { QVariantList possibleValues; + QStringList possibleValuesDisplayNames; foreach (const QJsonValue &possibleValueJson, st.value("possibleValues").toArray()) { QVariant possibleValue = possibleValueJson.toVariant(); - possibleValue.convert(stateType.type()); - possibleValues.append(possibleValue); + QVariant value; + QString name; + + if (possibleValueJson.isObject()) { + if (!possibleValue.toMap().contains("value") || !possibleValue.toMap().contains("displayName")) { + m_validationErrors.append("Thing class \"" + thingClass.name() + "\" state type \"" + stateTypeName + "\" has invalid possible value \"" + possibleValueJson.toString() + "\" which is of object type but does not have \"value\" and \"displayName\" properties."); + hasError = true; + break; + } + value = possibleValue.toMap().value("value"); + name = possibleValue.toMap().value("displayName").toString(); + } else { + value = possibleValue; + name = possibleValue.toString(); + } + value.convert(stateType.type()); + possibleValues.append(value); + possibleValuesDisplayNames.append(name); } stateType.setPossibleValues(possibleValues); + stateType.setPossibleValuesDisplayNames(possibleValuesDisplayNames); if (!stateType.possibleValues().contains(stateType.defaultValue())) { m_validationErrors.append("Thing class \"" + thingClass.name() + "\" state type \"" + stateTypeName + "\" has invalid default value \"" + stateType.defaultValue().toString() + "\" which is not in the list of possible values."); diff --git a/libnymea/integrations/thing.cpp b/libnymea/integrations/thing.cpp index 2e97ddfc..a658004b 100644 --- a/libnymea/integrations/thing.cpp +++ b/libnymea/integrations/thing.cpp @@ -135,6 +135,7 @@ #include "loggingcategories.h" #include "statevaluefilters/statevaluefilteradaptive.h" +#include #include /*! Construct a Thing with the given \a pluginId, \a id, \a thingClassId and \a parent. */ @@ -412,7 +413,7 @@ void Thing::setStateValue(const StateTypeId &stateTypeId, const QVariant &value) qCDebug(dcThing()).nospace() << this << ": State " << stateType.name() << " changed from " << oldValue << " to " << newValue; m_states[i].setValue(newValue); - emit stateValueChanged(stateTypeId, newValue, m_states.at(i).minValue(), m_states.at(i).maxValue()); + emit stateValueChanged(stateTypeId, newValue, m_states.at(i).minValue(), m_states.at(i).maxValue(), m_states.at(i).possibleValues()); return; } } @@ -460,7 +461,7 @@ void Thing::setStateMinValue(const StateTypeId &stateTypeId, const QVariant &min m_states[i].setValue(newMin); } - emit stateValueChanged(stateTypeId, m_states.at(i).value(), m_states.at(i).minValue(), m_states.at(i).maxValue()); + emit stateValueChanged(stateTypeId, m_states.at(i).value(), m_states.at(i).minValue(), m_states.at(i).maxValue(), m_states.at(i).possibleValues()); return; } } @@ -506,7 +507,7 @@ void Thing::setStateMaxValue(const StateTypeId &stateTypeId, const QVariant &max } } - emit stateValueChanged(stateTypeId, m_states.at(i).value(), m_states.at(i).minValue(), m_states.at(i).maxValue()); + emit stateValueChanged(stateTypeId, m_states.at(i).value(), m_states.at(i).minValue(), m_states.at(i).maxValue(), m_states.at(i).possibleValues()); return; } } @@ -557,7 +558,7 @@ void Thing::setStateMinMaxValues(const StateTypeId &stateTypeId, const QVariant } } - emit stateValueChanged(stateTypeId, m_states.at(i).value(), m_states.at(i).minValue(), m_states.at(i).maxValue()); + emit stateValueChanged(stateTypeId, m_states.at(i).value(), m_states.at(i).minValue(), m_states.at(i).maxValue(), m_states.at(i).possibleValues()); return; } } @@ -572,6 +573,39 @@ void Thing::setStateMinMaxValues(const QString &stateName, const QVariant &minVa setStateMinMaxValues(stateTypeId, minValue, maxValue); } +void Thing::setStatePossibleValues(const StateTypeId &stateTypeId, const QVariantList &values) +{ + StateType stateType = m_thingClass.stateTypes().findById(stateTypeId); + if (!stateType.isValid()) { + qCWarning(dcThing()) << "No such state type" << stateTypeId.toString() << "in" << m_name << "(" + thingClass().name() + ")"; + return; + } + for (int i = 0; i < m_states.count(); ++i) { + if (m_states.at(i).stateTypeId() == stateTypeId) { + if (values == m_states.at(i).possibleValues()) { + return; + } + + m_states[i].setPossibleValues(values); + + if (!values.contains(m_states.value(i).value())) { + if (values.contains(stateType.defaultValue())) { + qCInfo(dcThing).nospace() << this << ": Adjusting state value for " << stateType.name() << " from " << m_states.at(i).value() << " to default value of " << stateType.defaultValue(); + m_states[i].setValue(stateType.defaultValue()); + } else if (!values.isEmpty()) { + qCInfo(dcThing).nospace() << this << ": Adjusting state value for " << stateType.name() << " from " << m_states.at(i).value() << " to new value of " << values.first(); + m_states[i].setValue(values.first()); + } + } + emit stateValueChanged(stateTypeId, m_states.at(i).value(), m_states.at(i).minValue(), m_states.at(i).maxValue(), m_states.at(i).possibleValues()); + return; + } + } + qCWarning(dcThing).nospace() << this << ": Failed setting maximum state value " << stateType.name() << " to " << values; + Q_ASSERT_X(false, m_name.toUtf8(), QString("Failed setting possible state values for %1 to %2").arg(stateType.name()).arg(QString(QJsonDocument::fromVariant(values).toJson())).toUtf8()); + +} + /*! Returns the \l{State} with the given \a stateTypeId of this thing. */ State Thing::state(const StateTypeId &stateTypeId) const { diff --git a/libnymea/integrations/thing.h b/libnymea/integrations/thing.h index 7076bbb9..d1d52949 100644 --- a/libnymea/integrations/thing.h +++ b/libnymea/integrations/thing.h @@ -149,6 +149,7 @@ public: Q_INVOKABLE void setStateMaxValue(const QString &stateName, const QVariant &maxValue); Q_INVOKABLE void setStateMinMaxValues(const StateTypeId &stateTypeId, const QVariant &minValue, const QVariant &maxValue); Q_INVOKABLE void setStateMinMaxValues(const QString &stateName, const QVariant &minValue, const QVariant &maxValue); + Q_INVOKABLE void setStatePossibleValues(const StateTypeId &stateTypeId, const QVariantList &values); Q_INVOKABLE State state(const StateTypeId &stateTypeId) const; Q_INVOKABLE State state(const QString &stateName) const; @@ -173,7 +174,7 @@ public slots: void emitEvent(const QString &eventName, const ParamList ¶ms = ParamList()); signals: - void stateValueChanged(const StateTypeId &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue); + void stateValueChanged(const StateTypeId &stateTypeId, const QVariant &value, const QVariant &minValue, const QVariant &maxValue, const QVariantList &possibleValues); void settingChanged(const ParamTypeId ¶mTypeId, const QVariant &value); void nameChanged(); void setupStatusChanged(); diff --git a/libnymea/integrations/thingmanager.h b/libnymea/integrations/thingmanager.h index 7e889833..53f6b546 100644 --- a/libnymea/integrations/thingmanager.h +++ b/libnymea/integrations/thingmanager.h @@ -114,7 +114,7 @@ signals: void loaded(); void pluginConfigChanged(const PluginId &id, const ParamList &config); void eventTriggered(const Event &event); - void thingStateChanged(Thing *thing, const StateTypeId &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, const QVariantList &possibleValues); void thingRemoved(const ThingId &thingId); void thingAdded(Thing *thing); void thingChanged(Thing *thing); diff --git a/libnymea/types/state.cpp b/libnymea/types/state.cpp index 0f99319f..17907607 100644 --- a/libnymea/types/state.cpp +++ b/libnymea/types/state.cpp @@ -50,9 +50,9 @@ State::State() /*! Constructs a State reflecting the \l{StateType} given by \a stateTypeId * and associated with the \l{Device} given by \a deviceId */ -State::State(const StateTypeId &stateTypeId, const ThingId &deviceId): +State::State(const StateTypeId &stateTypeId, const ThingId &thingId): m_stateTypeId(stateTypeId), - m_thingId(deviceId) + m_thingId(thingId) { } @@ -90,6 +90,11 @@ void State::setMaxValue(const QVariant &maxValue) m_maxValue = maxValue; } +void State::setPossibleValues(const QVariantList &values) +{ + m_possibleValues = values; +} + QVariant State::minValue() const { return m_minValue; @@ -100,6 +105,11 @@ QVariant State::maxValue() const return m_maxValue; } +QVariantList State::possibleValues() const +{ + return m_possibleValues; +} + Types::StateValueFilter State::filter() const { return m_filter; diff --git a/libnymea/types/state.h b/libnymea/types/state.h index 8f799bb8..6c92fb1b 100644 --- a/libnymea/types/state.h +++ b/libnymea/types/state.h @@ -45,10 +45,11 @@ class LIBNYMEA_EXPORT State Q_PROPERTY(Types::StateValueFilter filter READ filter) Q_PROPERTY(QVariant minValue READ minValue USER true) Q_PROPERTY(QVariant maxValue READ maxValue USER true) + Q_PROPERTY(QVariantList possibleValues READ possibleValues USER true) public: State(); - State(const StateTypeId &stateTypeId, const ThingId &deviceId); + State(const StateTypeId &stateTypeId, const ThingId &thingId); StateTypeId stateTypeId() const; ThingId thingId() const; @@ -58,6 +59,8 @@ public: QVariant minValue() const; QVariant maxValue() const; + QVariantList possibleValues() const; + Types::StateValueFilter filter() const; private: @@ -65,6 +68,7 @@ private: void setValue(const QVariant &value); void setMinValue(const QVariant &minValue); void setMaxValue(const QVariant &maxValue); + void setPossibleValues(const QVariantList &values); void setFilter(Types::StateValueFilter filter); private: @@ -73,6 +77,7 @@ private: QVariant m_value; QVariant m_minValue; QVariant m_maxValue; + QVariantList m_possibleValues; Types::StateValueFilter m_filter = Types::StateValueFilterNone; }; Q_DECLARE_METATYPE(State) diff --git a/libnymea/types/statetype.cpp b/libnymea/types/statetype.cpp index 9d784019..f51752d8 100644 --- a/libnymea/types/statetype.cpp +++ b/libnymea/types/statetype.cpp @@ -160,6 +160,16 @@ void StateType::setPossibleValues(const QVariantList &possibleValues) m_possibleValues = possibleValues; } +QStringList StateType::possibleValuesDisplayNames() const +{ + return m_possibleValuesDisplayNames; +} + +void StateType::setPossibleValuesDisplayNames(const QStringList &possibleValuesDisplayNames) +{ + m_possibleValuesDisplayNames = possibleValuesDisplayNames; +} + /*! Returns the unit of this StateType. */ Types::Unit StateType::unit() const { diff --git a/libnymea/types/statetype.h b/libnymea/types/statetype.h index 422516bc..69d18b7e 100644 --- a/libnymea/types/statetype.h +++ b/libnymea/types/statetype.h @@ -50,6 +50,7 @@ class LIBNYMEA_EXPORT StateType Q_PROPERTY(QVariant minValue READ minValue WRITE setMinValue USER true) Q_PROPERTY(QVariant maxValue READ maxValue WRITE setMaxValue USER true) Q_PROPERTY(QVariantList possibleValues READ possibleValues WRITE setPossibleValues USER true) + Q_PROPERTY(QStringList possibleValuesDisplayNames READ possibleValuesDisplayNames WRITE setPossibleValuesDisplayNames USER true) public: StateType(); @@ -81,6 +82,9 @@ public: QVariantList possibleValues() const; void setPossibleValues(const QVariantList &possibleValues); + QStringList possibleValuesDisplayNames() const; + void setPossibleValuesDisplayNames(const QStringList &possibleValuesDisplayNames); + Types::Unit unit() const; void setUnit(const Types::Unit &unit); @@ -111,6 +115,7 @@ private: QVariant m_minValue; QVariant m_maxValue; QVariantList m_possibleValues; + QStringList m_possibleValuesDisplayNames; Types::Unit m_unit = Types::UnitNone; Types::IOType m_ioType = Types::IOTypeNone; bool m_writable = false; diff --git a/nymea.pro b/nymea.pro index ad128742..4011c6d6 100644 --- a/nymea.pro +++ b/nymea.pro @@ -5,7 +5,7 @@ NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p" # define protocol versions JSON_PROTOCOL_VERSION_MAJOR=8 -JSON_PROTOCOL_VERSION_MINOR=0 +JSON_PROTOCOL_VERSION_MINOR=1 JSON_PROTOCOL_VERSION="$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}" LIBNYMEA_API_VERSION_MAJOR=7 LIBNYMEA_API_VERSION_MINOR=4 diff --git a/plugins/mock/extern-plugininfo.h b/plugins/mock/extern-plugininfo.h index eafc85bb..9138c85b 100644 --- a/plugins/mock/extern-plugininfo.h +++ b/plugins/mock/extern-plugininfo.h @@ -141,6 +141,13 @@ extern ParamTypeId inputTypeMockThingIp4ParamTypeId; extern ParamTypeId inputTypeMockThingIp6ParamTypeId; extern ParamTypeId inputTypeMockThingUrlParamTypeId; extern ParamTypeId inputTypeMockThingMacParamTypeId; +extern ParamTypeId inputTypeMockSettingsBoolParamTypeId; +extern ParamTypeId inputTypeMockSettingsIntParamTypeId; +extern ParamTypeId inputTypeMockSettingsIntWithLimitsParamTypeId; +extern ParamTypeId inputTypeMockSettingsDoubleParamTypeId; +extern ParamTypeId inputTypeMockSettingsDoubleWithLimitsParamTypeId; +extern ParamTypeId inputTypeMockSettingsStringParamTypeId; +extern ParamTypeId inputTypeMockSettingsColorParamTypeId; extern StateTypeId inputTypeMockBoolStateTypeId; extern StateTypeId inputTypeMockWritableBoolStateTypeId; extern StateTypeId inputTypeMockIntStateTypeId; @@ -163,6 +170,7 @@ extern StateTypeId inputTypeMockTimestampIntStateTypeId; extern StateTypeId inputTypeMockWritableTimestampIntStateTypeId; extern StateTypeId inputTypeMockTimestampUIntStateTypeId; extern StateTypeId inputTypeMockWritableTimestampUIntStateTypeId; +extern StateTypeId inputTypeMockLocalizedListStateTypeId; extern ActionTypeId inputTypeMockWritableBoolActionTypeId; extern ParamTypeId inputTypeMockWritableBoolActionWritableBoolParamTypeId; extern ActionTypeId inputTypeMockWritableIntActionTypeId; @@ -189,6 +197,8 @@ extern ActionTypeId inputTypeMockWritableTimestampIntActionTypeId; extern ParamTypeId inputTypeMockWritableTimestampIntActionWritableTimestampIntParamTypeId; extern ActionTypeId inputTypeMockWritableTimestampUIntActionTypeId; extern ParamTypeId inputTypeMockWritableTimestampUIntActionWritableTimestampUIntParamTypeId; +extern ActionTypeId inputTypeMockLocalizedListActionTypeId; +extern ParamTypeId inputTypeMockLocalizedListActionLocalizedListParamTypeId; extern ThingClassId oAuthGoogleMockThingClassId; extern ThingClassId oAuthSonosMockThingClassId; extern ThingClassId userAndPassMockThingClassId; diff --git a/plugins/mock/integrationpluginmock.cpp b/plugins/mock/integrationpluginmock.cpp index e7db1ef2..85127145 100644 --- a/plugins/mock/integrationpluginmock.cpp +++ b/plugins/mock/integrationpluginmock.cpp @@ -757,6 +757,8 @@ void IntegrationPluginMock::executeAction(ThingActionInfo *info) info->thing()->setStateValue(inputTypeMockWritableTimestampIntStateTypeId, info->action().param(inputTypeMockWritableTimestampIntActionWritableTimestampIntParamTypeId).value().toLongLong()); } else if (info->action().actionTypeId() == inputTypeMockWritableTimestampUIntActionTypeId) { info->thing()->setStateValue(inputTypeMockWritableTimestampUIntStateTypeId, info->action().param(inputTypeMockWritableTimestampUIntActionWritableTimestampUIntParamTypeId).value().toULongLong()); + } else if (info->action().actionTypeId() == inputTypeMockLocalizedListActionTypeId) { + info->thing()->setStateValue(inputTypeMockLocalizedListStateTypeId, info->action().paramValue(inputTypeMockLocalizedListActionLocalizedListParamTypeId).toString()); } info->finish(Thing::ThingErrorNoError); return; diff --git a/plugins/mock/integrationpluginmock.json b/plugins/mock/integrationpluginmock.json index 170638fb..60af47ca 100644 --- a/plugins/mock/integrationpluginmock.json +++ b/plugins/mock/integrationpluginmock.json @@ -741,6 +741,60 @@ "defaultValue": "11:22:33:aa:bb:cc" } ], + "settingsTypes": [ + { + "id": "f3f62de8-22fa-4190-b212-2fa30b8db22e", + "name": "bool", + "displayName": "Bool", + "type": "bool", + "defaultValue": false + }, + { + "id": "315d94bd-52a1-45cc-8632-efe53fd96762", + "name": "int", + "displayName": "Integer", + "type": "int", + "defaultValue": 0 + }, + { + "id": "bc22a725-8c09-44b7-94a6-c3b89b042718", + "name": "intWithLimits", + "displayName": "Integer with limits", + "type": "int", + "minValue": 1, + "maxValue": 3, + "defaultValue": 0 + }, + { + "id": "513aa338-e471-4b2a-89f6-8f1470e74fca", + "name": "double", + "displayName": "Double", + "type": "double", + "defaultValue": 0 + }, + { + "id": "efd8a8a9-84cf-4273-b104-678195440fb0", + "name": "doubleWithLimits", + "displayName": "Double with limits", + "type": "double", + "minValue": -100, + "maxValue": 100 + }, + { + "id": "dd268303-8345-4b01-883a-210a4e387130", + "name": "string", + "displayName": "String", + "type": "QString", + "defaultValue": "" + }, + { + "id": "f9d3e963-ab7b-48ba-a475-077f3e80b68b", + "name": "color", + "displayName": "Color", + "type": "QColor", + "defaultValue": "#ff0000" + } + ], "stateTypes": [ { "id": "3bad3a09-5826-4ed7-a832-10e3e2ee2a7d", @@ -939,6 +993,29 @@ "defaultValue": 1549394745, "unit": "UnixTime", "writable": true + }, + { + "id": "23df3dce-bd10-4eb3-b5e3-221168440cd4", + "name": "localizedList", + "displayName": "Localized list", + "displayNameAction": "Set value", + "type": "QString", + "possibleValues": [ + { + "value": "value_a", + "displayName": "Value A" + }, + { + "value": "value_b", + "displayName": "Value B" + }, + { + "value": "value_c", + "displayName": "Value C" + } + ], + "defaultValue": "value_a", + "writable": true } ] }, diff --git a/plugins/mock/plugininfo.h b/plugins/mock/plugininfo.h index d1e42f09..37e1570c 100644 --- a/plugins/mock/plugininfo.h +++ b/plugins/mock/plugininfo.h @@ -145,6 +145,13 @@ ParamTypeId inputTypeMockThingIp4ParamTypeId = ParamTypeId("{9e5f86a0-4bb3-4892- ParamTypeId inputTypeMockThingIp6ParamTypeId = ParamTypeId("{43bf3832-dd48-4090-a836-656e8b60216e}"); ParamTypeId inputTypeMockThingUrlParamTypeId = ParamTypeId("{fa67229f-fcef-496f-b671-59a4b48f3ab5}"); ParamTypeId inputTypeMockThingMacParamTypeId = ParamTypeId("{e93db587-7919-48f3-8c88-1651de63c765}"); +ParamTypeId inputTypeMockSettingsBoolParamTypeId = ParamTypeId("{f3f62de8-22fa-4190-b212-2fa30b8db22e}"); +ParamTypeId inputTypeMockSettingsIntParamTypeId = ParamTypeId("{315d94bd-52a1-45cc-8632-efe53fd96762}"); +ParamTypeId inputTypeMockSettingsIntWithLimitsParamTypeId = ParamTypeId("{bc22a725-8c09-44b7-94a6-c3b89b042718}"); +ParamTypeId inputTypeMockSettingsDoubleParamTypeId = ParamTypeId("{513aa338-e471-4b2a-89f6-8f1470e74fca}"); +ParamTypeId inputTypeMockSettingsDoubleWithLimitsParamTypeId = ParamTypeId("{efd8a8a9-84cf-4273-b104-678195440fb0}"); +ParamTypeId inputTypeMockSettingsStringParamTypeId = ParamTypeId("{dd268303-8345-4b01-883a-210a4e387130}"); +ParamTypeId inputTypeMockSettingsColorParamTypeId = ParamTypeId("{f9d3e963-ab7b-48ba-a475-077f3e80b68b}"); StateTypeId inputTypeMockBoolStateTypeId = StateTypeId("{3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}"); StateTypeId inputTypeMockWritableBoolStateTypeId = StateTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}"); StateTypeId inputTypeMockIntStateTypeId = StateTypeId("{d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}"); @@ -167,6 +174,7 @@ 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}"); +StateTypeId inputTypeMockLocalizedListStateTypeId = StateTypeId("{23df3dce-bd10-4eb3-b5e3-221168440cd4}"); ActionTypeId inputTypeMockWritableBoolActionTypeId = ActionTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}"); ParamTypeId inputTypeMockWritableBoolActionWritableBoolParamTypeId = ParamTypeId("{a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}"); ActionTypeId inputTypeMockWritableIntActionTypeId = ActionTypeId("{857a8422-983c-47d6-a15f-d8450b3162f7}"); @@ -193,6 +201,8 @@ ActionTypeId inputTypeMockWritableTimestampIntActionTypeId = ActionTypeId("{88b6 ParamTypeId inputTypeMockWritableTimestampIntActionWritableTimestampIntParamTypeId = ParamTypeId("{88b6746a-b009-4df6-8986-d7884ffd94b2}"); ActionTypeId inputTypeMockWritableTimestampUIntActionTypeId = ActionTypeId("{45d0069a-63ac-4265-8170-8152778608ee}"); ParamTypeId inputTypeMockWritableTimestampUIntActionWritableTimestampUIntParamTypeId = ParamTypeId("{45d0069a-63ac-4265-8170-8152778608ee}"); +ActionTypeId inputTypeMockLocalizedListActionTypeId = ActionTypeId("{23df3dce-bd10-4eb3-b5e3-221168440cd4}"); +ParamTypeId inputTypeMockLocalizedListActionLocalizedListParamTypeId = ParamTypeId("{23df3dce-bd10-4eb3-b5e3-221168440cd4}"); ThingClassId oAuthGoogleMockThingClassId = ThingClassId("{805d1692-7bd0-449a-9d5c-43a332ff58f4}"); ThingClassId oAuthSonosMockThingClassId = ThingClassId("{783c615b-7bd6-49a4-98b0-8d1deb3c7156}"); ThingClassId userAndPassMockThingClassId = ThingClassId("{6fe07a77-9c07-4736-81e2-d504314bbcb9}"); @@ -264,6 +274,9 @@ const QString translations[] { //: The name of the StateType ({3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Bool"), + //: The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {f3f62de8-22fa-4190-b212-2fa30b8db22e}) + QT_TRANSLATE_NOOP("mock", "Bool"), + //: The name of the ParamType (ThingClass: mock, ActionType: pressButton, ID: {279e0157-78ea-4bb3-a756-b12fb46cf4fc}) QT_TRANSLATE_NOOP("mock", "Button name"), @@ -276,6 +289,9 @@ const QString translations[] { //: The name of the StateType ({4507d5c6-b692-4bd6-87f2-00364bc0cb4d}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Color"), + //: The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {f9d3e963-ab7b-48ba-a475-077f3e80b68b}) + QT_TRANSLATE_NOOP("mock", "Color"), + //: The name of the StateType ({9860d105-2bd9-4651-9bc9-13ff4b9039a7}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Connected"), @@ -300,6 +316,12 @@ const QString translations[] { //: The name of the StateType ({f7d2063d-959e-46ac-8568-8b99722d3b22}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Double"), + //: The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {513aa338-e471-4b2a-89f6-8f1470e74fca}) + QT_TRANSLATE_NOOP("mock", "Double"), + + //: The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {efd8a8a9-84cf-4273-b104-678195440fb0}) + QT_TRANSLATE_NOOP("mock", "Double with limits"), + //: The name of the StateType ({978b0ba5-d008-41bd-b63d-a3bd23cb6469}) of ThingClass autoMock QT_TRANSLATE_NOOP("mock", "Dummy bool state"), @@ -354,6 +376,18 @@ const QString translations[] { //: The name of the StateType ({d0fc56ae-5791-4e91-b76c-dadfbc7e7dbb}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Int"), + //: The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {315d94bd-52a1-45cc-8632-efe53fd96762}) + QT_TRANSLATE_NOOP("mock", "Integer"), + + //: The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {bc22a725-8c09-44b7-94a6-c3b89b042718}) + QT_TRANSLATE_NOOP("mock", "Integer with limits"), + + //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: localizedList, ID: {23df3dce-bd10-4eb3-b5e3-221168440cd4}) + QT_TRANSLATE_NOOP("mock", "Localized list"), + + //: The name of the StateType ({23df3dce-bd10-4eb3-b5e3-221168440cd4}) of ThingClass inputTypeMock + QT_TRANSLATE_NOOP("mock", "Localized list"), + //: The name of the ParamType (ThingClass: inputTypeMock, Type: thing, ID: {e93db587-7919-48f3-8c88-1651de63c765}) QT_TRANSLATE_NOOP("mock", "Mac address"), @@ -450,6 +484,9 @@ const QString translations[] { //: The name of the plugin mock ({727a4a9a-c187-446f-aadf-f1b2220607d1}) QT_TRANSLATE_NOOP("mock", "Mocked things"), + //: The name of a possible value of StateType {209d7afc-6fe9-4fe9-939b-e472ea0ad639} of ThingClass inputTypeMock + QT_TRANSLATE_NOOP("mock", "One"), + //: The name of the ParamType (ThingClass: mock, ActionType: withParams, ID: {d1e428ae-eb8c-45aa-b1b0-e3d7de659c3a}) QT_TRANSLATE_NOOP("mock", "Param with default value"), @@ -582,6 +619,9 @@ const QString translations[] { //: The name of the ActionType ({ebc41327-53d5-40c2-8e7b-1164a8ff359e}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Set update status"), + //: The name of the ActionType ({23df3dce-bd10-4eb3-b5e3-221168440cd4}) of ThingClass inputTypeMock + QT_TRANSLATE_NOOP("mock", "Set value"), + //: The name of the ParamType (ThingClass: mock, Type: settings, ID: {367f7ba4-5039-47be-abd8-59cc8eaf4b9a}) QT_TRANSLATE_NOOP("mock", "Setting 1"), @@ -594,6 +634,33 @@ const QString translations[] { //: The name of the StateType ({27f69ca9-a321-40ff-bfee-4b0272a671b4}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "String"), + //: The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {dd268303-8345-4b01-883a-210a4e387130}) + QT_TRANSLATE_NOOP("mock", "String"), + + //: The name of a possible value of StateType {b463c5ae-4d55-402f-8480-a5cdb485c143} of ThingClass displayPinMock + QT_TRANSLATE_NOOP("mock", "String value 1"), + + //: The name of a possible value of StateType {05f63f9c-f61e-4dcf-ad55-3f13fde2765b} of ThingClass pushButtonMock + QT_TRANSLATE_NOOP("mock", "String value 1"), + + //: The name of a possible value of StateType {b463c5ae-4d55-402f-8480-a5cdb485c143} of ThingClass displayPinMock + QT_TRANSLATE_NOOP("mock", "String value 2"), + + //: The name of a possible value of StateType {05f63f9c-f61e-4dcf-ad55-3f13fde2765b} of ThingClass pushButtonMock + QT_TRANSLATE_NOOP("mock", "String value 2"), + + //: The name of a possible value of StateType {b463c5ae-4d55-402f-8480-a5cdb485c143} of ThingClass displayPinMock + QT_TRANSLATE_NOOP("mock", "String value 3"), + + //: The name of a possible value of StateType {05f63f9c-f61e-4dcf-ad55-3f13fde2765b} of ThingClass pushButtonMock + QT_TRANSLATE_NOOP("mock", "String value 3"), + + //: The name of a possible value of StateType {b463c5ae-4d55-402f-8480-a5cdb485c143} of ThingClass displayPinMock + QT_TRANSLATE_NOOP("mock", "String value 4"), + + //: The name of a possible value of StateType {05f63f9c-f61e-4dcf-ad55-3f13fde2765b} of ThingClass pushButtonMock + QT_TRANSLATE_NOOP("mock", "String value 4"), + //: The name of the StateType ({db9cc518-1012-47e2-8212-6e616fed07a6}) of ThingClass virtualIoTemperatureSensorMock QT_TRANSLATE_NOOP("mock", "Temperature"), @@ -618,6 +685,9 @@ const QString translations[] { //: The name of the StateType ({6c9a96e8-0d48-4f42-8967-848358fd7f79}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "Timestamp (UInt)"), + //: The name of a possible value of StateType {209d7afc-6fe9-4fe9-939b-e472ea0ad639} of ThingClass inputTypeMock + QT_TRANSLATE_NOOP("mock", "Two"), + //: The name of the StateType ({19e74fcc-bfd5-491f-8eb6-af128e8f1162}) of ThingClass inputTypeMock QT_TRANSLATE_NOOP("mock", "UInt"), @@ -633,6 +703,15 @@ const QString translations[] { //: The name of the StateType ({ebc41327-53d5-40c2-8e7b-1164a8ff359e}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "Update status"), + //: The name of a possible value of StateType {23df3dce-bd10-4eb3-b5e3-221168440cd4} of ThingClass inputTypeMock + QT_TRANSLATE_NOOP("mock", "Value A"), + + //: The name of a possible value of StateType {23df3dce-bd10-4eb3-b5e3-221168440cd4} of ThingClass inputTypeMock + QT_TRANSLATE_NOOP("mock", "Value B"), + + //: The name of a possible value of StateType {23df3dce-bd10-4eb3-b5e3-221168440cd4} of ThingClass inputTypeMock + QT_TRANSLATE_NOOP("mock", "Value C"), + //: The name of the ParamType (ThingClass: inputTypeMock, ActionType: writableBool, ID: {a7c11774-f31f-4d64-99d1-e0ae5fb35a5c}) QT_TRANSLATE_NOOP("mock", "Writable Bool"), @@ -729,6 +808,9 @@ const QString translations[] { //: The name of the ParamType (ThingClass: mock, Type: thing, ID: {f2977061-4dd0-4ef5-85aa-3b7134743be3}) QT_TRANSLATE_NOOP("mock", "async"), + //: The name of a possible value of StateType {ebc41327-53d5-40c2-8e7b-1164a8ff359e} of ThingClass mock + QT_TRANSLATE_NOOP("mock", "available"), + //: The name of the StateType ({580bc611-1a55-41f3-996f-8d3ccf543db3}) of ThingClass mock QT_TRANSLATE_NOOP("mock", "battery level critical"), @@ -798,6 +880,9 @@ const QString translations[] { //: The name of the ParamType (ThingClass: mock, Type: thing, ID: {d4f06047-125e-4479-9810-b54c189917f5}) QT_TRANSLATE_NOOP("mock", "http port"), + //: The name of a possible value of StateType {ebc41327-53d5-40c2-8e7b-1164a8ff359e} of ThingClass mock + QT_TRANSLATE_NOOP("mock", "idle"), + //: The name of the ParamType (ThingClass: autoMock, ActionType: withParams, ID: {b8126ba6-3a54-45a3-be4d-63feb0ddb77b}) QT_TRANSLATE_NOOP("mock", "mockActionParam1"), @@ -847,7 +932,13 @@ const QString translations[] { QT_TRANSLATE_NOOP("mock", "resultCount"), //: The name of the ActionType ({064aed0d-da4c-49d4-b236-60f97e98ff84}) of ThingClass mock - QT_TRANSLATE_NOOP("mock", "set power") + QT_TRANSLATE_NOOP("mock", "set power"), + + //: The name of a possible value of StateType {ebc41327-53d5-40c2-8e7b-1164a8ff359e} of ThingClass mock + QT_TRANSLATE_NOOP("mock", "updating"), + + //: The name of a possible value of StateType {209d7afc-6fe9-4fe9-939b-e472ea0ad639} of ThingClass inputTypeMock + QT_TRANSLATE_NOOP("mock", "🎄") }; #endif // PLUGININFO_H diff --git a/plugins/mock/translations/727a4a9a-c187-446f-aadf-f1b2220607d1-de.ts b/plugins/mock/translations/727a4a9a-c187-446f-aadf-f1b2220607d1-de.ts index a0fb209d..e960c2f4 100644 --- a/plugins/mock/translations/727a4a9a-c187-446f-aadf-f1b2220607d1-de.ts +++ b/plugins/mock/translations/727a4a9a-c187-446f-aadf-f1b2220607d1-de.ts @@ -53,17 +53,23 @@ Bool - The name of the StateType ({3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}) of ThingClass inputTypeMock + The name of the StateType ({3bad3a09-5826-4ed7-a832-10e3e2ee2a7d}) of ThingClass inputTypeMock +---------- +The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {f3f62de8-22fa-4190-b212-2fa30b8db22e}) Boolscher Wert Color - The name of the StateType ({4507d5c6-b692-4bd6-87f2-00364bc0cb4d}) of ThingClass inputTypeMock + The name of the StateType ({4507d5c6-b692-4bd6-87f2-00364bc0cb4d}) of ThingClass inputTypeMock +---------- +The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {f9d3e963-ab7b-48ba-a475-077f3e80b68b}) Farbe Double - The name of the StateType ({f7d2063d-959e-46ac-8568-8b99722d3b22}) of ThingClass inputTypeMock + The name of the StateType ({f7d2063d-959e-46ac-8568-8b99722d3b22}) of ThingClass inputTypeMock +---------- +The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {513aa338-e471-4b2a-89f6-8f1470e74fca}) Gleitkommazahl @@ -340,7 +346,9 @@ The name of the ActionType ({72981c04-267a-4ba0-a59e-9921d2f3af9c}) of ThingClas String - The name of the StateType ({27f69ca9-a321-40ff-bfee-4b0272a671b4}) of ThingClass inputTypeMock + The name of the StateType ({27f69ca9-a321-40ff-bfee-4b0272a671b4}) of ThingClass inputTypeMock +---------- +The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {dd268303-8345-4b01-883a-210a4e387130}) Zeichenkette @@ -536,16 +544,6 @@ The name of the ParamType (ThingClass: pushButtonMock, ActionType: color, ID: {2 The name of the StateType ({20dc7c22-c50e-42db-837c-2bbced939f8e}) of ThingClass pushButtonMock Farbe - - configParamBool - The name of the ParamType (ThingClass: mock, Type: plugin, ID: {c75723b6-ea4f-4982-9751-6c5e39c88145}) - - - - configParamInt - The name of the ParamType (ThingClass: mock, Type: plugin, ID: {e1f72121-a426-45e2-b475-8262b5cdf103}) - - double value The name of the ParamType (ThingClass: displayPinMock, ActionType: double, ID: {17635624-7c19-4bae-8429-2f7aa5d2f843}) @@ -585,11 +583,6 @@ The name of the ParamType (ThingClass: mock, ActionType: withParams, ID: {304a48 The name of the ParamType (ThingClass: mock, EventType: event2, ID: {0550e16d-60b9-4ba5-83f4-4d3cee656121}) mockParameterGanzzahl - - nymea - The name of the vendor ({2062d64d-3232-433c-88bc-0d33c0ba2ba6}) - nymea - percentage The name of the ParamType (ThingClass: displayPinMock, ActionType: percentage, ID: {527f0687-0b28-4c26-852c-25b8f83e4797}) @@ -618,12 +611,12 @@ The name of the StateType ({064aed0d-da4c-49d4-b236-60f97e98ff84}) of ThingClass The name of the ParamType (ThingClass: displayPinMock, Type: discovery, ID: {35f6e4ba-28ad-4152-a58d-ec2600667bcf}) ---------- The name of the ParamType (ThingClass: pushButtonMock, Type: discovery, ID: {c40dbc59-4bba-4871-9b8e-bbd8d5d9193b}) - Anzahl Ergebnisse + Anzahl Ergebnisse set power The name of the ActionType ({064aed0d-da4c-49d4-b236-60f97e98ff84}) of ThingClass mock - Ein-/Ausschalten + Ein-/Ausschalten Mock setting @@ -635,108 +628,113 @@ The name of the ParamType (ThingClass: pushButtonMock, Type: discovery, ID: {c40 The name of the ParamType (ThingClass: genericIoMock, ActionType: analogInput1, ID: {ac56977c-cbba-47c6-a827-5735d8b0aed6}) ---------- The name of the StateType ({ac56977c-cbba-47c6-a827-5735d8b0aed6}) of ThingClass genericIoMock - + Analoger Eingang 1 Analog Input 2 The name of the StateType ({8e07e57e-ba4e-42df-81ee-5b72ed074532}) of ThingClass genericIoMock - + Analoger Eingang 2 Analog Output 1 The name of the ParamType (ThingClass: genericIoMock, ActionType: analogOutput1, ID: {70cf053e-4abc-4d88-8e1e-2bd9a62256c7}) ---------- The name of the StateType ({70cf053e-4abc-4d88-8e1e-2bd9a62256c7}) of ThingClass genericIoMock - + Analoger Ausgang 1 Analog Output 2 The name of the ParamType (ThingClass: genericIoMock, ActionType: analogOutput2, ID: {e40bcf7d-47b8-41fa-b213-3652a905b376}) ---------- The name of the StateType ({e40bcf7d-47b8-41fa-b213-3652a905b376}) of ThingClass genericIoMock - + Analoger Ausgang 2 Available firmware version The name of the StateType ({060d7947-2b70-4a2b-b33b-a3577f71faeb}) of ThingClass mock - + Verfügbare Firmware-Version Battery level The name of the ParamType (ThingClass: mock, ActionType: batteryLevel, ID: {6c8ab9a6-0164-4795-b829-f4394fe4edc4}) ---------- The name of the StateType ({6c8ab9a6-0164-4795-b829-f4394fe4edc4}) of ThingClass mock - + Batterie Level Button name The name of the ParamType (ThingClass: mock, ActionType: pressButton, ID: {279e0157-78ea-4bb3-a756-b12fb46cf4fc}) ---------- The name of the ParamType (ThingClass: mock, EventType: pressed, ID: {5f8adeb2-04f0-4b2e-9dbf-a91966bdcc24}) - + Tastenname Button pressed The name of the EventType ({f2708625-4b7b-42fd-9a18-3501d89ce599}) of ThingClass mock - + Taste gedrückt Connected The name of the StateType ({9860d105-2bd9-4651-9bc9-13ff4b9039a7}) of ThingClass mock - + Verbunden Digital Output 1 The name of the ParamType (ThingClass: genericIoMock, ActionType: digitalOutput1, ID: {d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}) ---------- The name of the StateType ({d6fcdb52-f7c3-423b-b9f5-1e29f164c42e}) of ThingClass genericIoMock - + Digitaler Ausgang 1 Digital Output 2 The name of the ParamType (ThingClass: genericIoMock, ActionType: digitalOutput2, ID: {35de8b68-0cf3-4850-a27d-cf9c4a26921f}) ---------- The name of the StateType ({35de8b68-0cf3-4850-a27d-cf9c4a26921f}) of ThingClass genericIoMock - + Digitaler Ausgang 2 Digital input 1 The name of the StateType ({07165c12-4d53-45c0-8bf1-34618443b706}) of ThingClass genericIoMock - + Digitaler Eingang 1 Digital input 2 The name of the StateType ({0a4362ba-a086-4540-84ba-107ef7b99ed8}) of ThingClass genericIoMock - + Digitaler Eingang 2 + + + Double with limits + The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {efd8a8a9-84cf-4273-b104-678195440fb0}) + Gleitkommazahl mit Grenzen Dummy int state with limits The name of the ParamType (ThingClass: mock, ActionType: intWithLimits, ID: {5aa479bd-537a-4716-9852-52f6eec58722}) ---------- The name of the StateType ({5aa479bd-537a-4716-9852-52f6eec58722}) of ThingClass mock - + Ganzzahliger Zustand mit Grenzen Event 1 The name of the EventType ({dad344b4-fff3-4803-b5cb-7cbb65aa5102}) of ThingClass childMock ---------- The name of the EventType ({61ebadc0-47ea-4800-8c45-ee5222cddb4b}) of ThingClass parentMock - + Ereignis 1 Firmware version The name of the StateType ({9f2e1e5d-3f1f-4794-aca3-4e05b7a48842}) of ThingClass mock - + Firmware-Version Generic IO pins The name of the ThingClass ({7cbd729a-465b-4ccb-b59c-5733039dbbed}) - + Generische I/O Pins Generic Light (Mock) The name of the ThingClass ({98ab137e-757e-43f8-9d9b-5d50d990242a}) - + Generisches Licht (Mock) Generic Temperature Sensor (Mock) @@ -750,6 +748,23 @@ The name of the EventType ({61ebadc0-47ea-4800-8c45-ee5222cddb4b}) of ThingClass The name of the StateType ({fd341f72-6d9a-4812-9f66-47197c48a935}) of ThingClass virtualIoTemperatureSensorMock + + Integer + The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {315d94bd-52a1-45cc-8632-efe53fd96762}) + + + + Integer with limits + The name of the ParamType (ThingClass: inputTypeMock, Type: settings, ID: {bc22a725-8c09-44b7-94a6-c3b89b042718}) + + + + Localized list + The name of the ParamType (ThingClass: inputTypeMock, ActionType: localizedList, ID: {23df3dce-bd10-4eb3-b5e3-221168440cd4}) +---------- +The name of the StateType ({23df3dce-bd10-4eb3-b5e3-221168440cd4}) of ThingClass inputTypeMock + + Maximum temperature The name of the ParamType (ThingClass: virtualIoTemperatureSensorMock, Type: settings, ID: {7077c56f-c35b-4252-8c15-8fb549be04ce}) @@ -770,6 +785,11 @@ The name of the StateType ({fd341f72-6d9a-4812-9f66-47197c48a935}) of ThingClass The name of the ParamType (ThingClass: mock, Type: settings, ID: {9c34c881-e825-4f27-bb5c-db868bc60fb1}) + + One + The name of a possible value of StateType {209d7afc-6fe9-4fe9-939b-e472ea0ad639} of ThingClass inputTypeMock + + Param with default value The name of the ParamType (ThingClass: mock, ActionType: withParams, ID: {d1e428ae-eb8c-45aa-b1b0-e3d7de659c3a}) @@ -847,6 +867,11 @@ The name of the StateType ({d1917b3d-1530-4cf9-90f7-263ee88e714b}) of ThingClass The name of the ActionType ({ebc41327-53d5-40c2-8e7b-1164a8ff359e}) of ThingClass mock + + Set value + The name of the ActionType ({23df3dce-bd10-4eb3-b5e3-221168440cd4}) of ThingClass inputTypeMock + + Signal strength The name of the ParamType (ThingClass: mock, ActionType: signalStrength, ID: {2a0213bf-4af3-4384-904e-3376348a597e}) @@ -854,11 +879,44 @@ The name of the StateType ({d1917b3d-1530-4cf9-90f7-263ee88e714b}) of ThingClass The name of the StateType ({2a0213bf-4af3-4384-904e-3376348a597e}) of ThingClass mock + + String value 1 + The name of a possible value of StateType {b463c5ae-4d55-402f-8480-a5cdb485c143} of ThingClass displayPinMock +---------- +The name of a possible value of StateType {05f63f9c-f61e-4dcf-ad55-3f13fde2765b} of ThingClass pushButtonMock + Textwert 1 + + + String value 2 + The name of a possible value of StateType {b463c5ae-4d55-402f-8480-a5cdb485c143} of ThingClass displayPinMock +---------- +The name of a possible value of StateType {05f63f9c-f61e-4dcf-ad55-3f13fde2765b} of ThingClass pushButtonMock + Textwert 2 + + + String value 3 + The name of a possible value of StateType {b463c5ae-4d55-402f-8480-a5cdb485c143} of ThingClass displayPinMock +---------- +The name of a possible value of StateType {05f63f9c-f61e-4dcf-ad55-3f13fde2765b} of ThingClass pushButtonMock + Textwert 3 + + + String value 4 + The name of a possible value of StateType {b463c5ae-4d55-402f-8480-a5cdb485c143} of ThingClass displayPinMock +---------- +The name of a possible value of StateType {05f63f9c-f61e-4dcf-ad55-3f13fde2765b} of ThingClass pushButtonMock + Textwert 4 + Temperature The name of the StateType ({db9cc518-1012-47e2-8212-6e616fed07a6}) of ThingClass virtualIoTemperatureSensorMock + + Two + The name of a possible value of StateType {209d7afc-6fe9-4fe9-939b-e472ea0ad639} of ThingClass inputTypeMock + + Update firmware The name of the ActionType ({f2b847dd-ab40-4278-940b-3615f1d7dfd3}) of ThingClass mock @@ -871,5 +929,55 @@ The name of the StateType ({2a0213bf-4af3-4384-904e-3376348a597e}) of ThingClass The name of the StateType ({ebc41327-53d5-40c2-8e7b-1164a8ff359e}) of ThingClass mock + + available + The name of a possible value of StateType {ebc41327-53d5-40c2-8e7b-1164a8ff359e} of ThingClass mock + + + + configParamBool + The name of the ParamType (ThingClass: mock, Type: plugin, ID: {c75723b6-ea4f-4982-9751-6c5e39c88145}) + + + + configParamInt + The name of the ParamType (ThingClass: mock, Type: plugin, ID: {e1f72121-a426-45e2-b475-8262b5cdf103}) + + + + idle + The name of a possible value of StateType {ebc41327-53d5-40c2-8e7b-1164a8ff359e} of ThingClass mock + + + + nymea + The name of the vendor ({2062d64d-3232-433c-88bc-0d33c0ba2ba6}) + + + + updating + The name of a possible value of StateType {ebc41327-53d5-40c2-8e7b-1164a8ff359e} of ThingClass mock + + + + 🎄 + The name of a possible value of StateType {209d7afc-6fe9-4fe9-939b-e472ea0ad639} of ThingClass inputTypeMock + + + + Value A + The name of a possible value of StateType {23df3dce-bd10-4eb3-b5e3-221168440cd4} of ThingClass inputTypeMock + Wert A + + + Value B + The name of a possible value of StateType {23df3dce-bd10-4eb3-b5e3-221168440cd4} of ThingClass inputTypeMock + Wert B + + + Value C + The name of a possible value of StateType {23df3dce-bd10-4eb3-b5e3-221168440cd4} of ThingClass inputTypeMock + Wert C + diff --git a/tests/auto/api.json b/tests/auto/api.json index b00aeca0..a9dd7667 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -1,4 +1,4 @@ -8.0 +8.1 { "enums": { "BasicType": [ @@ -2405,6 +2405,9 @@ "params": { "maxValue": "Variant", "minValue": "Variant", + "possibleValues": [ + "Variant" + ], "stateTypeId": "Uuid", "thingId": "Uuid", "value": "Variant" @@ -3034,6 +3037,9 @@ "r:filter": "$ref:StateValueFilter", "r:o:maxValue": "Variant", "r:o:minValue": "Variant", + "r:o:possibleValues": [ + "Variant" + ], "r:stateTypeId": "Uuid", "r:value": "Variant" }, @@ -3066,6 +3072,7 @@ "o:possibleValues": [ "Variant" ], + "o:possibleValuesDisplayNames": "StringList", "o:unit": "$ref:Unit", "r:id": "Uuid", "type": "$ref:BasicType" diff --git a/tools/nymea-plugininfocompiler/plugininfocompiler.cpp b/tools/nymea-plugininfocompiler/plugininfocompiler.cpp index f7eb0c98..e4c96acf 100644 --- a/tools/nymea-plugininfocompiler/plugininfocompiler.cpp +++ b/tools/nymea-plugininfocompiler/plugininfocompiler.cpp @@ -301,8 +301,11 @@ void PluginInfoCompiler::writeStateTypes(const StateTypes &stateTypes, const QSt } m_variableNames.append(variableName); write(QString("StateTypeId %1 = StateTypeId(\"%2\");").arg(variableName).arg(stateType.id().toString())); - m_translationStrings.insert(stateType.displayName(), QString("The name of the StateType (%1) of ThingClass %2").arg(stateType.id().toString()).arg(thingClassName)); writeExtern(QString("extern StateTypeId %1;").arg(variableName)); + m_translationStrings.insert(stateType.displayName(), QString("The name of the StateType (%1) of ThingClass %2").arg(stateType.id().toString()).arg(thingClassName)); + foreach (const QString &possibleValueDisplayName, stateType.possibleValuesDisplayNames()) { + m_translationStrings.insert(possibleValueDisplayName, QString("The name of a possible value of StateType %1 of ThingClass %2").arg(stateType.id().toString()).arg(thingClassName)); + } } }