Item

items. Item

Class representing an openHAB Item

Members

history :items.ItemHistory

Source:

Access historical states for this item

Type:

type

Source:

The type of the item: the Simple (without package) name of the Java item type, such as 'Switch'.

name

Source:

The name of the item.

label

Source:

The label attached to the item

state

Source:

The state of the item, as a string.

rawState

Source:

The raw state of the item, as a java object.

members

Source:

Members / children / direct descendents of the current group item (as returned by 'getMembers()'). Must be a group item.

descendents

Source:

All descendents of the current group item (as returned by 'getAllMembers()'). Must be a group item.

isUninitialized :boolean

Source:

Whether this item is initialized.

Type:
  • boolean

groupNames

Source:

Gets the tags from this item

tags

Source:

Gets the tags from this item

Methods

getMetadataValue(namespace) → {string}

Source:

Gets metadata values for this item.

Parameters:
Name Type Description
namespace string

The namespace for the metadata to retreive

Returns:

the metadata associated with this item and namespace

Type
string

updateMetadataValue(namespace, value) → {string}

Source:

Updates metadata values for this item.

Parameters:
Name Type Description
namespace string

The namespace for the metadata to update

value string

the value to update the metadata to

Returns:

the updated value

Type
string

upsertMetadataValue(namespace, value) → {boolean}

Source:

Inserts or updates metadata values for this item.

Parameters:
Name Type Description
namespace string

The namespace for the metadata to update

value string

the value to update the metadata to

Returns:

true iff a new value was inserted

Type
boolean

updateMetadataValues(namespaceToValues)

Source:

Updates metadata values for this item.

Parameters:
Name Type Description
namespaceToValues Map

A map of namespaces to values to update

sendCommand(value)

Source:
See:
  • sendCommandIfDifferent
  • postUpdate

Sends a command to the item

Parameters:
Name Type Description
value String | HostState

the value of the command to send, such as 'ON'

sendCommandIfDifferent(value) → {boolean}

Source:
See:
  • sendCommand

Sends a command to the item, but only if the current state is not what is being sent. Note

Parameters:
Name Type Description
value String | HostState

the value of the command to send, such as 'ON'

Returns:

true if the command was sent, false otherwise

Type
boolean

getToggleState()

Source:

Calculates the toggled state of this Item. For Items like Color and Dimmer, getStateAs(OnOffType) is used and the toggle calculated off of that.

Throws:

error if the Item is uninitialized or is a type that doesn't make sense to toggle

Returns:

the toggled state (e.g. 'OFF' if the Item is 'ON')

sendToggleCommand()

Source:

Sends a command to flip the Item's state (e.g. if it is 'ON' an 'OFF' command is sent).

Throws:

error if the Item is uninitialized or a type that cannot be toggled or commanded

postToggleUpdate()

Source:

Posts an update to flip the Item's state (e.g. if it is 'ON' an 'OFF' update is posted).

Throws:

error if the Item is uninitialized or a type that cannot be toggled

postUpdate(value)

Source:
See:
  • sendCommand

Posts an update to the item

Parameters:
Name Type Description
value String | HostState

the value of the command to send, such as 'ON'

addGroups(…groupNamesOrItems)

Source:

Adds groups to this item

Parameters:
Name Type Attributes Description
groupNamesOrItems String | Item <repeatable>

one or more names of the groups (or the group items themselves)

removeGroups(…groupNamesOrItems)

Source:

Removes groups from this item

Parameters:
Name Type Attributes Description
groupNamesOrItems String | Item <repeatable>

one or more names of the groups (or the group items themselves)

addTags(…tagNames)

Source:

Adds tags to this item

Parameters:
Name Type Attributes Description
tagNames String <repeatable>

names of the tags to add

removeTags(…tagNames)

Source:

Removes tags from this item

Parameters:
Name Type Attributes Description
tagNames String <repeatable>

names of the tags to remove