There are two ways to access the API
Use it the following way to access the api, if you have no access to the sh object in your method or function:
# to get access to the object instance: from lib.item import Items items = Items.get_instance() # to access a method (eg. to get the list of Items): items.return_items()
This is the preferred method.
Through the main SmartHome object
If you have access to the sh object in your method or function, you can use the following way:
# to access a method (eg. to get the list of Items): sh.items.return_items()
The API is implemented through the following module:
This library implements items in SmartHomeNG.
This library is part of the core of SmartHomeNG. Regular plugins should not need to use this API. It is manily implemented for plugins near to the core like backend and the core itself!
The API consists of two classes.
This class implements the item itself:
Item(smarthome, parent, path, config, items_instance=None)
Class from which item objects are created
Itemimplements the methods and attributes of an item. Each item is represented by an instance of the class
Item. For an item to be valid and usable, it has to be part of the item tree, which is maintained by an object of class
This class is used by the method
`load_itemdefinitions()of the Items object.
This class implements the loading and management of the items in form of the item-tree.
Items loader class. (Item-methods from bin/smarthome.py are moved here.)
An instance is created during initialization by bin/smarthome.py
There should be only one instance of this class. So: Don’t create another instance
smarthome (object) – Instance of the smarthome master-object