Class SmartPlugin
Die Klasse SmartPlugin
implementiert die Basisklasse aller SmartPlugins. Die vorhandenen Methoden sind im Folgenden beschrieben.
Zusätzlich werden die Methoden der Klasse lib.utils.Utils
vererbt.
-
class
lib.model.smartplugin.
SmartPlugin
(**kwargs)[Quellcode] Bases:
lib.model.smartobject.SmartObject
,lib.utils.Utils
The class SmartPlugin implements the base class of call smart-plugins. The implemented methods are described below.
In adition the methods implemented in lib.utils.Utils are inhereted.
-
ALLOW_MULTIINSTANCE
= None
-
shtime
= None Variable containing a pointer to the SmartHomeNG time handling object; is initialized during loading of the plugin; :Warning: Don’t change it
-
logger
= <Logger lib.model.smartplugin (WARNING)>
-
alive
= False
-
deinit
()[Quellcode] If the Plugin needs special code to be executed before it is unloaded, this method has to be overwirtten with the code needed for de-initialization
-
get_configname
()[Quellcode] return the name of the plugin instance as defined in plugin.yaml (section name)
- Note
Only available in SmartHomeNG versions beyond v1.4
- Rückgabe
name of the plugin instance as defined in plugin.yaml
- Rückgabetyp
str
-
get_shortname
()[Quellcode] return the shortname of the plugin (name of it’s directory)
- Note
Only available in SmartHomeNG versions beyond v1.3
- Rückgabe
shortname of the plugin
- Rückgabetyp
str
-
get_instance_name
()[Quellcode] Returns the name of this instance of the plugin
- Rückgabe
instance name
- Rückgabetyp
str
-
get_fullname
()[Quellcode] return the full name of the plugin (shortname & instancename)
- Note
Only available in SmartHomeNG versions v1.3c and up
- Rückgabe
full name of the plugin
- Rückgabetyp
str
-
get_classname
()[Quellcode] return the classname of the plugin
- Note
Only available in SmartHomeNG versions beyond v1.3
- Rückgabe
classname of the plugin
- Rückgabetyp
str
-
get_version
(extended=False)[Quellcode] Return plugin version
- Parameter
extended (bool) – If True, returned version string contains (pv) if not the latest version is loaded
- Rückgabe
plugin version
- Rückgabetyp
str
-
is_multi_instance_capable
()[Quellcode] Returns information if plugin is capable of multi instance handling
- Rückgabe
True: If multiinstance capable
- Rückgabetyp
bool
-
get_plugin_dir
()[Quellcode] return the directory where the pluing files are stored in
- Note
Only available in SmartHomeNG versions beyond v1.3
- Rückgabe
name of the directory
- Rückgabetyp
str
-
get_info
()[Quellcode] Returns a small plugin info like: class, version and instance name
- Rückgabe
plugin Info
- Rückgabetyp
str
-
get_parameter_value
(parameter_name)[Quellcode] Returns the configured value for the given parameter name
If the parameter is not defined, None is returned
- Parameter
parameter_name (str) – Name of the parameter for which the value should be retrieved
- Rückgabe
Configured value
- Rückgabetyp
depends on the type of the parameter definition
-
get_parameter_value_for_display
(parameter_name)[Quellcode] Returns the configured value for the given parameter name
If the parameter is not defined, None is returned If the parameter is marked as ‚hide‘, only ‚*‘s are returned
- Parameter
parameter_name (str) – Name of the parameter for which the value should be retrieved
- Rückgabe
Configured value
- Rückgabetyp
depends on the type of the parameter definition
-
update_config_section
(param_dict)[Quellcode] Update the config section of ../etc/plugin.yaml
- Parameter
param_dict – dict with the pareters that should be updated
- Rückgabe
-
get_loginstance
()[Quellcode] Returns a prefix for logmessages of multi instance capable plugins.
The result is an empty string, if the instancename is empty. Otherwise the result is a string containing the instance name preseeded by a ‚@‘ and traild by ‚: ‚.
This way it is easy to show the instance name in log messages. Just write
self.logger.info(self.get_loginstance()+“Your text“)
and the logmessage is preseeded by the instance name, if needed.
- Rückgabe
instance name for logstring
- Rückgabetyp
str
-
has_iattr
(conf, attr)[Quellcode] checks item configuration for an attribute
- Parameter
conf (str) – item configuration
attr (str) – attribute name
- Rückgabe
True, if attribute is in item configuration
- Rückgabetyp
Boolean
-
get_iattr_value
(conf, attr)[Quellcode] Returns value for an attribute from item config
- Parameter
conf (str) – item configuration
attr (str) – attribute name
- Rückgabe
value of an attribute
- Rückgabetyp
str
-
set_attr_value
(conf, attr, value)[Quellcode] Set value for an attribute in item configuration
- Parameter
conf (str) – item configuration
attr (str) – attribute name
value (str) – value to set the atteibute to
-
get_sh
()[Quellcode] Return the main object of smarthomeNG (usually refered to as smarthome or sh) You can reference the main object of SmartHomeNG by using self.get_sh() in your plugin
- Note
Only available in SmartHomeNG versions beyond v1.3
- Rückgabe
the main object of smarthomeNG (usually refered to as smarthome or sh)
- Rückgabetyp
object
-
get_module
(modulename)[Quellcode] Test if module http is loaded and if loaded, return a handle to the module
-
path_join
(path, dir)[Quellcode] Join an existing path and a directory
-
parse_logic
(logic)[Quellcode] This method is used to parse the configuration of a logic for this plugin. It is called for all plugins before the plugins are started (calling all run methods).
- Note
This method should to be overwritten by the plugin implementation.
-
parse_item
(item)[Quellcode] This method is used to parse the configuration of an item for this plugin. It is called for all plugins before the plugins are started (calling all run methods).
- Note
This method should to be overwritten by the plugin implementation.
-
now
()[Quellcode] Returns SmartHomeNGs current time (timezone aware)
-
scheduler_return_next
(name)[Quellcode]
-
scheduler_trigger
(name, obj=None, by=None, source=None, value=None, dest=None, prio=3, dt=None)[Quellcode] This methods triggers the scheduler entry for a plugin-scheduler
A plugin identification is added to the scheduler name
The parameters are identical to the scheduler.trigger method from lib.scheduler
-
scheduler_add
(name, obj, prio=3, cron=None, cycle=None, value=None, offset=None, next=None)[Quellcode] This methods adds a scheduler entry for a plugin-scheduler
A plugin identification is added to the scheduler name
The parameters are identical to the scheduler.add method from lib.scheduler
-
scheduler_change
(name, **kwargs)[Quellcode] This methods changes a scheduler entry of a plugin-scheduler
A plugin identification is added to the scheduler name
The parameters are identical to the scheduler.change method from lib.scheduler
-
scheduler_remove
(name)[Quellcode] This methods removes a scheduler entry of a plugin-scheduler
A plugin identifiction is added to the scheduler name
The parameters are identical to the scheduler.remove method from lib.scheduler
-
scheduler_get
(name)[Quellcode] This methods gets a scheduler entry of a plugin-scheduler
A plugin identifiction is added to the scheduler name
The parameters are identical to the scheduler.get method from lib.scheduler
-
run
()[Quellcode] This method of the plugin is called to start the plugin
- Note
This method needs to be overwritten by the plugin implementation. Otherwise an error will be raised
-
stop
()[Quellcode] This method of the plugin is called to stop the plugin when SmartHomeNG shuts down
- Note
This method needs to be overwritten by the plugin implementation. Otherwise an error will be raised
-
translate
(txt, vars=None, block=None)[Quellcode] Returns translated text
-
init_webinterface
(WebInterface=None)[Quellcode] “ Initialize the web interface for this plugin
This method is only needed if the plugin is implementing a web interface
-