Class Item

This class implements the following methods and properties:

class lib.item.Item(smarthome, parent, path, config)[source]

Bases: object

Class from which item objects are created

The class Item implements 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 Items.

This class is used by the method `load_itemdefinitions() of the Items object.

class Property(parent)[source]

Bases: object

Inner class Property of item class.

This class encapsulates all properties that are publicly available

An instance of this class is created in the __init__ method of the item class

property attributes

Read-Only Property: attributes. List of plugin-specific attribute names

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

init_dynamic_properties()[source]

Initialize dynamic properties to get the values of plugin-specific attributes

get_config_attribute(attr)[source]
property defined_in

Read-Only Property: defined_in . The filename in which the item was defined

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property enforce_updates

Property: enforce_updates

Available in SmartHomeNG v1.6 and above

Parameters

value (bool) – enforce_update state of the item

Returns

enforce_update state of the item

Return type

bool

property enforce_change

Property: enforce_change

Available in SmartHomeNG v1.6 and above

Parameters

value (bool) – enforce_change state of the item

Returns

enforce_change state of the item

Return type

bool

property eval

Property: eval expression

Available in SmartHomeNG v1.6 and above

Parameters

value (str) – eval expression of the item

Returns

eval expression of the item

Return type

str

property eval_unexpanded

Property: eval expression

Available in SmartHomeNG v1.6 and above

Parameters

value (str) – eval expression of the item

Returns

eval expression of the item

Return type

str

property last_change

Read-Only Property: last_change

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property last_change_age

Read-Only Property: last_change_age

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property last_change_by

Read-Only Property: last_change_by

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property last_update

Read-Only Property: last_update

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property last_update_age

Read-Only Property: last_update_age

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property last_update_by

Read-Only Property: last_update_by

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property name

Property: name

Available in SmartHomeNG v1.6 and above

Parameters

value (str) – name of the item

Returns

name of the item

Return type

str

property on_change

Read-Only Property: on_update

Available in SmartHomeNG v1.6 and above

Returns

path of on_update definitions

Return type

str

property on_change_unexpanded

Read-Only Property: on_update

Available in SmartHomeNG v1.6 and above

Returns

path of on_update definitions

Return type

str

property on_update

Read-Only Property: on_update

Available in SmartHomeNG v1.6 and above

Returns

path of on_update definitions

Return type

str

property on_update_unexpanded

Read-Only Property: on_update

Available in SmartHomeNG v1.6 and above

Returns

path of on_update definitions

Return type

str

property path

Read-Only Property: path

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property prev_change

Read-Only Property: prev_change

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property prev_change_age

Read-Only Property: prev_change_age

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property prev_change_by

Read-Only Property: prev_change_by

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property prev_update

Read-Only Property: prev_update

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property prev_update_age

Read-Only Property: prev_update_age

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property prev_update_by

Read-Only Property: prev_update_by

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property prev_value

Read-Only Property: prev_value

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property last_value

Read-Only Property: last_value

Available in SmartHomeNG v1.6 and above

Returns

path of the item

Return type

str

property trigger

Property: Triggers of the item

Available in SmartHomeNG v1.6 and above

Parameters

value (list) – list of triggers

Returns

[] if not defined or a list of triggers

Return type

list of str

property trigger_unexpanded

Property: Triggers of the item

Available in SmartHomeNG v1.6 and above

Parameters

value (list) – list of triggers

Returns

[] if not defined or a list of triggers

Return type

list of str

property type

Read-Only Property: type

Available in SmartHomeNG v1.6 and above

Returns

type of the item

Return type

str

property value

Property: value

Available in SmartHomeNG v1.6 and above

Parameters

value (<type of the item>) – value of the item

Returns

value of the item

Return type

<type of the item>

path()[source]

Path of the item

Available only in SmartHomeNG v1.6, not in versions above

Returns

String with the path of the item

Return type

str

id()[source]

Old method name - Use item.path() instead of item.id()

type()[source]

Datatype of the item

Returns

Datatype of the item

Return type

str

last_change()[source]

Timestamp of last change of item’s value

Returns

Timestamp of last change

age()[source]

Age of the item’s actual value. Returns the time in seconds since the last change of the value

Returns

Age of the value

Return type

int

last_update()[source]

Timestamp of last update of item’s value (not necessarily change)

Returns

Timestamp of last update

update_age()[source]

Update-age of the item’s actual value. Returns the time in seconds since the value has been updated (not necessarily changed)

Returns

Update-age of the value

Return type

int

prev_change()[source]

Timestamp of the previous (next-to-last) change of item’s value

Returns

Timestamp of previous change

prev_age()[source]

Age of the item’s previous value. Returns the time in seconds the item had the the previous value

Returns

Age of the previous value

Return type

int

prev_update()[source]

Timestamp of previous (next-to-last) update of item’s value (not necessarily change)

Returns

Timestamp of previous update

prev_update_age()[source]

Update-age of the item’s previous value. Returns the time in seconds the previous value existed since it had been updated (not necessarily changed)

Returns

Update-age of the previous value

Return type

int

prev_value()[source]

Next-to-last value of the item

Returns

Next-to-last value of the item

changed_by()[source]

Returns an indication, which plugin, logic or event changed the item’s value

Returns

Changer of item’s value

Return type

str

updated_by()[source]

Returns an indication, which plugin, logic or event updated (not necessarily changed) the item’s value

Returns

Updater of item’s value

Return type

str

get_absolutepath(relativepath, attribute='')[source]

Builds an absolute item path relative to the current item

Parameters
  • relativepath – string with the relative item path

  • attribute – string with the name of the item’s attribute, which contains the relative path (for log entries)

Returns

string with the absolute item path

expand_relativepathes(attr, begintag, endtag)[source]

converts a configuration attribute containing relative item paths to absolute paths

The item’s attribute can be of type str or list (of strings)

The begintag and the endtag remain in the result string!

Parameters
  • attr – Name of the attribute. Use * as a wildcard at the end

  • begintag – string or list of strings that signals the beginning of a relative path is following

  • endtag – string or list of strings that signals the end of a relative path

get_stringwithabsolutepathes(evalstr, begintag, endtag, attribute='')[source]

converts a string containing relative item paths to a string with absolute item paths

The begintag and the endtag remain in the result string!

Parameters
  • evalstr – string with the statement that may contain relative item paths

  • begintag – string that signals the beginning of a relative path is following

  • endtag – string that signals the end of a relative path

  • attribute – string with the name of the item’s attribute, which contains the relative path

Returns

string with the statement containing absolute item paths

add_logic_trigger(logic)[source]

Add a logic trigger to the item

Parameters

logic

Returns

remove_logic_trigger(logic)[source]
get_logic_triggers()[source]

Returns a list of logics to trigger, if the item gets changed

Returns

Logics to trigger

Return type

list

add_method_trigger(method)[source]
remove_method_trigger(method)[source]
get_method_triggers()[source]

Returns a list of item methods to trigger, if this item gets changed

Returns

methods to trigger

Return type

list

autotimer(time=None, value=None, compat='compat_1.2')[source]
fade(dest, step=1, delta=1)[source]
remove_timer()[source]
return_children()[source]
return_parent()[source]
set(value, caller='Logic', source=None, dest=None, prev_change=None, last_change=None)[source]
timer(time, value, auto=False, compat='')[source]
get_children_path()[source]
jsonvars()[source]

Translation method from object members to json :return: Key / Value pairs from object members

to_json()[source]