settingsmeta.yamlfile. This file must be in the root directory of the Skill and must follow a specific structure.
falseis surrounded by "quotation marks". This is because Mycroft expects a string of
"false"rather than a Boolean.
skillMetadataobject. This object must contain one or more
nameattribute that is used as the heading for that section, and an Array of
fields. Each field is a setting available to the user. Each field takes four properties:
fieldis used by the Skill to get and set the value of the
field. It will not usually be displayed to the user, unless the
labelproperty has not been set.
text: any kind of text
checkbox: boolean, True or False
number: text validated as a number
password: text hidden from view by default
select: a drop-down menu of options
label: special field to display text for information purposes only. No name or value is required for a
settingsmetafile, they will be presented to the user on their personal Skill Settings page.
settings.jsonfile. This file is automatically created when a Skill is loaded even if the Skill does not have any settings. Your Skill then accesses the settings from this file. Nowadays the file is located in the Skill's XDG_CONFIG_DIR (usually
~/config/mycroft/skills/<skillname>), however if a
settings.jsonfile already exists in the Skill's root directory (the deprecated location) that location is used for compatibility.
show_timevariable from our example above we would use the
getmethod will return
None. Instead of assigning this to a variable and then testing for
None, we can provide a default value as the second argument to the
show_timesetting has not been assigned, it will return the default value
Dict.getmethod above rather than accessing the setting directly with:
settingsdictionary will not be available in your Skills
__init__method as this is setting up your Skills Class. You should instead use an
initializemethod which is called after the Skill is fully constructed and registered with the system. More detail is available at:
settings.json. To perform some action when settings are updated, you can register a callback function in your Skill.
on_settings_changedmethod to be our callback function. We have then immediately called the method to perform the relevant actions when the Skill is being initialized even though the Skills settings have not changed.
on_settings_changedmethod we have assigned the value of the
show_timesetting to a local variable. Then we have passed it as an argument to another method in our Skill that will trigger the display of the time based on its value.
show_timesetting will persist until a new setting is assigned locally by the Skill, or remotely by the user clicking
saveon the web view.