-
-
Notifications
You must be signed in to change notification settings - Fork 17
Configuration
Plugins and widget can be configured. To prevent developper to manage himself the configuration, a standard configuration process has been defined. You just have to define the configuration schema in the package.json file

In order to manage configuration, the developer must provide a configuration schema in the description of its package.json file. This schema describe all parameters which can be configured in the configuration form.
Somme kind of types of parameter are available for plugins and widget and some others are only for plugins or widgets.
There are two fields that are in every type of parameter and have to be translated.
The name and the description. The name is used to define the visible name of the parameter. The description is used to define the description of the parameter to help the user to set value.

They must be directly in the parameter description in the package.json like this example
"offsetHour" : {
"type" : "int",
"name" : "hour offset",
"description" : "used to make an offset on the time in hour",
"defaultValue" : "0",
"maximumValue" : "23",
"minimumValue" : "0"
}In this case the translated fields must be found in all language files except en.json in the following format. This example can be found in the fr.json file
The description field supports mardown.
{
"configurationSchema" : {
"offsetHour" : {
"name" : "Offset d'heure",
"description" : "Permet de faire un offset sur l'heure courante"
}
...
}
}Some configuration items or values are dynamic and depends on the instance of a plugin. So there is a mechanism that allow you to fill some fields of configurationSchema dynamically. You can bind functions of your plugin or system functions that provide dynamic content. this content is added to the configuration schema before applying it.
For more information about binding see: json-binding
This example illustrate a configuration which use most of configuration items
"configurationSchema": {
"intParameter" : {
"type" : "int",
"name" : "int parameter",
"description" : "test of an int parameter",
"defaultValue" : "0",
"maximumValue" : "23"
},
"coefficient" : {
"type" : "decimal",
"name" : "coeff parameter",
"description" : "test of an decimal parameter",
"defaultValue" : "1.23",
"maximumValue" : "2",
"minimumValue" : "-2",
"precision" : "2"
},
"timeFormat" : {
"name" : "time format",
"description" : "Permit to change the time format of the clock",
"type" : "enum",
"values" : {
"12H" : "12 hours",
"24H" : "24 hours"
},
"defaultValue" : "12H"
},
"prefixText" : {
"name" : "String parameter",
"description" : "A free text parameter",
"type" : "string",
"defaultValue" : "default value",
"maximumLength" : "30"
},
"booleanParameter" : {
"name" : "Enabled",
"description" : "Permit to enable the widget",
"type" : "bool",
"defaultValue" : "true"
},
"advancedParameters" : {
"type" : "section",
"name" : "Advanced parameters",
"description" : "For advanced users only",
"enableWithCheckBox" : "true",
"enableWithCheckBoxDefaultValue" : "false",
"content" : {
"booleanParameter" : {
"type" : "bool",
"name" : "enabled",
"description" : "Permit to enable the widget",
"defaultValue" : "true"
},
"CurrentCoefficient" : {
"type" : "decimal",
"name" : "correction coefficient",
"description" : "Set a correction coefficient to adjust the value",
"defaultValue" : "0.0",
"maximumValue" : "1.0",
"minimumValue" : "-1.0",
"precision" : "2"
}
}
}
}
Yadoms -- The ultimate house automation solution