Update plugin json documentation

pull/135/head
Simon Stürz 2018-03-29 20:05:14 +02:00 committed by Michael Zanetti
parent 2d349e28b1
commit 280b3ded2b
2 changed files with 497 additions and 172 deletions

View File

@ -1,4 +1,4 @@
In following section you can find a detaild description of the current API version 1.3.
In following section you can find a detaild description of the current API version 1.4.
\list
\li \l{Types}
\li \l{Methods}

View File

@ -81,23 +81,53 @@
}
\endcode
\list
\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"}):
\note \b M is a mandatory parameter, \b O is an optional parameter.
\table
\row
\li \tt id
\li \b M
\li uuid
\li The actual uuid (\l{PluginId}) of the plugin \unicode{0x2192} \l{DevicePlugin::pluginId()}
\row
\li \tt name
\li \b M
\li string
\li This parameter will be used to define the PluginId variable named \tt{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!";
\endcode
The logging category allows you to categorise the debug output. It can be configured with the \tt -d argument of nymead (see \tt {$ nymead -h}).
\row
\li \tt displayName
\li \b M
\li string
\li The visible name of the plugin \unicode{0x2192} \l{DevicePlugin::pluginDisplayName()}. This string will be available for translations.
\row
\li \tt paramTypes
\li \b O
\li array
\li A list of \l{ParamType}{ParamTypes} which define the parameters of this plugin \unicode{0x2192} \l{DevicePlugin::configuration()}.
\b{See also:} \l{The ParamType definition}
\row
\li \tt vendors
\li \b M
\li array
\li The list of \l{Vendor}{Vendors} objects this plugin supports.
\b{See also:} \l{The Vendor definition}
\endtable
\code
qCdebug(dcExample()) << "Hello world!";
qCWarning(dcExample()) << "Warning the world!";
\endcode
Please start always 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}).
\li - \underline{\e id:} The actual uuid (\l{PluginId}) of the plugin \unicode{0x2192} \l{DevicePlugin::pluginId()}
\li - \underline{\e paramTypes:} Optionl: A list of \l{ParamType}{ParamTypes} which define the parameters of this plugin \unicode{0x2192} \l{DevicePlugin::configuration()} (see section "\l{The ParamType definition}").
\li - \underline{\e vendors:} The list of \l{Vendor}{Vendors} objects (see section "\l{The Vendor definition}");
\endlist
\section2 The Vendor definition
A plugin can support more then one \l{Vendor}, so the parameter \e vendors in the plugin definition is a list. Each element of this list represents a \l{Vendor} in nymea.
@ -117,17 +147,37 @@
}
\endcode
\note All parameters \underline{must} be definend.
\note \b M is a mandatory parameter, \b O is an optional parameter.
\list
\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
\table
\row
\li \tt id
\li \b M
\li uuid
\li The actual uuid (\l{VendorId}) of the vendor \unicode{0x2192} \l{Vendor::id()}.
\row
\li \tt name
\li \b M
\li string
\li This parameter will be used to define the VendorId variable named \tt{<name>VendorId} in the plugininfo.h, so it can be used in the code.
\row
\li \tt displayName
\li \b M
\li string
\li The visible name of the vendor \unicode{0x2192} \l{Vendor::displayName()}. This string will be available for translations.
\row
\li \tt deviceClasses
\li \b M
\li array
\li A list of \l{DeviceClass}{DeviceClasses} objects.
\b{See also:} \l{The DeviceClass definition}
\endtable
\section2 The DeviceClass definition
A \l{Vendor} can support more then one \l{DeviceClass}, so the parameter \e deviceClasses in the vendor definition is a list. Each element of this list represents a \l{DeviceClass} in nymea.
A \l{Vendor} can support more then one \l{DeviceClass}, so the parameter \e deviceClasses in the vendor definition is a list.
Each element of this list represents a \l{DeviceClass} in nymea.
\code
}
@ -161,52 +211,144 @@
}
\endcode
A \l{DeviceClass} contains following parameters:
\list
\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:
\note \b M is a mandatory parameter, \b O is an optional parameter.
\tt {DeviceClass::BasicTagService} \unicode{0x2192} \tt {"basicTags": [ "Service" ]}
\table
\row
\li \tt id
\li \b M
\li uuid
\li The actual uuid (\l{DeviceClassId}) of the \l{DeviceClass} \unicode{0x2192} \l{DeviceClass::id()}.
\row
\li \tt name
\li \b M
\li string
\li This parameter will be used to define the DeviceClassId variable named \tt{<name>DeviceClassId} in the plugininfo.h, so it can be used in the code.
\row
\li \tt displayName
\li \b M
\li string
\li The visible name of the \l{DeviceClass} \unicode{0x2192} \l{DeviceClass::displayName()}. This string will be available for translations.
\row
\li \tt interfaces
\li \b O
\li array
\li A string list of \l{Interfaces for DeviceClasses}{interfaces} this plugin implements. Interfaces show you how types
of this DeviceClass \underline{must} look like.
\row
\li \tt basicTags
\li \b O
\li array
\li A string 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:
\tt {DeviceClass::BasicTagLighting} \unicode{0x2192} \tt {"basicTags": [ "Lighting" ]}
\tt {DeviceClass::BasicTagService} \unicode{0x2192} \tt {"basicTags": [ "Service" ]}
\tt ...
\tt {DeviceClass::BasicTagLighting} \unicode{0x2192} \tt {"basicTags": [ "Lighting" ]}
\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 ...
\row
\li \tt deviceIcon
\li \b O
\li string
\li Defines the icon for this \l{DeviceClass}. See enum \l{DeviceClass::DeviceIcon} for more information. The expected value for the \tt deviceIcon
parameters matches the enum name like this:
\tt {DeviceClass::DeviceIconBed} \unicode{0x2192} \tt {"deviceIcon": "Bed" }
\tt {DeviceClass::DeviceIconBed} \unicode{0x2192} \tt {"deviceIcon": "Bed"}
\tt {DeviceClass::DeviceIconPower} \unicode{0x2192} \tt {"deviceIcon": "Power" }
\tt {DeviceClass::DeviceIconPower} \unicode{0x2192} \tt {"deviceIcon": "Power"}
\tt ...
\tt ...
\row
\li \tt createMethods
\li \b O
\li array
\li A string list of possible \l{DeviceClass::CreateMethod}{CreateMethods} for this device \unicode{0x2192} \l{DeviceClass::createMethods()}.
If no createMethods are definend, \l{DeviceClass::CreateMethodUser} will be used as default.
Some devices can be created in different ways. Possible strings are:
\list
\li \tt User \unicode{0x2192} \l{DeviceClass::CreateMethodUser}
\li \tt Discovery \unicode{0x2192} \l{DeviceClass::CreateMethodDiscovery}
\li \tt Auto \unicode{0x2192} \l{DeviceClass::CreateMethodAuto}
\endlist
\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}
\li \e discovery \unicode{0x2192} \l{DeviceClass::CreateMethodDiscovery}
\li \e auto \unicode{0x2192} \l{DeviceClass::CreateMethodAuto}
\endlist
\li - \underline{\e setupMethod:} Optional: Definens the \l{DeviceClass::SetupMethod}{SetupMethod} of this device \unicode{0x2192} \l{DeviceClass::setupMethod()}. Possible values are:
\list
\li \e justAdd \unicode{0x2192} \l{DeviceClass::SetupMethodJustAdd} (default)
\li \e displayPin \unicode{0x2192} \l{DeviceClass::SetupMethodDisplayPin}
\li \e enterPin \unicode{0x2192} \l{DeviceClass::SetupMethodEnterPin}
\li \e pushButton \unicode{0x2192} \l{DeviceClass::SetupMethodPushButton}
\endlist
\note For more information please take a look at \l{CreateMethods and SetupMethods} documentation.
\li - \underline{\e pairingInfo:} Optional: 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} has to be 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 application 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:} Optional: 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 parameters of a device \unicode{0x2192} \l{DeviceClass::paramTypes()} (see section "\l{The ParamType definition}").
\li - \underline{\e stateTypes:} Optional: A list of \l{StateType}{StateTypes} of the device \unicode{0x2192} \l{DeviceClass::stateTypes()} (see section "\l{The StateType definition}").
\li - \underline{\e actionTypes:} Optional: A list of \l{ActionType}{ActionTypes} of the device \unicode{0x2192} \l{DeviceClass::actionTypes()} (see section "\l{The ActionType definition}").
\li - \underline{\e eventTypes:} Optional: A list of \l{EventType}{EventTypes} of the device \unicode{0x2192} \l{DeviceClass::eventTypes()} (see section "\l{The EventType definition}").
\endlist
\b{See also:} \l{CreateMethods and SetupMethods}
\row
\li \tt setupMethod
\li \b O
\li string
\li Definens the \l{DeviceClass::SetupMethod}{SetupMethod} of this device \unicode{0x2192} \l{DeviceClass::setupMethod()}. Possible strings are:
\list
\li \tt JustAdd \unicode{0x2192} \l{DeviceClass::SetupMethodJustAdd} (default)
\li \tt DisplayPin \unicode{0x2192} \l{DeviceClass::SetupMethodDisplayPin}
\li \tt EnterPin \unicode{0x2192} \l{DeviceClass::SetupMethodEnterPin}
\li \tt PushButton \unicode{0x2192} \l{DeviceClass::SetupMethodPushButton}
\endlist
\b{See also:} \l{CreateMethods and SetupMethods}
\row
\li \tt pairingInfo
\li \b O
\li string
\li 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."
\row
\li \tt criticalStateTypeId
\li \b O
\li string
\li Deprecated: please use \l{Interfaces for DeviceClasses}{interfaces} instead.
\row
\li \tt primaryStateTypeId
\li \b O
\li string
\li Deprecated: please use \l{Interfaces for DeviceClasses}{interfaces} instead.
\row
\li \tt primaryActionTypeId
\li \b O
\li string
\li Deprecated: please use \l{Interfaces for DeviceClasses}{interfaces} instead.
\row
\li \tt discoveryParamTypes
\li \b O
\li array
\li 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}.
\b{See also:} \l{The ParamType definition}
\row
\li \tt paramTypes
\li \b O
\li array
\li A list of \l{ParamType}{ParamTypes} which define the parameters of a device \unicode{0x2192} \l{DeviceClass::paramTypes()}.
\b{See also:} \l{The ParamType definition}"
\row
\li \tt stateTypes
\li \b O
\li array
\li A list of \l{StateType}{StateTypes} of the device \unicode{0x2192} \l{DeviceClass::stateTypes()}.
\b{See also:} \l{The StateType definition}
\row
\li \tt actionTypes
\li \b O
\li array
\li A list of \l{ActionType}{ActionTypes} of the device \unicode{0x2192} \l{DeviceClass::actionTypes()}.
\b{See also:} \l{The ActionType definition}
\row
\li \tt eventTypes
\li \b O
\li array
\li A list of \l{EventType}{EventTypes} of the device \unicode{0x2192} \l{DeviceClass::eventTypes()}
\b{See also:} \l{The EventType definition}
\endtable
\section2 The ParamType definition
@ -235,36 +377,87 @@
}
\endcode
\list
\li - \underline{\e id:} The actual uuid (\l{ParamTypeId}) of the \l{ParamType} \unicode{0x2192} \l{ParamType::id()}.
\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 parameter \unicode{0x2192} \l{ParamType::type()}.
\li - \underline{\e inputType:} Optional: A parameter 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:
\note \b M is a mandatory parameter, \b O is an optional parameter.
\tt {Types::InputTypeTextArea} \unicode{0x2192} \tt {"inputType": "TextArea"}
\table
\row
\li \tt id
\li \b M
\li uuid
\li The actual uuid (\l{ParamTypeId}) of the \l{ParamType} \unicode{0x2192} \l{ParamType::id()}.
\row
\li \tt name
\li \b M
\li string
\li This parameter will be used to define the ParamTypeId variable named \tt{deviceClassName<name>ParamTypeId} in the plugininfo.h, so it can be used in the code.
\row
\li \tt displayName
\li \b M
\li string
\li The visible name of the \l{ParamType} \unicode{0x2192} \l{ParamType::displayName()}. This string will be available for translations.
\row
\li \tt type
\li \b M
\li string
\li The data type of this parameter \unicode{0x2192} \l{ParamType::type()}.
\row
\li \tt defaultValue
\li \b O
\li variant
\li Sets the default value of the \l{ParamType}. If a parameter will not be set by the user,
the parameter will be set to this value \unicode{0x2192} \l{ParamType::defaultValue()}.
\row
\li \tt inputType
\li \b O
\li string
\li A parameter 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::InputTypePassword} \unicode{0x2192} \tt {"inputType": "Password"}
\tt {Types::InputTypeTextArea} \unicode{0x2192} \tt {"inputType": "TextArea"}
\tt ...
\tt {Types::InputTypePassword} \unicode{0x2192} \tt {"inputType": "Password"}
\tt ...
\row
\li \tt unit
\li \b O
\li string
\li With this parameter you can specify the \l{Types::Unit}{Unit} of the parameter i.e. \unicode{0x00B0}C \unicode{0x2192} DegreeCelsius.
See enum \l{Types::Unit} for more information. The expected value for the \e unit parameter matches the enum name like this:
\li - \underline{\e defaultValue:} Sets the default value of the \l{ParamType}. If a parameter will not be set by the user, the parameter will be set to this value \unicode{0x2192} \l{ParamType::defaultValue()}.
\li - \underline{\e unit:} Optional: With this parameter you can specify the \l{Types::Unit}{Unit} of the parameter i.e. \unicode{0x00B0}C \unicode{0x2192} DegreeCelsius. See enum \l{Types::Unit} for more information. The expected value for the \e unit parameter matches the enum name like this:
\tt {Types::UnitDegreeCelsius} \unicode{0x2192} \tt {"unit": "DegreeCelsius"}
\tt {Types::UnitDegreeCelsius} \unicode{0x2192} \tt {"unit": "DegreeCelsius"}
\tt {Types::UnitMetersPerHour} \unicode{0x2192} \tt {"unit": "MetersPerHour"}
\tt ...
\li - \underline{\e minValue:} Optional: Sets the minimum limit for this \l{ParamType}. Can only be set for \e int and \e double values. If the user tries to set the value smaller than the \e minValue, the DeviceManager will catch the invalid parameter and report the error code. You don't have to check this value in the plugin implementation.
\li - \underline{\e maxValue:} Optional: Sets the maximum limit for this \l{ParamType}. Can only be set for \e int and \e double values. If the user tries to set the value greater than the \e maxValue, the DeviceManager will catch the invalid parameter and report the error code. You don't have to check this value in the plugin implementation.
\li - \underline{\e allowedValues:} Optional: Gives you the possibility to define a list of allowed values. If the user tries to set the value which is not in the \e allowedValues list, the DeviceManager will catch the invalid parameter and report the error code. You don't have to check this value in the plugin implementation. This is typically used for strings i.e. ["North", "East", "South", "West"].
\li - \underline{\e readOnly:} Optional: Bool value to make this \l{ParamType} realOnly. When you want to edit the params of a device you only can edit the parameters which are \tt {"readOnly": false}. If not specified, the parameter is writeable by default.
\endlist
\tt {Types::UnitMetersPerHour} \unicode{0x2192} \tt {"unit": "MetersPerHour"}
\tt ...
\row
\li \tt minValue
\li \b O
\li number
\li Sets the minimum limit for this \l{ParamType}. Can only be set for \e int and \e double values. If the user tries to set the value
smaller than the \e minValue, the DeviceManager will catch the invalid parameter and report the error code. You don't have to check
this value in the plugin implementation.
\row
\li \tt maxValue
\li \b O
\li number
\li Sets the maximum limit for this \l{ParamType}. Can only be set for \e int and \e double values. If the user tries to set the value
greater than the \e maxValue, the DeviceManager will catch the invalid parameter and report the error code. You don't have to check
this value in the plugin implementation.
\row
\li \tt allowedValues
\li \b O
\li array
\li Gives you the possibility to define a list of allowed values. If the user tries to set the value which is not in the \e allowedValues list,
the DeviceManager will catch the invalid parameter and report the error code. You don't have to check this value in the plugin implementation.
This is typically used for strings i.e. ["North", "East", "South", "West"].
\row
\li \tt readOnly
\li \b O
\li bool
\li Bool value to make this \l{ParamType} realOnly. When you want to edit the params of a device you only can edit the parameters which
are \tt {"readOnly": false}. If not specified, the parameter is writeable by default.
\endtable
\section2 The StateType definition
A \l{DeviceClass} can have a list of \l{StateType}{StateTypes} which allow you to represent a state of a device. A \l{State} can be changed/updated in the plugin code. If you change a state in the plugin using \l{Device::setStateValue()} an \l{Event} will generate automatically in the \l{nymeaserver::NymeaCore}. This \l{Event} has the same uuid (\l{EventTypeId}) like the \l{State} which created the "<stateName> changed" \l{Event}. The event will have exactly one \l{Param}, which has the same properties like the \l{StateType} value and contains the new value.
@ -289,9 +482,7 @@ A \l{StateType} has following parameters:
"o:unit": "The unit of the state value.",
"o:minValue": "Numeric minimum value for this state.",
"o:maxValue": "Numeric maximum value for this state.",
"o:possibleValues": [
"value"
],
"o:possibleValues": [ ],
"o:writable": true,
"o:displayNameAction": "Name of the created ActionType (translatable)"
}
@ -299,84 +490,167 @@ A \l{StateType} has following parameters:
}
\endcode
\list
\li - \underline{\e id:} The actual uuid (\l{StateTypeId}) of the \l{StateType} \unicode{0x2192} \l{StateType::id()}.
\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 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 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 "<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>"}.
\note \b M is a mandatory parameter, \b O is an optional parameter.
\table
\row
\li \tt id
\li \b M
\li uuid
\li The actual uuid (\l{StateTypeId}) of the \l{StateType} \unicode{0x2192} \l{StateType::id()}.
\row
\li \tt name
\li \b M
\li string
\li This parameter will be used to define the StateTypeId variable named \tt{deviceClassName<name>StateTypeId} in the plugininfo.h, so it can be used in the code.
\row
\li \tt displayName
\li \b M
\li string
\li The visible name of the \l{StateType} \unicode{0x2192} \l{StateType::displayName()}. This string will be available for translations.
\row
\li \tt displayNameEvent
\li \b M
\li string
\li Will be used for the name of the created \l EventType for this \l {StateType}. This string will be available for translations.
\row
\li \tt displayNameAction
\li \b O
\li string
\li Will be used for the name of the created \l ActionType for this \l StateType if "\tt {writable : true}" is definend. This string will be available for translations.
\row
\li \tt type
\li \b M
\li string
\li The data type of this state \unicode{0x2192} \l{StateType::type()}.
\row
\li \tt defaultValue
\li \b O
\li variant
\li The state will be initialized with this value.
\b{See also:} \tt cached
\row
\li \tt cached
\li \b O
\li bool
\li 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.
\row
\li \tt ruleRelevant
\li \b O
\li bool
\li 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.
\row
\li \tt eventRuleRelevant
\li \b O
\li bool
\li Deprecated: please use \l{Interfaces for DeviceClasses}{interfaces} instead.
\row
\li \tt graphRelevant
\li \b O
\li bool
\li Deprecated: please use \l{Interfaces for DeviceClasses}{interfaces} instead.
\row
\li \tt unit
\li \b O
\li string
\li With this parameter you can specify the \l{Types::Unit}{Unit} of the parameter i.e. \unicode{0x00B0}C \unicode{0x2192} DegreeCelsius.
See enum \l{Types::Unit} for more information. The expected value for the \e unit parameter matches the enum name like this:
\tt {Types::UnitDegreeCelsius} \unicode{0x2192} \tt {"unit": "DegreeCelsius"}
\tt {Types::UnitMetersPerHour} \unicode{0x2192} \tt {"unit": "MetersPerHour"}
\tt ...
\row
\li \tt possibleValues
\li \b O
\li array
\li 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. \tt {["Loading", "Installing", "Removing"]}.
\row
\li \tt writable
\li \b O
\li bool
\li 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}.
\endtable
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.
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.
This mechanism was created to ensure that the \l{EventType} and \l{ActionType} which correspond to a certain \l{StateType} will always be equal. This makes it possible for clients to know that an \l{Action} will set the \a value of a \l{State}, and an \l{Event} was generated by the corresponding \l{State}.
This mechanism was created to ensure that the \l{EventType} and \l{ActionType} which correspond to a certain \l{StateType} will always be equal. This makes it
possible for clients to know that an \l{Action} will set the \a value of a \l{State}, and an \l{Event} was generated by the corresponding \l{State}.
\tt {\l{StateTypeId} == \l{EventTypeId} == \l{ActionTypeId}}
\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{<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}.
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}",
"name": "volume",
"displayName": "Volume",
"unit": "Percentage",
"type": "int",
"minValue": 0,
"maxValue": 100,
"writable": true,
"displayNameAction": "Set volume",
"displayNameEvent": "Volume changed"
}
\endcode
This \l{StateType} definition will create for you an \l{ActionType} looking like this:
\code
{
"id": "{9dfe5d78-4c3f-497c-bab1-bb9fdf7e93a9}",
"displayName": "Set volume",
"paramTypes": [
{
"id": "{9bc84381-785f-46bf-94c8-6e35116f50d3}",
"displayName": "Volume",
"type": "int",
"maxValue": 100,
"minValue": 0,
"unit": "Percentage"
}
]
}
\endcode
And an \l{EventType} looking like this:
\code
{
"id": "{9dfe5d78-4c3f-497c-bab1-bb9fdf7e93a9}",
"displayName": "Volume changed",
"paramTypes": [
{
"id": "{9bc84381-785f-46bf-94c8-6e35116f50d3}",
"displayName": "Volume",
"type": "int",
"maxValue": 100,
"minValue": 0,
"unit": "Percentage"
}
]
}
\endcode
\endlist
\code
{
"id": "{9bc84381-785f-46bf-94c8-6e35116f50d3}",
"name": "volume",
"displayName": "Volume",
"unit": "Percentage",
"type": "int",
"minValue": 0,
"maxValue": 100,
"writable": true,
"displayNameAction": "Set volume",
"displayNameEvent": "Volume changed"
}
\endcode
This \l{StateType} definition will create for you an \l{ActionType} looking like this:
\code
{
"id": "{9dfe5d78-4c3f-497c-bab1-bb9fdf7e93a9}",
"displayName": "Set volume",
"paramTypes": [
{
"id": "{9bc84381-785f-46bf-94c8-6e35116f50d3}",
"displayName": "Volume",
"type": "int",
"maxValue": 100,
"minValue": 0,
"unit": "Percentage"
}
]
}
\endcode
And an \l{EventType} looking like this:
\code
{
"id": "{9dfe5d78-4c3f-497c-bab1-bb9fdf7e93a9}",
"displayName": "Volume changed",
"paramTypes": [
{
"id": "{9bc84381-785f-46bf-94c8-6e35116f50d3}",
"displayName": "Volume",
"type": "int",
"maxValue": 100,
"minValue": 0,
"unit": "Percentage"
}
]
}
\endcode
\section2 The ActionType definition
A \l{DeviceClass} can have more then one \l{ActionType}, so the parameter \e actionTypes in the \l{DeviceClass} definition is a list. Each element of this list represents an \l{ActionType} in nymea.
@ -397,12 +671,33 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w
}
\endcode
\list
\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 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
\note \b M is a mandatory parameter, \b O is an optional parameter.
\table
\row
\li \tt id
\li \b M
\li uuid
\li The actual uuid (\l{ActionTypeId}) of the \l{ActionType} \unicode{0x2192} \l{ActionType::id()}.
\row
\li \tt name
\li \b M
\li string
\li This parameter will be used to define the ActionTypeId variable named \tt{deviceClassName<name>ActionTypeId} in the plugininfo.h, so it can be used in the code.
\row
\li \tt displayName
\li \b M
\li string
\li The visible name of the \l{ActionType} \unicode{0x2192} \l{ActionType::displayName()}. This string will be available for translations.
\row
\li \tt paramTypes
\li \b O
\li array
\li A list of \l{ParamType}{ParamTypes} which define the parameters of this action \unicode{0x2192} \l{ActionType::paramTypes()}.
\b{See also:} \l{The ParamType definition}"
\endtable
\section2 The EventType definition
A \l{DeviceClass} can have more then one \l{EventType}, so the parameter \e eventTypes in the \l{DeviceClass} definition is a list. Each element of this list represents an \l{EventType} in nymea.
@ -425,13 +720,43 @@ This mechanism was created to ensure that the \l{EventType} and \l{ActionType} w
}
\endcode
\list
\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 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}.
\endlist
\note \b M is a mandatory parameter, \b O is an optional parameter.
\table
\row
\li \tt id
\li \b M
\li uuid
\li The actual uuid (\l{EventTypeId}) of the \l{EventType} \unicode{0x2192} \l{EventType::id()}.
\row
\li \tt name
\li \b M
\li string
\li This parameter will be used to define the EventTypeId variable named \tt{deviceClassName<name>EventTypeId} in the plugininfo.h, so it can be used in the code.
\row
\li \tt displayName
\li \b M
\li string
\li The visible name of the \l{EventType} \unicode{0x2192} \l{EventType::displayName()}. This string will be available for translations.
\row
\li \tt paramTypes
\li \b O
\li array
\li A list of \l{ParamType}{ParamTypes} which define the parameters of this event \unicode{0x2192} \l{EventType::paramTypes()}.
\b{See also:} \l{The ParamType definition}"
\row
\li \tt ruleRelevant
\li \b O
\li bool
\li 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.
\row
\li \tt graphRelevant
\li \b O
\li bool
\li Deprecated: please use \l{Interfaces for DeviceClasses}{interfaces} instead.
\endtable
*/