Update plugin info documentation

pull/135/head
Simon Stürz 2018-03-01 14:33:30 +01:00 committed by Michael Zanetti
parent cc6ab96b57
commit dc1b10955a
1 changed files with 63 additions and 73 deletions

View File

@ -11,13 +11,13 @@
The \tt {\b nymea-generateplugininfo} precompiler will parse this file and generates a \tt plugininfo.h and a \tt extern-plugininfo.h file containing the definitions of:
\list
\li \l{PluginId}: <\e pluginId \unicode{0x2192} the defined UUID for the \l{DevicePlugin}.
\li \l{VendorId}: <\e idName>VendorId \unicode{0x2192} the defined UUID for the corresponding \l{Vendor}.
\li \l{DeviceClassId}: <\e idName>DeviceClassId \unicode{0x2192} the definend UUID for the corresponding \l{DeviceClass}.
\li \l{ActionTypeId}: <\e idName>ActionTypeId \unicode{0x2192} the defined UUID for the corresponding \l{ActionType}.
\li \l{StateTypeId}: <\e idName>StateTypeId \unicode{0x2192} the defidefinednend UUID for the corresponding \l{StateType}.
\li \l{EventTypeId}: <\e idName>EventTypeId \unicode{0x2192} the defined UUID for the corresponding \l{EventType}.
\li \l{ParamTypeId}: <\e idName>ParamTypeId \unicode{0x2192} the defined UUID for the corresponding \l{ParamType}.
\li Logging Category: \e dc<idName>
\li \l{VendorId}: <\e name>VendorId \unicode{0x2192} the defined UUID for the corresponding \l{Vendor}.
\li \l{DeviceClassId}: <\e name>DeviceClassId \unicode{0x2192} the definend UUID for the corresponding \l{DeviceClass}.
\li \l{ActionTypeId}: <\e name>ActionTypeId \unicode{0x2192} the defined UUID for the corresponding \l{ActionType}.
\li \l{StateTypeId}: <\e name>StateTypeId \unicode{0x2192} the defidefinednend UUID for the corresponding \l{StateType}.
\li \l{EventTypeId}: <\e name>EventTypeId \unicode{0x2192} the defined UUID for the corresponding \l{EventType}.
\li \l{ParamTypeId}: <\e name>ParamTypeId \unicode{0x2192} the defined UUID for the corresponding \l{ParamType}.
\li Logging Category: \e dc<Name>
\endlist
The \tt plugininfo.h has to be included in the main plugin \tt cpp file (\tt{deviceplugin<\b pluginName>.cpp}). The \tt extern-plugininfo.h can be included in other classes/files of the plugin to get the extern definitions of the ID's and the logging category.
@ -32,13 +32,13 @@
\code
{
"name": "Name of the plugin",
"idName": "PluginName",
"name": "PluginName",
"displayName": "Name of the plugin",
"id": "uuid",
"vendors": [
{
"name": "Name of the plugin",
"idName": "Name of the logging category",
"name": "VendorName",
"displayName": "Name of the vendor",
"id": "uuid",
"deviceClasses": [
...
@ -64,13 +64,13 @@
\section1 Writing the plugin JSON file
\section2 The Plugin definition
The parameters of the first object (\e name, \e idName, \e id and \e vendors) describe the properties of the plugin it self.
The parameters of the first object (\e name, \e displayName, \e id and \e vendors) describe the properties of the plugin it self.
\code
{
"name": "Name of the plugin (translatable)",
"idName": "PluginName",
"id": "uuid",
"name": "PluginName",
"displayName": "Name of the plugin (translatable)",
"o:paramTypes": [
...
],
@ -83,12 +83,13 @@
\endcode
\list
\li - \underline{\e name:} The visible name of the plugin \unicode{0x2192} \l{DevicePlugin::pluginName()}
\li - \underline{\e idName:} This parameter will be used to define the PluginId variable named <idName>PluginId in the plugininfo.h, so it can be used in the code. This parameter also defines the logging categorie for this plugin. The loging category will always definend as \tt dc<idName> and can be used as follows (\tt {"idName":"Example"}):
\li - \underline{\e id:} The actual uuid (\l{PluginId}) of the plugin \unicode{0x2192} \l{DevicePlugin::pluginId()}
\li - \underline{\e displayName:} The visible name of the plugin \unicode{0x2192} \l{DevicePlugin::pluginDisplayName()}
\li - \underline{\e name:} This parameter will be used to define the PluginId variable named <name>PluginId in the plugininfo.h, so it can be used in the code. This parameter also defines the logging categorie for this plugin. The logging category will always definend as \tt dc<Name> and can be used as follows (\tt {"name":"Example"}):
\code
qCdebug(dcExample) << "Hello world!";
qCWarning(dcExample) << "Warning the world!";
qCdebug(dcExample()) << "Hello world!";
qCWarning(dcExample()) << "Warning the world!";
\endcode
Please start allways with a capital letter i.e. \tt {"idName": "Example"}. The logging category allowes you to categorise the debug output. It can be configured with the \tt -d argument of nymead (see \tt {$ man nymead}).
@ -106,9 +107,9 @@
...
"vendors": [
{
"name": "Name of the vendor (translatable)",
"idName": "vendorName",
"id": "uuid",
"name": "vendorName",
"displayName": "Name of the vendor (translatable)",
"deviceClasses": [
...
]
@ -120,9 +121,9 @@
\note All parameters \underline{must} be definend.
\list
\li - \underline{\e name:} The visible name of the vendor \unicode{0x2192} \l{Vendor::name()}.
\li - \underline{\e idName:} This parameter will be used to define the VendorId variable named <idName>VendorId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e id:} The actual uuid (\l{VendorId}) of the plugin \unicode{0x2192} \l{Vendor::id()}.
\li - \underline{\e name:} This parameter will be used to define the VendorId variable named <name>VendorId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e displayName:} The visible name of the vendor \unicode{0x2192} \l{Vendor::displayName()}.
\li - \underline{\e deviceClasses:} A list of \l{DeviceClass}{DeviceClasses} objects (see section "\l{The DeviceClass definition}").
\endlist
@ -137,9 +138,9 @@
..
"deviceClasses": [
{
"name": "The name of the device class (translatable)",
"idName": "deviceClassName",
"id": "uuid",
"name": "deviceClassName",
"displayName": "The name of the device class (translatable)",
"o:deviceIcon": "Icon",
"o:interfaces": [ "String" ],
"o:basicTags": [
@ -148,6 +149,7 @@
"createMethods": [
"CreateMethod"
],
"o:interfaces" [ "connectable" ],
"o:setupMethod": "SetupMethod",
"o:pairingInfo": "Information how to pair the device. (translatable)",
"o:criticalStateTypeId": "uuid",
@ -172,9 +174,9 @@
A \l{DeviceClass} contains following parameters:
\list
\li - \underline{\e name:} The visible name of the \l{DeviceClass} \unicode{0x2192} \l{DeviceClass::name()}.
\li - \underline{\e idName:} This parameter will be used to define the DeviceClassId variable named <idName>DeviceClassId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e id:} The actual uuid (\l{DeviceClassId}) of the \l{DeviceClass} \unicode{0x2192} \l{DeviceClass::id()}.
\li - \underline{\e name:} This parameter will be used to define the DeviceClassId variable named <name>DeviceClassId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e displayName:} The visible name of the \l{DeviceClass} \unicode{0x2192} \l{DeviceClass::displayName()}.
\li - \underline{\e interfaces: } A list of \l{Interfaces for DeviceClasses}{interfaces} this plugin implements.
\li - \underline{\e basicTags:} A list of \l{DeviceClass::BasicTag}{BasicTags} for this device \unicode{0x2192} \l{DeviceClass::basicTags()}. A \l{DeviceClass} can have multiple \l{DeviceClass::BasicTag}{BasicTags} which describe the basic category of the DeviceClass. A \l{DeviceClass} should be eighter a Service or a Device, never both. See enum \l{DeviceClass::BasicTag} for more information. The expected value for the \e basicTags parameters matches the enum name like this:
@ -227,10 +229,9 @@
"paramTypes": [
{
"id": "uuid",
"idName": "paramName"
"name": "name of the param (translatable)",
"name": "paramName"
"displayName": "name of the param (translatable)",
"type": "DataType",
"index": "int",
"defaultValue": "The default value which will be used if the param is not given.",
"o:inputType": "InputType",
"o:unit": "The unit of the parameter",
@ -247,10 +248,9 @@
\list
\li - \underline{\e id:} The actual uuid (\l{ParamTypeId}) of the \l{ParamType} \unicode{0x2192} \l{ParamType::id()}.
\li - \underline{\e idName:} This parameter will be used to define the ParamTypeId variable named <idName>ParamTypeId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e name:} The visible name of the \l{ParamType} \unicode{0x2192} \l{ParamType::name()}.
\li - \underline{\e name:} This parameter will be used to define the ParamTypeId variable named deviceClassName<Name>ParamTypeId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e displayName:} The visible name of the \l{ParamType} \unicode{0x2192} \l{ParamType::displayName()}.
\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:} Optional: 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"}
@ -287,44 +287,44 @@ A \l{StateType} has following parameters:
...
"stateTypes": [
{
"name": "Name of the state (translatable)",
"id": "uuid",
"idName": "stateName",
"index": "int",
"name": "stateName",
"displayName": "Name of the state (translatable)",
"displayNameEvent": "Name of the created EventType (translatable)",
"type": "DataType",
"defaultValue": "The state will be initialized with this value."
"o:cached": "bool",
"o:ruleRelevant": "bool",
"o:eventRuleRelevant": "bool",
"eventTypeName": "Name of the created EventType (translatable)",
"o:graphRelevant": "bool",
"o:unit": "The unit of the state value.",
"defaultValue": "The state will be initialized with this value."
"o:minValue": "Numeric minimum value for this state.",
"o:maxValue": "Numeric maximum value for this state.",
"o:possibleValues": [
"value"
],
"o:writable": true,
"o:actionTypeName": "Name of the the created ActionType (translatable)"
"o:displayNameAction": "Name of the the created ActionType (translatable)"
}
]
}
\endcode
\list
\li - \underline{\e name:} The visible name of the \l{ParamType} \unicode{0x2192} \l{ParamType::name()}.
\li - \underline{\e idName:} This parameter will be used to define the StateTypeId variable named <idName>StateTypeId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e id:} The actual uuid (\l{StateTypeId}) of the \l{StateType} \unicode{0x2192} \l{StateType::id()}.
\li - \underline{\e index:} The order index of the \l{StateType} \unicode{0x2192} \l{StateType::index()}. This index will be used for sorting the \l{State}{States} of a \l{Device} to make sure the types looks the same on all clients. Please make sure all \l{StateType}{StateTypes} together will create a list from \tt 0 to \tt x.
\li - \underline{\e name:} This parameter will be used to define the StateTypeId variable named <displayName>StateTypeId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e displayName:} The visible name of the \l{ParamType} \unicode{0x2192} \l{ParamType::displayName()}.
\li - \underline{\e displayNameEvent:} Will be used for the name of the created \l EventType for this \l StateType. It is good practice to name the event \tt{"<stateDisplayName> changed"}.
\li - \underline{\e type:} The data type of this state \unicode{0x2192} \l{StateType::type()}.
\li - \underline{\e defaultValue:} The state will be initialized with this value.
\li - \underline{\e cached:} Optional: Indicates if a state value should be cached over reboot of the server. The value will be initialized with the last known value. By default all states get chached. If you want to disable that behaviour you can set this property to \tt{false}. In that case the value will be initialized with the default value of the State.
\li - \underline{\e ruleRelevant:} Optional: Since not all \l{State}{States} make sense for the user in a rule, with this flag can be specified if this state should be visible in the rule engine for the user or not. This flag has no effect to the ruleengine mechanism and is only ment to filter out not interesting \l{State}{States}. By default, every state is rule relevant.
\li - \underline{\e graphRelevant:} Optional: This flag indicates that this \l{State} is interesting to be shown in a graph/chart. By default every state is \underline not \tt {graphRelevant}. The corresponding EventType will not be graphRelevant, because the graph will be generated from the \l{State} logs.
\li - \underline{\e eventRuleRelevant:} Optional: The same thing as \e {ruleRelevat}, but this flag is for the \l{EventType}, which will be generated for this \l{StateType}.
\li - \underline{\e eventTypeName:} Will be used for the name of the created \l EventType for this \l StateType. It is good practice to name the event \tt{"<stateName> changed"}.
\li - \underline{\e unit:} Optional: With this parameter you can specify the unit of the state value i.e. \unicode{0x00B0}C \unicode{0x2192} DegreeCelsius (\l{Types::Unit}).
\li - \underline{\e defaultValue:} The state will be initialized with this value.
\li - \underline{\e possibleValues:} Optional: Gives you the possibility to define a list of possible values which this state can have. This allowes a user to create a rule based on a state and define only values which are possible. This is typically used for strings i.e. ["Loading", "Installing", "Removing"].
\li - \underline{\e writable:} Optional: If you define the "\e writable : true" value an \l{ActionType} will be created to set the \l{State} value. The created \l{ActionType} has the same uuid (\l{ActionTypeId}) like the \l{StateType} uuid and will be named "set <stateName>". The \l{ParamType} of the created \l{ActionType} will have the same values in the \e allowedValues list as the \l{StateType} in the \e possibleValues list. Also the \e minValue / \e maxValue will be taken over from the \l{StateType}.
\li - \underline{\e actionTypeName:} Optional: Will be used for the name of the created \l ActionType for this \l StateType if "\e writable : true" is definend. It is good practice to name the ActionType \tt{"Set <stateName>"}.
\li - \underline{\e writable:} Optional: If you define the "\e writable : true" value an \l{ActionType} will be created to set the \l{State} value. The created \l{ActionType} has the same uuid (\l{ActionTypeId}) like the \l{StateType} uuid and will be named "<displayNameAction>". The \l{ParamType} of the created \l{ActionType} will have the same values in the \e allowedValues list as the \l{StateType} in the \e possibleValues list. Also the \e minValue / \e maxValue will be taken over from the \l{StateType}.
\li - \underline{\e displayNameAction:} Optional: Will be used for the name of the created \l ActionType for this \l StateType if "\e writable : true" is definend. It is good practice to name the ActionType \tt{"Set <stateDisplayName>"}.
If a \l{StateType} has the property \e writable the \l{DeviceManager} will create automatically an \l{ActionType} for this state, which will also have exactly one \l{ParamType} with the same properties like the \l{StateType}. The created \l{ActionType} has the same uuid (\l{ActionTypeId}) like the \l{StateType} uuid and will be named \tt actionTypeName.
@ -333,23 +333,22 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w
\tt {\l{StateTypeId} == \l{EventTypeId} == \l{ActionTypeId}}
The \l{ParamType} for the created \l{EventType} will have the same id. In the code, the \l{ParamTypeId} will be named: \tt{<stateIdName>StateParamTypeId}.
The \l{ParamType} for the created \l{EventType} will have the same id. In the code, the \l{ParamTypeId} will be named: \tt{<stateName>StateParamTypeId}.
Example \l{StateType}: Following \l{StateType} stands for a volume \l{State} named \e volume. The value of this \l{State} has the data type \tt int and the unit \tt \%. This \l{StateType} is writable, which means there will be an \l{ActionType} generated with \e id \tt 9bc84381-785f-46bf-94c8-6e35116f50d3. The generated \l{ActionType} will have one \e ParamType which has the \e id = \tt 9bc84381-785f-46bf-94c8-6e35116f50d3, \e name = \tt volume, \e type = \tt int, \e minValue = \tt 0, \e maxValue =\tt 100, \e unit = \tt Percentage. The \l{ActionType} name will be . If the value of the \l{State} will be changed, an \l{Event} will be generated. The \l{ParamType} of the event will be equal to the \l{ParamType} of the generated \l{ActionType}.
\code
{
"id": "{9bc84381-785f-46bf-94c8-6e35116f50d3}",
"idName": "volume",
"name": "volume",
"displayName": "Volume",
"unit": "Percentage",
"index": "0",
"type": "int",
"minValue": 0,
"maxValue": 100,
"writable": true,
"actionTypeName": "Set volume",
"eventTypeName": "volume changed"
"displayNameAction": "Set volume",
"displayNameEvent": "Volume changed"
}
\endcode
@ -357,14 +356,12 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w
\code
{
"id": "{9dfe5d78-4c3f-497c-bab1-bb9fdf7e93a9}",
"name": "Set volume",
"displayName": "Set volume",
"paramTypes": [
{
"id": "{9bc84381-785f-46bf-94c8-6e35116f50d3}",
"idName": "volumeStateParamTypeId",
"name": "volume",
"displayName": "Volume",
"type": "int",
"index": 0,
"maxValue": 100,
"minValue": 0,
"unit": "Percentage"
@ -377,15 +374,12 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w
\code
{
"id": "{9dfe5d78-4c3f-497c-bab1-bb9fdf7e93a9}",
"name": "volume changed",
"index": 0,
"displayName": "Volume changed",
"paramTypes": [
{
"id": "{9bc84381-785f-46bf-94c8-6e35116f50d3}",
"idName": "volumeStateParamTypeId",
"name": "volume",
"displayName": "Volume",
"type": "int",
"index": 0,
"maxValue": 100,
"minValue": 0,
"unit": "Percentage"
@ -403,10 +397,9 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w
...
"actionTypes": [
{
"name": "Name of the action (translatable)",
"idName": "actionName",
"id": "uuid",
"index": "int",
"name": "actionName",
"displayName": "Name of the action (translatable)",
"o:paramTypes": [
...
]
@ -416,10 +409,9 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w
\endcode
\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 <idName>ActionTypeId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e displayName:} The visible name of the \l{ActionType} \unicode{0x2192} \l{ActionType::displayName()}.
\li - \underline{\e name:} This parameter will be used to define the ActionTypeId variable named <name>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 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:} Optional: 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
@ -431,10 +423,9 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w
...
"eventTypes": [
{
"name": "Name of the event (translatable)",
"idName": "eventName",
"id": "uuid",
"index": "int",
"name": "eventName",
"displayName": "Name of the event (translatable)",
"o:ruleRelevant": "bool",
"o:graphRelevant": "bool",
"o:paramTypes": [
@ -446,10 +437,9 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w
\endcode
\list
\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 <idName>EventTypeId in the plugininfo.h, so it can be used in the code.
\li - \underline{\e displayName:} The visible name of the \l{EventType} \unicode{0x2192} \l{EventType::displayName()}.
\li - \underline{\e name:} This parameter will be used to define the EventTypeId variable named <name>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 ruleRelevant:} Optional: Since not all \l{Event}{Events} make sense for the user in a rule, with this flag can be specidied if this event should be visible in the rule engine for the user or not. This flag has no effect to the ruleengine mechanism and is only ment to filter out not interesting \l{Event}{Events}. By default, every event is rule relevant.
\li - \underline{\e graphRelevant:} Optional: This flag indicates that this \l{Event} is interesting to be shown in a graph/chart. By default all \l{Event} are \underline not \tt {graphRelevant}.
\li - \underline{\e paramTypes:} Optional: 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}.