lib.module

This library implements loading and starting of core modules of SmartHomeNG.

The methods of the class Modules implement the API for modules. They can be used the following way: To call eg. xxx(), use the following syntax:

from lib.module import Modules
modules = Modules.get_instance()

# to access a method (eg. enable_logic()):
moddules.xxx()
Warning:This library is part of the core of SmartHomeNG. It should not be called directly from plugins!
class lib.module.Modules(smarthome, configfile)[source]

Bases: object

Module loader class. Parses config file and creates an instance for each module. To start the modules, the start() method has to be called.

Parameters:
  • smarthome – Instance of the smarthome master-object
  • configfile (str) – Basename of the module configuration file
static get_instance()[source]

Returns the instance of the Modules class, to be used to access the modules-api

Use it the following way to access the api:

from lib.module import Modules
modules = Modules.get_instance()

# to access a method (eg. xxx()):
modules.xxx()
Returns:modules instance
Return type:object of None
return_modules()[source]

Returns a list with the names of all loaded modules

Returns:list of module names
Return type:list
get_module(name)[source]

Returns the module object for the module named by the parameter or None, if the named module is not loaded

Parameters:name (str) – Name of the module to return
Returns:list of module names
Return type:object
start()[source]

Start all modules

Call start routine of module in case the module wants to start any threads

stop()[source]

Stop all modules

Call stop routine of module to clean up in case the module has started any threads