From a23b3ed46d72ef5df8b8629b49df5bb51cd5458d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 13 May 2016 21:21:04 +0200 Subject: [PATCH] add index, criticalStateTypeId, primary Action/StateType --- doc/paramtypes-ui-elements.qdoc | 4 +- doc/plugin-json.qdoc | 26 ++- libguh/plugin/deviceplugin.cpp | 107 ++++++++++-- libguh/plugin/deviceplugin.h | 3 +- libguh/types/actiontype.cpp | 34 +++- libguh/types/actiontype.h | 5 +- libguh/types/eventtype.cpp | 17 +- libguh/types/eventtype.h | 5 +- libguh/types/paramtype.cpp | 14 ++ libguh/types/paramtype.h | 4 + libguh/types/statetype.cpp | 14 ++ libguh/types/statetype.h | 4 + .../devicepluginavahimonitor.json | 4 + .../awattar/devicepluginawattar.json | 17 ++ .../deviceplugincommandlauncher.json | 18 +- .../conrad/devicepluginconrad.json | 9 +- .../datetime/deviceplugindatetime.json | 78 +++++++-- .../denon/deviceplugindenon.json | 6 + .../dollhouse/deviceplugindollhouse.json | 13 +- .../elgato/devicepluginelgato.json | 13 ++ .../deviceplugins/elro/devicepluginelro.json | 35 ++-- .../deviceplugins/eq-3/deviceplugineq-3.json | 158 +++++++++++++----- .../deviceplugingenericelements.json | 9 + .../intertechno/devicepluginintertechno.json | 4 + .../deviceplugins/kodi/devicepluginkodi.json | 21 +++ server/jsonrpc/jsontypes.cpp | 36 +++- 26 files changed, 533 insertions(+), 125 deletions(-) diff --git a/doc/paramtypes-ui-elements.qdoc b/doc/paramtypes-ui-elements.qdoc index 43893343..cb057a68 100644 --- a/doc/paramtypes-ui-elements.qdoc +++ b/doc/paramtypes-ui-elements.qdoc @@ -6,11 +6,11 @@ The images used for this examples were created with the Ubuntu SDK and are ment as an example, not as a directive. Depending on where a \l{ParamType} will be read there are different methods how to present them to the user. - If you have an \l{Action}, you can check out the \i Actions list to get a feeling how an \l{ActionType} can + If you have an \l{Action}, you can check out the \e Actions list to get a feeling how an \l{ActionType} can be interpreted. If a user has to fill out a list of \l{Params}{Param} for a \l{Device} setup or configuration, some examples can be found - in the \i Params list. + in the \e Params list. \chapter Actions \section2 Without params diff --git a/doc/plugin-json.qdoc b/doc/plugin-json.qdoc index 1bd834e9..86b6dc4f 100644 --- a/doc/plugin-json.qdoc +++ b/doc/plugin-json.qdoc @@ -140,6 +140,7 @@ "name": "The name of the device class", "idName": "deviceClassName", "deviceClassId": "uuid", + "deviceIcon": "Icon", "basicTags": [ "BasicTag" ], @@ -148,6 +149,9 @@ ], "setupMethod": "SetupMethod", "pairingInfo": "Information how to pair the device.", + "criticalStateTypeId": "uuid", + "primaryStateTypeId": "uuid", + "primaryActionTypeId": "uuid", "discoveryParamTypes": [ ], "paramTypes": [ @@ -178,6 +182,14 @@ \tt ... + \li - \underline{\e deviceIcon:} Defines the icon for this \l{DeviceClass}. See enum \l{DeviceClass::DeviceIcon} for more information. The expected value for the \e deviceIcon parameters matches the enum name like this: + + \tt {DeviceClass::DeviceIconBed} \unicode{0x2192} \tt {"deviceIcon": "Bed" } + + \tt {DeviceClass::DeviceIconPower} \unicode{0x2192} \tt {"deviceIcon": "Power" } + + \tt ... + \li - \underline{\e createMethods:} A list of possible \l{DeviceClass::CreateMethod}{CreateMethods} for this device \unicode{0x2192} \l{DeviceClass::createMethods()}. Some devices can be created in different ways. Possible values are: \list \li \e user \unicode{0x2192} \l{DeviceClass::CreateMethodUser} @@ -193,6 +205,9 @@ \endlist \note For more information please take a look at \l{CreateMethods and SetupMethods} documentation. \li - \underline{\e pairingInfo:} The \l{DeviceClass::pairingInfo()}{pairingInfo} will inform the user how to pair the device \unicode{0x2192} \l{DeviceClass::setupMethod()}. This parameter will only be used for \l{DeviceClass::SetupMethodDisplayPin}{DisplayPin} and \l{DeviceClass::SetupMethodEnterPin}{EnterPin} and \l{DeviceClass::SetupMethodPushButton}{PushButton}. Example: "Please press the button on the device before continue." + \li - \underline{\e criticalStateTypeId:} Optional: Define which \l{StateType} is critical for this \l{Device}. The given \l{StateTypeId} sould refer to a \tt{bool} \l{State} which enables / disables the whole \l{Device} i.e. \e{"connected"}, \e{"available"} or \e{"reachable"}. This allowes a client developer to disable the device until this \l{State} becomes true. + \li - \underline{\e primaryStateTypeId:} Optional: Define which \l{StateType} is the primary \l{State} for this \l{Device}. This allowes a client developer to place the primary \l{State} value in the device overview. + \li - \underline{\e primaryActionTypeId:} Optional: Define which \l{ActionType} is the primary \l{Action} for this \l{Device}. This allowes a client developer to place the primary \l{Action} element in the device overview. \li - \underline{\e discoveryParamTypes:} A list of \l{ParamType}{ParamTypes} which will be needed for discovering a device \unicode{0x2192} \l{DeviceClass::discoveryParamTypes()}. This parameter will only be used for devices with the \l{DeviceClass::CreateMethodDiscovery}{CreateMethodDiscovery} (see section "\l{The ParamType definition}"). \li - \underline{\e paramTypes:} A list of \l{ParamType}{ParamTypes} which define the paramters of a device \unicode{0x2192} \l{DeviceClass::paramTypes()} (see section "\l{The ParamType definition}"). \li - \underline{\e stateTypes:} A list of \l{StateType}{StateTypes} of the device \unicode{0x2192} \l{DeviceClass::stateTypes()} (see section "\l{The StateType definition}"). @@ -211,6 +226,7 @@ { "name": "name of the param", "type": "DataType", + "index": "int", "inputType": "InputType", "defaultValue": "The default value which will be used if the param is not given." "unit": "The unit of the parameter", @@ -219,8 +235,7 @@ "allowedValues": [ "value" ], - "readOnly": "bool" - + "readOnly": "bool" } ] } @@ -229,6 +244,7 @@ \list \li - \underline{\e name:} The visible name of the \l{ParamType} \unicode{0x2192} \l{ParamType::name()}. \li - \underline{\e type:} The data type of this paramter \unicode{0x2192} \l{ParamType::type()}. + \li - \underline{\e index:} The order index of the \l{ParamType} \unicode{0x2192} \l{ParamType::index()}. This index will be used for sorting the \l{Param}{Params} of a \l{Device}/\l{Action}/\l{Event} to make sure the types looks the same on all clients. Please make sure all \l{ParamType}{ParamTypes} together will create a list from \tt 0 to \tt x. \li - \underline{\e inputType:} A paramter for clients to know which kind of \l{Types::InputType}{InputType} this. See enum \l{Types::InputType} for more information. The expected value for the \e inputType parameter matches the enum name like this: \tt {Types::InputTypeTextArea} \unicode{0x2192} \tt {"inputType": "TextArea"} @@ -357,6 +373,7 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w "name": "name of the action", "idName": "actionName", "id": "uuid", + "index": "int", "paramTypes": [ ... ] @@ -368,7 +385,8 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w \list \li - \underline{\e name:} The visible name of the \l{ActionType} \unicode{0x2192} \l{ActionType::name()}. \li - \underline{\e idName:} This parameter will be used to define the ActionTypeId variable named ActionTypeId in the plugininfo.h, so it can be used in the code. - \li - \underline{\e id:} The actual uuid (\l{ActionTypeId}) of the \l{ActionType} \unicode{0x2192} \l{ActionType::id()}. + \li - \underline{\e id:} The actual uuid (\l{ActionTypeId}) of the \l{ActionType} \unicode{0x2192} \l{ActionType::id()}. + \li - \underline{\e index:} The order index of the \l{ActionType} \unicode{0x2192} \l{ActionType::index()}. This index will be used for sorting the \l{Action}{Actions} of a \l{Device} to make sure the \l{Device} looks the same on all clients. Please make sure all \l{ActionType}{ActionTypes} together will create a list from \tt 0 to \tt x. \li - \underline{\e paramTypes:} A list of \l{ParamType}{ParamTypes} (see section "\l{The ParamType definition}") for this \l{ActionType}. This parameter is optional. You can also create an \l{ActionType} which has no \l{ParamType}{ParamTypes}. \endlist @@ -383,6 +401,7 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w "name": "name of the event", "idName": "eventName", "id": "uuid", + "index": "int", "paramTypes": [ ... ] @@ -395,6 +414,7 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w \li - \underline{\e name:} The visible name of the \l{EventType} \unicode{0x2192} \l{EventType::name()}. \li - \underline{\e idName:} This parameter will be used to define the EventTypeId variable named EventTypeId in the plugininfo.h, so it can be used in the code. \li - \underline{\e id:} The actual uuid (\l{EventTypeId}) of the \l{EventType} \unicode{0x2192} \l{EventType::id()}. + \li - \underline{\e index:} The order index of the \l{EventType} \unicode{0x2192} \l{EventType::index()}. This index will be used for sorting the \l{Event}{Events} of a \l{Device} to make sure the \l{Device} looks the same on all clients. Please make sure all \l{EventType}{EventTypes} together will create a list from \tt 0 to \tt x. \li - \underline{\e paramTypes:} A list of \l{ParamType}{ParamTypes} (see section "\l{The ParamType definition}") for this \l{EventType}. This parameter is optional. You can also create an \l{EventType} which has no \l{ParamType}{ParamTypes}. \endlist diff --git a/libguh/plugin/deviceplugin.cpp b/libguh/plugin/deviceplugin.cpp index 86971486..85e65e1d 100644 --- a/libguh/plugin/deviceplugin.cpp +++ b/libguh/plugin/deviceplugin.cpp @@ -212,7 +212,12 @@ QList DevicePlugin::supportedDevices() const } deviceClass.setCreateMethods(createMethods); deviceClass.setDeviceIcon(loadAndVerifyDeviceIcon(jo.value("deviceIcon").toString())); - deviceClass.setDiscoveryParamTypes(parseParamTypes(jo.value("discoveryParamTypes").toArray())); + QPair > discoveryParamVerification = parseParamTypes(jo.value("discoveryParamTypes").toArray()); + if (!discoveryParamVerification.first) { + broken = true; + } else { + deviceClass.setDiscoveryParamTypes(discoveryParamVerification.second); + } QString setupMethod = jo.value("setupMethod").toString(); if (setupMethod == "pushButton") { @@ -227,7 +232,12 @@ QList DevicePlugin::supportedDevices() const deviceClass.setSetupMethod(DeviceClass::SetupMethodJustAdd); } deviceClass.setPairingInfo(jo.value("pairingInfo").toString()); - deviceClass.setParamTypes(parseParamTypes(jo.value("paramTypes").toArray())); + QPair > paramTypesVerification = parseParamTypes(jo.value("paramTypes").toArray()); + if (!paramTypesVerification.first) { + broken = true; + } else { + deviceClass.setParamTypes(paramTypesVerification.second); + } QList basicTags; foreach (const QJsonValue &basicTagJson, jo.value("basicTags").toArray()) { @@ -239,7 +249,7 @@ QList DevicePlugin::supportedDevices() const QList stateTypes; foreach (const QJsonValue &stateTypesJson, jo.value("stateTypes").toArray()) { QJsonObject st = stateTypesJson.toObject(); - QStringList missingFields = verifyFields(QStringList() << "type" << "id" << "name", st); + QStringList missingFields = verifyFields(QStringList() << "type" << "id" << "name" << "index", st); if (!missingFields.isEmpty()) { qCWarning(dcDeviceManager) << "Skipping device class" << deviceClass.name() << "because of missing" << missingFields.join(", ") << "in stateTypes"; broken = true; @@ -249,6 +259,7 @@ QList DevicePlugin::supportedDevices() const QVariant::Type t = QVariant::nameToType(st.value("type").toString().toLatin1().data()); StateType stateType(st.value("id").toString()); stateType.setName(st.value("name").toString()); + stateType.setIndex(st.value("index").toInt()); stateType.setType(t); stateType.setUnit(loadAndVerifyUnit(st.value("unit").toString())); stateType.setDefaultValue(st.value("defaultValue").toVariant()); @@ -279,6 +290,7 @@ QList DevicePlugin::supportedDevices() const // Note: fields already checked in StateType ActionType actionType(ActionTypeId(stateType.id().toString())); actionType.setName("set " + stateType.name()); + actionType.setIndex(stateType.index()); ParamType paramType(stateType.name(), t, stateType.defaultValue()); paramType.setAllowedValues(stateType.possibleValues()); paramType.setUnit(stateType.unit()); @@ -291,7 +303,7 @@ QList DevicePlugin::supportedDevices() const foreach (const QJsonValue &actionTypesJson, jo.value("actionTypes").toArray()) { QJsonObject at = actionTypesJson.toObject(); - QStringList missingFields = verifyFields(QStringList() << "id" << "name", at); + QStringList missingFields = verifyFields(QStringList() << "id" << "name" << "index", at); if (!missingFields.isEmpty()) { qCWarning(dcDeviceManager) << "Skipping device class" << deviceClass.name() << "because of missing" << missingFields.join(", ") << "in actionTypes"; broken = true; @@ -300,7 +312,14 @@ QList DevicePlugin::supportedDevices() const ActionType actionType(at.value("id").toString()); actionType.setName(at.value("name").toString()); - actionType.setParamTypes(parseParamTypes(at.value("paramTypes").toArray())); + actionType.setIndex(at.value("index").toInt()); + QPair > paramVerification = parseParamTypes(at.value("paramTypes").toArray()); + if (!paramVerification.first) { + broken = true; + } else { + actionType.setParamTypes(paramVerification.second); + } + actionTypes.append(actionType); } deviceClass.setActionTypes(actionTypes); @@ -308,7 +327,7 @@ QList DevicePlugin::supportedDevices() const QList eventTypes; foreach (const QJsonValue &eventTypesJson, jo.value("eventTypes").toArray()) { QJsonObject et = eventTypesJson.toObject(); - QStringList missingFields = verifyFields(QStringList() << "id" << "name", et); + QStringList missingFields = verifyFields(QStringList() << "id" << "name" << "index", et); if (!missingFields.isEmpty()) { qCWarning(dcDeviceManager) << "Skipping device class" << deviceClass.name() << "because of missing" << missingFields.join(", ") << "in eventTypes"; broken = true; @@ -317,11 +336,50 @@ QList DevicePlugin::supportedDevices() const EventType eventType(et.value("id").toString()); eventType.setName(et.value("name").toString()); - eventType.setParamTypes(parseParamTypes(et.value("paramTypes").toArray())); + eventType.setIndex(et.value("index").toInt()); + + QPair > paramVerification = parseParamTypes(et.value("paramTypes").toArray()); + if (!paramVerification.first) { + broken = true; + } else { + eventType.setParamTypes(paramVerification.second); + } + eventTypes.append(eventType); } deviceClass.setEventTypes(eventTypes); + // Note: do this after the actionType / stateType / eventType parsing + if (jo.contains("criticalStateTypeId")) { + StateTypeId criticalStateTypeId = StateTypeId(jo.value("criticalStateTypeId").toString()); + if (!deviceClass.hasStateType(criticalStateTypeId)) { + qCWarning(dcDeviceManager) << "Skipping device class" << deviceClass.name() << ": the definend critical stateTypeId" << criticalStateTypeId.toString() << "does not match any StateType of this DeviceClass."; + broken = true; + } else { + deviceClass.setCriticalStateTypeId(criticalStateTypeId); + } + } + + if (jo.contains("primaryStateTypeId")) { + StateTypeId primaryStateTypeId = StateTypeId(jo.value("primaryStateTypeId").toString()); + if (!deviceClass.hasStateType(primaryStateTypeId)) { + qCWarning(dcDeviceManager) << "Skipping device class" << deviceClass.name() << ": the definend primary stateTypeId" << primaryStateTypeId.toString() << "does not match any StateType of this DeviceClass."; + broken = true; + } else { + deviceClass.setPrimaryStateTypeId(primaryStateTypeId); + } + } + + if (jo.contains("primaryActionTypeId")) { + ActionTypeId primaryActionTypeId = ActionTypeId(jo.value("primaryActionTypeId").toString()); + if (!deviceClass.hasActionType(primaryActionTypeId)) { + qCWarning(dcDeviceManager) << "Skipping device class" << deviceClass.name() << ": the definend primary actionTypeId" << primaryActionTypeId.toString() << "does not match any ActionType of this DeviceClass."; + broken = true; + } else { + deviceClass.setPrimaryActionTypeId(primaryActionTypeId); + } + } + if (!broken) deviceClasses.append(deviceClass); @@ -438,25 +496,41 @@ void DevicePlugin::initPlugin(const QJsonObject &metaData, DeviceManager *device m_metaData = metaData; // parse plugin configuration params - if (m_metaData.contains("paramTypes")) - m_configurationDescription = parseParamTypes(m_metaData.value("paramTypes").toArray()); + if (m_metaData.contains("paramTypes")) { + QPair > paramVerification = parseParamTypes(m_metaData.value("paramTypes").toArray()); + if (paramVerification.first) { + m_configurationDescription = paramVerification.second; + } + } m_deviceManager = deviceManager; init(); } -QList DevicePlugin::parseParamTypes(const QJsonArray &array) const +QPair > DevicePlugin::parseParamTypes(const QJsonArray &array) const { QList paramTypes; foreach (const QJsonValue ¶mTypesJson, array) { QJsonObject pt = paramTypesJson.toObject(); + + // Check fields + QStringList missingFields = verifyFields(QStringList() << "name" << "index" << "type", pt); + if (!missingFields.isEmpty()) { + qCWarning(dcDeviceManager) << pluginName() << "Error parsing ParamType: missing fields" << missingFields.join(", ") << endl << pt; + return QPair >(false, QList()); + } + + // Check type QVariant::Type t = QVariant::nameToType(pt.value("type").toString().toLatin1().data()); - Q_ASSERT_X(t != QVariant::Invalid, - pluginName().toLatin1().data(), - QString("Invalid type %1 for param %2 in json file.") - .arg(pt.value("type").toString()) - .arg(pt.value("name").toString()).toLatin1().data()); + if (t == QVariant::Invalid) { + qCWarning(dcDeviceManager()) << pluginName() << QString("Invalid type %1 for param %2 in json file.") + .arg(pt.value("type").toString()) + .arg(pt.value("name").toString()).toLatin1().data(); + return QPair >(false, QList()); + } + ParamType paramType(pt.value("name").toString(), t, pt.value("defaultValue").toVariant()); + paramType.setIndex(pt.value("index").toInt()); // set allowed values QVariantList allowedValues; @@ -482,7 +556,8 @@ QList DevicePlugin::parseParamTypes(const QJsonArray &array) const paramType.setLimits(pt.value("minValue").toVariant(), pt.value("maxValue").toVariant()); paramTypes.append(paramType); } - return paramTypes; + + return QPair >(true, paramTypes); } /*! diff --git a/libguh/plugin/deviceplugin.h b/libguh/plugin/deviceplugin.h index 72a1734c..93fd5a25 100644 --- a/libguh/plugin/deviceplugin.h +++ b/libguh/plugin/deviceplugin.h @@ -41,6 +41,7 @@ #include #include #include +#include class DeviceManager; class Device; @@ -126,7 +127,7 @@ protected: private: void initPlugin(const QJsonObject &metaData, DeviceManager *deviceManager); - QList parseParamTypes(const QJsonArray &array) const; + QPair > parseParamTypes(const QJsonArray &array) const; QStringList verifyFields(const QStringList &fields, const QJsonObject &value) const; diff --git a/libguh/types/actiontype.cpp b/libguh/types/actiontype.cpp index cb835070..75c782ed 100644 --- a/libguh/types/actiontype.cpp +++ b/libguh/types/actiontype.cpp @@ -31,44 +31,60 @@ by the plugin. All Actions must have valid a ActionType in order to be useful. + \sa Action */ #include "actiontype.h" -/*! Constructs an ActionType with the given \a id. */ +/*! Constructs an \l{ActionType} with the given \a id. */ ActionType::ActionType(const ActionTypeId &id): - m_id(id) + m_id(id), + m_index(0) { + } -/*! Returns the id of this ActionType. */ +/*! Returns the id of this \l{ActionType}. */ ActionTypeId ActionType::id() const { return m_id; } -/*! Returns the name of this ActionType. */ +/*! Returns the name of this \l{ActionType}. */ QString ActionType::name() const { return m_name; } -/*! Set the \a name for this Action. This will be visible to the user. */ +/*! Set the \a name for this \l{ActionType}. This will be visible to the user. */ void ActionType::setName(const QString &name) { m_name = name; } -/*! Returns the parameter description of this ActionType. \l{Action}{Actions} created - * from this ActionType must have their parameters matching to this template. */ +/*! Returns the index of this \l{ActionType}. The index of an \l{ActionType} indicates the order in the \l{DeviceClass}. + * This guarantees that a \l{Device} will look always the same (\l{Action} order). */ +int ActionType::index() const +{ + return m_index; +} + +/*! Set the \a index of this \l{ActionType}. */ +void ActionType::setIndex(const int &index) +{ + m_index = index; +} + +/*! Returns the parameter description of this \l{ActionType}. \l{Action}{Actions} created + * from this \l{ActionType} must have their parameters matching to this template. */ QList ActionType::paramTypes() const { return m_paramTypes; } -/*! Set the parameter description of this ActionType. \l{Action}{Actions} created - * from this ActionType must have their \a paramTypes matching to this template. */ +/*! Set the parameter description of this \l{ActionType}. \l{Action}{Actions} created + * from this \l{ActionType} must have their \a paramTypes matching to this template. */ void ActionType::setParamTypes(const QList ¶mTypes) { m_paramTypes = paramTypes; diff --git a/libguh/types/actiontype.h b/libguh/types/actiontype.h index 0538ca17..ab3c65f4 100644 --- a/libguh/types/actiontype.h +++ b/libguh/types/actiontype.h @@ -38,13 +38,16 @@ public: QString name() const; void setName(const QString &name); + int index() const; + void setIndex(const int &index); + QList paramTypes() const; void setParamTypes(const QList ¶mTypes); private: ActionTypeId m_id; QString m_name; - + int m_index; QList m_paramTypes; }; diff --git a/libguh/types/eventtype.cpp b/libguh/types/eventtype.cpp index 5cbe8b25..d349845c 100644 --- a/libguh/types/eventtype.cpp +++ b/libguh/types/eventtype.cpp @@ -33,8 +33,10 @@ /*! Constructs a EventType object with the given \a id. */ EventType::EventType(const EventTypeId &id): - m_id(id) + m_id(id), + m_index(0) { + } /*! Returns the id. */ @@ -55,6 +57,19 @@ void EventType::setName(const QString &name) m_name = name; } +/*! Returns the index of this \l{EventType}. The index of an \l{EventType} indicates the order in the \l{DeviceClass}. + * This guarantees that a \l{Device} will look always the same (\l{Event} order). */ +int EventType::index() const +{ + return m_index; +} + +/*! Set the \a index of this \l{EventType}. */ +void EventType::setIndex(const int &index) +{ + m_index = index; +} + /*! Holds a List describing possible parameters for a \l{Event} of this EventType. * e.g. QList(ParamType("temperature", QVariant::Real)). */ QList EventType::paramTypes() const diff --git a/libguh/types/eventtype.h b/libguh/types/eventtype.h index 67b5c89a..38a6e788 100644 --- a/libguh/types/eventtype.h +++ b/libguh/types/eventtype.h @@ -38,15 +38,18 @@ public: QString name() const; void setName(const QString &name); + int index() const; + void setIndex(const int &index); + QList paramTypes() const; void setParamTypes(const QList ¶mTypes); private: EventTypeId m_id; QString m_name; + int m_index; QList m_paramTypes; - }; #endif // TRIGGERTYPE_H diff --git a/libguh/types/paramtype.cpp b/libguh/types/paramtype.cpp index cd29143c..d6c35b5f 100644 --- a/libguh/types/paramtype.cpp +++ b/libguh/types/paramtype.cpp @@ -35,12 +35,14 @@ /*! Constructs a ParamType object with the given \a name, \a type and \a defaultValue. */ ParamType::ParamType(const QString &name, const QVariant::Type type, const QVariant &defaultValue): m_name(name), + m_index(0), m_type(type), m_defaultValue(defaultValue), m_inputType(Types::InputTypeNone), m_unit(Types::UnitNone), m_readOnly(false) { + } /*! Returns the name of this ParamType. */ @@ -55,6 +57,18 @@ void ParamType::setName(const QString &name) m_name = name; } +/*! Returns the index of this \l{ParamType}. The index of an \l{ParamType} indicates the order in the corresponding Type. */ +int ParamType::index() const +{ + return m_index; +} + +/*! Set the \a index of this \l{ParamType}. */ +void ParamType::setIndex(const int &index) +{ + m_index = index; +} + /*! Returns the type of this ParamType. */ QVariant::Type ParamType::type() const { diff --git a/libguh/types/paramtype.h b/libguh/types/paramtype.h index 59860c02..f0519d8c 100644 --- a/libguh/types/paramtype.h +++ b/libguh/types/paramtype.h @@ -36,6 +36,9 @@ public: QString name() const; void setName(const QString &name); + int index() const; + void setIndex(const int &index); + QVariant::Type type() const; void setType(QVariant::Type type); @@ -65,6 +68,7 @@ public: private: QString m_name; + int m_index; QVariant::Type m_type; QVariant m_defaultValue; QVariant m_minValue; diff --git a/libguh/types/statetype.cpp b/libguh/types/statetype.cpp index ea557ffd..a701b214 100644 --- a/libguh/types/statetype.cpp +++ b/libguh/types/statetype.cpp @@ -36,6 +36,7 @@ * hardcode it into the plugin. */ StateType::StateType(const StateTypeId &id): m_id(id), + m_index(0), m_defaultValue(QVariant()), m_minValue(QVariant()), m_maxValue(QVariant()), @@ -63,6 +64,19 @@ void StateType::setName(const QString &name) m_name = name; } +/*! Returns the index of this \l{StateType}. The index of an \l{StateType} indicates the order in the \l{DeviceClass}. + * This guarantees that a \l{Device} will look always the same (\l{State} order). */ +int StateType::index() const +{ + return m_index; +} + +/*! Set the \a index of this \l{StateType}. */ +void StateType::setIndex(const int &index) +{ + m_index = index; +} + /*! Returns the Type of the StateType (e.g. QVariant::Real). */ QVariant::Type StateType::type() const { diff --git a/libguh/types/statetype.h b/libguh/types/statetype.h index 83517703..076f6f09 100644 --- a/libguh/types/statetype.h +++ b/libguh/types/statetype.h @@ -37,6 +37,9 @@ public: QString name() const; void setName(const QString &name); + int index() const; + void setIndex(const int &index); + QVariant::Type type() const; void setType(const QVariant::Type &type); @@ -58,6 +61,7 @@ public: private: StateTypeId m_id; QString m_name; + int m_index; QVariant::Type m_type; QVariant m_defaultValue; QVariant m_minValue; diff --git a/plugins/deviceplugins/avahimonitor/devicepluginavahimonitor.json b/plugins/deviceplugins/avahimonitor/devicepluginavahimonitor.json index 82f71199..819f4c52 100644 --- a/plugins/deviceplugins/avahimonitor/devicepluginavahimonitor.json +++ b/plugins/deviceplugins/avahimonitor/devicepluginavahimonitor.json @@ -13,6 +13,7 @@ "name": "Avahi Monitor", "idName": "avahi", "deviceIcon": "Network", + "primaryStateTypeId": "b5616fd3-da12-4613-9576-6516b2267180", "basicTags": [ "Device", "Sensor" @@ -22,11 +23,13 @@ { "name": "service name", "type": "QString", + "index": 0, "inputType": "TextLine" }, { "name": "host name", "type": "QString", + "index": 1, "inputType": "TextLine" } ], @@ -36,6 +39,7 @@ "name": "online", "idName": "online", "type": "bool", + "index": 0, "defaultValue": false } ] diff --git a/plugins/deviceplugins/awattar/devicepluginawattar.json b/plugins/deviceplugins/awattar/devicepluginawattar.json index a7034184..680d0fef 100644 --- a/plugins/deviceplugins/awattar/devicepluginawattar.json +++ b/plugins/deviceplugins/awattar/devicepluginawattar.json @@ -6,6 +6,7 @@ { "name": "RPL address", "type": "QString", + "index": 0, "inputType": "TextLine", "defaultValue": "fdaa:e9b8:d03a::ff:fe00:1" } @@ -21,6 +22,8 @@ "name": "aWATTar", "createMethods": ["user"], "deviceIcon": "Energy", + "primaryStateTypeId": "eab37309-3dd8-46a0-94d4-bd05b5bb0430", + "criticalStateTypeId": "470b9b88-17f3-42e3-9250-cc181984eafe", "basicTags": [ "Service", "Actuator", @@ -31,11 +34,13 @@ { "name": "user uuid", "type": "QString", + "index": 0, "inputType": "TextLine" }, { "name": "token", "type": "QString", + "index": 1, "inputType": "Password" } ], @@ -45,6 +50,7 @@ "idName": "currentMarketPrice", "name": "current market price", "type": "double", + "index": 0, "unit": "EuroCentPerKiloWattHour", "defaultValue": 0 }, @@ -52,6 +58,7 @@ "id": "38b86cee-9588-4269-a585-128907929dc2", "idName": "averageDeviation", "name": "average deviation", + "index": 1, "type": "int", "unit": "Percentage", "defaultValue": 0 @@ -60,6 +67,7 @@ "id": "d5a8a176-aca0-45b1-b043-95c43750f383", "idName": "validUntil", "name": "valid until", + "index": 2, "unit": "UnixTime", "type": "int", "defaultValue": 0 @@ -68,6 +76,7 @@ "id": "55d6d7a8-446f-48ae-8014-1225810d03ee", "idName": "averagePrice", "name": "average market price [± 12 h]", + "index": 3, "type": "double", "unit": "EuroCentPerKiloWattHour", "defaultValue": 0 @@ -76,6 +85,7 @@ "id": "e7af5bdc-48d7-4e96-b877-331da4dcfae5", "idName": "lowestPrice", "name": "lowest market price [± 12 h]", + "index": 4, "type": "double", "unit": "EuroCentPerKiloWattHour", "defaultValue": 0 @@ -84,6 +94,7 @@ "id": "0c171c42-b070-453e-8a63-df9aebfa8533", "idName": "highestPrice", "name": "highest market price [± 12 h]", + "index": 5, "type": "double", "unit": "EuroCentPerKiloWattHour", "defaultValue": 0 @@ -91,6 +102,7 @@ { "id": "470b9b88-17f3-42e3-9250-cc181984eafe", "idName": "online", + "index": 6, "name": "online", "type": "bool", "defaultValue": false @@ -98,6 +110,7 @@ { "id": "1c9d139a-6618-4a39-bc83-37f80942017d", "idName": "reachable", + "index": 7, "name": "pump reachable", "type": "bool", "defaultValue": false @@ -106,6 +119,7 @@ "id": "b83d3533-aeae-4a9b-95d8-28466bf6c0cf", "idName": "sgMode", "name": "sg-mode", + "index": 8, "type": "QString", "possibleValues": [ "0 - Invalid", @@ -120,6 +134,7 @@ "id": "4c303bcd-152d-45ad-874d-d57fc87a26bb", "idName": "sgSyncMode", "name": "sync mode", + "index": 9, "type": "QString", "possibleValues": [ "auto", @@ -134,10 +149,12 @@ "id": "dd82f6c7-5e92-48ca-b0bc-bdc55d3e1482", "idName": "setSgMode", "name": "set sg-mode", + "index": 0, "paramTypes": [ { "name": "sg-mode", "type": "QString", + "index": 0, "allowedValues": [ "1 - Off", "2 - Normal", diff --git a/plugins/deviceplugins/commandlauncher/deviceplugincommandlauncher.json b/plugins/deviceplugins/commandlauncher/deviceplugincommandlauncher.json index caeedaf3..a125a4f5 100644 --- a/plugins/deviceplugins/commandlauncher/deviceplugincommandlauncher.json +++ b/plugins/deviceplugins/commandlauncher/deviceplugincommandlauncher.json @@ -12,6 +12,7 @@ "idName": "application", "name": "Application launcher", "createMethods": ["user"], + "primaryActionTypeId": "cf52b41d-3108-423c-8907-ca5b4d97cac5", "basicTags": [ "Service", "Actuator" @@ -20,6 +21,7 @@ { "name": "command", "type": "QString", + "index": 0, "inputType": "TextLine" } ], @@ -28,6 +30,7 @@ "id": "28d7e933-ff05-4f4c-95a0-482689543de5", "idName": "running", "name": "running", + "index": 0, "type": "bool", "defaultValue": false } @@ -36,12 +39,14 @@ { "id": "cf52b41d-3108-423c-8907-ca5b4d97cac5", "idName": "execute", - "name": "execute" + "name": "execute", + "index": 0 }, { "id": "d21b1fed-1dd9-4c5a-a64e-0c6ba94059be", "idName": "kill", - "name": "kill" + "name": "kill", + "index": 1 } ] }, @@ -54,10 +59,12 @@ "Actuator" ], "createMethods": ["user"], + "primaryActionTypeId": "cf52b41d-3108-423c-8907-ca5b4d97cac5", "paramTypes": [ { "name": "script", "type": "QString", + "index": 0, "inputType": "Url" } ], @@ -66,6 +73,7 @@ "id": "28d7e933-ff05-4f4c-95a0-482689543de5", "idName": "running", "name": "running", + "index": 0, "type": "bool", "defaultValue": false } @@ -74,12 +82,14 @@ { "id": "cf52b41d-3108-423c-8907-ca5b4d97cac5", "idName": "execute", - "name": "execute" + "name": "execute", + "index": 0 }, { "id": "d21b1fed-1dd9-4c5a-a64e-0c6ba94059be", "idName": "kill", - "name": "kill" + "name": "kill", + "index": 1 } ] } diff --git a/plugins/deviceplugins/conrad/devicepluginconrad.json b/plugins/deviceplugins/conrad/devicepluginconrad.json index ca4aee72..158eb9c5 100644 --- a/plugins/deviceplugins/conrad/devicepluginconrad.json +++ b/plugins/deviceplugins/conrad/devicepluginconrad.json @@ -24,17 +24,20 @@ { "id": "e015419c-9df9-4bf5-a439-f1f32aedd1db", "idName": "up", - "name": "up" + "name": "up", + "index": 0 }, { "id": "c58a463a-f765-4a61-b2e2-883cc23878c0", "idName": "down", - "name": "down" + "name": "down", + "index": 1 }, { "id": "4125a18e-fa2d-4b25-acd1-e148d5d665f5", "idName": "sync", - "name": "Send sync signal" + "name": "Send sync signal", + "index": 2 } ] } diff --git a/plugins/deviceplugins/datetime/deviceplugindatetime.json b/plugins/deviceplugins/datetime/deviceplugindatetime.json index 172be0dd..ab93fa47 100644 --- a/plugins/deviceplugins/datetime/deviceplugindatetime.json +++ b/plugins/deviceplugins/datetime/deviceplugindatetime.json @@ -24,6 +24,7 @@ "id": "ab16997c-be29-438e-b588-2507d723d264", "idName": "timeZone", "name": "timezone", + "index": 0, "type": "QString", "defaultValue": "-" }, @@ -31,6 +32,7 @@ "id": "65d2a5ff-bcab-43a8-b043-f88cf01586f4", "idName": "city", "name": "city", + "index": 1, "type": "QString", "defaultValue": "-" }, @@ -38,13 +40,15 @@ "id": "a534bd8b-6826-4d71-b9f9-df1433964b94", "idName": "country", "name": "country", + "index": 2, "type": "QString", "defaultValue": "-" }, { "id": "eb5231ea-6a1b-4d7e-a95f-d49e7b25122e", - "name": "day", "idName": "day", + "name": "day", + "index": 3, "type": "int", "defaultValue": 1, "minValue": 1, @@ -52,8 +56,9 @@ }, { "id": "fcd8ec96-4488-438a-8b30-58bfe2a7fae2", - "name": "month", "idName": "month", + "name": "month", + "index": 4, "type": "int", "defaultValue": 1, "minValue": 1, @@ -63,6 +68,7 @@ "id": "a37acc9c-5cfb-4687-adce-e56beb32586f", "idName": "monthName", "name": "month name", + "index": 5, "type": "QString", "defaultValue": "-" }, @@ -70,6 +76,7 @@ "id": "79d4ae9b-ea27-4346-8229-1d90f1ddfc9d", "idName": "year", "name": "year", + "index": 6, "type": "int", "defaultValue": "1970" }, @@ -78,6 +85,7 @@ "idName": "weekday", "name": "weekday", "type": "int", + "index": 7, "defaultValue": 1, "minValue": 1, "maxValue": 7 @@ -86,6 +94,7 @@ "id": "f627d052-cee6-4727-b9c6-0e935d41e04a", "idName": "weekdayName", "name": "weekday name", + "index": 8, "type": "QString", "defaultValue": "-" }, @@ -93,6 +102,7 @@ "id": "4de5b57b-bb1a-4d66-9ce3-22bb280b075d", "idName": "weekend", "name": "weekend", + "index": 9, "type": "bool", "defaultValue": false }, @@ -100,6 +110,7 @@ "id": "44a99419-fbcd-4d8e-9441-897848b8f77c", "idName": "dusk", "name": "dusk", + "index": 10, "unit": "UnixTime", "type": "int", "defaultValue": 0 @@ -108,6 +119,7 @@ "id": "3a08824d-285b-412e-a515-9664b491a85c", "idName": "sunrise", "name": "sunrise", + "index": 11, "unit": "UnixTime", "type": "int", "defaultValue": 0 @@ -116,6 +128,7 @@ "id": "d92be29a-929c-4240-91a0-30153850f838", "idName": "noon", "name": "sun noon", + "index": 12, "unit": "UnixTime", "type": "int", "defaultValue": 0 @@ -124,6 +137,7 @@ "id": "a5779b11-0499-4a6d-a7bd-8143dcc546b4", "idName": "dawn", "name": "dawn", + "index": 13, "unit": "UnixTime", "type": "int", "defaultValue": 0 @@ -132,6 +146,7 @@ "id": "377f04a7-df58-42ad-a234-e9e23bdc2f85", "idName": "sunset", "name": "sunset", + "index": 14, "unit": "UnixTime", "type": "int", "defaultValue": 0 @@ -141,27 +156,32 @@ { "id": "792885f3-f505-42db-8c74-3d0460b575a1", "idName": "dusk", - "name": "dusk" + "name": "dusk", + "index": 0 }, { "id": "726acb30-928b-43da-a790-977a821c979e", "idName": "sunrise", - "name": "sunrise" + "name": "sunrise", + "index": 1 }, { "id": "97ae8dd8-640c-4f9b-8773-aa7abb1d32fa", "idName": "noon", - "name": "noon" + "name": "noon", + "index": 2 }, { "id": "5e3657b0-a459-4837-a632-0b20de4b7349", "idName": "dawn", - "name": "dawn" + "name": "dawn", + "index": 3 }, { "id": "f40d6e0f-fda2-475e-a6ae-c3fee03138b9", "idName": "sunset", - "name": "sunset" + "name": "sunset", + "index": 4 } ] }, @@ -180,48 +200,58 @@ { "name": "monday", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 0 }, { "name": "tuesday", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 1 }, { "name": "wednesday", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 2 }, { "name": "thursday", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 3 }, { "name": "friday", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 4 }, { "name": "saturday", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 5 }, { "name": "sunday", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 6 }, { "name": "minutes", + "index": 7, "type": "int", "unit": "Minutes", "minValue": 0, "maxValue": 60, "defaultValue": 0 + }, { "name": "hours", + "index": 8, "type": "int", "minValue": 0, "maxValue": 24, @@ -231,6 +261,7 @@ { "name": "time type", "type": "QString", + "index": 9, "allowedValues": [ "time", "dusk", @@ -243,6 +274,7 @@ }, { "name": "offset", + "index": 10, "type": "int", "minValue": -120, "maxValue": 120, @@ -254,6 +286,7 @@ { "id": "5ec9a4af-d5ea-4f68-ab32-f7a3fcd75ccc", "idName": "alarm", + "index": 0, "name": "alarm" } ] @@ -272,6 +305,7 @@ "paramTypes": [ { "name": "seconds", + "index": 0, "type": "int", "unit": "Seconds", "minValue": 0, @@ -280,6 +314,7 @@ }, { "name": "minutes", + "index": 1, "type": "int", "unit": "Minutes", "minValue": 0, @@ -288,6 +323,7 @@ }, { "name": "hours", + "index": 2, "type": "int", "unit": "Hours", "minValue": 0, @@ -296,6 +332,7 @@ }, { "name": "repeating", + "index": 3, "type": "bool", "defaultValue": false } @@ -304,7 +341,8 @@ { "id": "1db11351-ad67-448e-a784-216741a06a58", "idName": "timeout", - "name": "timeout" + "name": "timeout", + "index": 0 } ], "stateTypes": [ @@ -312,6 +350,7 @@ "id": "b21ccd53-1ebd-41a0-a2a3-662874e79837", "idName": "running", "name": "running", + "index": 0, "type": "bool", "defaultValue": false } @@ -320,17 +359,20 @@ { "id": "436e9923-6eff-444e-bde7-a61228a4d748", "idName": "start", - "name": "start" + "name": "start", + "index": 0 }, { "id": "bf4d1def-4159-4254-a76d-fd31aaa84e2d", "idName": "stop", - "name": "stop" + "name": "stop", + "index": 1 }, { "id": "14aad613-b972-411f-93c9-f00bfd254285", "idName": "restart", - "name": "restart" + "name": "restart", + "index": 2 } ] } diff --git a/plugins/deviceplugins/denon/deviceplugindenon.json b/plugins/deviceplugins/denon/deviceplugindenon.json index f5da6710..57709a73 100644 --- a/plugins/deviceplugins/denon/deviceplugindenon.json +++ b/plugins/deviceplugins/denon/deviceplugindenon.json @@ -13,6 +13,7 @@ "idName": "AVRX1000", "name": "AVR X1000", "createMethods": ["user"], + "criticalStateTypeId": "4d1790bf-28c6-4c1f-8892-ba1a0ef140f5", "deviceIcon": "Hifi", "basicTags": [ "Device", @@ -22,6 +23,7 @@ { "name": "ip", "type" : "QString", + "index": 0, "inputType": "IPv4Address" } ], @@ -30,6 +32,7 @@ "id": "4d1790bf-28c6-4c1f-8892-ba1a0ef140f5", "idName": "connected", "name": "connected", + "index": 0, "type": "bool" }, { @@ -37,6 +40,7 @@ "id": "1cdb6b54-6831-4900-95b2-c78f64497701", "idName": "power", "type": "bool", + "index": 1, "defaultValue": false, "writable": true }, @@ -44,6 +48,7 @@ "name": "volume", "id": "773636b9-304d-463a-8755-fc7488dc0ff3", "idName": "volume", + "index": 2, "type": "int", "unit": "Dezibel", "defaultValue": 0, @@ -55,6 +60,7 @@ "name": "channel", "id": "f29ffa2c-31d6-4d88-b160-a38288c82ce1", "idName": "channel", + "index": 3, "type": "QString", "writable": true, "possibleValues": [ diff --git a/plugins/deviceplugins/dollhouse/deviceplugindollhouse.json b/plugins/deviceplugins/dollhouse/deviceplugindollhouse.json index c3650d28..196fe7a5 100644 --- a/plugins/deviceplugins/dollhouse/deviceplugindollhouse.json +++ b/plugins/deviceplugins/dollhouse/deviceplugindollhouse.json @@ -21,11 +21,13 @@ { "name": "name", "type": "QString", + "index": 0, "defaultValue": "Dollhouse Connection" }, { "name": "RPL address", "type": "QString", + "index": 1, "inputType": "TextLine", "defaultValue": "fdaa:e9b8:d03a::ff:fe00:1" } @@ -36,6 +38,7 @@ "idName": "light", "deviceClassId": "b4dd5f10-36d4-4232-867a-6d3b04a08bad", "createMethods": ["auto"], + "criticalStateTypeId": "93c539b4-50d8-431e-8be4-5ebba89452b7", "basicTags": [ "Device", "Lighting" @@ -44,21 +47,25 @@ { "name": "name", "type": "QString", + "index": 0, "defaultValue": "Dollhouse Light" }, { "name": "address", - "type": "QString" + "type": "QString", + "index": 1 }, { "name": "light id", "type": "int", + "index": 2, "defaultValue": 0, "readOnly": true }, { "name": "connection uuid", "type": "QString", + "index": 3, "inputType": "TextLine", "readOnly": true } @@ -68,6 +75,7 @@ "id": "e4885a73-9fe1-48ca-b773-aeb93f34cd54", "idName": "color", "name": "color", + "index": 0, "type": "QColor", "defaultValue": "#fff30a", "writable": true @@ -76,6 +84,7 @@ "id": "e78c9136-c10a-45c9-b6bc-2d937f09cdec", "idName": "brightness", "name": "brightness", + "index": 1, "type": "int", "unit": "Percentage", "minValue": 0, @@ -87,6 +96,7 @@ "id": "f6ac30a0-77b8-4f1f-8c44-4c2e6d542663", "idName": "power", "name": "power", + "index": 2, "type": "bool", "defaultValue": false, "writable": true @@ -95,6 +105,7 @@ "id": "93c539b4-50d8-431e-8be4-5ebba89452b7", "idName": "reachable", "name": "reachable", + "index": 3, "type": "bool", "defaultValue": false } diff --git a/plugins/deviceplugins/elgato/devicepluginelgato.json b/plugins/deviceplugins/elgato/devicepluginelgato.json index 4ad2d1bb..f3224c54 100644 --- a/plugins/deviceplugins/elgato/devicepluginelgato.json +++ b/plugins/deviceplugins/elgato/devicepluginelgato.json @@ -12,6 +12,7 @@ "idName": "avea", "name": "Avea", "deviceIcon": "LightBulb", + "criticalStateTypeId": "6d5e792a-c786-40d2-ae35-a48ac6fafcbc", "basicTags": [ "Device", "Actuator", @@ -22,11 +23,13 @@ { "name": "name", "type": "QString", + "index": 0, "inputType": "TextLine" }, { "name": "mac address", "type": "QString", + "index": 1, "inputType": "MacAddress" } ], @@ -35,6 +38,7 @@ "id": "6d5e792a-c786-40d2-ae35-a48ac6fafcbc", "idName": "available", "name": "available", + "index": 0, "type": "bool", "defaultValue": false }, @@ -42,6 +46,7 @@ "id": "c38181a0-e19b-423f-8b66-dedda94e89b5", "idName": "brightness", "name": "brightness", + "index": 1, "type": "int", "minimumValue": 0, "maximumValue": 100, @@ -52,6 +57,7 @@ "id": "2073b44b-2f99-4abf-8d9f-6b33be8e1763", "idName": "liveliness", "name": "liveliness", + "index": 2, "type": "int", "minimumValue": 0, "maximumValue": 100, @@ -63,26 +69,31 @@ { "id": "30b6334d-37cd-4b94-a397-3b9b642c762e", "idName": "connect", + "index": 0, "name": "connect" }, { "id": "1daa8def-85d7-44fb-b0bd-77a4301056e5", "idName": "disconnect", + "index": 1, "name": "disconnect" }, { "id": "b2f39b7b-dd11-4db4-a82b-dd3d4b973bd5", "idName": "powerOff", + "index": 2, "name": "power off" }, { "id": "7936bd51-7ea3-4df4-9998-7325de85b677", "idName": "color", + "index": 3, "name": "set color", "paramTypes": [ { "name": "color", "type": "QString", + "index": 0, "allowedValues": [ "green", "yellow", @@ -98,11 +109,13 @@ { "id": "dfbc86e8-3891-4782-ae14-05228e70423e", "idName": "mood", + "index": 4, "name": "set mood", "paramTypes": [ { "name": "mood", "type": "QString", + "index": 0, "allowedValues": [ "calm provence", "cozy flames", diff --git a/plugins/deviceplugins/elro/devicepluginelro.json b/plugins/deviceplugins/elro/devicepluginelro.json index 509a4786..bcb8099f 100644 --- a/plugins/deviceplugins/elro/devicepluginelro.json +++ b/plugins/deviceplugins/elro/devicepluginelro.json @@ -18,46 +18,57 @@ ], "idName": "elroSocket", "createMethods": ["user"], + "primaryActionTypeId": "31c9758e-6567-4f89-85bb-29e1a7c55d44", "paramTypes": [ { "name": "channel 1", - "type": "bool" + "type": "bool", + "index": 0 }, { "name": "channel 2", - "type": "bool" + "type": "bool", + "index": 1 }, { "name": "channel 3", - "type": "bool" + "type": "bool", + "index": 3 }, { "name": "channel 4", - "type": "bool" + "type": "bool", + "index": 4 }, { "name": "channel 5", - "type": "bool" + "type": "bool", + "index": 5 }, { "name": "A", - "type": "bool" + "type": "bool", + "index": 6 }, { "name": "B", - "type": "bool" + "type": "bool", + "index": 7 }, { "name": "C", - "type": "bool" + "type": "bool", + "index": 8 }, { "name": "D", - "type": "bool" + "type": "bool", + "index": 9 }, { "name": "E", - "type": "bool" + "type": "bool", + "index": 10 } ], "actionTypes": [ @@ -65,10 +76,12 @@ "id": "31c9758e-6567-4f89-85bb-29e1a7c55d44", "idName": "power", "name": "set power", + "index": 0, "paramTypes": [ { "name": "power", - "type": "bool" + "type": "bool", + "index": 0 } ] } diff --git a/plugins/deviceplugins/eq-3/deviceplugineq-3.json b/plugins/deviceplugins/eq-3/deviceplugineq-3.json index 2e91e3bf..ba2fdaad 100644 --- a/plugins/deviceplugins/eq-3/deviceplugineq-3.json +++ b/plugins/deviceplugins/eq-3/deviceplugineq-3.json @@ -13,6 +13,7 @@ "idName": "cube", "name": "Max! Cube LAN Gateway", "deviceIcon": "Gateway", + "criticalStateTypeId": "d0a9a369-cf8c-47c4-a12e-f2d076bf12fd", "basicTags": [ "Device", "Gateway", @@ -24,20 +25,24 @@ { "name": "host address", "type": "QString", - "inputType": "IPv4Address" + "inputType": "IPv4Address", + "index": 0 }, { "name": "port", - "type": "int" + "type": "int", + "index": 1 }, { "name": "serial number", "type": "QString", - "inputType": "TextLine" + "inputType": "TextLine", + "index": 2 }, { "name": "firmware version", - "type": "int" + "type": "int", + "index": 3 } ], "stateTypes": [ @@ -45,6 +50,7 @@ "id": "d0a9a369-cf8c-47c4-a12e-f2d076bf12fd", "idName": "connection", "name": "connected", + "index": 0, "type": "bool", "defaultValue": false }, @@ -52,6 +58,7 @@ "id": "2c2367da-c229-40ed-9d47-a6e73cd6dc3b", "idName": "portalEnabled", "name": "portal enabled", + "index": 1, "type": "bool", "defaultValue": false } @@ -62,6 +69,7 @@ "idName": "wallThermostate", "name": "Max! Wall Thermostat", "deviceIcon": "Thermometer", + "primaryStateTypeId": "852e7708-db1d-42d1-96e4-19c13598262c", "basicTags": [ "Device", "Heating", @@ -72,54 +80,65 @@ "paramTypes": [ { "name": "serial number", - "type": "QString" + "type": "QString", + "index": 0 }, { "name": "name", - "type": "QString" + "type": "QString", + "index": 1 }, { "name": "parent cube", - "type": "QString" + "type": "QString", + "index": 2 }, { "name": "rf address", - "type": "QString" + "type": "QString", + "index": 3 }, { "name": "room id", - "type": "int" + "type": "int", + "index": 4 }, { "name": "room name", - "type": "QString" + "type": "QString", + "index": 5 } ], "actionTypes": [ { "id": "162b4b3d-9923-4f2c-a755-b50c8a06a6f0", "idName": "setAutoMode", - "name": "set auto mode" + "name": "set auto mode", + "index": 0 }, { "id": "8e604437-9f5b-4c17-b5b0-e2db6007af5b", "idName": "setManualMode", - "name": "set manual mode" + "name": "set manual mode", + "index": 1 }, { "id": "27a981e8-ec23-4ba8-921e-33b911a7dd89", "idName": "setEcoMode", - "name": "set eco mode" + "name": "set eco mode", + "index": 2 }, { "id": "184fb112-7a03-4560-8634-0257c969c26e", "idName": "displayCurrentTemp", "name": "display current temperature", + "index": 3, "paramTypes": [ { "name": "display", "type": "bool", - "defaultValue": true + "defaultValue": true, + "index": 0 } ] } @@ -130,6 +149,7 @@ "idName": "comfortTemp", "name": "comfort temperature", "type": "double", + "index": 0, "unit": "DegreeCelsius", "defaultValue": 0 }, @@ -138,6 +158,7 @@ "idName": "ecoTemp", "name": "eco temperature", "type": "double", + "index": 1, "unit": "DegreeCelsius", "defaultValue": 0 }, @@ -146,6 +167,7 @@ "idName": "maxSetpointTemp", "name": "max setpoint", "type": "double", + "index": 2, "unit": "DegreeCelsius", "defaultValue": 0 }, @@ -154,6 +176,7 @@ "idName": "minSetpointTemp", "name": "min setpoint", "type": "double", + "index": 3, "unit": "DegreeCelsius", "defaultValue": 0 }, @@ -162,6 +185,7 @@ "idName": "errorOccurred", "name": "error occurred", "type": "bool", + "index": 4, "defaultValue": false }, { @@ -169,6 +193,7 @@ "idName": "initialized", "name": "initialized", "type": "bool", + "index": 5, "defaultValue": false }, { @@ -176,6 +201,7 @@ "idName": "batteryLow", "name": "battery low", "type": "bool", + "index": 6, "defaultValue": false }, { @@ -183,6 +209,7 @@ "idName": "linkStatusOK", "name": "link status ok", "type": "bool", + "index": 7, "defaultValue": false }, { @@ -190,6 +217,7 @@ "idName": "panelLocked", "name": "panel locked", "type": "bool", + "index": 8, "defaultValue": false }, { @@ -197,6 +225,7 @@ "idName": "gatewayKnown", "name": "gateway known", "type": "bool", + "index": 9, "defaultValue": false }, { @@ -204,6 +233,7 @@ "idName": "dtsActive", "name": "dts active", "type": "bool", + "index": 10, "defaultValue": false }, { @@ -211,12 +241,14 @@ "idName": "deviceMode", "name": "device mode", "type": "int", + "index": 11, "defaultValue": -1 }, { "id": "ff5194e3-5641-4ac2-92c7-48c431b4a2eb", "idName": "deviceModeString", "name": "device mode string", + "index": 12, "type": "QString" }, { @@ -225,6 +257,7 @@ "name": "desired temperature", "type": "double", "unit": "DegreeCelsius", + "index": 13, "defaultValue": 0, "writable": true @@ -234,6 +267,7 @@ "idName": "currentTemperature", "name": "current temp", "unit": "DegreeCelsius", + "index": 14, "type": "double", "defaultValue": 0 } @@ -254,44 +288,53 @@ "paramTypes": [ { "name": "serial number", - "type": "QString" + "type": "QString", + "index": 0 }, { "name": "name", - "type": "QString" + "type": "QString", + "index": 1 }, { "name": "parent cube", - "type": "QString" + "type": "QString", + "index": 2 }, { "name": "rf address", - "type": "QString" + "type": "QString", + "index": 3 }, { "name": "room id", - "type": "int" + "type": "int", + "index": 4 }, { "name": "room name", - "type": "QString" + "type": "QString", + "index": 5 } ], "actionTypes": [ { "id": "162b4b3d-9923-4f2c-a755-b50c8a06a6f0", "idName": "setAutoMode", - "name": "set auto mode" + "name": "set auto mode", + "index": 0 }, { "id": "8e604437-9f5b-4c17-b5b0-e2db6007af5b", "idName": "setManualMode", - "name": "set manual mode" + "name": "set manual mode", + "index": 1 }, { "id": "27a981e8-ec23-4ba8-921e-33b911a7dd89", "idName": "setEcoMode", - "name": "set eco mode" + "name": "set eco mode", + "index": 2 } ], "stateTypes": [ @@ -301,7 +344,8 @@ "name": "comfort temperature", "unit": "DegreeCelsius", "type": "double", - "defaultValue": 0 + "defaultValue": 0, + "index": 0 }, { "id": "24dfd20d-bc8d-48e4-8162-b20ae0465c41", @@ -309,7 +353,8 @@ "name": "eco temperature", "unit": "DegreeCelsius", "type": "double", - "defaultValue": 0 + "defaultValue": 0, + "index": 1 }, { "id": "a8536ddf-a6e4-41c2-89c1-e7102608f5f6", @@ -317,7 +362,8 @@ "name": "max setpoint", "unit": "DegreeCelsius", "type": "double", - "defaultValue": 0 + "defaultValue": 0, + "index": 2 }, { "id": "ceb0ad05-37ad-4b79-a4d9-540c34a7e3e4", @@ -325,69 +371,79 @@ "name": "min setpoint", "unit": "DegreeCelsius", "type": "double", - "defaultValue": 0 + "defaultValue": 0, + "index": 3 }, { "id": "9880247b-cf9a-453c-b0c3-d910eba8a253", "idName": "errorOccurred", "name": "error occured", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 4 }, { "id": "a9e29f03-063e-4686-8aac-2f6d8f8a4937", "idName": "initialized", "name": "initialized", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 5 }, { "id": "53b89f32-8894-4290-92a0-6a470c6b69ab", "idName": "batteryLow", "name": "battery low", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 6 }, { "id": "aff38be8-7ea6-4fd8-b0fa-e987ab05c719", "idName": "batteryLow", "name": "link status ok", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 7 }, { "id": "979df197-09a1-46f9-9217-9d323b1062bd", "idName": "panelLocked", "name": "panel locked", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 8 }, { "id": "1d6bd962-5c31-47ad-80a4-dda87bff98f5", "idName": "gatewayKnown", "name": "gateway known", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 9 }, { "id": "1b402ba6-a8ae-45b1-8acf-2b0a89f71889", "idName": "dtsActive", "name": "dts active", "type": "bool", - "defaultValue": false + "defaultValue": false, + "index": 10 }, { "id": "639360f0-bb65-43e6-b227-50ae0ac39d6c", "idName": "deviceMode", "name": "device mode", "type": "int", - "defaultValue": -1 + "defaultValue": -1, + "index": 11 }, { "id": "ff5194e3-5641-4ac2-92c7-48c431b4a2eb", "idName": "deviceModeString", "name": "device mode string", - "type": "QString" + "type": "QString", + "index": 12 }, { "id": "579aa8c6-8814-491b-9e7c-b98108c323d1", @@ -396,7 +452,8 @@ "unit": "DegreeCelsius", "type": "double", "defaultValue": 0, - "writable": true + "writable": true, + "index": 13 }, { "id": "576da571-9a65-478f-96bf-19256c8b9ece", @@ -404,7 +461,8 @@ "name": "offset temperature", "unit": "DegreeCelsius", "type": "double", - "defaultValue": 0 + "defaultValue": 0, + "index": 14 }, { "id": "81c6c74a-b0cd-4daa-9eb9-f1cd68f328af", @@ -412,14 +470,16 @@ "name": "window open duration", "unit": "Minutes", "type": "int", - "defaultValue": 0 + "defaultValue": 0, + "index": 15 }, { "id": "7c41fa64-b1a1-48d2-9d03-67aa16cd83ad", "idName": "boostValveValue", "name": "boost valve value", "type": "int", - "defaultValue": 0 + "defaultValue": 0, + "index": 16 }, { "id": "e75c1398-9ad7-466c-b3b9-b03bbb686a30", @@ -427,28 +487,32 @@ "name": "boost duration", "unit": "Seconds", "type": "int", - "defaultValue": 0 + "defaultValue": 0, + "index": 17 }, { "id": "bd6f5947-d4b4-444b-81c8-77eec46957e4", "idName": "discalcWeekDay", "name": "discalc weekday", "type": "QString", - "defaultValue": "" + "defaultValue": "", + "index": 18 }, { "id": "e78235ee-affc-41e3-a463-9f0512b4a6c3", "idName": "discalcTime", "name": "discalc time", "type": "QString", - "defaultValue": "" + "defaultValue": "", + "index": 19 }, { "id": "e367fa3a-b30f-49bd-af3f-cff92360ad32", "idName": "valveMaximumSettings", "name": "valve maximum setting", "type": "double", - "defaultValue": 0 + "defaultValue": 0, + "index": 20 }, { "id": "ffaff87b-b741-4db8-9875-3380af4f1885", @@ -456,7 +520,8 @@ "name": "valve offset", "unit": "Percentage", "type": "int", - "defaultValue": 0 + "defaultValue": 0, + "index": 21 }, { "id": "72956000-0203-4c32-a6b6-3bb7e46c03ca", @@ -464,7 +529,8 @@ "name": "valve position", "unit": "Percentage", "type": "int", - "defaultValue": 0 + "defaultValue": 0, + "index": 22 } ] } diff --git a/plugins/deviceplugins/genericelements/deviceplugingenericelements.json b/plugins/deviceplugins/genericelements/deviceplugingenericelements.json index 0008bcc6..b53b451e 100644 --- a/plugins/deviceplugins/genericelements/deviceplugingenericelements.json +++ b/plugins/deviceplugins/genericelements/deviceplugingenericelements.json @@ -13,6 +13,7 @@ "idName": "toggleButton", "name": "Toggle Button", "deviceIcon": "Switch", + "primaryActionTypeId": "b5e90567-54aa-49bd-a78a-3c19fb38aaf5", "basicTags": [ "Device", "Actuator" @@ -24,6 +25,7 @@ "id": "b5e90567-54aa-49bd-a78a-3c19fb38aaf5", "idName": "state", "name": "state", + "index": 0, "type": "bool", "defaultValue": false, "writable": true @@ -35,6 +37,7 @@ "idName": "button", "name": "Button", "deviceIcon": "Switch", + "primaryActionTypeId": "01f38af1-b2ab-4ec3-844e-ef52f0f229a9", "basicTags": [ "Device", "Actuator" @@ -45,6 +48,7 @@ { "id": "01f38af1-b2ab-4ec3-844e-ef52f0f229a9", "idName": "buttonPress", + "index": 0, "name": "press" } ], @@ -52,6 +56,7 @@ { "id": "effdbc2d-e467-4b0b-80a9-9dda251bfa5c", "idName": "buttonPressed", + "index": 0, "name": "button pressed" } ] @@ -71,11 +76,13 @@ { "id": "892596d2-0863-4807-97da-469b9f7003f2", "idName": "onOffButtonOn", + "index": 0, "name": "press ON" }, { "id": "a8d64050-0b58-4ccf-b052-77ce2b7368ad", "idName": "onOffButtonOff", + "index": 1, "name": "press OFF" } ], @@ -83,11 +90,13 @@ { "id": "4eeba6a2-e4c7-4a2e-8360-2797d98114e6", "idName": "onOffButtonOn", + "index": 0, "name": "ON pressed" }, { "id": "b636c5f3-2eb0-4682-96d4-88a4aa9d2c12", "idName": "onOffButtonOff", + "index": 1, "name": "OFF pressed" } ] diff --git a/plugins/deviceplugins/intertechno/devicepluginintertechno.json b/plugins/deviceplugins/intertechno/devicepluginintertechno.json index 22606f53..c01e70f2 100644 --- a/plugins/deviceplugins/intertechno/devicepluginintertechno.json +++ b/plugins/deviceplugins/intertechno/devicepluginintertechno.json @@ -13,6 +13,7 @@ "name": "Intertechno switch", "createMethods": ["user"], "deviceIcon": "Switch", + "primaryActionTypeId": "df19fb51-c3cd-4b95-8d88-ebbb535f4789", "basicTags": [ "Device", "Actuator" @@ -21,11 +22,13 @@ { "name": "family code", "type": "QString", + "index": 0, "allowedValues": ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P"] }, { "name": "button code", "type": "int", + "index": 1, "minValue": 1, "maxValue": 16 } @@ -34,6 +37,7 @@ { "id": "df19fb51-c3cd-4b95-8d88-ebbb535f4789", "name": "set power", + "index": 0, "paramTypes": [ { "name": "power", diff --git a/plugins/deviceplugins/kodi/devicepluginkodi.json b/plugins/deviceplugins/kodi/devicepluginkodi.json index 4f82b84d..98b350c6 100644 --- a/plugins/deviceplugins/kodi/devicepluginkodi.json +++ b/plugins/deviceplugins/kodi/devicepluginkodi.json @@ -19,19 +19,23 @@ "Actuator" ], "createMethods": ["user", "discovery"], + "criticalStateTypeId": "09dfbd40-c97c-4a20-9ecd-f80e389a4864", "paramTypes": [ { "name": "name", "type": "QString", + "index": 0, "inputType": "TextLine" }, { "name": "ip", "type" : "QString", + "index": 1, "inputType": "IPv4Address" }, { "name": "port", + "index": 2, "type" : "int" } ], @@ -40,12 +44,14 @@ "id": "09dfbd40-c97c-4a20-9ecd-f80e389a4864", "idName": "connected", "name": "connected", + "index": 0, "type": "bool" }, { "id": "bc98cdb0-4d0e-48ca-afc7-922e49bb7813", "idName": "mute", "name": "mute", + "index": 1, "type": "bool", "writable": true }, @@ -55,6 +61,7 @@ "name": "volume", "unit": "Percentage", "type": "int", + "index": 2, "minValue": 0, "maxValue": 100, "writable": true @@ -64,16 +71,19 @@ { "id": "2535a1eb-7643-4874-98f6-b027fdff6311", "idName": "onPlayerPlay", + "index": 0, "name": "player play" }, { "id": "99498b1c-e9c0-480a-9e91-662ee79ba976", "idName": "onPlayerPause", + "index": 1, "name": "player pause" }, { "id": "a02ce255-3abb-435d-a92e-7f99c952ecb2", "idName": "onPlayerStop", + "index": 2, "name": "player stop" } ], @@ -82,15 +92,18 @@ "id": "dc0aa3b5-4eae-4e58-a4ac-d4c124da53f1", "idName": "showNotification", "name": "show notification", + "index": 0, "paramTypes": [ { "name": "message", "type": "QString", + "index": 0, "inputType": "TextLine" }, { "name": "type", "type": "QString", + "index": 1, "defaultValue": "info", "allowedValues": [ "info", @@ -104,10 +117,12 @@ "id": "28060803-aa85-44a4-9dec-ee669dfb629f", "idName": "pressButton", "name": "press button", + "index": 1, "paramTypes": [ { "name": "button", "type": "QString", + "index": 0, "allowedValues": [ "left", "right", @@ -147,10 +162,12 @@ "id": "8d51cd64-ecef-44f8-85b0-697bef252ce5", "idName": "system", "name": "system", + "index": 2, "paramTypes": [ { "name": "command", "type": "QString", + "index": 0, "defaultValue": "shutdown", "allowedValues": [ "hibernate", @@ -165,10 +182,12 @@ "id": "59f7ad10-16eb-40b7-a88b-c8393ae8e413", "idName": "videoLibrary", "name": "video library", + "index": 3, "paramTypes": [ { "name": "command", "type": "QString", + "index": 0, "defaultValue": "scan", "allowedValues": [ "scan", @@ -181,10 +200,12 @@ "id": "3d5120eb-1007-46c3-b76e-d9d4b105b9f2", "idName": "audioLibrary", "name": "audio library", + "index": 4, "paramTypes": [ { "name": "command", "type": "QString", + "index": 0, "defaultValue": "scan", "allowedValues": [ "scan", diff --git a/server/jsonrpc/jsontypes.cpp b/server/jsonrpc/jsontypes.cpp index a919f0b9..4d6fa658 100644 --- a/server/jsonrpc/jsontypes.cpp +++ b/server/jsonrpc/jsontypes.cpp @@ -135,6 +135,7 @@ void JsonTypes::init() // ParamType s_paramType.insert("name", basicTypeToString(String)); s_paramType.insert("type", basicTypeRef()); + s_paramType.insert("index", basicTypeToString(Int)); s_paramType.insert("o:defaultValue", basicTypeToString(Variant)); s_paramType.insert("o:minValue", basicTypeToString(Variant)); s_paramType.insert("o:maxValue", basicTypeToString(Variant)); @@ -167,6 +168,7 @@ void JsonTypes::init() s_stateType.insert("id", basicTypeToString(Uuid)); s_stateType.insert("name", basicTypeToString(String)); s_stateType.insert("type", basicTypeRef()); + s_stateType.insert("index", basicTypeToString(Int)); s_stateType.insert("defaultValue", basicTypeToString(Variant)); s_stateType.insert("o:unit", unitRef()); s_stateType.insert("o:minValue", basicTypeToString(Variant)); @@ -192,27 +194,29 @@ void JsonTypes::init() // EventType s_eventType.insert("id", basicTypeToString(Uuid)); s_eventType.insert("name", basicTypeToString(String)); + s_eventType.insert("index", basicTypeToString(Int)); s_eventType.insert("paramTypes", QVariantList() << paramTypeRef()); // Event s_event.insert("eventTypeId", basicTypeToString(Uuid)); s_event.insert("deviceId", basicTypeToString(Uuid)); - s_event.insert("o:params", QVariantList() << paramRef()); + s_event.insert("params", QVariantList() << paramRef()); // EventDescriptor s_eventDescriptor.insert("eventTypeId", basicTypeToString(Uuid)); s_eventDescriptor.insert("deviceId", basicTypeToString(Uuid)); - s_eventDescriptor.insert("o:paramDescriptors", QVariantList() << paramDescriptorRef()); + s_eventDescriptor.insert("paramDescriptors", QVariantList() << paramDescriptorRef()); // ActionType s_actionType.insert("id", basicTypeToString(Uuid)); s_actionType.insert("name", basicTypeToString(Uuid)); - s_actionType.insert("paramTypes", QVariantList() << paramTypeRef()); + s_actionType.insert("index", basicTypeToString(Int)); + s_actionType.insert("o:paramTypes", QVariantList() << paramTypeRef()); // Action s_action.insert("actionTypeId", basicTypeToString(Uuid)); s_action.insert("deviceId", basicTypeToString(Uuid)); - s_action.insert("o:params", QVariantList() << paramRef()); + s_action.insert("params", QVariantList() << paramRef()); // Pugin s_plugin.insert("id", basicTypeToString(Uuid)); @@ -230,13 +234,16 @@ void JsonTypes::init() s_deviceClass.insert("name", basicTypeToString(String)); s_deviceClass.insert("deviceIcon", deviceIconRef()); s_deviceClass.insert("basicTags", QVariantList() << basicTagRef()); + s_deviceClass.insert("setupMethod", setupMethodRef()); + s_deviceClass.insert("createMethods", QVariantList() << createMethodRef()); + s_deviceClass.insert("o:criticalStateTypeId", basicTypeToString(Uuid)); + s_deviceClass.insert("o:primaryStateTypeId", basicTypeToString(Uuid)); + s_deviceClass.insert("o:primaryActionTypeId", basicTypeToString(Uuid)); s_deviceClass.insert("stateTypes", QVariantList() << stateTypeRef()); s_deviceClass.insert("eventTypes", QVariantList() << eventTypeRef()); s_deviceClass.insert("actionTypes", QVariantList() << actionTypeRef()); s_deviceClass.insert("paramTypes", QVariantList() << paramTypeRef()); s_deviceClass.insert("discoveryParamTypes", QVariantList() << paramTypeRef()); - s_deviceClass.insert("setupMethod", setupMethodRef()); - s_deviceClass.insert("createMethods", QVariantList() << createMethodRef()); // Device s_device.insert("id", basicTypeToString(Uuid)); @@ -384,6 +391,7 @@ QVariantMap JsonTypes::packEventType(const EventType &eventType) QVariantMap variant; variant.insert("id", eventType.id()); variant.insert("name", eventType.name()); + variant.insert("index", eventType.index()); QVariantList paramTypes; foreach (const ParamType ¶mType, eventType.paramTypes()) { paramTypes.append(packParamType(paramType)); @@ -426,6 +434,7 @@ QVariantMap JsonTypes::packActionType(const ActionType &actionType) QVariantMap variantMap; variantMap.insert("id", actionType.id()); variantMap.insert("name", actionType.name()); + variantMap.insert("index", actionType.index()); QVariantList paramTypes; foreach (const ParamType ¶mType, actionType.paramTypes()) { paramTypes.append(packParamType(paramType)); @@ -492,6 +501,7 @@ QVariantMap JsonTypes::packStateType(const StateType &stateType) QVariantMap variantMap; variantMap.insert("id", stateType.id()); variantMap.insert("name", stateType.name()); + variantMap.insert("index", stateType.index()); variantMap.insert("type", basicTypeToString(stateType.type())); variantMap.insert("defaultValue", stateType.defaultValue()); @@ -568,7 +578,9 @@ QVariantMap JsonTypes::packParamType(const ParamType ¶mType) QVariantMap variantMap; variantMap.insert("name", paramType.name()); variantMap.insert("type", basicTypeToString(paramType.type())); - // optional + variantMap.insert("index", paramType.index()); + + // Optional values if (paramType.defaultValue().isValid()) { variantMap.insert("defaultValue", paramType.defaultValue()); } @@ -587,7 +599,6 @@ QVariantMap JsonTypes::packParamType(const ParamType ¶mType) if (paramType.unit() != Types::UnitNone) { variantMap.insert("unit", s_unit.at(paramType.unit())); } - // only add if this param is NOT writable if (paramType.readOnly()) { variantMap.insert("readOnly", paramType.readOnly()); } @@ -638,6 +649,15 @@ QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass) discoveryParamTypes.append(packParamType(paramType)); } + if (!deviceClass.criticalStateTypeId().isNull()) + variant.insert("criticalStateTypeId", deviceClass.criticalStateTypeId()); + + if (!deviceClass.primaryStateTypeId().isNull()) + variant.insert("primaryStateTypeId", deviceClass.primaryStateTypeId()); + + if (!deviceClass.primaryActionTypeId().isNull()) + variant.insert("primaryActionTypeId", deviceClass.primaryActionTypeId()); + variant.insert("basicTags", basicTags); variant.insert("paramTypes", paramTypes); variant.insert("discoveryParamTypes", discoveryParamTypes);