lib.metadata

This library module implements the metadata handling for plugins and SmartHomeNG modules.

class lib.metadata.Metadata(sh, addon_name, addon_type, classpath='')[source]

Bases: object

get_string(key)[source]

Return the value for a global key as a string

Parameters:key (str) – global key to look up (in section ‘plugin’ or ‘module’)
Returns:value for the key
Return type:str
get_mlstring(mlkey)[source]

Return the value for a global multilanguage-key as a string

It trys to lookup th value for the default language. If the value for the default language is empty, it trys to look up the value for English. If there is no value for the default language and for English, it trys to lookup the value for German.

Parameters:key (str) – global multilabguage-key to look up (in section ‘plugin’ or ‘module’)
Returns:value for the key
Return type:str
get_bool(key)[source]

Return the value for a global key as a bool

Parameters:key (str) – global key to look up (in section ‘plugin’ or ‘module’)
Returns:value for the key
Return type:bool
test_shngcompatibility()[source]

Test if the actual running version of SmartHomeNG is in the range of supported versions for this addon (module/plugin)

Returns:True if the SmartHomeNG version is in the supported range
Return type:bool
get_version()[source]

Returns the version of the addon

If test_version has been called before, the code_version is taken into account, otherwise the version of the metadata-file is returned

Returns:version
Return type:str
test_version(code_version)[source]

Tests if the loaded Python code has a version set and compares it to the metadata version.

Parameters:code_version (str) – version of the python code
Returns:True: version numbers match, or Python code has no version
Return type:bool
get_parameterlist()[source]

Returns the list of parameter names

Returns:List of strings with parameter names
Return type:list of str
get_itemdefinitionlist()[source]

Returns the list of item attribute definitions

Returns:List of strings with item attribute names
Return type:list of str
get_parameter_type(param)[source]

Returns the datatype of a parameter

get_itemdefinition_type(definition)[source]

Returns the datatype of an item attribute definition

get_parameter_subtype(param)[source]

Returns the subtype of a parameter

get_itemdefinition_subtype(definition)[source]

Returns the subtype of an item attribute definition

get_parameter_listlen(param)[source]

Returns the len of a parameter of type list of a parameter

get_itemdefinition_listlen(definition)[source]

Returns the len of a parameter of type list of an item attribute definition

get_parameter_type_with_subtype(param)[source]

Returns the datatype of a parameter with subtype (if subtype exists)

get_itemdefinition_type_with_subtype(definition)[source]

Returns the datatype of an item attribute definition with subtype (if subtype exists)

get_parameter_defaultvalue(param)[source]

Returns the default value for the parameter

get_itemdefinition_defaultvalue(definition)[source]

Returns the default value for an item attribute definition

get_parameterdefinition(param, key)[source]

Returns the value for a key of a parameter as a string

get_itemdefinition(definition, key)[source]

Returns the value for a key of a parameter as a string

check_parameters(args)[source]

Checks the values of a dict of configured parameters.

Returns a dict with all defined parameters with values and a bool indicating if all parameters are ok (True) or if a mandatory parameter is not configured (False). It returns default values for parameters that have not been configured. The resulting dict contains the values in the the datatype of the parameter definition

Parameters:args (dict of parameter-values (values as string)) – Configured parameters with the values
Returns:All defined parameters with values, Flag if all parameters are ok (no mandatory is missing)
Return type:dict, bool